int TSessionSqlObjectStore::gc(const QDateTime &expire)
{
    TSqlORMapper<TSessionObject> mapper;
    TCriteria cri(TSessionObject::UpdatedAt, TSql::LessThan, expire);
    int cnt = mapper.removeAll(cri);
    return cnt;
}
bool TSessionSqlObjectStore::store(TSession &session)
{
    TSqlORMapper<TSessionObject> mapper;
    TCriteria cri(TSessionObject::Id, TSql::Equal, session.id());
    TSessionObject so = mapper.findFirst(cri);

#ifndef TF_NO_DEBUG
    {
        QByteArray badummy;
        QDataStream dsdmy(&badummy, QIODevice::ReadWrite);
        dsdmy << *static_cast<const QVariantMap *>(&session);

        TSession dummy;
        dsdmy.device()->seek(0);
        dsdmy >> *static_cast<QVariantMap *>(&dummy);
        if (dsdmy.status() != QDataStream::Ok) {
            tSystemError("Failed to store a session into the cookie store. Must set objects that can be serialized.");
        }
    }
#endif

    QDataStream ds(&so.data, QIODevice::WriteOnly);
    ds << *static_cast<const QVariantMap *>(&session);

    if (ds.status() != QDataStream::Ok) {
        tSystemError("Failed to store session. Must set objects that can be serialized.");
        return false;
    }

    if (so.isNull()) {
        so.id = session.id();
        return so.create();
    }
    return so.update();
}
bool TSessionSqlObjectStore::remove(const QDateTime &garbageExpiration)
{
    TSqlORMapper<TSessionObject> mapper;
    TCriteria cri(TSessionObject::UpdatedAt, TSql::LessThan, garbageExpiration);
    int cnt = mapper.removeAll(cri);
    return (cnt >= 0);
}
示例#4
0
RefPackingDef RefPackingDef::get(const QString &createdBy, const QString &updatedBy)
{
    TCriteria cri;
    cri.add(RefPackingDefObject::CreatedBy, createdBy);
    cri.add(RefPackingDefObject::UpdatedBy, updatedBy);
    TSqlORMapper<RefPackingDefObject> mapper;
    return RefPackingDef(mapper.findFirst(cri));
}
示例#5
0
文件: vehicles.cpp 项目: czjin/bbpark
Vehicles Vehicles::get(int id, int lockRevision)
{
    TSqlORMapper<VehiclesObject> mapper;
    TCriteria cri;
    cri.add(VehiclesObject::Id, id);
    cri.add(VehiclesObject::LockRevision, lockRevision);
    return Vehicles(mapper.findFirst(cri));
}
示例#6
0
ParkAttendants ParkAttendants::get(int id, int lockRevision)
{
    TSqlORMapper<ParkAttendantsObject> mapper;
    TCriteria cri;
    cri.add(ParkAttendantsObject::Id, id);
    cri.add(ParkAttendantsObject::LockRevision, lockRevision);
    return ParkAttendants(mapper.findFirst(cri));
}
示例#7
0
ChatLog ChatLog::get(int id, int lockRevision)
{
    TSqlORMapper<ChatLogObject> mapper;
    TCriteria cri;
    cri.add(ChatLogObject::Id, id);
    cri.add(ChatLogObject::LockRevision, lockRevision);
    return ChatLog(mapper.findFirst(cri));
}
示例#8
0
UserVehicle UserVehicle::get(int id, int lockRevision)
{
    TSqlORMapper<UserVehicleObject> mapper;
    TCriteria cri;
    cri.add(UserVehicleObject::Id, id);
    cri.add(UserVehicleObject::LockRevision, lockRevision);
    return UserVehicle(mapper.findFirst(cri));
}
示例#9
0
QJsonArray AccountsRecharge::getAllJson()
{
    QJsonArray array;
    TSqlORMapper<AccountsRechargeObject> mapper;

    if (mapper.find() > 0) {
        for (TSqlORMapperIterator<AccountsRechargeObject> i(mapper); i.hasNext(); ) {
            array.append(QJsonValue(QJsonObject::fromVariantMap(AccountsRecharge(i.next()).toVariantMap())));
        }
    }
    return array;
}
示例#10
0
QJsonArray ParkAttendants::getAllJson()
{
    QJsonArray array;
    TSqlORMapper<ParkAttendantsObject> mapper;

    if (mapper.find() > 0) {
        for (TSqlORMapperIterator<ParkAttendantsObject> i(mapper); i.hasNext(); ) {
            array.append(QJsonValue(QJsonObject::fromVariantMap(ParkAttendants(i.next()).toVariantMap())));
        }
    }
    return array;
}
示例#11
0
QJsonArray UserVehicle::getAllJson()
{
    QJsonArray array;
    TSqlORMapper<UserVehicleObject> mapper;

    if (mapper.find() > 0) {
        for (TSqlORMapperIterator<UserVehicleObject> i(mapper); i.hasNext(); ) {
            array.append(QJsonValue(QJsonObject::fromVariantMap(UserVehicle(i.next()).toVariantMap())));
        }
    }
    return array;
}
示例#12
0
void ChatLog::removeOldLogs(int remainingCount)
{
    int del = count() - remainingCount;
    if (del > 0) {
        TSqlORMapper<ChatLogObject> mapper;
        mapper.setSortOrder(ChatLogObject::Id, Tf::DescendingOrder);
        auto log = mapper.findFirst();
        int maxId = log.id;

        TCriteria ctr(ChatLogObject::Id, TSql::LessEqual, maxId - remainingCount);
        mapper.removeAll(ctr);
    }
}
bool TSessionSqlObjectStore::store(TSession &session)
{
    TSqlORMapper<TSessionObject> mapper;
    TCriteria cri(TSessionObject::Id, TSql::Equal, session.id());
    TSessionObject so = mapper.findFirst(cri);

    QDataStream ds(&so.data, QIODevice::WriteOnly);
    ds << *static_cast<const QVariantHash *>(&session);

    if (so.isEmpty()) {
        so.id = session.id();
        return so.create();
    }
    return so.update();
}
TSession TSessionSqlObjectStore::find(const QByteArray &id, const QDateTime &modified)
{
    TSqlORMapper<TSessionObject> mapper;
    TCriteria cri;
    cri.add(TSessionObject::Id, TSql::Equal, id);
    cri.add(TSessionObject::UpdatedAt, TSql::GreaterEqual, modified);

    TSessionObject sess = mapper.findFirst(cri);
    if (sess.isEmpty())
        return TSession();
    
    TSession result(id);
    QDataStream ds(&sess.data, QIODevice::ReadOnly);
    ds >> *static_cast<QVariantHash *>(&result);
    return result;  
}
TSession TSessionSqlObjectStore::find(const QByteArray &id)
{
    QDateTime modified = QDateTime::currentDateTime().addSecs(-lifeTimeSecs());
    TSqlORMapper<TSessionObject> mapper;
    TCriteria cri;
    cri.add(TSessionObject::Id, TSql::Equal, id);
    cri.add(TSessionObject::UpdatedAt, TSql::GreaterEqual, modified);

    TSessionObject so = mapper.findFirst(cri);
    if (so.isNull()) {
        return TSession();
    }

    TSession session(id);
    QDataStream ds(&so.data, QIODevice::ReadOnly);
    ds >> *static_cast<QVariantMap *>(&session);

    if (ds.status() != QDataStream::Ok) {
        tSystemError("Failed to load a session from the sqlobject store.");
    }
    return session;
}
示例#16
0
VMenusGroupMenuRole VMenusGroupMenuRole::get(int roleId, int menusGroupOrder, int menusGroupId, const QString &menusGroupCd, const QString &menusGroupNameZh, const QString &menusGroupNameEn, const QString &menusGroupTooltip, const QString &menusGroupDesc, int menuId, int menuOrder, const bool &breakBool, const QString &menuCd, const QString &menuNameZh, const QString &menuNameEn, const QString &menuTooltip, const QString &menuDesc, const QString &controller, const QString &action)
{
    TCriteria cri;
    cri.add(VMenusGroupMenuRoleObject::RoleId, roleId);
    cri.add(VMenusGroupMenuRoleObject::MenusGroupOrder, menusGroupOrder);
    cri.add(VMenusGroupMenuRoleObject::MenusGroupId, menusGroupId);
    cri.add(VMenusGroupMenuRoleObject::MenusGroupCd, menusGroupCd);
    cri.add(VMenusGroupMenuRoleObject::MenusGroupNameZh, menusGroupNameZh);
    cri.add(VMenusGroupMenuRoleObject::MenusGroupNameEn, menusGroupNameEn);
    cri.add(VMenusGroupMenuRoleObject::MenusGroupTooltip, menusGroupTooltip);
    cri.add(VMenusGroupMenuRoleObject::MenusGroupDesc, menusGroupDesc);
    cri.add(VMenusGroupMenuRoleObject::MenuId, menuId);
    cri.add(VMenusGroupMenuRoleObject::MenuOrder, menuOrder);
    cri.add(VMenusGroupMenuRoleObject::BreakBool, breakBool);
    cri.add(VMenusGroupMenuRoleObject::MenuCd, menuCd);
    cri.add(VMenusGroupMenuRoleObject::MenuNameZh, menuNameZh);
    cri.add(VMenusGroupMenuRoleObject::MenuNameEn, menuNameEn);
    cri.add(VMenusGroupMenuRoleObject::MenuTooltip, menuTooltip);
    cri.add(VMenusGroupMenuRoleObject::MenuDesc, menuDesc);
    cri.add(VMenusGroupMenuRoleObject::Controller, controller);
    cri.add(VMenusGroupMenuRoleObject::Action, action);
    TSqlORMapper<VMenusGroupMenuRoleObject> mapper;
    return VMenusGroupMenuRole(mapper.findFirst(cri));
}
示例#17
0
文件: evtvendor.cpp 项目: hks2002/AM
int EvtVendor::count()
{
    TSqlORMapper<EvtVendorObject> mapper;
    return mapper.findCount();
}
示例#18
0
文件: evtvendor.cpp 项目: hks2002/AM
EvtVendor EvtVendor::get(int eventId, int vendorId)
{
    TSqlORMapper<EvtVendorObject> mapper;
    return EvtVendor(mapper.findByPrimaryKey(QVariantList()<<QVariant(eventId)<<QVariant(vendorId)));
}
示例#19
0
int TaskSchedRuleMesur::count()
{
    TSqlORMapper<TaskSchedRuleMesurObject> mapper;
    return mapper.findCount();
}
示例#20
0
TaskSchedRuleMesur TaskSchedRuleMesur::get(int taskId, int dataTypeId, int mesurUnitId)
{
    TSqlORMapper<TaskSchedRuleMesurObject> mapper;
    return TaskSchedRuleMesur(mapper.findByPrimaryKey(QVariantList()<<QVariant(taskId)<<QVariant(dataTypeId)<<QVariant(mesurUnitId)));
}
示例#21
0
int RefReceivePriority::count()
{
    TSqlORMapper<RefReceivePriorityObject> mapper;
    return mapper.findCount();
}
示例#22
0
EqpAssmblBomDataType EqpAssmblBomDataType::get(int assmblBomId, int dataTypeId)
{
    TSqlORMapper<EqpAssmblBomDataTypeObject> mapper;
    return EqpAssmblBomDataType(mapper.findByPrimaryKey(QVariantList()<<QVariant(assmblBomId)<<QVariant(dataTypeId)));
}
示例#23
0
WarrantyInit WarrantyInit::get(int warrantyInitId)
{
    TSqlORMapper<WarrantyInitObject> mapper;
    return WarrantyInit(mapper.findByPrimaryKey(warrantyInitId));
}
示例#24
0
文件: evthr.cpp 项目: hks2002/AM
EvtHr EvtHr::get(int eventId, int userId)
{
    TSqlORMapper<EvtHrObject> mapper;
    return EvtHr(mapper.findByPrimaryKey(QVariantList()<<QVariant(eventId)<<QVariant(userId)));
}
示例#25
0
int OrgVendorApproval::count()
{
    TSqlORMapper<OrgVendorApprovalObject> mapper;
    return mapper.findCount();
}
示例#26
0
文件: tasktask.cpp 项目: hks2002/AM
TaskTask TaskTask::get(int taskId)
{
    TSqlORMapper<TaskTaskObject> mapper;
    return TaskTask(mapper.findByPrimaryKey(taskId));
}
示例#27
0
文件: tasktask.cpp 项目: hks2002/AM
int TaskTask::count()
{
    TSqlORMapper<TaskTaskObject> mapper;
    return mapper.findCount();
}
示例#28
0
int WarrantyInit::count()
{
    TSqlORMapper<WarrantyInitObject> mapper;
    return mapper.findCount();
}
示例#29
0
int EqpAssmblBomDataType::count()
{
    TSqlORMapper<EqpAssmblBomDataTypeObject> mapper;
    return mapper.findCount();
}
示例#30
0
RefReceivePriority RefReceivePriority::get(const QString &rcvPriorityCd)
{
    TSqlORMapper<RefReceivePriorityObject> mapper;
    return RefReceivePriority(mapper.findByPrimaryKey(rcvPriorityCd));
}