#include "StdAfx.h" #include "MBPsnDocMgr.h" CMBPsnDocMgr::CMBPsnDocMgr(void) { } CMBPsnDocMgr::~CMBPsnDocMgr(void) { } bool CMBPsnDocMgr::AddDocInfo(CMBPsnDocInfo *pDocInfo) { return AddDocObj(pDocInfo); } CMBPsnDocInfo* CMBPsnDocMgr::GetDocInfo( CString strID ) { return (CMBPsnDocInfo*)GetDocObj(strID); } CMBPsnDocInfo *CMBPsnDocMgr::GetDocInfoByName( CString strName ) { CMBBaseDocObjMap::iterator it; CMBBaseDocObj *pDocObj = NULL; for( it = m_mapDocObj.begin();it != m_mapDocObj.end();it++ ) { pDocObj = it->second; if( pDocObj->m_strName == strName ) return (CMBPsnDocInfo*)pDocObj; } return NULL; } bool CMBPsnDocMgr::RemoveAllDocInfo() { return RemoveAllDocObj(); } bool CMBPsnDocMgr::ParseXml( CString &strXml,CString &strErrInfo ) { if( strXml.IsEmpty() ) { strErrInfo = _T("CMBDocMgr::ParseXml,²ÎÊýstrXmlΪ¿Õ£¡"); return false; } pugi::xml_document xmlDoc; CString strFileSize; if (!xmlDoc.load(strXml)) { return false; } pugi::xml_node form = xmlDoc.child(_T("Body")).child(_T("Doc")); for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Doc"))) { CMBPsnDocInfo *pDocInfo = new CMBPsnDocInfo(); pDocInfo->m_strID = node.attribute(_T("ID")).value(); pDocInfo->m_strStatus = node.attribute(_T("Status")).value(); pDocInfo->m_strFileType = node.attribute(_T("FileType")).value(); pDocInfo->m_strFileTime = node.attribute(_T("FileTime")).value(); strFileSize = node.attribute(_T("FileSize")).value(); pDocInfo->m_nFileSize = _ttoi(strFileSize); pDocInfo->m_strDTCreate = node.attribute(_T("DTCreate")).value(); pDocInfo->m_strCreatorID = node.attribute(_T("CreatorID")).value(); pDocInfo->m_strCreatorName = node.attribute(_T("CreatorName")).value(); pDocInfo->m_strLocker = node.attribute(_T("Locker")).value(); pDocInfo->m_strLockerName = node.attribute(_T("LockerName")).value(); pDocInfo->m_strLockTime = node.attribute(_T("LockTime")).value(); //pDocInfo->m_strIsLock = node.attribute(_T("IsLock")).value(); pDocInfo->m_strTags = node.attribute(_T("Tags")).value(); pDocInfo->m_strName = node.child_value(_T("Name")); pDocInfo->m_strFileName = node.child_value(_T("FileName")); pDocInfo->m_strTags = node.child_value(_T("Tags")); // ExtAttr pDocInfo->m_strCN_C_ACTIVE_VER = node.child(_T("ExtAttr")).child_value(_T("CN_C_ACTIVE_VER")); pDocInfo->m_strCN_N_DOWNLOAD = node.child(_T("ExtAttr")).child_value(_T("CN_N_DOWNLOAD")); pDocInfo->m_strCN_N_FILE_SIZE = node.child(_T("ExtAttr")).child_value(_T("CN_N_FILE_SIZE")); pDocInfo->m_strCN_S_CREATOR = node.child(_T("ExtAttr")).child_value(_T("CN_S_CREATOR")); pDocInfo->m_strCN_S_VERSION = node.child(_T("ExtAttr")).child_value(_T("CN_S_VERSION")); pDocInfo->m_strCN_T_CREATE = node.child(_T("ExtAttr")).child_value(_T("CN_T_CREATE")); // ThumbURL pDocInfo->m_strThumbURL = node.child_value(_T("ThumbURL")); if( !AddDocInfo(pDocInfo) ) { // ÖØÖÃËõÂÔͼµØÖ· GetDocInfo( pDocInfo->m_strID )->m_strThumbURL = pDocInfo->m_strThumbURL; delete pDocInfo; pDocInfo = NULL; } } return true; } bool CMBPsnDocMgr::ParseDocListXml( CString &strXml,CString &strErrInfo ) { if( strXml.IsEmpty() ) { strErrInfo = _T("CMBDocMgr::ParseDocListXml,²ÎÊýstrXmlΪ¿Õ£¡"); return false; } CString strFileSize; pugi::xml_document xmlDoc; if (!xmlDoc.load(strXml)) { return false; } pugi::xml_node form = xmlDoc.child(_T("Body")).child(_T("DocList")).child(_T("Doc")); for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Doc"))) { CMBPsnDocInfo *pDocInfo = new CMBPsnDocInfo(); // DELETE pDocInfo->m_strDeleteBy = node.attribute(_T("DeleteBy")).value(); pDocInfo->m_strDeleteByName = node.attribute(_T("DeleteByName")).value(); pDocInfo->m_strDeleteTime = node.attribute(_T("DeleteTime")).value(); // »ù±¾ÐÅÏ¢ pDocInfo->m_strID = node.attribute(_T("ID")).value(); pDocInfo->m_strStatus = node.attribute(_T("Status")).value(); pDocInfo->m_strFileType = node.attribute(_T("FileType")).value(); pDocInfo->m_strFileTime = node.attribute(_T("FileTime")).value(); strFileSize = node.attribute(_T("FileSize")).value(); pDocInfo->m_nFileSize = _ttoi(strFileSize); pDocInfo->m_strDTCreate = node.attribute(_T("DTCreate")).value(); pDocInfo->m_strCreatorID = node.attribute(_T("CreatorID")).value(); pDocInfo->m_strCreatorName = node.attribute(_T("CreatorName")).value(); pDocInfo->m_strLocker = node.attribute(_T("Locker")).value(); pDocInfo->m_strLockerName = node.attribute(_T("LockerName")).value(); pDocInfo->m_strLockTime = node.attribute(_T("LockTime")).value(); //pDocInfo->m_strIsLock = node.attribute(_T("IsLock")).value(); pDocInfo->m_strTags = node.attribute(_T("Tags")).value(); pDocInfo->m_strName = node.child_value(_T("Name")); pDocInfo->m_strFileName = node.child_value(_T("FileName")); // ExtAttr pDocInfo->m_strCN_C_ACTIVE_VER = node.child(_T("ExtAttr")).child_value(_T("CN_C_ACTIVE_VER")); pDocInfo->m_strCN_N_DOWNLOAD = node.child(_T("ExtAttr")).child_value(_T("CN_N_DOWNLOAD")); pDocInfo->m_strCN_N_FILE_SIZE = node.child(_T("ExtAttr")).child_value(_T("CN_N_FILE_SIZE")); pDocInfo->m_strCN_S_CREATOR = node.child(_T("ExtAttr")).child_value(_T("CN_S_CREATOR")); pDocInfo->m_strCN_S_VERSION = node.child(_T("ExtAttr")).child_value(_T("CN_S_VERSION")); pDocInfo->m_strCN_T_CREATE = node.child(_T("ExtAttr")).child_value(_T("CN_T_CREATE")); // ThumbURL pDocInfo->m_strThumbURL = node.child_value(_T("ThumbURL")); if( !AddDocInfo(pDocInfo) ) { // ÖØÖÃËõÂÔͼµØÖ· GetDocInfo( pDocInfo->m_strID )->m_strThumbURL = pDocInfo->m_strThumbURL; delete pDocInfo; pDocInfo = NULL; } } return true; } bool CMBPsnDocMgr::EmptyMgr( ) { m_mapDocObj.clear(); m_vecotrDocObj.clear(); return true; }