使用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
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
#include "StdAfx.h"
#include "MBCfgInfo.h"
 
 
CMBCfgInfo::CMBCfgInfo(CString strCfgName)
    m_pStrFileUtils = NULL;
 
    if( m_pStrFileUtils->IsExist(strCfgName) )
    {
        m_pStrFileUtils = new CStrFileUtils();
 
        m_iniFile.SetFileName(strCfgName);
        ReInit();
    } 
}
 
CMBCfgInfo::CMBCfgInfo()
{
 
 
}
 
CMBCfgInfo::~CMBCfgInfo(void)
{
    if(m_pStrFileUtils == NULL){
        delete m_pStrFileUtils;
        m_pStrFileUtils = NULL;
    }
}
 
void CMBCfgInfo::ReInit(CString strCfgName)
{
    m_pStrFileUtils = NULL;
 
    if( m_pStrFileUtils->IsExist(strCfgName) )
    {
        m_pStrFileUtils = new CStrFileUtils();
 
        m_iniFile.SetFileName(strCfgName);
        ReInit();
    }  
}
 
 
void CMBCfgInfo::ReInit()
    m_arServerLst.RemoveAll();
    m_arServerLoginLst.RemoveAll();
    m_arServerIDLst.RemoveAll();
 
    m_iniFile.GetProfileString(_T("MOBOX_APPSET"),_T("ServerName"), m_strServerName );   //µÇ¼µÄ·þÎñ 
    m_iniFile.GetProfileString(_T("MOBOX_APPSET"),_T("Port"), m_strPort );               //µÇ¼µÄ·þÎñ¶Ë¿Ú    
    m_iniFile.GetProfileString(_T("MOBOX_APPSET"),_T("LoginName"), m_strLoginName );     //µÇ¼µÄÓû§µÇ¼Ãû                                            
    m_iniFile.GetProfileString(_T("MOBOX_APPSET"),_T("AutoLogin"), m_strAutoLogin );     //ÊÇ·ñ×Ô¶¯µÇ¼ 1 ×Ô¶¯µÇ¼ 0 ²»ÊÇ                                            
    m_iniFile.GetProfileString(_T("MOBOX_APPSET"),_T("SavePwd"), m_strSavePwd );         //ÊÇ·ñ±£´æÃÜÂë 1 ÊDZ£´æ   0 ÊDz»±£´æ    
    //m_iniFile.GetProfileString(_T("MOBOX_APPSET"),_T("Password"), m_strPwd );            //ÃÜÂ룬¼ÓÃܺóµÄ
    m_iniFile.GetProfileSection(_T("SERVERLIST"),m_arServerLst);                         //·þÎñÆ÷Áбí
    m_iniFile.GetProfileSection(_T("SERVERLOGINLIST"),m_arServerLoginLst);               //µÇ¼µÄ·þÎñ¶ÔÓ¦µÇ¼µÄһЩÓû§Áбí
    m_iniFile.GetProfileSection(_T("SERVERIDLIST"),m_arServerIDLst);                     //µÇ½¹ýµÄ·þÎñ¶ÔÓ¦µÄServerID£¬Ã¿¸ö·þÎñ¶¼ÓÐÒ»¸öΨһµÄID  
    m_iniFile.GetProfileString(_T("MOBOX_APPSET"),_T("Offline"),m_strOffline);             // ÀëÏß  1 ÊÇÀëÏß   0 ²»ÀëÏß                                
 
void CMBCfgInfo::GetServerLst(  CStringArray &strArray )
{
    strArray.RemoveAll();
    for( int i = 0;i < m_arServerLst.GetCount();i++ )
    {
        CString strTmp = m_arServerLst[i];
        int npos = strTmp.Find(_T('='));
        CString strKey = strTmp.Left(npos);
        CString strValue = strTmp.Mid(npos + 1);
        strArray.Add(strValue);
    }
}
 
CString CMBCfgInfo::GetServerSection( CString strServer )
{
    for( int i = 0;i < m_arServerLst.GetCount();i++ )
    {
        CString strTmp = m_arServerLst[i];
        int npos = strTmp.Find(_T('='));
        CString strKey = strTmp.Left(npos);
        CString strValue = strTmp.Mid(npos + 1);
        if( strValue == strServer )
        {
            return strKey;
        }
    } 
    return GetMaxServerSection();
}
 
CString CMBCfgInfo::GetMaxServerSection()
{
    CString strMaxSection;
    int nMax = 1;
    for( int i = 0;i < m_arServerLst.GetCount();i++ )
    {
        CString strTmp = m_arServerLst[i];
        int npos = strTmp.Find(_T('='));
        CString strKey = strTmp.Left(npos); 
         strKey.Replace(_T("server"),_T(""));
        if( _ttoi(strKey) > nMax )
        {
            nMax =  _ttoi(strKey) ;
        }
    } 
    nMax++;
    strMaxSection.Format(_T("server%d"),nMax);
    return strMaxSection;
}
 
void  CMBCfgInfo::GetLoginLst( CString strServerName,CStringArray &strArray )
{
    strArray.RemoveAll();
    CString strTmpLogins;
    for( int i = 0;i < m_arServerLoginLst.GetCount();i++ )
    {
        CString strTmp = m_arServerLoginLst[i];
        int npos = strTmp.Find(_T('='));
        CString strKey = strTmp.Left(npos);
        CString strValue = strTmp.Mid(npos + 1);
        if( strKey == strServerName ){
             strTmpLogins = strValue;
             break;
        } 
    }
    CMBStrOper::SplitString(strTmpLogins, _T(';'), strArray);         
}
 
CString CMBCfgInfo::GetServerID( CString strServerName )
{     
    for( int i = 0;i < m_arServerIDLst.GetCount();i++ )
    {
        CString strTmp = m_arServerIDLst[i];
        int npos = strTmp.Find(_T('='));
        CString strKey = strTmp.Left(npos);
        CString strValue = strTmp.Mid(npos + 1);
        if( strKey == strServerName ){
             return strValue;
        } 
    }
    return _T("");
}
 
 
 
CString CMBCfgInfo::GetLoginLstStr( CString strServerName,CString strLogin  )
    CString strTmpLogins,strTmpLogin;
    CStringArray strArray;
    bool bExist = false;
 
    for( int i = 0;i < m_arServerLoginLst.GetCount();i++ )
    {
        CString strTmp = m_arServerLoginLst[i];
        int npos = strTmp.Find(_T('='));
        CString strKey = strTmp.Left(npos);
        CString strValue = strTmp.Mid(npos + 1);
        if( strKey == strServerName ){
            strTmpLogins = strValue;
            break;
        } 
    }
    if( !strTmpLogins.IsEmpty() )
    {
        CMBStrOper::SplitString(strTmpLogins, _T(';'), strArray);
        for( int i = 0;i < strArray.GetCount();i++ )
        {
            strTmpLogin = strArray[i];
            if( strTmpLogin == strLogin )
            {
                bExist = true;
                return strTmpLogins;
            } 
        }
        if( !bExist )
        {
            return (strTmpLogins + _T(";") + strLogin);
        }
    }
    return strLogin;
}