Ejemplo n.º 1
0
bool CWizDatabase::UpdateAttachment(const WIZDOCUMENTATTACHMENTDATAEX& data)
{
    bool bRet = false;

    WIZDOCUMENTATTACHMENTDATAEX dataTemp;
    if (AttachmentFromGUID(data.strGUID, dataTemp))
    {
        bRet = ModifyAttachmentInfoEx(data);

        bool changed = dataTemp.strDataMD5 != data.strDataMD5;
        if (changed)
        {
            SetObjectDataDownloaded(data.strGUID, "attachment", false);
        }
    }
    else
    {
        bRet = CreateAttachmentEx(data);
    }

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

    return bRet;
}
Ejemplo n.º 2
0
bool CWizIndexBase::ModifyAttachmentInfoEx(const WIZDOCUMENTATTACHMENTDATA& data)
{
    qDebug() << "modify attachment, name: " << data.strName;

    Q_ASSERT(data.strKbGUID == m_strKbGUID);

    WIZDOCUMENTATTACHMENTDATA dataOld;
    AttachmentFromGUID(data.strGUID, dataOld);

    CString strFormat = FormatUpdateSQLFormat(TABLE_NAME_WIZ_DOCUMENT_ATTACHMENT, FIELD_LIST_WIZ_DOCUMENT_ATTACHMENT_MODIFY, TABLE_KEY_WIZ_DOCUMENT_ATTACHMENT);

    CString strSQL;
    strSQL.Format(strFormat,
        STR2SQL(data.strName).utf16(),
        STR2SQL(data.strURL).utf16(),
        STR2SQL(data.strDescription).utf16(),
        TIME2SQL(data.tInfoModified).utf16(),
        STR2SQL(data.strInfoMD5 ).utf16(),
        TIME2SQL(data.tDataModified).utf16(),
        STR2SQL(data.strDataMD5 ).utf16(),
        WizInt64ToStr(data.nVersion).utf16(),
        STR2SQL(data.strGUID).utf16()
    );

    if (!ExecSQL(strSQL))
        return false;

    WIZDOCUMENTATTACHMENTDATA dataNew;
    AttachmentFromGUID(data.strGUID, dataNew);

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

    return true;
}