使用soui开发的mbc,只支持windows版本
w1146869587
2022-01-24 0408576e9da10015ffa9da0079b8c985113ce4b3
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
#include "StdAfx.h"
#include "MBParseServerXml.h"
#include "MBBaseDef.h"
 
CMBParseServerXml::CMBParseServerXml(void)
{
}
 
 
CMBParseServerXml::~CMBParseServerXml(void)
{
}
 
bool  CMBParseServerXml::ParseErrInfo( CString  strXml,int&  nErrCode,CString & strErr)
{
    CString strErrCode;
    pugi::xml_document              xmlDoc;    
    if (!xmlDoc.load(strXml))   
    {  
        return false;
    }   
    pugi::xml_node form = xmlDoc.child(_T("Body"));  
    strErrCode =     form.child_value(_T("ErrCode"));
    nErrCode = _ttoi(strErrCode); 
    strErr =     form.child_value(_T("ErrInfo"));
    return true;
}
 
bool  CMBParseServerXml::ParseLoginInfo(CString  strXml,CMBUserLogin *pUserLogin)
{
    if( NULL == pUserLogin ) 
        return false;
     
    CMBFileSvrInfo *pFileSvrInfo =  pUserLogin->GetFileSvrInfo();
    if( NULL == pFileSvrInfo ) 
        return false;
 
    pugi::xml_document    xmlDoc;    
    if (!xmlDoc.load(strXml))   
    {  
        return false;
    }   
    COleDateTime    dtCurrent= COleDateTime::GetCurrentTime();    
    pUserLogin->m_strLoginTime = dtCurrent.Format(_T("%Y-%m-%d %H:%M:%S"));
    pugi::xml_node form = xmlDoc.child(_T("User"));
    pUserLogin->m_strLoginName =  form.attribute(_T("Login")).value();
    pUserLogin->m_strUserName  =  form.attribute(_T("Name")).value();
    pUserLogin->m_strAliasName=  form.attribute(_T("Alias")).value();
    pUserLogin->m_strUserConnIP =  form.child_value(_T("ConnIP"));
    pUserLogin->m_strToken =  form.child_value(_T("Token"));
    form = xmlDoc.child(_T("User")).child(_T("Admin"));
    pUserLogin->m_bIsSysAdmin  =  _tstoi(form.attribute(_T("SysAdmin")).value()) ? true: false; 
    form = xmlDoc.child(_T("User")).child(_T("FileService"));
    pFileSvrInfo->m_strFlag        = form.attribute(_T("Flag")).value();
    pFileSvrInfo->m_strExterIP     = form.attribute(_T("ExterIP")).value();
    pFileSvrInfo->m_strExterPort   = form.attribute(_T("ExterPort")).value();
    if( _tstol(pFileSvrInfo->m_strExterPort) < 0)
        pFileSvrInfo->m_strExterPort.Format(_T("%d"),DEFAULTPORT_FILE);
    pFileSvrInfo->m_strInterIP     = form.attribute(_T("InterIP")).value();
    pFileSvrInfo->m_strInterPort   = form.attribute(_T("InterPort")).value();
    if( _tstol(pFileSvrInfo->m_strInterPort) < 0)
        pFileSvrInfo->m_strInterPort.Format(_T("%d"),DEFAULTPORT_FILE);
    pFileSvrInfo->m_strInterURL     = form.child_value(_T("InterURL"));
    pFileSvrInfo->m_strExterURL = form.child_value(_T("ExterURL")); 
    pFileSvrInfo->CheckServerInfo(pUserLogin->m_strServerName);
    pUserLogin->m_strFileSFlag =  pFileSvrInfo->m_strFlag  ;
    CMBAuthInfo   *pAuthInfo =  pUserLogin->GetAuthInfo();
    if( NULL == pAuthInfo )
        return false;
 
    pugi::xml_node node = xmlDoc.child(_T("User")).child(_T("AuthInfo")).child(_T("App"));
     
    for(pugi::xml_node nodeTmp = node; nodeTmp; nodeTmp = nodeTmp.next_sibling(_T("App")))
    {
        CMBAuthApp *pApp = new CMBAuthApp();  
        pApp->m_strFlag         = nodeTmp.attribute(_T("Flag")).value();
        pApp->m_strName         = nodeTmp.attribute(_T("Name")).value();
        pApp->m_strVer          = nodeTmp.attribute(_T("Ver")).value();
        pApp->m_strFuncModule   = nodeTmp.attribute(_T("FuncModule")).value();
 
        if( !pAuthInfo->Add(pApp) ){
            delete pApp;
            pApp = NULL;
            return false;
        }
    }
 
    return true;
}
 
bool  CMBParseServerXml::ParseParamInfo( CString &strParam,long &nTrID, CString &strAppType,CString &strMethod )
{
    CStringArray strArray,strTmpArray;
    CString strName,strValue;
    CMBStrOper::SplitString(strParam, _T(';'), strArray);
    for( int i= 0;i < strArray.GetCount();i++ )
    {
        strTmpArray.RemoveAll();
 
        CMBStrOper::SplitString(strArray[i], _T(':'), strTmpArray);
        strName = strTmpArray[0];
        if( strTmpArray.GetCount() == 2 ){            
            strValue = strTmpArray[1];
        }else{
            strValue = _T("");
        }        
        if(strName.CompareNoCase(_T("TrID")) == 0)
        {
            nTrID = _tstol(strValue);
        }
        else if(strName.CompareNoCase(_T("AppType")) == 0)
        {
            strAppType = strValue;
        }
        else if(strName.CompareNoCase(_T("Method")) == 0)
        {
            strMethod = strValue;
        } 
    } 
    return true;
}
 
 
bool  CMBParseServerXml::ParseParamErrInfo( CMBParamErrInfoMap & mapParam,CString &strParam  )
{
    CStringArray aryItem;
    int n = CMBStrOper::SplitString(strParam,_T(';'), aryItem);
    for( int i =0;i < aryItem.GetCount();i++ )
    {
        CString strTmp = aryItem[i];
        int nPos = strTmp.Find(_T("="));
        CString strKey     = strTmp.Left(nPos);
        CString strValue = strTmp.Right( strTmp.GetLength() - nPos -1 ) ; 
        mapParam[strKey] = strValue;
    } 
    return true;
}