使用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
#include "StdAfx.h"
#include "MBOnlineEdDBMgr.h"
 
 
CMBOnlineEdDBMgr::CMBOnlineEdDBMgr(void)
{
    m_pOnlineEdMgr = new CMBOnlineEdMgr();
}
 
 
CMBOnlineEdDBMgr::~CMBOnlineEdDBMgr(void)
{
    MBSAFE_DELETE(m_pOnlineEdMgr)
}
 
// µÃµ½ÔÚÏ߱༭¹ÜÀíÆ÷
CMBOnlineEdMgr     *CMBOnlineEdDBMgr::GetOnlineEdMgr()
{
    return m_pOnlineEdMgr;
}
 
bool CMBOnlineEdDBMgr::Init( BOOL & bThreadStop,CString strSqliteDBPath,CString &strErrInfo )
    try{
        m_db.Close(); 
        // ´ò¿ªÊý¾Ý¿â
        if( !m_db.Open( strSqliteDBPath ))
        {
             strErrInfo = _T("´ò¿ªsqliteʧ°Ü£¡");
             return false;
        }
        // ³õʼ»¯ÔÚÏ߱༭Êý¾Ý¿â
        if( !InitOnlineEdDb( bThreadStop,strErrInfo ) )
        {
            return false;
        } 
    }
    catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;    
    }  
     
    return true;
}
 
 
bool CMBOnlineEdDBMgr::InitOnlineEdDb( BOOL &bThreadStop,CString &strErrInfo )
{
    CString strSql; 
    CDBRecord  dbRecord;
    long nRecordCount = 0;    
     
    strSql.Format(_T("select * from OI_MBC_EDIT_FILE"));
 
    try{
        if(!dbRecord.Open(&m_db,strSql))
        {  
            strErrInfo = _T("´ò¿ª±íOI_MBC_UPLOAD_FILEʧ°Ü£¡");
            return false;
        }    
        //nRecordCount = dbRecord.GetRecordCount(); 
        if(!LoadOnlineEdDb(dbRecord,bThreadStop, strErrInfo ))
        {
            return false;
        } 
        dbRecord.Close();     
    }
    catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;    
    } 
 
    return true;
 
}
 
 
bool CMBOnlineEdDBMgr::LoadOnlineEdDb( CDBRecord  &dbRecord,BOOL &bThreadStop, CString &strErrInfo )
{     
    HRESULT hR = dbRecord.MoveFirst(); 
    while(S_OK== hR )
    {
        if( bThreadStop )
            return false;
 
        CMBOnlineEdInfo *pOnlineEdInfo = new CMBOnlineEdInfo();
 
        dbRecord.GetValue(_T("CN_G_DOC_ID"),pOnlineEdInfo->m_strDocID); 
        dbRecord.GetValue(_T("CN_S_SERVER_PATH"),pOnlineEdInfo->m_strSvrPath); 
        dbRecord.GetValue(_T("CN_S_LOCAL_PATH"),pOnlineEdInfo->m_strLocalPath); 
        dbRecord.GetValue(_T("CN_S_FILE_SVR"),pOnlineEdInfo->m_strFileSvr); 
        dbRecord.GetValue(_T("CN_G_FILE_ID"),pOnlineEdInfo->m_strFileID); 
        dbRecord.GetValue(_T("CN_S_FILE_NAME"),pOnlineEdInfo->m_strFileName); 
        dbRecord.GetValue(_T("CN_S_CABINET_NAME"),pOnlineEdInfo->m_strCabinetName); 
        dbRecord.GetValue(_T("CN_G_CABINET_ID"),pOnlineEdInfo->m_strCabinetID); 
        dbRecord.GetValue(_T("CN_T_LAST_MODIFY"),pOnlineEdInfo->m_strTLastModify); 
        dbRecord.GetValue(_T("CN_T_CREATE"),pOnlineEdInfo->m_strTCreate); 
        dbRecord.GetValue(_T("CN_T_UPLOAD"),pOnlineEdInfo->m_strTUpload); 
        dbRecord.GetValue(_T("CN_N_FILE_SIZE"),pOnlineEdInfo->m_nFileSize); 
        dbRecord.GetValue(_T("CN_N_CABINET_TYPE"),pOnlineEdInfo->m_nCabinetType); 
        dbRecord.GetValue(_T("CN_N_SAVEMODE"),pOnlineEdInfo->m_nSaveMode);  
 
        if(!m_pOnlineEdMgr->AddOnlineEd(pOnlineEdInfo))
        {
            delete pOnlineEdInfo;
            pOnlineEdInfo = NULL;
        } 
 
        hR = dbRecord.MoveNext();    
    }      
 
    return true;
}
 
 
bool   CMBOnlineEdDBMgr::InsertOnlineEdDB( CMBOnlineEdInfo *pOnlineEdInfo,CString &strErrInfo )
    if( NULL == pOnlineEdInfo )
        return false;
 
    CString strSql;
 
    if(IsInOnlineEdDB( pOnlineEdInfo->m_strDocID,strErrInfo ))  
        return true;
    
    strSql.Format(_T("insert into OI_MBC_EDIT_FILE(CN_G_DOC_ID,CN_S_SERVER_PATH,CN_S_LOCAL_PATH,CN_S_FILE_SVR,CN_G_FILE_ID, \
                     CN_S_FILE_NAME,CN_N_FILE_SIZE,CN_S_CABINET_NAME,CN_G_CABINET_ID,CN_N_CABINET_TYPE,CN_T_LAST_MODIFY,CN_T_CREATE,CN_T_UPLOAD) \
                     VALUES(\"%s\",\"%s\",\"%s\",'%s','%s','%s',\"%I64d\",\"%s\",\"%s\",\"%d\",\"%s\",\"%s\",\"%s\")"),
                     pOnlineEdInfo->m_strDocID,pOnlineEdInfo->m_strSvrPath,pOnlineEdInfo->m_strLocalPath,pOnlineEdInfo->m_strFileSvr,pOnlineEdInfo->m_strFileID,
                     pOnlineEdInfo->m_strFileName,pOnlineEdInfo->m_nFileSize,pOnlineEdInfo->m_strCabinetName,pOnlineEdInfo->m_strCabinetID,
                     pOnlineEdInfo->m_nCabinetType,pOnlineEdInfo->m_strTLastModify,pOnlineEdInfo->m_strTCreate,pOnlineEdInfo->m_strTUpload);
     
    try{
        int nRet = CDBSQLiteCommFun::RunSQL(strSql, &m_db );
    }
    catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;
    }
    return true;  
}
 
// ÅжÏÊÇ·ñÔÚÊý¾Ý¿â
bool CMBOnlineEdDBMgr::IsInOnlineEdDB( CString strDocID,CString &strErrInfo )
{
    CString strSql; 
    CDBRecord  dbRecord;
    long nRecordCount = 0;
 
    strSql.Format(_T("select *from OI_MBC_EDIT_FILE where CN_G_DOC_ID=\"%s\""),strDocID);
 
    try{
        if(!dbRecord.Open(&m_db,strSql))
        {  
            strErrInfo = _T("´ò¿ª±íOI_MBC_EDIT_FILEʧ°Ü£¡");
            return false;
        }     
        nRecordCount = dbRecord.GetRecordCount();
        if( 0 ==  nRecordCount){
            return false;
        }
    }
    catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;
    }
    return true;  
}
 
bool CMBOnlineEdDBMgr::UpdateOnlineEdDb1(CString strDocID,CString strTLastMdyTime,CString strTUploadTime,CString &strErrInfo)
{
    CString strSql;     
    try{
        strSql.Format(_T("UPDATE OI_MBC_EDIT_FILE SET CN_T_LAST_MODIFY=\"%s\",CN_T_UPLOAD=\"%s\" where  CN_G_DOC_ID=\"%s\""),strTLastMdyTime,strTUploadTime,strDocID);
        int nRet = CDBSQLiteCommFun::RunSQL(strSql, &m_db );    
    }catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;        
    } 
    return true; 
}
 
bool CMBOnlineEdDBMgr::UpdateOnlineEdDb2(CString strDocID,CString strTUploadTime,CString &strErrInfo)
{
    CString strSql;     
    try{
        strSql.Format(_T("UPDATE OI_MBC_EDIT_FILE SET CN_T_UPLOAD=\"%s\" where   CN_G_DOC_ID=\"%s\""),strTUploadTime,strDocID);
        int nRet = CDBSQLiteCommFun::RunSQL(strSql, &m_db );    
    }catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;        
    } 
    return true; 
}
 
bool CMBOnlineEdDBMgr::UpdateOnlineEdDb3(CString strDocID,CString strTLastMdyTime,CString &strErrInfo)
{
    CString strSql;     
    try{
        strSql.Format(_T("UPDATE OI_MBC_EDIT_FILE SET CN_T_LAST_MODIFY=\"%s\" where   CN_G_DOC_ID=\"%s\""),strTLastMdyTime,strDocID);
        int nRet = CDBSQLiteCommFun::RunSQL(strSql, &m_db );    
    }catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;        
    } 
    return true; 
}
 
// ¸üб£´æÄ£Ê½
bool CMBOnlineEdDBMgr::UpdateSaveModToOnlineEdDb( CString strDocID,int nMode,CString &strErrInfo )
{
    CString strSql;     
    try{
        strSql.Format(_T("UPDATE OI_MBC_EDIT_FILE SET CN_N_SAVEMODE=\"%d\"  where   CN_G_DOC_ID=\"%s\""),nMode,strDocID);
        int nRet = CDBSQLiteCommFun::RunSQL(strSql, &m_db );    
    }catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;        
    } 
    return true;  
}
 
bool CMBOnlineEdDBMgr::DelOnlineEdDB( CString strDocID,CString &strErrInfo )
{
    if( strDocID.IsEmpty() )
        return false;
 
    CString strSql;     
 
    try{
        strSql.Format(_T("DELETE FROM OI_MBC_EDIT_FILE SET   where   CN_G_DOC_ID=\"%s\""),strDocID);
        int nRet = CDBSQLiteCommFun::RunSQL(strSql, &m_db );    
    }catch(...)
    {
        CDBSQliteException sqliteException(m_db.m_pDB);
        strErrInfo = sqliteException.GetErrInfo();
        return false;        
    } 
    return true; 
}
 
 
// ÖØÐÂдÈëÊý¾Ý 
bool CMBOnlineEdDBMgr::ReInsertOnlineEd( CString strOldDocID,CString strNewDocID,CString &strErrInfo )
{
    if( strOldDocID.IsEmpty() || strNewDocID.IsEmpty() )
        return false;
 
    CMBOnlineEdInfo  *pOnlineEdInfo =  m_pOnlineEdMgr->GetOnlineEd1(strOldDocID);
    if( NULL == pOnlineEdInfo )
        return false;
 
    CMBOnlineEdInfo *pTmpOnlineEdInfo = new CMBOnlineEdInfo();
    *pTmpOnlineEdInfo = *pOnlineEdInfo;
    pTmpOnlineEdInfo->m_strDocID   = strNewDocID;
     
    // ÒƳý¾ÉÊý¾Ý
    if( !m_pOnlineEdMgr->RemoveOnlineEd(pOnlineEdInfo) )
    {
        delete pTmpOnlineEdInfo;
        pTmpOnlineEdInfo = NULL;
        return false;
    } 
    // Ìí¼ÓеÄ
    if( !m_pOnlineEdMgr->AddOnlineEd(pTmpOnlineEdInfo) )
    {
        delete pTmpOnlineEdInfo;
        pTmpOnlineEdInfo = NULL;
        return false;
    }
    // ´ÓDBÖÐɾ³ý
    if( !DelOnlineEdDB( strOldDocID,strErrInfo ) )
        return false;
    // ÏòDBÖвåÈëÊý¾Ý
    if( !InsertOnlineEdDB( pOnlineEdInfo,strErrInfo ) )
        return false;
 
    return true;
}