使用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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#include "StdAfx.h"
#include "MBUserLogin.h"
#include "MBParseServerXml.h"
#include "MBBaseDef.h"
 
#define            WEB_PARAM_HOSTNAME        _T("[hostname]")//Ö÷·þÎñµØÖ·
#define            WEB_PARAM_PORT            _T("[port]")//Ö÷·þÎñ¶Ë¿Ú
 
#define            WEB_PARAM_ORGSERVER        _T("[orgserver]")//org·þÎñip
#define            WEB_PARAM_ORGSPORT        _T("[orgsport]")//org·þÎñi¶Ë¿Ú
 
#define            WEB_PARAM_LOGINNAME        _T("[loginname]")//µÇ¼Óû§µÄµÇ¼Ãû 
#define            WEB_PARAM_SL            _T("[sl]")  //µÇ¼Óû§µÄµÇ¼Ãû P512D790¼ÓÃܺó
#define            WEB_PARAM_USERNAME        _T("[username]")//µÇ¼Óû§µÄÓû§Ãû 
#define            WEB_PARAM_SU            _T("[su]")//µÇ¼Óû§µÄÓû§Ãû P512D790¼ÓÃܺó
 
#define            WEB_PARAM_INPUTNAME        _T("[inputname]")//µÇ¼ʱÊäÈëµÄÃû×Ö
 
#define            WEB_PARAM_SP            _T("[sp]")//µÇ¼Óû§µÄÃÜÂë P512D790¼ÓÃܺó
#define            WEB_PARAM_PASSWORD        _T("[password]")//µÇ¼Óû§µÄÃÜÂë
#define            WEB_PARAM_MP            _T("[mp]")  //µÇ¼Óû§µÄÃÜÂë md5¼ÓÃܺó
 
 
#define            WEB_PARAM_SESSIONID        _T("[sessionid]") //Org»á»°id
 
#define            WEB_PARAM_TOKEN            _T("[token]")//Org»á»°Token
#define            WEB_PARAM_CONNIP        _T("[connip]")//µÇ¼Óû§µÄÍⲿip
#define            WEB_PARAM_PCNAME        _T("[pcname]")//µÇ¼Óû§µÄ¼ÆËã»úÃû³Æ
 
CMBUserLogin::CMBUserLogin(void)
{
    m_pSvrInfo = new CMBFileSvrInfo();
    m_pAuthInfo  = new CMBAuthInfo();
    m_bIsSysAdmin = false;
    m_nMBCShowMode = 0;
    m_pUserAce = new CMBUserAce();
    m_pMBUserPro    = new CMBUserPro;
    m_asUserIP.RemoveAll();
 
    m_strOrgServer = _T("");
    m_nOrgServerPort = DEFAULTPORT_ORG;
 
    m_strFileSFlag = _T("");
 
    m_strAceServer = _T("");
    m_nAceServerPort = DEFAULTPORT_ACE;
    m_nMoboxSPort = DEFAULTPORT_MOBOX;
    m_strMoboxServer= _T("");
 
    m_nNetDiakSPort = DEFAULTPORT_NETDISK;
    m_strNetDiakServer= _T("");
 
    m_nCalendarWebSPort = DEFAULTPORT_CANLENDARWEB;
    m_strCalendarWebServer= _T("");
    m_strMainCrowdServer = _T("");
    m_nMainCrowdPort = DEFAULTPORT_MCROWD ;
    m_strUpsServer = _T("");
    m_nUpsServerPort = DEFAULTPORT_UPS ;
    m_strExtServer = _T("");
    m_nExtServerPort = DEFAULTPORT_EXT ;
 
    m_strExtWebServer = _T("");
    m_nExtWebServerPort = DEFAULTPORT_EXTWEB ;
    m_bIsOffline         = false;         // ÊÇÀëÏß״̬
 
    m_strDataServer      = _T("");
    m_nDataPort          = DEFAULTPORT_DATA;
}
 
 
CMBUserLogin::~CMBUserLogin(void)
{
    if( m_pSvrInfo )
    {
        delete m_pSvrInfo;
        m_pSvrInfo = NULL;
    }
    if( m_pAuthInfo )
    {
        delete m_pAuthInfo;
        m_pAuthInfo = NULL;
    }
    if( m_pUserAce )
    {
        delete m_pUserAce;
        m_pUserAce = NULL;
    }
 
    
}
 
CMBFileSvrInfo *CMBUserLogin::GetFileSvrInfo()
{
    return m_pSvrInfo;
}
 
bool  CMBUserLogin::ParseUserLoginXml( CString &strXml )
{
    return CMBParseServerXml::ParseLoginInfo(strXml,this); 
}
 
//bool  CMBUserLogin::ParseUserInfoXml( CString &strXml,CString &strErrInfo )
//{
//    pugi::xml_document    xmlDoc;    
//    if (!xmlDoc.load(strXml))   
//    {  
//        return false;
//    }   
//    CString strSecret;
//    pugi::xml_node form = xmlDoc.child(_T("User"));
//    m_strLoginName =  form.attribute(_T("Login")).value();
//    m_strUserName  =  form.attribute(_T("Name")).value();
//    m_pMBUser->m_strAlias =  form.attribute(_T("Alias")).value(); 
//
//    m_pMBUser->m_strNamePY = form.attribute(_T("NamePY")).value();
//    m_pMBUser->m_strDispName = form.attribute(_T("DispName")).value();
//    m_pMBUser->m_strLevel = form.attribute(_T("Level")).value();
//    m_pMBUser->m_strState = form.attribute(_T("State")).value();
//    m_pMBUser->m_strPhoto = form.attribute(_T("Photo")).value();
//    strSecret= form.attribute(_T("Secret")).value();
//    m_pMBUser->m_nSecret = _ttoi(strSecret);
//    m_pMBUser->m_strSex = form.attribute(_T("Sex")).value();
//    m_pMBUser->m_strDTJoin = form.attribute(_T("DTJoin")).value(); 
//    m_pMBUser->m_strMobile = form.attribute(_T("Mobile")).value();
//    m_pMBUser->m_strEmail = form.attribute(_T("Email")).value();
//    m_pMBUser->m_strDepart = form.attribute(_T("Depart")).value();
//    m_pMBUser->m_strUnit = form.attribute(_T("Unit")).value();
//    m_pMBUser->m_strSign = form.child_value(_T("Sign")) ; 
//     
//    return true;
//}
BOOL CMBUserLogin::ParseOrgBaseInfoXml( CString &strXmlBuff,CString &strErrInfo )
{
    if(strXmlBuff.IsEmpty())
        return FALSE;
    COIXMLParser        xmlParser;
    IXMLDOMElementPtr    ptrBody;
    IXMLDOMNodePtr        ptrNode,ptrNext;
    CString                strNodeName,strNodeValue,strAttrValue;
    if( !xmlParser.ParseXMLStr(strXmlBuff, ptrBody) )
    {
        return FALSE;
    }
    COIXMLParser::GetNodeContent(ptrBody, strNodeName, strNodeValue);
    if(0 != strNodeName.CompareNoCase(_T("Body")))
    {
        return FALSE;
    }
    ptrBody->get_firstChild( &ptrNode);
    while(ptrNode)
    {
        COIXMLParser::GetNodeContent(ptrNode, strNodeName, strNodeValue);
        if ( strNodeName.CompareNoCase( _T("Name") ) == 0  )
        {
            m_strCompany= strNodeValue;
        }
        else if ( strNodeName.CompareNoCase( _T("ShortName") ) == 0  )
        {
            m_strCompanyShort= strNodeValue;
        }
        ptrNode->get_nextSibling( &ptrNext);
        ptrNode = ptrNext;
    }
    return TRUE;
}
 
//====================================
// »ñÈ¡±¾»úÃû³Æ
//====================================
bool  CMBUserLogin::GetHostName(  )
{
    char strHost[260] = { 0 };
    LPWSTR        pszW = NULL; 
    if( SOCKET_ERROR == gethostname(strHost, sizeof(strHost)) )
        return false;
    if ( CBaseCommFun::AnsiToUnicode((LPCSTR)strHost, &pszW))
    {
        m_strPCName.Format(_T("%s"), pszW);
        CoTaskMemFree( pszW );
    }
    return true;
}
//====================================
// »ñÈ¡±¾»úµÄIPµØÖ·
//====================================
bool  CMBUserLogin::GetHostIP( CStringArray &asIP )
{
    char strHost[260] = { 0 };
    LPWSTR        pszW = NULL; 
    asIP.RemoveAll();
    if( SOCKET_ERROR == gethostname(strHost, sizeof(strHost)) )
        return false;
    if (  CBaseCommFun::AnsiToUnicode((LPCSTR)strHost, &pszW))
    {
        m_strPCName.Format(_T("%s"), pszW);
        CoTaskMemFree( pszW );
    }
    struct hostent *hp = NULL;
    hp = gethostbyname(strHost);
    if (hp != NULL && hp->h_addr_list[0] != NULL)
    {
        if ( hp ->h_length < 4)
            return TRUE;
    }
    CString        strLog;
    int            nAdapter = 0;
    CString        strIPTemp;
    in_addr        address;
    
    while( hp->h_addr_list[nAdapter] )
    {
        CopyMemory(&address.S_un.S_addr, hp->h_addr_list[nAdapter], hp->h_length);
        strIPTemp = inet_ntoa (address);
        asIP.Add( strIPTemp );
        nAdapter ++;
    }
    return true;
}
void CMBUserLogin::ReplaceSysValue(CString &strData )
{
    CString        strPassword;
    CString        strLoginName, strUserName;
 
    CString strParam    = strData;
    //strParam.MakeLower();
 
    strParam.Replace(WEB_PARAM_LOGINNAME, m_strLoginName );
    strParam.Replace(WEB_PARAM_INPUTNAME, m_strInputName );
    strParam.Replace(WEB_PARAM_USERNAME,m_strUserName );
    strParam.Replace(WEB_PARAM_PASSWORD,m_strPwd );
    strParam.Replace(WEB_PARAM_TOKEN,m_strToken );
 
    strPassword = m_strPwd;
    CEncrypt::Encrypt( strPassword, _T("P512D790") );
    strParam.Replace( WEB_PARAM_SP , strPassword );
 
    strLoginName =  m_strLoginName;
    CEncrypt::Encrypt( strLoginName, _T("P512D790") );
    strParam.Replace( WEB_PARAM_SL, strLoginName );
 
    strUserName = m_strUserName  ;
    CEncrypt::Encrypt( strUserName, _T("P512D790") );
    strParam.Replace( WEB_PARAM_SU, strUserName );
 
    strPassword =m_strPwd;
    MD5Encrypt( strPassword );
    strParam.Replace( WEB_PARAM_MP, strPassword );
 
    strParam.Replace(WEB_PARAM_HOSTNAME, m_strServerName);
    strParam.Replace(WEB_PARAM_SESSIONID, m_strSessionID);
    strParam.Replace(WEB_PARAM_PORT,m_strPort);
 
    strParam.Replace(WEB_PARAM_ORGSERVER, m_strServerName);
    strParam.Replace(WEB_PARAM_ORGSPORT, m_strPort);
 
    strParam.Replace(WEB_PARAM_PCNAME, m_strPCName);
    strParam.Replace(WEB_PARAM_CONNIP, m_strUserConnIP);
    strData = strParam;
    //strData = CSTKCommFun::URLEncode(strParam);
    //CSTKCommFun::WriteLog(strData);
}
 
//===================================
// MD5¼ÓÃÜ
//===================================
void CMBUserLogin::MD5Encrypt( CString &strData )
{
    CMD5Encrypt        md5;
    TCHAR            szEncrypt[33]    = { 0 };
    CString            strStuff;
    int                nLength(0);
 
    strStuff = strData;
    nLength     = strStuff.GetLength();
    md5.digest_md5( (TCHAR*)strStuff.GetBuffer( nLength ), nLength, szEncrypt );
    strStuff.ReleaseBuffer();
 
    strData    = szEncrypt;
}
CMBAuthInfo         *CMBUserLogin::GetAuthInfo()
{
    return m_pAuthInfo;
}
 
CMBUserAce    *CMBUserLogin::GetUserAce()
{
    return m_pUserAce;
}
CMBUserPro   *CMBUserLogin::GetUserPro()
{
    return m_pMBUserPro;
}