コード例 #1
0
bool CWizDatabase::UpdateSyncObjectLocalData(const WIZOBJECTDATA& data)
{
    if (data.eObjectType == wizobjectDocumentAttachment)
    {
        if (!SaveCompressedAttachmentData(data.strObjectGUID, data.arrayData))
        {
            Q_EMIT updateError("Failed to save attachment data: " + data.strDisplayName);
            return false;
        }
    }
    else
    {
        CString strFileName = GetObjectFileName(data);
        if (!::WizSaveDataToFile(strFileName, data.arrayData))
        {
            Q_EMIT updateError("Failed to save document data: " + data.strDisplayName);
            return false;
        }
    }

    if (data.eObjectType == wizobjectDocument)
    {
        WIZDOCUMENTDATA document;
        if (DocumentFromGUID(data.strObjectGUID, document))
        {
            Q_EMIT documentDataModified(document);
        }

        UpdateDocumentAbstract(data.strObjectGUID);
    }

    SetObjectDataDownloaded(data.strObjectGUID, WIZOBJECTDATA::ObjectTypeToTypeString(data.eObjectType), true);

    return true;
}
コード例 #2
0
bool CWizDatabase::UpdateDocument(const WIZDOCUMENTDATAEX& data)
{
    bool bRet = false;

    WIZDOCUMENTDATAEX dataTemp;
    if (DocumentFromGUID(data.strGUID, dataTemp))
    {
        if (data.nObjectPart & WIZKM_XMLRPC_OBJECT_PART_INFO)
        {
            bRet = ModifyDocumentInfoEx(data);
            if (dataTemp.strDataMD5 != data.strDataMD5)
            {
                SetObjectDataDownloaded(data.strGUID, "document", false);
            }
        }
        else
        {
            bRet = true;
        }
    }
    else
    {
        Q_ASSERT(data.nObjectPart & WIZKM_XMLRPC_OBJECT_PART_INFO);

        bRet = CreateDocumentEx(data);
    }

    if (!bRet) {
        Q_EMIT updateError("Failed to update document: " + data.strTitle);
    }

    WIZDOCUMENTDATA dataRet = data;

    bool resetVersion = false;
    if (!data.arrayParam.empty())
    {
        SetDocumentParams(dataRet, data.arrayParam);
        resetVersion = true;
    }
    if (!data.arrayTagGUID.empty())
    {
        SetDocumentTags(dataRet, data.arrayTagGUID);
        resetVersion = true;
    }

    if (resetVersion)
    {
        //reset document info
        ModifyDocumentInfoEx(data);
    }

    return bRet;
}
コード例 #3
0
bool CWizDatabase::UpdateSyncObjectLocalData(const WIZOBJECTDATA& data)
{
    qDebug() << "update object data, name: " << data.strDisplayName << "guid: " << data.strObjectGUID;

    if (data.eObjectType == wizobjectDocumentAttachment)
    {
        if (!SaveCompressedAttachmentData(data.strObjectGUID, data.arrayData))
        {
            Q_EMIT updateError("Failed to save attachment data: " + data.strDisplayName);
            return false;
        }
    }
    else if (data.eObjectType == wizobjectDocument)
    {
        WIZDOCUMENTDATA document;
        if (!DocumentFromGUID(data.strObjectGUID, document)) {
            qDebug() << "\n[Fatal] update object data failed, can't find database record!\n";
            return false;
        }


        CString strFileName = GetObjectFileName(data);
        if (!::WizSaveDataToFile(strFileName, data.arrayData))
        {
            Q_EMIT updateError("Failed to save document data: " + data.strDisplayName);
            return false;
        }

        Q_EMIT documentDataModified(document);
        UpdateDocumentAbstract(data.strObjectGUID);
        setDocumentSearchIndexed(data.strObjectGUID, false);
    } else {
        Q_ASSERT(0);
    }

    SetObjectDataDownloaded(data.strObjectGUID, WIZOBJECTDATA::ObjectTypeToTypeString(data.eObjectType), true);

    return true;
}
コード例 #4
0
ファイル: wizIndexBase.cpp プロジェクト: flyfire/WizQTClient
bool CWizIndexBase::ModifyDocumentInfoEx(const WIZDOCUMENTDATA& dataCur)
{
    qDebug() << "modify document, title: " << dataCur.strTitle;

    Q_ASSERT(dataCur.strKbGUID == m_strKbGUID);

    WIZDOCUMENTDATA dataOld;
    DocumentFromGUID(dataCur.strGUID, dataOld);

    WIZDOCUMENTDATA data = dataCur;

    // try to fill the fields not allowed empty
    if (data.strTitle.isEmpty()) {
        if (!dataOld.strTitle.isEmpty()) {
            data.strTitle = dataOld.strTitle;
        } else {
            data.strTitle = "New note";
        }

        TOLOG2("Document Title is empty: %1, Try to rename to the %2", data.strGUID, data.strTitle);
    }

    if (data.strLocation.isEmpty()) {
        if (!dataOld.strLocation.isEmpty()) {
            data.strLocation = dataOld.strLocation;
        } else {
            data.strLocation = "/My Notes/";
        }

        TOLOG2("Document Location is empty: %1, Try to relocation to the %2", data.strTitle, data.strLocation);
    }

    CString strFormat = FormatUpdateSQLFormat(TABLE_NAME_WIZ_DOCUMENT, FIELD_LIST_WIZ_DOCUMENT_MODIFY, TABLE_KEY_WIZ_DOCUMENT);

    CString strSQL;
    strSQL.Format(strFormat,
        STR2SQL(data.strTitle).utf16(),
        STR2SQL(data.strLocation).utf16(),
        STR2SQL(data.strName).utf16(),
        STR2SQL(data.strSEO).utf16(),
        STR2SQL(data.strURL).utf16(),
        STR2SQL(data.strAuthor).utf16(),
        STR2SQL(data.strKeywords).utf16(),
        STR2SQL(data.strType).utf16(),
        STR2SQL(data.strOwner).utf16(),
        STR2SQL(data.strFileType).utf16(),
        STR2SQL(data.strStyleGUID).utf16(),

        TIME2SQL(data.tCreated).utf16(),
        TIME2SQL(data.tModified).utf16(),
        TIME2SQL(data.tAccessed).utf16(),

        data.nIconIndex,
        data.nSync,
        data.nProtected,
        data.nReadCount,
        data.nAttachmentCount,
        data.nIndexed,

        TIME2SQL(data.tInfoModified).utf16(),
        STR2SQL(data.strInfoMD5 ).utf16(),
        TIME2SQL(data.tDataModified).utf16(),
        STR2SQL(data.strDataMD5 ).utf16(),
        TIME2SQL(data.tParamModified).utf16(),
        STR2SQL(data.strParamMD5 ).utf16(),
        WizInt64ToStr(data.nVersion).utf16(),

        STR2SQL(data.strGUID).utf16()
    );

    if (!ExecSQL(strSQL))
        return false;

    WIZDOCUMENTDATA dataNew;
    DocumentFromGUID(data.strGUID, dataNew);

    if (!m_bUpdating) {
        emit documentModified(dataOld, dataNew);
    }

    return true;
}