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; }
//----------------------------------------------------------------------------------// bool CTradesCache::ProcessTradeForAnalytics(CTradePtr spTrade){ if (spTrade.get()){ long lStep = 0; IRisks retRisks; try{ retRisks = spTrade->m_spContract->Calculate(NULL, NULL); } catch (_com_error& err){ std::ostringstream out_stream; out_stream << "Analytical data for trade ["; out_stream << spTrade->m_nTradeID; out_stream<< "] has not been ready at this moment. It will be respocessed one more time by queue."; TRACE_COM_ERROR(LOG4CPLUS_WARN, VS::Log, err, std::string(out_stream.str())); return false; } try{ //format xml to pass to DB lStep = 1; _bstr_t bstrXML; bstrXML.Attach(GetXMLString(&retRisks, spTrade)); lStep = 2; //save to DB InitializeDB(); CStoredProc<CClientRecordset> rs(GetDBConnection(), L"usp_ContractAnalytics_Save"); rs << bstrXML; lStep = 3; rs.Open(); lStep = 4; rs.Close(); return true; } catch (_com_error& err){ std::ostringstream out_stream; out_stream<<"Exception occured while ProcessTradeForAnalytics().\n\tStep = " << lStep; out_stream<<"\n\tTradeID = " << spTrade->m_nTradeID; TRACE_COM_ERROR(LOG4CPLUS_ERROR, VS::Log, err, std::string(out_stream.str())); return false; } catch (...){ std::ostringstream out_stream; out_stream<<"Unknown C++ exception occured while ProcessTradeForAnalytics().\n\tStep = " << lStep; out_stream<<"\n\tTradeID = " << spTrade->m_nTradeID; TRACE_UNKNOWN_ERROR(LOG4CPLUS_ERROR, VS::Log, std::string(out_stream.str())); return false; } } return false; };