STDMETHODIMP InterfaceDatabase::UtilGetFileNameByMessageID(hyper lMessageID, BSTR *Output) { try { if (!GetIsServerAdmin()) return GetAccessDenied(); HRESULT hRes = EnsureDatabaseConnectivity_(); if (hRes != S_OK) return hRes; HM::String sSQL; sSQL.Format(_T("select messagefilename from hm_messages where messageid = %d"), lMessageID); std::shared_ptr<HM::DALRecordset> pRS = db_manager_->OpenRecordset(HM::SQLCommand(sSQL)); if (!pRS) return S_OK; HM::String sRetVal = ""; if (!pRS->IsEOF()) sRetVal = pRS->GetStringValue("messagefilename"); *Output = sRetVal.AllocSysString(); return S_OK; } catch (...) { return COMError::GenerateGenericMessage(); } }
HRESULT InterfaceDatabase::EnsureDatabaseConnectivity_() { db_manager_ = HM::Application::Instance()->GetDBManager(); if (!db_manager_) { return COMError::GenerateError("The connection to the database is not available. Please check the hMailServer error log for details."); } if (!db_manager_->GetIsConnected()) { HM::String sError; sError.Format(_T("The connection to the database is not available.\r\n%s"), HM::Application::Instance()->GetLastErrorMessage().c_str()); return COMError::GenerateError(sError); } return S_OK; }
// <?xml version='1.0'?> // <TAG attr1="value1" attr2='value2' attr3=value3 > // </TAG> // or // <TAG /> // ^- return pointer //======================================================== // Name : Load // Desc : load xml plain text for xml document // Param : pszXml - plain xml text // pi = parser information // Return : advanced string pointer (error return NULL) //-------------------------------------------------------- // Coder Date Desc // bro 2002-10-29 //======================================================== LPTSTR _tagXMLDocument::Load( LPCTSTR pszXml, LPPARSEINFO pi /*= NULL*/ ) { LPXNode node = new XNode; node->parent = (LPXNode)this; node->type = XNODE_ELEMENT; node->doc = this; LPTSTR end; if( pi == NULL ) pi = &parse_info; if( (end = node->Load( pszXml, pi )) == NULL ) { delete node; if (pi->erorr_occur == true) { // This error should be logged. HM::String sErrorMessage; sErrorMessage.Format(_T("The XML data stream contains formatting errors. Code: %d, Error: %s"), pi->error_code, pi->error_string); HM::ErrorManager::Instance()->ReportError(HM::ErrorManager::Medium, 4229, "_tagXMLDocument::Load", sErrorMessage); } return NULL; } childs.push_back( node ); // Load Other Node after </Tag>(pi, comment, CDATA etc) LPTSTR ret; bool bRet = false; ret = LoadOtherNodes( node, &bRet, end, pi ); if( ret != NULL ) end = ret; return end; }