使用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
#include "StdAfx.h"
#include "MBGridStyleMgr.h"
#include "json.h"
 
CMBGridStyleMgr::CMBGridStyleMgr(void)
{
    RemoveAllGridStyle(); 
}
 
 
CMBGridStyleMgr::~CMBGridStyleMgr(void)
{
    RemoveAllGridStyle();
}
 
void CMBGridStyleMgr::GetGridStyleMap( CMBGridStyleAttrMgrMap &map)
{
    map.clear();
    map = m_map;     
}
 
CMBGridStyleAttrMgr      *CMBGridStyleMgr::GetGridStyle( CString strVaultID )
{
    if( strVaultID.IsEmpty() )
        return NULL;
 
    CMBGridStyleAttrMgrMap::iterator    it; 
    CMBGridStyleAttrMgr *pObj  = NULL;
 
    it = m_map.find(strVaultID);
 
    if( it!= m_map.end() )
        pObj = it->second;
 
    return pObj;   
}
 
bool     CMBGridStyleMgr::AddGridStyle( CMBGridStyleAttrMgr *pObj )
{
    if( NULL ==  pObj || pObj->m_strVaultID.IsEmpty() )
        return false;
 
    CMBGridStyleAttrMgrMap::iterator    it; 
    CString strVaultID;
 
 
    strVaultID = pObj->m_strVaultID;
    it = m_map.find(strVaultID);
 
    // Èç¹ûÕҵõ½ ·µ»Ø
    if( it != m_map.end() )
        return false;
 
    m_map[strVaultID] = pObj;      
 
    return true;
 
}
 
bool       CMBGridStyleMgr::RemoveAllGridStyle()
{
    CMBGridStyleAttrMgrMap::iterator    it; 
    CMBGridStyleAttrMgr *pObj  = NULL;
    
    for( it = m_map.begin();it != m_map.end();it++ )
    {
        pObj = it->second;
        delete pObj;
        pObj = NULL;        
    }
 
    m_map.clear();  
 
    return true;
}
 
 
bool  CMBGridStyleMgr::AddGridStyle(CString strVaultID,CString strExePath,CString &strErrInfo)
{
    CString strGridStyle,strJsonContent,strWidth;
    Json::Reader reader;
    Json::Value json_object;
    Json::Value json_cell;
    Json::Value json_attr;
    string json,attr,showName,width;    
 
    strGridStyle.Format(_T("%svalut\\%s\\GridStyle.json"),strExePath,strVaultID);
    // ¶ÁÎļþÄÚÈÝ
    if(! CStrFileUtils::GetStrFromFile(strGridStyle,strJsonContent))
    {
        strErrInfo = _T("¶ÁÎļþ ") + strGridStyle + _T(" Ê§°Ü£¡");
        return false;
    }
     
    json = CT2A(strJsonContent);
  
    if (!reader.parse(json, json_object)){
         strErrInfo = strGridStyle+ _T(" ·Çjson¸ñʽ£¡");
         return false;
    }
 
    json_cell     = json_object["Cell"] ;
    if( json_cell.isArray() )
    {
        CMBGridStyleAttrMgr *pObj = new CMBGridStyleAttrMgr();
        pObj->m_strVaultID        = strVaultID;
 
        int nSize = json_cell.size();
        for( int i =0;i<nSize;i++ )
        {
             json_attr = json_cell[i];
              
             CMBGridStyleAttr *pAttr = new CMBGridStyleAttr();
             attr       = json_attr["Attr"].asString();    
             showName   = json_attr["ShowName"].asString();  
             width        = json_attr["Width"].asString();
 
             pAttr->m_strAttr     = CA2T(attr.c_str());
             pAttr->m_strShowName = CA2T(showName.c_str());    
             strWidth              = CA2T(width.c_str());      
             pAttr->m_nWidth       = _ttoi(strWidth);
                
             if( !pObj->AddAttr(pAttr) )
             {
                delete pAttr;
                pAttr = NULL;
             }
        }// end for
 
        if(!AddGridStyle( pObj ) )
        {
            delete pObj;
            pObj = NULL;
        } 
    }
     
 
    return true;
}