使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 4905e2e7537d507f218e8e9595485e09d9f3a2b4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include "StdAfx.h"
#include "MBSelUserMgr.h"
 
 
CMBSelUserMgr::CMBSelUserMgr(void)
{
    RemoveAll();
}
 
 
CMBSelUserMgr::~CMBSelUserMgr(void)
{
    RemoveAll();
}
 
bool            CMBSelUserMgr::GetVector( CMBSelUserVector  &vector )
{
    vector.clear(); 
    vector = m_vector; 
    return true;
}
 
bool            CMBSelUserMgr::Add(CMBSelUser *pUser)
{    
    if( NULL ==  pUser || pUser->m_strLogin.IsEmpty() )
        return false;
 
    CMBSelUserMap::iterator    it;
    CString strLogin;
  
 
    strLogin = pUser->m_strLogin;
    it = m_map.find(strLogin);
 
    // Èç¹ûÕҵõ½ ·µ»Ø
    if( it != m_map.end() )
        return false;
 
    m_map[strLogin] = pUser; 
    m_vector.push_back(pUser);
    return true; 
}
 
CMBSelUser       *CMBSelUserMgr::Get( CString strLogin )
{
    if( strLogin.IsEmpty() )
    {
        return NULL;
    }
 
    CMBSelUserMap::iterator    it;
    CMBSelUser *pUser = NULL;
 
    it = m_map.find(strLogin);
 
    if( it!= m_map.end() )
        pUser = it->second;
 
    return pUser; 
}
 
bool            CMBSelUserMgr::Remove( CMBSelUser *pUser )
{
    bool bDelte = false;
    if( NULL ==  pUser )
        return false;
    CMBSelUserMap::iterator    it = m_map.find(pUser->m_strLogin);
 
    if( it!= m_map.end() )
    {
        bDelte = true;
        m_map.erase(it);
    } 
    CMBSelUserVector::iterator    it1 = std::find(m_vector.begin( ), m_vector.end( ), pUser); //²éÕÒ3
    if( it1 != m_vector.end( ) ){
        bDelte = true;
        m_vector.erase(it1);
    }    
    if( bDelte ){
        delete pUser;
        pUser = NULL;
    }
    return true;
}
 
bool            CMBSelUserMgr::RemoveAll()
{
    CMBSelUserMap::iterator    it;
    CMBSelUser *pUser = NULL;
 
    for( it = m_map.begin();it != m_map.end();it++ )
    {
        pUser = it->second;
        delete pUser;
        pUser = NULL;        
    }
 
    m_map.clear(); 
    m_vector.clear();
 
    return true;
}
    
int  CMBSelUserMgr::GetCount()
{
    return m_map.size();
}
 
CString  CMBSelUserMgr::GetUsersXml()
{
    CString strUsersXml,strUserXml;
    CMBSelUserVector::iterator    it;
    CMBSelUser *pUser = NULL;
 
    for( it = m_vector.begin();it != m_vector.end();it++ )
    {
        pUser = *it;
        strUserXml.Format(_T("<User ID='%s' Name='%s' />"),pUser->m_strLogin,pUser->m_strName);
        strUsersXml +=  strUserXml;    
    }
    return strUsersXml;
}
 
 
bool  CMBSelUserMgr::ParseShareXml( CString &strXml,CString &strErrInfo )
{
    if( strXml.IsEmpty() )
    { 
        //strErrInfo = _T("CMBSelUserMgr::ParseShareXml,²ÎÊýstrXmlΪ¿Õ£¡");
        return true;
    }
 
    CString               strFileSize;
    pugi::xml_document    xmlDoc;
 
    if (!xmlDoc.load(strXml))   
    {  
        return false;
    }   
    pugi::xml_node form  = xmlDoc.child(_T("Body")).child(_T("User")); 
    for(pugi::xml_node node = form; node; node = node.next_sibling(_T("User")))
    {
        CMBSelUser *pUser    = new CMBSelUser();
         
        pUser->m_strLogin        = node.attribute(_T("Login")).value();
        pUser->m_strName         = node.attribute(_T("Name")).value(); 
        pUser->m_nType           = 0;
 
        if( !Add(pUser) )
        {  
            delete pUser;
            pUser = NULL;
        }
    } 
 
    return true; 
}