#include "StdAfx.h" #include "MBDocMgr.h" CMBDocMgr::CMBDocMgr(void) { } CMBDocMgr::~CMBDocMgr(void) { } bool CMBDocMgr::AddDocInfo(CMBDocInfo *pDocInfo) { return AddDocObj(pDocInfo); } CMBDocInfo* CMBDocMgr::GetDocInfo( CString strID ) { return (CMBDocInfo*)GetDocObj(strID); } bool CMBDocMgr::RemoveAllDocInfo() { return RemoveAllDocObj(); } // Çå¿Õ¹ÜÀíÆ÷ bool CMBDocMgr::EmptyMgr() { m_mapDocObj.clear(); m_vecotrDocObj.clear(); return true; } bool CMBDocMgr::RelaceDoc( CMBDocInfo *pOldDocInfo,CMBDocInfo *pNewDocInfo ) { if( NULL == pNewDocInfo || NULL == pOldDocInfo || pNewDocInfo->m_strID.IsEmpty() ) return false; CMBBaseDocObjMap::iterator it; CString strID; bool bDelte = false; ////////////²Á³ý it = m_mapDocObj.find(pOldDocInfo->m_strID); if( it!= m_mapDocObj.end() ) { bDelte = true; m_mapDocObj.erase(it); } for( UINT i = 0;i < m_vecotrDocObj.size();i++ ) { CMBBaseDocObj *pTmpDoc = m_vecotrDocObj[i]; if( pTmpDoc->m_strID == pOldDocInfo->m_strID ) { bDelte = true; m_vecotrDocObj[i] = pNewDocInfo; // Ìæ»» break; } } ////////////²Á³ý if( bDelte ){ delete pOldDocInfo; pOldDocInfo = NULL; } ///////////// ·ÅÈëmap strID = pNewDocInfo->m_strID; it = m_mapDocObj.find(strID); // Èç¹ûÕҵõ½ ·µ»Ø if( it != m_mapDocObj.end() ) return false; m_mapDocObj[strID] = pNewDocInfo; //////////////////////////////////////// return true; } bool CMBDocMgr::ParseXml( CString &strXml,CString &strErrInfo ) { if( strXml.IsEmpty() ) { strErrInfo = _T("CMBDocMgr::ParseXml,²ÎÊý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("Doc")); for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Doc"))) { CMBDocInfo *pDocInfo = new CMBDocInfo(); pDocInfo->m_strID = node.attribute(_T("ID")).value(); pDocInfo->m_strName = node.child_value(_T("Name")); 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")); // 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 CMBDocMgr::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"))) { CMBDocInfo *pDocInfo = new CMBDocInfo(); // 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_strCabinetID = 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_strName = node.child_value(_T("Name")); 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")); // 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; }