#include "StdAfx.h"
|
#include "MBCatalogMgr.h"
|
|
|
CMBCatalogMgr::CMBCatalogMgr(void)
|
{
|
|
}
|
|
|
CMBCatalogMgr::~CMBCatalogMgr(void)
|
{
|
|
}
|
|
bool CMBCatalogMgr::AddCatalogInfo(CMBCatalogInfo *pCatalogInfo)
|
{
|
|
return AddCatalogObj(pCatalogInfo);
|
}
|
|
// ÒÆ³ýĿ¼
|
bool CMBCatalogMgr::RemoveAllCatalogInfo()
|
{
|
return RemoveAllCatalogObj();
|
}
|
|
CMBBaseCatalogObj *CMBCatalogMgr::DeepFindCatalogObj( CString &strCatalogID )
|
{
|
CMBBaseCatalogObjMap::iterator it;
|
CMBBaseCatalogObj *pCatalogObj = NULL;
|
|
for( it = m_mapCatalogObj.begin();it != m_mapCatalogObj.end();it++ )
|
{
|
pCatalogObj = it->second;
|
if( pCatalogObj->m_strID == strCatalogID )
|
{
|
return pCatalogObj;
|
}else{
|
CMBBaseCatalogObj *pObj = ((CMBCatalogInfo*)pCatalogObj)->GetCatalogMgr()->DeepFindCatalogObj(strCatalogID );
|
if( pObj != NULL )
|
return pObj;
|
}
|
}
|
return NULL;
|
}
|
|
CMBCatalogInfo *CMBCatalogMgr::GetCatalogInfo( CString strID )
|
{
|
return (CMBCatalogInfo *)GetCatalogObj(strID);
|
}
|
|
|
bool CMBCatalogMgr::EmptyMgr()
|
{
|
m_mapCatalogObj.clear();
|
m_vectorCatalogObj.clear();
|
return true;
|
}
|
|
bool CMBCatalogMgr::ParseXml( CString &strXml,CString &strErrInfo )
|
{
|
if( strXml.IsEmpty() )
|
{
|
strErrInfo = _T("CMBCatalogMgr::ParseXml,²ÎÊýΪ¿Õ£¡");
|
return false;
|
}
|
|
pugi::xml_document xmlDoc;
|
|
if (!xmlDoc.load(strXml))
|
{
|
return false;
|
}
|
pugi::xml_node form = xmlDoc.child(_T("Body")).child(_T("Catalog"));
|
for(pugi::xml_node node = form; node; node = node.next_sibling(_T("Catalog")))
|
{
|
CMBCatalogInfo *pCatalogInfo = new CMBCatalogInfo();
|
//pCatalogInfo->m_strTreeID = CStrFileUtils::GenerateGuid();
|
pCatalogInfo->m_strID = node.attribute(_T("ID")).value();
|
pCatalogInfo->m_strListType = node.attribute(_T("ListType")).value();
|
pCatalogInfo->m_strOrder = node.attribute(_T("Order")).value();
|
|
CString strSubCount = node.attribute(_T("SubCount")).value();
|
pCatalogInfo->m_nSubCount = _ttoi(strSubCount);
|
CString strFileCount = node.attribute(_T("FileCount")).value();
|
pCatalogInfo->m_nFileCount = _ttoi(strFileCount);
|
pCatalogInfo->m_strDtCreate = node.attribute(_T("DTCreate")).value();
|
pCatalogInfo->m_strHasAce = node.attribute(_T("HasAce")).value();
|
pCatalogInfo->m_strPermit = node.attribute(_T("Permit")).value();
|
pCatalogInfo->m_strGlobalEdit = node.attribute(_T("GlobalEdit")).value();
|
pCatalogInfo->m_strMasterID = node.attribute(_T("MasterID")).value();
|
pCatalogInfo->m_strMasterName = node.attribute(_T("MasterName")).value();
|
pCatalogInfo->m_strName = node.child_value(_T("Name"));
|
|
if( !AddCatalogInfo(pCatalogInfo) )
|
{
|
// Èç¹û´æÔÚ ÖØÖÃ bLoadCatalog
|
GetCatalogObj( pCatalogInfo->m_strID )->m_bLoadCatalog = false;
|
GetCatalogObj( pCatalogInfo->m_strID )->m_nSubCount = pCatalogInfo->m_nSubCount;
|
GetCatalogObj( pCatalogInfo->m_strID )->m_nFileCount = pCatalogInfo->m_nFileCount;
|
delete pCatalogInfo;
|
pCatalogInfo = NULL;
|
}
|
}
|
|
return true;
|
|
}
|