使用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
293
294
295
296
297
298
#include "StdAfx.h"
#include "MBFireAppExtParam.h"
#include "json.h"
 
CMBFireAppExtParam::CMBFireAppExtParam(void)
{
    m_pMasterCls    = new CMBFireMasterCls();
    m_pComposeCls   = new CMBFireComposeCls();
    m_pDataCls      = new CMBFireDataCls();
    m_pGroupSet     = new CMBFireGroupSet();
    m_pQrCodeSet    = new CMBFireQrCodeSet();
    m_pPrintStyle   = new CMBFirePrintStyle();
    m_pOutputSet    = new CMBFireOutputSet(); 
}
 
 
CMBFireAppExtParam::~CMBFireAppExtParam(void)
{
    MBSAFE_DELETE(m_pMasterCls)
    MBSAFE_DELETE(m_pComposeCls)
    MBSAFE_DELETE(m_pDataCls)
    MBSAFE_DELETE(m_pGroupSet)
    MBSAFE_DELETE(m_pQrCodeSet)
    MBSAFE_DELETE(m_pPrintStyle)
    MBSAFE_DELETE(m_pOutputSet)
}
 
 
CMBFireMasterCls   *CMBFireAppExtParam::GetMasterCls()
{
    return m_pMasterCls;
}
 
CMBFireComposeCls  *CMBFireAppExtParam::GetComposeCls()
{
    return m_pComposeCls;
}
 
CMBFireDataCls     *CMBFireAppExtParam::GetDataCls()
{
    return m_pDataCls;
}
 
CMBFireGroupSet    *CMBFireAppExtParam::GetGroupSet()
{
    return m_pGroupSet;
}
 
CMBFireQrCodeSet   *CMBFireAppExtParam::GetQrCodeSet()
{
    return m_pQrCodeSet;
}
 
CMBFirePrintStyle  *CMBFireAppExtParam::GetPrintStyle()
{
    return m_pPrintStyle;
}
 
CMBFireOutputSet   *CMBFireAppExtParam::GetOutputSet()
    return m_pOutputSet;
}
 
// {"mastercls":{"cls_id":"0031","cls_name":"µç¿Ø×ܳÉ","key_attr":"CODE","key_attrname":"ÎïÁϱàÂë","key_attrsize":"32","attrs":[{"attr":"NAME","name":"Ãû³Æ","size":"128"}]},"composecls":{"cls_id":"0032","cls_name":"Èí¼þ"},"datacls":{"cls_id":"0030","cls_name":"µç¿ØÈí¼þ"},"groupset":{"group":"1","attr":"TYPE","attr_name":"Èí¼þÀàÐÍ"},"qr_code_set":[{"clsid":"0031","attr":"CODE"},{"clsid":"0030","attr":"SOFT_CODE"}]}
bool            CMBFireAppExtParam::ParseJson( CString strJson,CString &strErrInfo )
{
    if( strJson.IsEmpty() )
        return false;
 
    ////////³õʼ»¯///////////////////
    MBSAFE_DELETE(m_pMasterCls)
    MBSAFE_DELETE(m_pComposeCls)
    MBSAFE_DELETE(m_pDataCls)
    MBSAFE_DELETE(m_pGroupSet)
    MBSAFE_DELETE(m_pQrCodeSet)
    MBSAFE_DELETE(m_pPrintStyle)
    MBSAFE_DELETE(m_pOutputSet)
 
    m_pMasterCls    = new CMBFireMasterCls();
    m_pComposeCls   = new CMBFireComposeCls();
    m_pDataCls      = new CMBFireDataCls();
    m_pGroupSet     = new CMBFireGroupSet();
    m_pQrCodeSet    = new CMBFireQrCodeSet();    
    m_pPrintStyle   = new CMBFirePrintStyle();
    m_pOutputSet    = new CMBFireOutputSet(); 
    //////////////////////////////////////////
    Json::Reader reader;
    Json::Value json_object;
    Json::Value json_orderby;
    Json::Value json_groupset;
    Json::Value json_outputset;
    Json::Value json_masterclsattr;
 
    CString strDataType,strDesc;
    string json;     
    string masterCls,composeCls,dataCls,groupSet,qrCodeSet;
 
    strJson.Replace(_T("'"),_T("\""));
 
    json = CT2A(strJson);
  
    if (!reader.parse(json, json_object)){
         strErrInfo = strJson + _T(" ·Çjson¸ñʽ£¡");
         return false;
    }
 
    m_pMasterCls->m_strClsID         = json_object["mastercls"]["cls_id"].asString().c_str();
    m_pMasterCls->m_strClsName         = json_object["mastercls"]["cls_name"].asString().c_str();
    m_pMasterCls->m_strKeyAttr         = json_object["mastercls"]["key_attr"].asString().c_str();
    m_pMasterCls->m_strKeyAttrName     = json_object["mastercls"]["key_attrname"].asString().c_str();
    m_pMasterCls->m_strKeyAttrSize     = json_object["mastercls"]["keyattr_size"].asString().c_str();
    m_pMasterCls->m_strNameAttr       = json_object["mastercls"]["name_attr"].asString().c_str();
    m_pMasterCls->m_strNameAttrName  = json_object["mastercls"]["name_attrname"].asString().c_str(); 
    m_pMasterCls->m_strNameAttrSize  = json_object["mastercls"]["nameattr_size"].asString().c_str(); 
    json_masterclsattr               = json_object["mastercls"]["attrs"];
    if( json_masterclsattr.isArray() )
    { 
        int nSize = json_masterclsattr.size();
        for( int i = 0; i< nSize; i++ )
        {
            CMBFireMasterClsAttr *pAttr = new CMBFireMasterClsAttr();
              
            pAttr->m_strAttr = json_masterclsattr[i]["attr"].asString().c_str();
            pAttr->m_strName  = json_masterclsattr[i]["name"].asString().c_str();
            pAttr->m_strSize  = json_masterclsattr[i]["size"].asString().c_str();
             
            if( !m_pMasterCls->GetAttrMgr()->AddAttr( pAttr ) )
            {
                MBSAFE_DELETE(pAttr)
            }
             
        }// end for 
    } // end if( json_masterclsattr.isArray() )
 
  
    m_pComposeCls->m_strClsID        = json_object["composecls"]["cls_id"].asString().c_str();
    m_pComposeCls->m_strClsName      = json_object["composecls"]["cls_name"].asString().c_str();
 
    // orderby
    json_orderby = json_object["composecls"]["orderby"];
    if( json_orderby.isArray() )
    { 
        int nSize = json_orderby.size();
        for( int i = 0; i< nSize; i++ )
        {
            CMBFireOrderBy *pOrderBy = new CMBFireOrderBy();
            pOrderBy->m_strAttr      = json_orderby[i]["attr"].asString().c_str(); 
            strDesc                     = json_orderby[i]["desc"].asString().c_str();
            if( strDesc == _T("1") )
            {
                 pOrderBy->m_bDesc = true;
            }                 
            if( !m_pComposeCls->AddOrderBy(pOrderBy) )
            {
                MBSAFE_DELETE(pOrderBy)
            }
        }
    }
    
 
     
    m_pDataCls->m_strClsID           = json_object["datacls"]["cls_id"].asString().c_str();
    m_pDataCls->m_strClsName         = json_object["datacls"]["cls_name"].asString().c_str();
     
    m_pGroupSet->m_strGroup          = json_object["groupset"]["group"].asString().c_str();
    m_pGroupSet->m_strAttr           = json_object["groupset"]["attr"].asString().c_str();
    m_pGroupSet->m_strAttrName       = json_object["groupset"]["attr_name"].asString().c_str();
 
    //// qr_code_set
    json_groupset     = json_object["qr_code_set"] ;
    if( json_groupset.isArray() )
    { 
        int nSize = json_groupset.size();
        for( int i = 0; i< nSize; i++ )
        {
            CMBFireQrCodeInfo *pQrCodeInfo = new CMBFireQrCodeInfo();
            strDataType              =  json_groupset[i]["datatype"].asString().c_str();
            pQrCodeInfo->m_nDataType = _ttoi(strDataType);
            pQrCodeInfo->m_strClsID = json_groupset[i]["clsid"].asString().c_str();
            pQrCodeInfo->m_strAttr  = json_groupset[i]["attr"].asString().c_str();
            pQrCodeInfo->m_strValue  = json_groupset[i]["value"].asString().c_str();
              
            if( !m_pQrCodeSet->AddQrCode(pQrCodeInfo) )
            {
                MBSAFE_DELETE(pQrCodeInfo)
            }
             
        }// end for 
    } // end if( json_groupset.isArray() )
    /// print_style
    m_pPrintStyle->m_strLayout         = json_object["print_style"]["layout"].asString().c_str();
    m_pPrintStyle->m_strQrPosition   = json_object["print_style"]["qr_position"].asString().c_str();
    //// attr_output_set    
    json_outputset     = json_object["attr_output_set"] ;
    if( json_outputset.isArray() )
    { 
        int nSize = json_outputset.size();
        for( int i = 0; i< nSize; i++ )
        {
            CMBFireOutputSetInfo *pSetInfo = new CMBFireOutputSetInfo();
            strDataType              = json_outputset[i]["datatype"].asString().c_str();
            pSetInfo->m_nDataType     = _ttoi(strDataType);
            pSetInfo->m_strClsID     = json_outputset[i]["clsid"].asString().c_str();
            pSetInfo->m_strAttr         = json_outputset[i]["attr"].asString().c_str();
            pSetInfo->m_strValue     = json_outputset[i]["value"].asString().c_str();
            pSetInfo->m_strTitle     = json_outputset[i]["title"].asString().c_str();
            if( !m_pOutputSet->Add(pSetInfo) )
            {
                MBSAFE_DELETE(pSetInfo)
            }
             
        }// end for 
    } // end if( json_groupset.isArray() )
     
    return true;
}
 
 // ÊÇ·ñ´ïµ½ÒªÇó 
bool            CMBFireAppExtParam::IsReachRequire(CString &strErrInfo)
{
    if(m_pMasterCls->m_strClsID.IsEmpty())
    {
        strErrInfo = _T("master clsidΪ¿Õ£¡");
        return false;
    }
 
    if( m_pComposeCls->m_strClsID.IsEmpty() )
    {
        strErrInfo = _T("Compose clsidΪ¿Õ£¡");
        return false;
    }
 
    if( m_pDataCls->m_strClsID.IsEmpty() )
    {
        strErrInfo = _T("data clsidΪ¿Õ£¡");
        return false;
    }
    
 
    return true;
}
 
 
CString         CMBFireAppExtParam::GetTN_XXX_XXXTableName()
{
    CString strTableName;
 
    strTableName.Format(_T("TN_%s_%s"),m_pMasterCls->m_strClsID,m_pDataCls->m_strClsID);
 
    return strTableName;
}
 
CString         CMBFireAppExtParam::GetTN_XXXTableName()
{
    CString strTableName;
 
    strTableName.Format(_T("TN_%s"),m_pDataCls->m_strClsID);
 
    return strTableName;
}
 
 
CString          CMBFireAppExtParam::GetTN_MClsID_DClsIDCreateTableSql()
{
    CString strSql,strTableName,strKeyAttrSize,
            strNameAttrSize,strAttrSql,strKeyAttr;
     
    strTableName = GetTN_XXX_XXXTableName();
 
    // Ä¬ÈÏ
    strKeyAttrSize  = _T("32");
    strNameAttrSize = _T("64");
    strKeyAttr        = m_pMasterCls->m_strKeyAttr;
 
    if( !m_pMasterCls->m_strKeyAttrSize.IsEmpty() )
    {
        strKeyAttrSize = m_pMasterCls->m_strKeyAttrSize;
    }
    
    if( !m_pMasterCls->m_strNameAttrSize.IsEmpty() )
    {
        strNameAttrSize = m_pMasterCls->m_strNameAttrSize;
    }
 
    strAttrSql = m_pMasterCls->GetAttrMgr()->GetAttrSql();
 
    strSql.Format(_T("CREATE TABLE  %s(G_MASTER_OBJ_ID char(36),G_SLAVE_OBJ_ID char(36),G_SLAVE_OBJ_VID char(36),%s varchar(%s),%s,C_Order int,C_Effect char(10),C_Invalidate char(10),PRIMARY KEY(G_MASTER_OBJ_ID,G_SLAVE_OBJ_ID))"),
        strTableName,strKeyAttr,strKeyAttrSize,strAttrSql );
     
 
    return strSql;
}
 
// Ö÷ÀàÊôÐÔ
CString         CMBFireAppExtParam::GetMasterClassAttrs()
{
    return m_pMasterCls->GetMasterClassAttrs();    
}