HRESULT __stdcall CXMiLFilesControl::OnFileUpdate(long parentFolderId, long fileId, long action) { // CWebSite* pWebSite = ((CWebSite*)m_document.p); DWORD rootItem; m_treeCtl->GetRootItem(&rootItem); #if 0 if (action == 1) // New File { CSiteDir* pParentDir = (CSiteDir*)FindFileById(rootItem, parentFolderId); if (pParentDir && pParentDir->m_bPopulated) { WCHAR sql[256]; swprintf(sql, L"SELECT id,filename,type,file_size,file_date FROM files WHERE id = %d", fileId); _variant_t va; ADODB::_ConnectionPtr conn = GetDBConnection(); ADODB::_RecordsetPtr recordset = conn->Execute(sql, &va, ADODB::adCmdText); CSiteItem* pNewItem = FromElement(pParentDir, recordset); if (pNewItem) { m_treeCtl->InsertItem((DWORD)pNewItem, pParentDir->m_treeItem, NULL, NULL, pNewItem->m_iIcon, pNewItem->m_cChildren, &pNewItem->m_treeItem); } } } else if (action == 2) // Delete File { CSiteItem* pItem = FindFileById(rootItem, fileId); if (pItem) { m_treeCtl->DeleteItem(pItem->m_treeItem); delete pItem; // TODO, this doesn't delete children } } else if (action == 3) // Update file { CSiteItem* pItem = FindFileById(rootItem, fileId); if (pItem) { WCHAR sql[256]; swprintf(sql, L"SELECT id,filename,type,file_size,file_date FROM files WHERE id = %d", fileId); _variant_t va; ADODB::_ConnectionPtr conn = GetDBConnection(); ADODB::_RecordsetPtr recordset = conn->Execute(sql, &va, ADODB::adCmdText); CSiteItem* pNewItem = FromRecordSet((CSiteDir*)pItem->m_parent, recordset); if (pNewItem) { pNewItem->m_treeItem = pItem->m_treeItem; m_treeCtl->SetItemInfo(pItem->m_treeItem, (DWORD)pNewItem, pNewItem->m_iIcon, pNewItem->m_cChildren); delete pItem; } } } #endif return S_OK; }
/** * Executes the passed in command on the database. * * @param CommandString Command to execute * * @return TRUE if execution was successful, FALSE otherwise */ virtual UBOOL Execute( const TCHAR* CommandString ) { try { // Execute command, passing in optimization to tell DB to not return records. DataBaseConnection->Execute( CommandString, NULL, ADODB::adExecuteNoRecords ); } catch(_com_error &Error) { // Log error and return. This will not log if called before appInit due to use of debugf. TCHAR* ErrorDescription = (TCHAR*) Error.Description(); warnf(NAME_DevDataBase,TEXT("Failure executing command [%s] [%s]"),CommandString,ErrorDescription); return FALSE; } return TRUE; }