使用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
#include "StdAfx.h"
#include "MBFileSvrInfo.h"
#include "MBBaseDef.h"
CMBFileSvrInfo::CMBFileSvrInfo(void)
{
    m_bServerChecked = FALSE;
    m_pThreadCheckServer = new CMBThreadCheckServer();
    m_pThreadCheckServer->m_pSvrInfo = this;
}
CMBFileSvrInfo::~CMBFileSvrInfo(void)
{
    m_pThreadCheckServer->OverThread();
    MBSAFE_DELETE(m_pThreadCheckServer);    
}
CString CMBFileSvrInfo::GetUrl( )
{  
    CString strURL; 
    if( !m_strInterURL.IsEmpty() )
    {
        strURL = m_strInterURL;
    }
    else{
        strURL = m_strExterURL;
    }
    return strURL;
}
 
// <FileService Flag="NetDisk" ExterServer="0" ExterIP="115.29.185.26" ExterPort="5012"><ExterURL><![CDATA[http://115.29.185.26:80]]></ExterURL></FileService>
 
bool CMBFileSvrInfo::ParseXml( CString strXml,CString strOrgServer,CString &strErrInfo )
{
    pugi::xml_document    xmlDoc;    
    if (!xmlDoc.load(strXml))   
    {  
        return false;
    }   
    m_bServerChecked = FALSE;
    pugi::xml_node  form = xmlDoc.child(_T("FileService"));
    m_strFlag        = form.attribute(_T("Flag")).value();
    m_strExterIP     = form.attribute(_T("ExterIP")).value();
    m_strExterPort   = form.attribute(_T("ExterPort")).value();
    if( _tstol(m_strExterPort) < 0)
        m_strExterPort.Format(_T("%d"),DEFAULTPORT_FILE);
    m_strInterIP     = form.attribute(_T("InterIP")).value();
    m_strInterPort   = form.attribute(_T("InterPort")).value();
    if( _tstol(m_strInterPort) < 0)
        m_strInterPort.Format(_T("%d"),DEFAULTPORT_FILE);
    m_strExterURL = form.child_value(_T("ExterURL")); 
    m_strInterURL    = form.child_value(_T("InterURL"));
    return CheckServerInfo(strOrgServer);
}
bool CMBFileSvrInfo::CheckServerInfo( CString strOrgServer)
{
    CString strExtURLValue = m_strExterURL; 
    CString strInterURLValue    = m_strInterURL;
    m_strInterURL  = _T("");
    m_strExterURL  = _T("");
    if(m_strInterIP.IsEmpty() )
    {
        if(m_strExterIP.IsEmpty() )
        {
            m_strExterIP = strOrgServer;
            
        }
        SetValidSvrInfo(m_strExterIP, m_strExterPort);
    }
    else
    {
        if(m_strExterIP.IsEmpty())
        {
            SetValidSvrInfo(m_strInterIP, m_strInterIP);
        }
        else
        {
            if(m_strExterIP.CompareNoCase(m_strInterIP) == 0)
            {
                SetValidSvrInfo(m_strExterIP, m_strExterPort);
            }
            else
            {
                m_pThreadCheckServer->StartThread();
            }
        }
    }
    if( !strInterURLValue.IsEmpty())
    {
        CString strIP = m_strInterIP;
        if(strIP.IsEmpty())
            strIP = strOrgServer; 
        CString strInterURL = strInterURLValue;
        strInterURLValue.MakeLower();
        CString strHttp = _T("http://:");
        int nPos = strInterURLValue.Find(strHttp);
        if(nPos == 0)
        {
            strInterURLValue.Format(_T("http://%s:%s"),strIP, strInterURL.Right(strInterURLValue.GetLength() -strHttp.GetLength() ));
            strInterURL = strInterURLValue;
        }
        else
        {
            strHttp = _T("https://:");
            nPos = strInterURLValue.Find(strHttp);
            if(nPos == 0)
            {
                strInterURLValue.Format(_T("https://%s:%s"),strIP, strInterURL.Right(strInterURLValue.GetLength() -strHttp.GetLength() ));
                strInterURL = strInterURLValue;
            }
        }
        m_strInterURL  = strInterURL;
    }
    else
    {
        CString strIP = m_strExterIP;
        if(strIP.IsEmpty())
            strIP = strOrgServer; 
        CString strExtURL = strExtURLValue;
        strExtURLValue.MakeLower();
        CString strHttp = _T("http://:");
        int nPos = strExtURLValue.Find(strHttp);
        if(nPos == 0)
        {
            strExtURLValue.Format(_T("http://%s:%s"),strIP, strExtURL.Right(strExtURLValue.GetLength() -strHttp.GetLength() ));
            strExtURL = strExtURLValue;
        }
        else
        {
            strHttp = _T("https://:");
            nPos = strExtURLValue.Find(strHttp);
            if(nPos == 0)
            {
                strExtURLValue.Format(_T("https://%s:%s"),strIP, strExtURL.Right(strExtURLValue.GetLength() -strHttp.GetLength() ));
                strExtURL = strExtURLValue;
            }
        }
        m_strExterURL  = strExtURL;
    }
    return true;
}