ClientProcess.cpp 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185
  1. #include "StdAfx.h"
  2. #include "ClientProcess.h"
  3. #include "GuardInfo.h"
  4. #include "GuardCommand.h"
  5. #include "..\..\..\common\cJson\cJSON.h"
  6. #include "Base64.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #endif
  10. #define INVALID_VALUE ((DWORD)-1)
  11. CRITICAL_SECTION CClientProcess::m_csMsgInfo;
  12. list<MsgInfo> CClientProcess::m_listMsgInfo;
  13. ThreadSection g_critSection;
  14. CString GetAuthCode(CString requestcode, long newsecond)
  15. {
  16. AutoThreadSection aSection(&g_critSection);
  17. try
  18. {
  19. UINT m_year;
  20. UINT m_month;
  21. UINT m_day;
  22. UINT m_hour;
  23. UINT m_minute;
  24. {
  25. TCHAR year[10],month[10],day[10],hour[10],minute[10], second[10];
  26. ConvertTimerToStringReal(newsecond, year, month, day, hour, minute, second);
  27. m_year=_ttoi(year);
  28. m_month=_ttoi(month);
  29. m_day=_ttoi(day);
  30. m_hour=_ttoi(hour);
  31. m_minute=_ttoi(minute);
  32. if(newsecond==60)
  33. {
  34. m_year=60;
  35. m_month=0;
  36. m_day=0;
  37. m_hour=0;
  38. m_minute=0;
  39. }
  40. }
  41. if(m_year<0 || m_month<0 || m_day<0 || m_hour<0 || m_minute<0)
  42. {
  43. return _T("");
  44. }
  45. requestcode.TrimLeft();
  46. requestcode.TrimRight();
  47. requestcode.Replace("\n", "");
  48. requestcode.Replace("\r", "");
  49. if(requestcode.IsEmpty())
  50. {
  51. return "";
  52. }
  53. TString str,temp,temp2;
  54. int id,time1,time2,idtemp;
  55. int leng;
  56. str=requestcode;
  57. temp=str.substr(0,3);
  58. str=str.substr(3);
  59. leng=_ttoi(temp.substr(0,2).c_str());
  60. temp2=str.substr(0, leng);
  61. str=str.substr(leng);
  62. id=_ttoi(temp2.c_str());
  63. if(temp.substr(temp.length() -1)=="1")id=-id;
  64. //////////////////////////////////////////////////
  65. temp=str.substr(0,3);
  66. str=str.substr(3);
  67. leng=_ttoi(temp.substr(0,2).c_str());
  68. temp2=str.substr(0, leng);
  69. str=str.substr(leng);
  70. time1=_ttoi(temp2.c_str());
  71. if(temp.substr(temp.length() -1)=="1")time1=-time1;
  72. //////////////////////////////////////////////////
  73. temp=str.substr(0,3);
  74. str=str.substr(3);
  75. leng=_ttoi(temp.substr(0,2).c_str());
  76. temp2=str.substr(0, leng);
  77. str=str.substr(leng);
  78. time2=_ttoi(temp2.c_str());
  79. if(temp.substr(temp.length() -1)=="1")time2=-time2;
  80. //////////////////////////////////////////////////////
  81. temp=str.substr(0,3);
  82. str=str.substr(3);
  83. leng=_ttoi(temp.substr(0,2).c_str());
  84. temp2=str.substr(0, leng);
  85. str=str.substr(leng);
  86. idtemp=_ttoi(temp2.c_str());
  87. if(temp.substr(temp.length() -1)=="1")idtemp=-idtemp;
  88. //////////////////////////////////////////////////////
  89. int ret=0;//ytSoftKey.Ini();
  90. int d[8];double f[8];
  91. char s0[50]="",s1[50]="",s2[50]="",s3[50]="",s4[50]="",s5[50]="",s6[50]="",s7[50]="";
  92. // 运行自定义函数;
  93. ret = g_ytSoftKey.code2(&id,&idtemp,&time1,&time2,&d[4],&d[5],&d[6],&d[7],&f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],s0,s1,s2,s3,s4,s5,s6,s7);
  94. if( ret!=0 && ret != -43)
  95. {
  96. printf("获取用户运行时间出错:%s\n",Encryptlockkernel::GetYtUSBKey32ErrInfo(ret));
  97. LOG4C_NO_FILENUM((LOG_NOTICE, "获取用户运行时间出错:%s", Encryptlockkernel::GetYtUSBKey32ErrInfo(ret)));
  98. return "";
  99. }
  100. ////////////////////////////////////////////////////////////////////////
  101. TCHAR DevicePath[ 260];
  102. if(FindPort(0,DevicePath)!=0)
  103. return "";
  104. DWORD OutID;
  105. int version;
  106. GetIDVersion(&OutID, &version, DevicePath);
  107. TCHAR year[10],month[10],day[10],hour[10],minute[10], OutString[100];
  108. _stprintf_s(year, _T("%d"), m_year);
  109. _stprintf_s(month, _T("%d"), m_month);
  110. _stprintf_s(day, _T("%d"), m_day);
  111. _stprintf_s(hour, _T("%d"), m_hour);
  112. _stprintf_s(minute, _T("%d"), m_minute);
  113. MakeTimerAuth("20D30D15FFB7F6AF9EAB30FD229F797B", id, year, month, day, hour, minute, OutString,DevicePath);
  114. CString authcode=OutString;
  115. TCHAR szTemp[50] = {0};
  116. //str.Format ("%04d", m_year);
  117. _stprintf_s(szTemp, _T("%04d"), m_year);
  118. authcode += szTemp;
  119. //str.Format ("%02d", m_month);
  120. _stprintf_s(szTemp, _T("%02d"), m_month);
  121. authcode += szTemp;
  122. //str.Format ("%02d", m_day);
  123. _stprintf_s(szTemp, _T("%02d"), m_day);
  124. authcode+=szTemp;
  125. _stprintf_s(szTemp, _T("%02d"), m_hour);
  126. //str.Format ("%02d", m_hour);
  127. authcode+=szTemp;
  128. _stprintf_s(szTemp, _T("%02d"), m_minute);
  129. //str.Format ("%02d", m_minute);
  130. authcode+=szTemp;
  131. //str.Format ("%08d", id);
  132. _stprintf_s(szTemp, _T("%08d"), id);
  133. authcode+=szTemp;
  134. TString str1,str2,str3,str4,str5;
  135. str1=authcode.Mid (0, 20);
  136. str2=authcode.Mid (20, 20);
  137. str3=authcode.Mid (40, 20);
  138. str4=authcode.Mid (60, 20);
  139. str5=authcode.Mid (80, 20);
  140. _stprintf_s(s0, "%s", str1.c_str());
  141. _stprintf_s(s1, "%s", str2.c_str());
  142. _stprintf_s(s2, "%s", str3.c_str());
  143. _stprintf_s(s3, "%s", str4.c_str());
  144. _stprintf_s(s4, "%s", str5.c_str());
  145. //运行自定义函数
  146. {
  147. //SoftKey ytSoftKey2;
  148. //ret=ytSoftKey2.Ini();
  149. //if (ret!=0 )
  150. //{
  151. // return "";
  152. //}
  153. {
  154. int d[8];double f[8];
  155. char s5[50]="",s6[50]="",s7[50]="";
  156. ret=g_ytSoftKey.code1(&d[0],&d[1],&d[2],&d[3],&d[4],&d[5],&d[6],&d[7],&f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],s0,s1,s2,s3,s4,s5,s6,s7);
  157. if(ret!=0 && ret!=-43)
  158. {
  159. printf("解释用户运行时间出错:%s\n",Encryptlockkernel::GetYtUSBKey32ErrInfo(ret));
  160. LOG4C_NO_FILENUM((LOG_NOTICE, "解释用户运行时间出错:%s", Encryptlockkernel::GetYtUSBKey32ErrInfo(ret)));
  161. return "";
  162. }
  163. }
  164. str1=s0;
  165. str2=s1;
  166. str3=s2;
  167. str4=s3;
  168. str5=s4;
  169. }
  170. authcode=str1.c_str();
  171. authcode+=str2.c_str();
  172. authcode+=str3.c_str();
  173. authcode+=str4.c_str();
  174. authcode+=str5.c_str();
  175. return authcode;
  176. }
  177. catch(...)
  178. {
  179. }
  180. return _T("");
  181. }
  182. CString GetUseDays(CString requestcode)
  183. {
  184. AutoThreadSection aSection(&g_critSection);
  185. try
  186. {
  187. CString sRet;
  188. requestcode.TrimLeft();
  189. requestcode.TrimRight();
  190. requestcode.Replace("\n", "");
  191. requestcode.Replace("\r", "");
  192. if(requestcode.IsEmpty())
  193. {
  194. printf("获取运行时间出错:请求码空\n");
  195. //LOG4C_NO_FILENUM((LOG_NOTICE, "获取运行时间出错:请求码空"));
  196. return "";
  197. }
  198. TString str,temp,temp2;
  199. int id,time1,time2,idtemp;
  200. int leng;
  201. str=requestcode;
  202. temp=str.substr(0,3);
  203. str=str.substr(3);
  204. leng=_ttoi(temp.substr(0,2).c_str());
  205. temp2=str.substr(0,leng);
  206. str=str.substr(leng);
  207. id=_ttoi(temp2.c_str());
  208. if(temp.substr(temp.length() - 1)=="1")id=-id;
  209. //////////////////////////////////////////////////
  210. temp=str.substr(0,3);
  211. str=str.substr(3);
  212. leng=_ttoi(temp.substr(0,2).c_str());
  213. temp2=str.substr(0,leng);
  214. str=str.substr(leng);
  215. time1=_ttoi(temp2.c_str());
  216. if(temp.substr(temp.length() - 1)=="1")time1=-time1;
  217. //////////////////////////////////////////////////
  218. temp=str.substr(0,3);
  219. str=str.substr(3);
  220. leng=_ttoi(temp.substr(0,2).c_str());
  221. temp2=str.substr(0,leng);
  222. str=str.substr(leng);
  223. time2=_ttoi(temp2.c_str());
  224. if(temp.substr(temp.length() - 1)=="1")time2=-time2;
  225. //////////////////////////////////////////////////////
  226. temp=str.substr(0,3);
  227. str=str.substr(3);
  228. leng=_ttoi(temp.substr(0,2).c_str());
  229. temp2=str.substr(0,leng);
  230. str=str.substr(leng);
  231. idtemp=_ttoi(temp2.c_str());
  232. if(temp.substr(temp.length() - 1)=="1")idtemp=-idtemp;
  233. //////////////////////////////////////////////////////
  234. int ret=0;
  235. int d[8];double f[8];
  236. char s0[50]="",s1[50]="",s2[50]="",s3[50]="",s4[50]="",s5[50]="",s6[50]="",s7[50]="";
  237. //运行自定义函数
  238. ret=g_ytSoftKey.code2(&id,&idtemp,&time1,&time2,&d[4],&d[5],&d[6],&d[7],&f[0],&f[1],&f[2],&f[3],&f[4],&f[5],&f[6],&f[7],s0,s1,s2,s3,s4,s5,s6,s7);
  239. if(ret!=0 && ret!=-43)
  240. {
  241. printf("获取用户运行时间出错:%s\n",Encryptlockkernel::GetYtUSBKey32ErrInfo(ret));
  242. LOG4C_NO_FILENUM((LOG_NOTICE, "获取用户运行时间出错:%s", Encryptlockkernel::GetYtUSBKey32ErrInfo(ret)));
  243. return "";
  244. }
  245. // TODO: Add your control notification handler code here
  246. TCHAR year[10],month[10],day[10],hour[10],minute[10], second[10];
  247. ConvertTimerToStringReal(time2, year, month, day, hour, minute, second);
  248. TCHAR szTemp[MAX_PATH];
  249. _stprintf_s(szTemp, _T("已运行:%d年%d月%d日 "), _ttoi(year), _ttoi(month), _ttoi(day));
  250. sRet+=szTemp;
  251. if(time1>0)
  252. ConvertTimerToStringReal(time1, year, month, day, hour, minute, second);
  253. else
  254. {
  255. _stprintf_s(year, "%s", "0");
  256. _stprintf_s(month, "%s", "0");
  257. _stprintf_s(day, "%s", "0");
  258. _stprintf_s(hour, "%s", "0");
  259. _stprintf_s(minute, "%s", "0");
  260. }
  261. _stprintf_s(szTemp, _T("能运行:%d年%d月%d日---%d"), _ttoi(year), _ttoi(month), _ttoi(day), time2);
  262. sRet+=szTemp;
  263. return sRet;
  264. }
  265. catch(...)
  266. {
  267. }
  268. return "";
  269. }
  270. CClientProcess::CClientProcess(void)
  271. {
  272. m_hEvent = NULL;
  273. m_hThread = NULL;
  274. m_hEvent2 = NULL;
  275. m_hThread2 = NULL;
  276. m_dwOverBuffer = m_dwOverIndex = 0;
  277. m_pOverBuffer = NULL;
  278. InitializeCriticalSection(&m_csMsgInfo);
  279. }
  280. CClientProcess::~CClientProcess(void)
  281. {
  282. DeleteCriticalSection(&m_csMsgInfo);
  283. m_listMsgInfo.clear();
  284. }
  285. void CClientProcess::StartMsgWork()
  286. {
  287. m_hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
  288. if ( m_hEvent == NULL )
  289. {
  290. // 创建事件失败;
  291. return;
  292. }
  293. m_hThread = CreateThread(NULL, 0, MsgThread, this, 0, NULL);
  294. if ( m_hThread == NULL )
  295. {
  296. CloseHandle(m_hEvent);
  297. m_hEvent = NULL;
  298. }
  299. //////////////////////////////////////////////////////////////////////////
  300. m_hEvent2 = CreateEvent(NULL, TRUE, FALSE, NULL);
  301. if ( m_hEvent2 == NULL )
  302. {
  303. // 创建事件失败;
  304. return;
  305. }
  306. m_hThread2 = CreateThread(NULL, 0, MsgThread, this, 0, NULL);
  307. if ( m_hThread2 == NULL )
  308. {
  309. CloseHandle(m_hEvent2);
  310. m_hEvent2 = NULL;
  311. }
  312. }
  313. void CClientProcess::EndOfMsgWork()
  314. {
  315. if ( m_hEvent )
  316. {
  317. SetEvent(m_hEvent);
  318. }
  319. if ( m_hThread )
  320. {
  321. WaitForSingleObject(m_hThread, INFINITE);
  322. CloseHandle(m_hThread);
  323. m_hThread = NULL;
  324. }
  325. if (m_hEvent)
  326. CloseHandle(m_hEvent);
  327. m_hEvent = NULL;
  328. //////////////////////////////////////////////////////////////////////////
  329. if ( m_hEvent2 )
  330. {
  331. SetEvent(m_hEvent2);
  332. }
  333. if ( m_hThread2 )
  334. {
  335. WaitForSingleObject(m_hThread2, INFINITE);
  336. CloseHandle(m_hThread2);
  337. m_hThread2 = NULL;
  338. }
  339. if (m_hEvent2)
  340. CloseHandle(m_hEvent2);
  341. m_hEvent2 = NULL;
  342. }
  343. void CClientProcess::InsertMsgInfo(IN MsgInfo& msgInfo)
  344. {
  345. EnterCriticalSection(&m_csMsgInfo);
  346. m_listMsgInfo.push_back(msgInfo);
  347. LeaveCriticalSection(&m_csMsgInfo);
  348. }
  349. BOOL CClientProcess::PopMsgInfo(IN MsgInfo& msgInfo)
  350. {
  351. BOOL bRet = FALSE;
  352. EnterCriticalSection(&m_csMsgInfo);
  353. if ( m_listMsgInfo.size())
  354. {
  355. msgInfo = m_listMsgInfo.front();
  356. m_listMsgInfo.pop_front();
  357. bRet = TRUE;
  358. }
  359. LeaveCriticalSection(&m_csMsgInfo);
  360. return bRet;
  361. }
  362. DWORD CClientProcess::WorkSendInfo(IN CONST SOCKET& nSock, IN TString &strIPAddr, IN const DWORD& dwUserId, IN CONST INT& wMessageLen, IN TString &strInfo, OUT INT& ArySize, OUT BYTE** pAryData, OUT DWORD& dwAryDataSize)
  363. {
  364. CSocketHandle tClientSo;
  365. tClientSo.Attach(nSock);
  366. SockAddrIn saddr;
  367. tClientSo.GetPeerName(saddr);
  368. TCHAR szIPAddr[MAX_PATH] = { 0 };
  369. CSocketHandle::FormatIP(szIPAddr, MAX_PATH, saddr);
  370. CString str;
  371. str.Format(_T("%s : %d"), szIPAddr, static_cast<int>(static_cast<UINT>(ntohs(saddr.GetPort()))));
  372. if ( str.CompareNoCase(strIPAddr.c_str()) != 0 )
  373. {
  374. tClientSo.Detach();
  375. printf("SOCKET[%d]地址接收前[%s]和发送前地址[%s]不一样\n", nSock, strIPAddr.c_str(), str.GetString());
  376. //LOG4C_NO_FILENUM((LOG_NOTICE,"SOCKET[%d]地址接收前[%s]和发送前地址[%s]不一样", nSock, strIPAddr.c_str(), str.GetString()));
  377. return INVALID_VALUE;
  378. }
  379. //////////////////////////////////////////////////////////////////////////
  380. DWORD dwFromUserID = wMessageLen;
  381. WORD wMessageId = MSG_CHATMESSAGE_RESP;
  382. DWORD dwDataLen;
  383. BYTE *pSendData;
  384. TCHAT_MESSAGE_STRU *pChatMessage;
  385. TMessageHeader tHeader = {0};
  386. tHeader.wMessageId = wMessageId;
  387. SENDHEAD tSendhead;
  388. ZeroMemory(&tSendhead,sizeof(SENDHEAD));
  389. if ( strInfo.empty() )
  390. strInfo = _T("OK");
  391. int nDataLen = strInfo.length();
  392. if( dwAryDataSize )
  393. {
  394. nDataLen = dwAryDataSize;
  395. if ( dwUserId == 8)
  396. tSendhead.count[0] = ArySize;
  397. }
  398. dwDataLen = sizeof(TCHAT_MESSAGE_STRU) + nDataLen ;
  399. pSendData = new BYTE[dwDataLen];
  400. pChatMessage=(TCHAT_MESSAGE_STRU*)pSendData;
  401. memset(pChatMessage, 0x00, dwDataLen);
  402. memcpy(pSendData, &tSendhead, sizeof(SENDHEAD));
  403. pChatMessage->tCommonMsg.dwConnectionID = dwFromUserID;
  404. pChatMessage->tCommonMsg.wMessageId = wMessageId;
  405. pChatMessage->dwFromUserID = dwFromUserID;
  406. pChatMessage->dwToUserID = pChatMessage->wMessageLen;
  407. pChatMessage->wMessageLen = nDataLen;
  408. if(dwAryDataSize)
  409. {
  410. memcpy(pChatMessage->byFileContent, *pAryData, nDataLen);
  411. }
  412. else
  413. {
  414. memcpy(pChatMessage->byFileContent, strInfo.c_str(), nDataLen);
  415. }
  416. DWORD dwResult = net_Send(&tClientSo, &tHeader, (void *)pChatMessage, dwDataLen);
  417. tClientSo.Detach();
  418. delete [] pSendData;
  419. return dwResult;
  420. }
  421. DWORD CClientProcess::MsgThread(LPVOID lpParam)
  422. {
  423. INT nRet = -1;
  424. BOOL bSend = FALSE;
  425. INT nArySize = 0;
  426. DWORD dwAryDataSize = 0;
  427. BYTE *pAryData = NULL;
  428. CClientProcess *pInstance = (CClientProcess*)lpParam;
  429. do
  430. {
  431. MsgInfo tagMsgInfo;
  432. if ( PopMsgInfo(tagMsgInfo) )
  433. {
  434. bSend = FALSE;
  435. switch( tagMsgInfo.dwUserId )
  436. {
  437. case 6:
  438. bSend = Work_No6(tagMsgInfo.strMessage, tagMsgInfo.strIPAddress.c_str());
  439. break;
  440. case 7:
  441. bSend = Work_No7(tagMsgInfo.strMessage);
  442. break;
  443. case 8:
  444. bSend = Work_No8(tagMsgInfo.strMessage, nArySize, &pAryData, dwAryDataSize);
  445. break;
  446. case 9:
  447. bSend = Work_No9(tagMsgInfo.strMessage, tagMsgInfo.pData, tagMsgInfo.wMessageLen);
  448. break;
  449. case 10:
  450. bSend = Work_No10(tagMsgInfo.strIPAddress.c_str(), tagMsgInfo.strMessage);
  451. break;
  452. case 11:
  453. bSend = Work_No11(tagMsgInfo.strMessage);
  454. break;
  455. case 12:
  456. bSend = Work_No12(tagMsgInfo.strMessage);
  457. break;
  458. case 13:
  459. bSend = Work_No13(tagMsgInfo.strMessage);
  460. break;
  461. case 14:
  462. bSend = Work_No14(tagMsgInfo.strMessage);
  463. break;
  464. case 15:
  465. bSend = Work_No15(tagMsgInfo.strMessage);
  466. break;
  467. case 16:
  468. bSend = Work_No16(tagMsgInfo.strIPAddress.c_str(), tagMsgInfo.strMessage);
  469. break;
  470. case 17:
  471. bSend = Work_No17(tagMsgInfo.strIPAddress.c_str(), tagMsgInfo.pData, tagMsgInfo.wMessageLen, &pAryData, dwAryDataSize);
  472. break;
  473. case 18:
  474. nRet = Work_No18(tagMsgInfo.strIPAddress.c_str(), tagMsgInfo.strMessage);
  475. break;
  476. default:
  477. break;
  478. }
  479. if ( tagMsgInfo.dwUserId == 18 )
  480. {
  481. DWORD dwResult = WorkSendInfo(tagMsgInfo.nSocket, tagMsgInfo.strIPAddress, tagMsgInfo.dwUserId, tagMsgInfo.wMessageLen, tagMsgInfo.strMessage, nArySize, &pAryData, dwAryDataSize);
  482. if ( pAryData )
  483. {
  484. delete []pAryData;
  485. pAryData = NULL;
  486. }
  487. nArySize = 0;
  488. dwAryDataSize = 0;
  489. if ( nRet > 0 && dwResult != INVALID_VALUE )
  490. {// 更新;
  491. CString strSQL = _T("");
  492. strSQL.Format(_T("UPDATE [StudioInfo] SET [CommandStatus] = 'true' WHERE [StudioAutoID] = %d"), nRet);
  493. g_podbc->ExecuteSQL(strSQL);
  494. }
  495. }
  496. else if ( bSend )
  497. {
  498. WorkSendInfo(tagMsgInfo.nSocket, tagMsgInfo.strIPAddress, tagMsgInfo.dwUserId, tagMsgInfo.wMessageLen, tagMsgInfo.strMessage, nArySize, &pAryData, dwAryDataSize);
  499. if ( tagMsgInfo.dwUserId == 17 && tagMsgInfo.pData )
  500. {
  501. delete []tagMsgInfo.pData;
  502. }
  503. if ( pAryData )
  504. {
  505. delete []pAryData;
  506. pAryData = NULL;
  507. }
  508. nArySize = 0;
  509. dwAryDataSize = 0;
  510. }
  511. else
  512. {
  513. // 这里有问题,原来旧的代码也没有做处理,会导致客户端接收不到服务器响应;
  514. }
  515. }
  516. } while (WaitForSingleObject(pInstance->m_hEvent, 10) == WAIT_TIMEOUT );
  517. return 0;
  518. }
  519. DWORD CClientProcess::net_Send(CSocketHandle* pSH, IN void *pHeader, IN void *pMessage, IN unsigned long ulDataLen)
  520. {
  521. unsigned long ulSendLen = 0;
  522. unsigned long ulBufLen = 0;
  523. TMessageHeader *pSendHeader = (TMessageHeader *)pHeader;
  524. ulBufLen = MESSAGE_HEADER_LEN + ulDataLen;
  525. BYTE *pSendBuf = new BYTE[ulBufLen];
  526. memset(pSendBuf, 0, ulBufLen);
  527. TMessageHeader *pMessageHeader = (TMessageHeader *)pSendBuf;
  528. pMessageHeader->byVersion = 101;
  529. pMessageHeader->wHeaderFlag = MESSAGE_HEADER_FLAG;
  530. pMessageHeader->wMessageId = pSendHeader->wMessageId;
  531. pMessageHeader->wMessageSubId = pSendHeader->wMessageSubId;
  532. pMessageHeader->dwDataLen = ulDataLen;
  533. pMessageHeader->wReserve = 0;
  534. memcpy((void *)(pSendBuf+MESSAGE_HEADER_LEN), pMessage, ulDataLen);
  535. // convert network word
  536. htons(pMessageHeader->wHeaderFlag);
  537. htons(pMessageHeader->wMessageId);
  538. htons(pMessageHeader->wMessageSubId);
  539. htonl(pMessageHeader->dwDataLen);
  540. htons(pMessageHeader->wCheckSum);
  541. htonl(pMessageHeader->wReserve);
  542. INT nBytes = pSH->Write(pSendBuf, ulBufLen, NULL, 1000);
  543. DWORD dwError = WSAGetLastError();
  544. if ( dwError != 0 )
  545. {
  546. printf("\t发送给客户端信息失败:%d\n", dwError);
  547. }
  548. delete []pSendBuf;
  549. pSendBuf = NULL;
  550. return nBytes;
  551. }
  552. void CClientProcess::ClientProcess(IN const SOCKET sClient, IN const BYTE* pbData, IN DWORD dwCount, IN LPCTSTR lpaddr, IN BYTE** PendingBuf, IN UINT &nPendingSize, IN UINT &nCurSize)
  553. {
  554. try
  555. {
  556. TMessageHeader *pMessageHeader = (TMessageHeader *)pbData;
  557. if(pMessageHeader->wMessageId == MSG_LOGIN_REQ)
  558. {
  559. WORD wMessageId = MSG_LOGIN_RESP;
  560. LOGIN_RESULT_STRU tLoginResult = {0};
  561. tLoginResult.tCommonMsg.dwConnectionID = 0;
  562. tLoginResult.tCommonMsg.wMessageId = wMessageId;
  563. tLoginResult.byResult = LOGIN_RESULT_SUC;
  564. tLoginResult.dwUserID = 0;
  565. tLoginResult.byStatus = USER_STATUS_ONLINE ;
  566. DWORD dwDataLen = sizeof(LOGIN_RESULT_STRU);
  567. TMessageHeader tHeader = {0};
  568. tHeader.wMessageId = wMessageId;
  569. tHeader.dwDataLen = dwDataLen;
  570. if ( (pMessageHeader->dwDataLen + sizeof(LOGIN_RESULT_STRU)) != dwCount )
  571. {
  572. return;
  573. }
  574. CSocketHandle hClient;
  575. hClient.Attach(sClient);
  576. net_Send(&hClient, &tHeader, (void *)&tLoginResult, dwDataLen);
  577. hClient.Detach();
  578. }
  579. else //if(pMessageHeader->wMessageId == MSG_CHATMESSAGE_REQ)
  580. {
  581. TCHAT_MESSAGE_STRU *ptChatMessage = (TCHAT_MESSAGE_STRU *)(pbData+MESSAGE_HEADER_LEN);
  582. if ( dwCount != ( ptChatMessage->wMessageLen + sizeof(TCHAT_MESSAGE_STRU) + sizeof(TMessageHeader) ))
  583. {
  584. return;
  585. if (m_pOverBuffer == NULL && m_dwOverBuffer == 0 && m_dwOverIndex == 0)
  586. {
  587. m_dwOverBuffer = ptChatMessage->wMessageLen + sizeof(TCHAT_MESSAGE_STRU) + sizeof(TMessageHeader);
  588. m_pOverBuffer = new BYTE[m_dwOverBuffer];
  589. memset(m_pOverBuffer, 0, m_dwOverBuffer);
  590. }
  591. memcpy(m_pOverBuffer + m_dwOverIndex, pbData, dwCount);
  592. m_dwOverIndex += dwCount;
  593. if ( m_dwOverBuffer == m_dwOverIndex )
  594. {
  595. ptChatMessage = (TCHAT_MESSAGE_STRU *)(m_pOverBuffer+MESSAGE_HEADER_LEN);
  596. }
  597. else if ( m_dwOverIndex > m_dwOverBuffer )
  598. {
  599. if (m_pOverBuffer)
  600. {
  601. delete []m_pOverBuffer;
  602. m_pOverBuffer = NULL;
  603. m_dwOverIndex = m_dwOverBuffer = 0;
  604. }
  605. return;
  606. }
  607. else
  608. {
  609. return;
  610. }
  611. }
  612. DWORD dwUserId = ptChatMessage->tCommonMsg.dwConnectionID;
  613. if ( ptChatMessage->length[98] != 987123768 )
  614. {
  615. if (m_pOverBuffer)
  616. {
  617. delete []m_pOverBuffer;
  618. m_pOverBuffer = NULL;
  619. m_dwOverIndex = m_dwOverBuffer = 0;
  620. }
  621. return;
  622. }
  623. TString strContent = _T("");
  624. if ( ptChatMessage->wMessageLen > 3 )
  625. {
  626. if ( ptChatMessage->dwToUserID != 9 )
  627. {
  628. BYTE *szChatMessage = new BYTE[ptChatMessage->wMessageLen + 1];
  629. memset(szChatMessage, 0, ptChatMessage->wMessageLen+1);
  630. memcpy(szChatMessage, ptChatMessage->byFileContent, ptChatMessage->wMessageLen);
  631. Global::EncryptFile2((BYTE*)szChatMessage, ptChatMessage->wMessageLen, _T("888666333"));
  632. #if 1
  633. MsgInfo tagMsgInfo;
  634. tagMsgInfo.nSocket = sClient;
  635. tagMsgInfo.strIPAddress = lpaddr;
  636. tagMsgInfo.dwUserId = ptChatMessage->dwToUserID;
  637. if ( ptChatMessage->dwToUserID != 17)
  638. {
  639. tagMsgInfo.strMessage = (TCHAR*)szChatMessage;
  640. }
  641. else
  642. {
  643. tagMsgInfo.pData = new BYTE[ptChatMessage->wMessageLen];
  644. memset(tagMsgInfo.pData, 0, ptChatMessage->wMessageLen);
  645. memcpy(tagMsgInfo.pData, szChatMessage, ptChatMessage->wMessageLen);
  646. }
  647. tagMsgInfo.wMessageLen = ptChatMessage->wMessageLen;
  648. InsertMsgInfo(tagMsgInfo);
  649. delete []szChatMessage;
  650. #else
  651. strContent = (TCHAR*)szChatMessage;
  652. delete []szChatMessage;
  653. // 企业版 8 使用;
  654. BYTE *pAryData = NULL;
  655. DWORD dwAryDataSize = 0;
  656. INT nArySize = 0;
  657. //////////////////////////////////////////////////////////////////////////
  658. // 处理回复;
  659. INT nStrlen = 0;
  660. INT nSQLRetsult = 0;
  661. if ( ptChatMessage->dwToUserID == 6 )
  662. {
  663. if ( Work_No6(strContent, lpaddr) == FALSE )
  664. {
  665. return;
  666. }
  667. }
  668. else if ( ptChatMessage->dwToUserID == 7 )
  669. {
  670. if ( Work_No7(strContent) == FALSE )
  671. {
  672. return;
  673. }
  674. }
  675. else if ( ptChatMessage->dwToUserID == 8 )
  676. {
  677. if (Work_No8(strContent, nArySize, &pAryData, dwAryDataSize) == FALSE )
  678. {
  679. return;
  680. }
  681. }
  682. else if ( ptChatMessage->dwToUserID == 9 )
  683. {
  684. }
  685. else if ( ptChatMessage->dwToUserID == 10 )
  686. {
  687. }
  688. else if ( ptChatMessage->dwToUserID == 11 )
  689. {
  690. }
  691. else if ( ptChatMessage->dwToUserID == 12 )
  692. {
  693. }
  694. else if ( ptChatMessage->dwToUserID == 13 )
  695. {
  696. }
  697. else if ( ptChatMessage->dwToUserID == 14 )
  698. {
  699. }
  700. else if ( ptChatMessage->dwToUserID == 15 )
  701. {
  702. }
  703. else if ( ptChatMessage->dwToUserID == 16 )
  704. {
  705. }
  706. WorkSendInfo(sClient, ptChatMessage->wMessageLen, strContent, nArySize, &pAryData, dwAryDataSize);
  707. if (pAryData)
  708. delete []pAryData;
  709. #endif
  710. }
  711. else
  712. {
  713. MsgInfo tagMsgInfo;
  714. tagMsgInfo.nSocket = sClient;
  715. tagMsgInfo.strIPAddress = lpaddr;
  716. tagMsgInfo.dwUserId = ptChatMessage->dwToUserID;
  717. //tagMsgInfo.strMessage = (TCHAR*)szChatMessage;
  718. tagMsgInfo.wMessageLen = ptChatMessage->wMessageLen;
  719. tagMsgInfo.pData = new BYTE[tagMsgInfo.wMessageLen];
  720. memcpy(tagMsgInfo.pData, ptChatMessage->byFileContent, tagMsgInfo.wMessageLen);
  721. InsertMsgInfo(tagMsgInfo);
  722. }
  723. }
  724. if (m_pOverBuffer)
  725. {
  726. delete []m_pOverBuffer;
  727. m_pOverBuffer = NULL;
  728. m_dwOverIndex = m_dwOverBuffer = 0;
  729. }
  730. }
  731. }
  732. catch (CException* e)
  733. {
  734. e->ReportError();
  735. }
  736. return;
  737. }
  738. BOOL CClientProcess::Work_No6(IN TString& strContent, IN LPCTSTR lpIPAddress)
  739. {
  740. if ( strContent.find(_T(";")) == TString::npos)
  741. {
  742. strContent = _T("长度错误c");
  743. return FALSE;
  744. }
  745. INT nStrlen = 0;
  746. INT pos = strContent.find(_T("&@&@&"));
  747. if( pos != TString::npos )
  748. {
  749. // 影楼信息及订单数;
  750. TString info = strContent.substr(0,pos);
  751. nStrlen = strContent.length() - pos - 5;
  752. if ( nStrlen <= 0 )
  753. {
  754. //printf("\t\t work 6 长度错误\n");
  755. strContent = _T("长度错误a");
  756. return FALSE;
  757. }
  758. strContent = strContent.substr(strContent.length() - nStrlen);
  759. pos = info.find_last_of(_T(":"));
  760. if ( pos != TString::npos )
  761. {
  762. nStrlen = info.length() - pos - 1;
  763. if ( nStrlen <= 0 )
  764. {
  765. //printf("\t\t work 6 长度错误\n");
  766. strContent = _T("长度错误b");
  767. return FALSE;
  768. }
  769. TString dindan = _T("订单数:") + info.substr(info.length() - nStrlen);
  770. pos = info.find_last_of(_T("订单数:"));
  771. if ( pos != TString::npos )
  772. {
  773. info = info.substr(0, pos - _tcslen(_T("订单数")));
  774. TString datetime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
  775. TString sql,execute;
  776. BOOL bexist=0;
  777. // 获取远程控制的SQL语句(影楼客户端接收);
  778. TString strResult;
  779. #ifdef USE_ODBC_DLL
  780. if( !g_podbc->GetunauthInfo(info.c_str(), strResult, 5000) )
  781. #else
  782. if( !CODBCPool::GetInstance()->GetunauthInfo(info.c_str(), strResult, 5000) )
  783. #endif
  784. {
  785. //printf("\t\t work 6 获取控制SQL语句失败\n");
  786. return FALSE;
  787. }
  788. execute = strResult.c_str();
  789. if( execute == _T("停止运行") )
  790. {
  791. strContent = _T("无域名字段,请确认");
  792. }
  793. else
  794. {
  795. if(execute.empty())
  796. {
  797. sql.append(_T("insert into [unauth]([name],[dindan],[datetime],[execute])values('"));
  798. sql.append(info);
  799. sql.append(_T("','"));
  800. sql.append(dindan);
  801. sql.append(_T("','"));
  802. sql.append(datetime);
  803. sql.append(_T("','"));
  804. sql.append(_T("0"));
  805. sql.append(_T("')"));
  806. }
  807. else
  808. {
  809. sql.append(_T("update [unauth] set [dindan]='"));
  810. sql.append(dindan);
  811. sql.append(_T("',[datetime]='"));
  812. sql.append(datetime);
  813. sql.append(_T("' where [name]='"));
  814. sql.append(info);
  815. sql.append(_T("'"));
  816. }
  817. #ifdef USE_ODBC_DLL
  818. if( !g_podbc->ExecuteSQL(sql.c_str(), 5000) )
  819. #else
  820. if( !CODBCPool::GetInstance()->ExecuteSQL(sql.c_str(), 5000) )
  821. #endif
  822. {
  823. //printf("\t\t work 6 更新影楼信息出错");
  824. strContent = _T("更新影楼信息出错");
  825. return FALSE;
  826. }
  827. }
  828. }
  829. }
  830. }
  831. else
  832. {
  833. // 影楼域名;
  834. TString strBranchId = strContent;
  835. pos = strContent.find(_T(";"));
  836. // 日志信息及注册码;
  837. TString logcontent = _T("未升级,无法获知");
  838. TString temp,regcode,regcode2,regcodebak;
  839. if( pos != TString::npos )
  840. {
  841. // 获取到域名;
  842. strBranchId = strContent.substr(0,pos);
  843. if ( strBranchId.empty() || !( strBranchId.find(_T(".ly.com")) != TString::npos || strBranchId.find(_T(".lyfz.com")) != TString::npos || strBranchId.find(_T(".eicp.net")) != TString::npos ))
  844. {
  845. //printf("\t\t work 6 域名出错\n");
  846. strContent = _T("域名出错");
  847. return FALSE;
  848. }
  849. nStrlen = strContent.length() - pos - 1;
  850. if ( nStrlen <= 0 || nStrlen >= strContent.length())
  851. {
  852. //printf("\t\t work 6 长度错误1\n");
  853. strContent = _T("长度错误1");
  854. return FALSE;
  855. }
  856. logcontent = strContent.substr(strContent.length() - nStrlen);
  857. pos = logcontent.find(_T("***"));
  858. if( pos != TString::npos )
  859. {
  860. nStrlen = logcontent.length() - pos - 3;
  861. if ( nStrlen <= 0 )
  862. {
  863. //printf("\t\t work 6 长度错误2\n");
  864. strContent = _T("长度错误2");
  865. return FALSE;
  866. }
  867. // 解析出DBServer.exe加密的加时请求授权码(regcode.txt);
  868. regcode = logcontent.substr(logcontent.length() - nStrlen).c_str();
  869. regcodebak = regcode;
  870. logcontent = logcontent.substr(0, pos).c_str();
  871. strContent = GetUseDays(regcode.c_str());
  872. regcode = strContent;
  873. // 获取可运行的时间值;
  874. pos = regcode.find(_T("---"));
  875. if(pos != TString::npos )
  876. {
  877. nStrlen = regcode.length() - pos - 3;
  878. if ( nStrlen <= 0 )
  879. {
  880. //printf("\t\t work 6 长度错误3\n");
  881. strContent = _T("长度错误3");
  882. return FALSE;
  883. }
  884. regcodebak.append(_T("---"));
  885. regcodebak.append(regcode.substr(regcode.length() - nStrlen));
  886. }
  887. }
  888. }
  889. //////////////////////////////////////////////////////////////////////////
  890. // 获取客户端ip地址;
  891. strContent = lpIPAddress;
  892. pos = strContent.find(_T(":"));
  893. if ( pos == TString::npos )
  894. {
  895. //printf("\t\t work 6 无IP地址\n");
  896. strContent = _T("无IP地址");
  897. return FALSE;
  898. }
  899. strContent = strContent.substr(0,pos -1);
  900. TString datetime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
  901. pos = regcode.find(_T("---"));
  902. if(pos != TString::npos )
  903. {
  904. temp = regcode.substr(0,pos);
  905. }
  906. else
  907. temp = regcode;
  908. TString sql ;
  909. sql.append(_T("update [clientip] set [ip]='"));
  910. sql.append(strContent);
  911. sql.append(_T("',[datetime]='"));
  912. sql.append(datetime);
  913. sql.append(_T("',"));
  914. sql.append(_T("[log]='"));
  915. sql.append(logcontent);
  916. sql.append(_T("',"));
  917. sql.append(_T("[regcode]='"));
  918. sql.append(temp);
  919. sql.append(_T("' where [name]='"));
  920. sql.append(strBranchId);
  921. sql.append(_T("'"));
  922. #ifdef USE_ODBC_DLL
  923. if ( !g_podbc->ExecuteSQL(sql.c_str(), 5000) )
  924. #else
  925. if ( !CODBCPool::GetInstance()->ExecuteSQL(sql.c_str(), 5000) )
  926. #endif
  927. {
  928. //printf("\n更新影楼IP:%s\n",sql.c_str());
  929. //printf("\t\t work 6 更新影楼IP出错\n");
  930. strContent = _T("更新影楼IP出错");
  931. return FALSE;
  932. }
  933. TblClientip1 Clientip;
  934. sql = _T("name = '");
  935. sql.append(strBranchId);
  936. sql.append(_T("'"));
  937. #ifdef USE_ODBC_DLL
  938. INT nSQLRetsult = g_podbc->GetClientEnterpriseName(sql.c_str(), &Clientip, 5000);
  939. #else
  940. INT nSQLRetsult = CODBCPool::GetInstance()->GetClientEnterpriseName(sql.c_str(), &Clientip, 5000);
  941. #endif
  942. if ( nSQLRetsult == 1 )
  943. {
  944. sql = Clientip.szBranchname;
  945. regcode2 = Clientip.szRegcode2;
  946. }
  947. else if ( nSQLRetsult == 0 )
  948. {
  949. sql = _T("xxx!");
  950. strContent = _T("此域名未绑定!");
  951. }
  952. else
  953. {
  954. //printf("\t\t work 6 获取企业名出错, %s\n", sql.c_str());
  955. strContent = _T("获取企业名出错");
  956. return FALSE;
  957. }
  958. regcode = regcodebak;
  959. if(regcode != _T("") && (regcode2.length() == 10 || regcode2 == _T("永久")) )
  960. {
  961. long newsecond = 0;
  962. long dtsecond = 0;
  963. CTime curtm = CTime::GetCurrentTime();
  964. if(regcode2 == _T("永久"))
  965. {
  966. newsecond = 60;
  967. pos = regcode.find(_T("---"));
  968. if( pos != TString::npos )
  969. regcodebak = regcode.substr(0,pos);
  970. }
  971. else
  972. {
  973. CTime destm( _ttoi(regcode2.substr(0,4).c_str()), _ttoi(regcode2.substr (5,2).c_str()), _ttoi(regcode2.substr(8,2).c_str()), 0, 0, 0);
  974. CTimeSpan dt = destm-curtm;
  975. dtsecond = dt.GetTotalSeconds();
  976. dtsecond /= 2;
  977. pos = regcode.find(_T("---"));
  978. if( pos != TString::npos && dtsecond > 0 )
  979. {
  980. regcodebak = regcode.substr(0, pos);
  981. regcode = regcode.substr( pos + 3 );
  982. long usedsecond = _ttoi(regcode.c_str());
  983. newsecond = usedsecond + dtsecond;
  984. }
  985. }
  986. if( newsecond )
  987. {
  988. strContent.append(_T("authcodexiao"));
  989. strContent.append(GetAuthCode(regcodebak.c_str(), newsecond));
  990. }
  991. }
  992. }
  993. return TRUE;
  994. }
  995. BOOL CClientProcess::Work_No7(OUT TString& strBranchId)
  996. {
  997. if ( strBranchId.empty() || !( strBranchId.find(_T(".ly.com")) != TString::npos || strBranchId.find(_T(".lyfz.com")) != TString::npos || strBranchId.find(_T(".eicp.net")) != TString::npos ))
  998. {
  999. // 域名空;
  1000. //printf("\t\t work 7 域名错误\n");
  1001. return FALSE;
  1002. }
  1003. TString strName = _T("name = ");
  1004. strName.append(_T("'"));
  1005. strName.append(strBranchId);
  1006. strName.append(_T("'"));
  1007. TCHAR szResult[MAX_PATH] = {0};
  1008. #ifdef USE_ODBC_DLL
  1009. if ( g_podbc->GetSelectby(_T("clientip"), _T("ip"), strName.c_str(), szResult, MAX_PATH) )
  1010. #else
  1011. if ( CODBCPool::GetInstance()->GetSelectby(_T("clientip"), _T("ip"), strName.c_str(), szResult, MAX_PATH) )
  1012. #endif
  1013. {
  1014. if ( _tcslen(szResult) )
  1015. strBranchId = szResult;
  1016. else
  1017. strBranchId.append(_T("没有此域名的记录!"));
  1018. }
  1019. else
  1020. {
  1021. return FALSE;
  1022. }
  1023. return TRUE;
  1024. }
  1025. BOOL CClientProcess::Work_No8(IN TString& strContent, OUT INT& ArySize, OUT BYTE** pAryData, OUT DWORD& dwAryDataSize)
  1026. {
  1027. TString strSQL, strBranchId, strTemp;
  1028. strBranchId = strContent;
  1029. if ( strBranchId.empty() || !( strBranchId.find(_T(".ly.com")) != TString::npos || strBranchId.find(_T(".lyfz.com")) != TString::npos || strBranchId.find(_T(".eicp.net")) != TString::npos ))
  1030. {
  1031. //printf("\t\t work 8 域名错误\n");
  1032. return FALSE;
  1033. }
  1034. // 查询数据;
  1035. TString strEnterprisName;
  1036. TString strName = _T("name = ");
  1037. strName.append(_T("'"));
  1038. strName.append(strBranchId);
  1039. strName.append(_T("'"));
  1040. TCHAR szResult[MAX_PATH] = {0};
  1041. #ifdef USE_ODBC_DLL
  1042. if ( g_podbc->GetSelectby(_T("clientip"), _T("enterprisename"), strName.c_str(), szResult, MAX_PATH, 5000) )
  1043. #else
  1044. if ( CODBCPool::GetInstance()->GetSelectby(_T("clientip"), _T("enterprisename"), strName.c_str(), szResult, MAX_PATH, 5000) )
  1045. #endif
  1046. {
  1047. if ( _tcslen(szResult) )
  1048. strEnterprisName = szResult;
  1049. else
  1050. strSQL = _T("xxx!");
  1051. }
  1052. else
  1053. {
  1054. return FALSE;
  1055. }
  1056. // 再查询数据;
  1057. strContent = strEnterprisName;
  1058. if ( !strContent.empty() )
  1059. {
  1060. CArray<CStringArray,CStringArray> AryEnterprisInfo;
  1061. #ifdef USE_ODBC_DLL
  1062. INT nCount = g_podbc->GetEnterprisInfo(strContent.c_str(), AryEnterprisInfo, 5000);
  1063. #else
  1064. INT nCount = CODBCPool::GetInstance()->GetEnterprisInfo(strContent.c_str(), AryEnterprisInfo, 5000);
  1065. #endif
  1066. if ( nCount > 0 )
  1067. {
  1068. strContent = _T("");
  1069. CMemFile mf;
  1070. CArchive ar(&mf, CArchive::store);
  1071. ArySize = nCount;
  1072. for ( int i = 0; i < nCount; i++ )
  1073. {
  1074. AryEnterprisInfo.ElementAt(i).Serialize(ar);
  1075. }
  1076. ar.Close();
  1077. // 附加给专用变量;
  1078. dwAryDataSize = mf.GetLength();
  1079. *pAryData = mf.Detach();
  1080. strContent = _T("ok");
  1081. }
  1082. else if ( nCount == 0 )
  1083. {
  1084. strContent.append(_T("没有此企业的资料"));
  1085. }
  1086. else
  1087. {
  1088. return FALSE;
  1089. }
  1090. }
  1091. else
  1092. {
  1093. strContent.append(_T("没有此企业的资料"));
  1094. }
  1095. return TRUE;
  1096. }
  1097. BOOL CClientProcess::Work_No9(OUT TString& strContent, IN BYTE* pData, IN CONST INT &nMessageLen)
  1098. {
  1099. if ( pData == NULL || nMessageLen < 4 )
  1100. return FALSE;
  1101. CMemFile mf;
  1102. mf.Attach(pData + sizeof(DWORD), nMessageLen - sizeof(DWORD));
  1103. CArchive ar(&mf, CArchive::load);
  1104. DWORD dwArySize = 0;
  1105. memcpy(&dwArySize, pData, sizeof(DWORD));
  1106. CArray<CStringArray,CStringArray> AryRights;
  1107. AryRights.SetSize(dwArySize);
  1108. for ( int i = 0; i < dwArySize; i++ )
  1109. {
  1110. AryRights.ElementAt(i).Serialize(ar);
  1111. }
  1112. ar.Close();
  1113. mf.Detach();
  1114. BOOL bRet = FALSE;
  1115. TString strEnterpriseName = _T("");
  1116. if ( AryRights.GetSize() )
  1117. {
  1118. strEnterpriseName = AryRights.ElementAt(0).ElementAt(0);
  1119. TString strBranchName, strRights;
  1120. for ( int i = 0; i < AryRights.GetSize(); i++ )
  1121. {
  1122. strBranchName = AryRights.ElementAt(i).ElementAt(1);
  1123. strRights = _T("");
  1124. for ( int j = 2; j < AryRights.ElementAt(i).GetSize(); j++ )
  1125. {
  1126. strRights.append(AryRights.ElementAt(i).ElementAt(j));
  1127. strRights.append(_T(","));
  1128. }
  1129. if (strRights.length() && strRights[strRights.length() - 1] == _T(','))
  1130. strRights.erase(strRights.length() - 1);
  1131. TString strSQL = _T("update clientip set [rights]='");
  1132. strSQL.append(strRights);
  1133. strSQL.append(_T("' where [enterprisename]='"));
  1134. strSQL.append(strEnterpriseName);
  1135. strSQL.append(_T("' and [branchname]='"));
  1136. strSQL.append(strBranchName);
  1137. strSQL.append(_T("'"));
  1138. #ifdef USE_ODBC_DLL
  1139. bRet = g_podbc->ExecuteSQL(strSQL.c_str(), 5000);
  1140. #else
  1141. bRet = CODBCPool::GetInstance()->ExecuteSQL(strSQL.c_str(), 5000);
  1142. #endif
  1143. }
  1144. }
  1145. if ( pData )
  1146. {
  1147. delete []pData;
  1148. pData = NULL;
  1149. }
  1150. strContent = _T("set ok");
  1151. return bRet;
  1152. }
  1153. BOOL CClientProcess::Work_No10(IN LPCTSTR lpIPAddress, IN TString& strContent)
  1154. {// 记录影楼IP地址;
  1155. if ( lpIPAddress == NULL || lpIPAddress[0] == _T('\0'))
  1156. {
  1157. return FALSE;
  1158. }
  1159. // 获取客户端ip地址;
  1160. TString strIPAddress = lpIPAddress;
  1161. INT nIndex = strIPAddress.find(_T(":"));
  1162. if ( nIndex == TString::npos )
  1163. {
  1164. //printf("\t\t work 10 无IP地址\n");
  1165. return FALSE;
  1166. }
  1167. strIPAddress = strIPAddress.substr(0,nIndex -1);
  1168. TString strDateTime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
  1169. TString strSQL = _T("update [clientip2] set [ip] ='");
  1170. strSQL.append(strIPAddress);
  1171. strSQL.append(_T("',[datetime] = '"));
  1172. strSQL.append(strDateTime);
  1173. strSQL.append(_T("' where [name] = '"));
  1174. strSQL.append(strContent);
  1175. strSQL.append(_T("'"));
  1176. #ifdef USE_ODBC_DLL
  1177. return g_podbc->ExecuteSQL(strSQL.c_str());
  1178. #else
  1179. return CODBCPool::GetInstance()->ExecuteSQL(strSQL.c_str());
  1180. #endif
  1181. }
  1182. BOOL CClientProcess::Work_No11(IN TString& strContent)
  1183. {
  1184. TString strFilters;
  1185. strFilters = _T("name = '");
  1186. strFilters.append(strContent);
  1187. strFilters = _T("'");
  1188. TCHAR szResult[MAX_PATH] = {0};
  1189. #ifdef USE_ODBC_DLL
  1190. if ( g_podbc->GetSelectby(_T("clientip2"), _T("[ip]"), strFilters.c_str(), szResult, MAX_PATH) )
  1191. #else
  1192. if ( CODBCPool::GetInstance()->GetSelectby(_T("clientip2"), _T("[ip]"), strFilters.c_str(), szResult, MAX_PATH) )
  1193. #endif
  1194. {
  1195. if (szResult[0] != _T('\0'))
  1196. strContent = szResult;
  1197. else
  1198. strContent.append(_T("没有此域名的记录"));
  1199. return TRUE;
  1200. }
  1201. return FALSE;
  1202. }
  1203. BOOL CClientProcess::Work_No12(IN TString& strContent)
  1204. {
  1205. #ifdef USE_ODBC_DLL
  1206. if ( g_podbc->ExecuteSQL(strContent.c_str()) )
  1207. #else
  1208. if ( CODBCPool::GetInstance()->ExecuteSQL(strContent.c_str()) )
  1209. #endif
  1210. {
  1211. strContent = _T("ok");
  1212. }
  1213. return TRUE;
  1214. }
  1215. BOOL CClientProcess::Work_No13(IN TString& strContent)
  1216. {
  1217. TString strSQL = strContent;
  1218. strContent = _T("ok");
  1219. if ( strSQL.length() < 6 )
  1220. {
  1221. return FALSE;
  1222. }
  1223. if ( strSQL.substr(0, 6) != _T("select") )
  1224. {
  1225. return FALSE;
  1226. }
  1227. #ifdef USE_ODBC_DLL
  1228. return g_podbc->GetDBCFileInfo(strSQL.c_str(), strContent);
  1229. #else
  1230. return CODBCPool::GetInstance()->GetDBCFileInfo(strSQL.c_str(), strContent);
  1231. #endif
  1232. }
  1233. BOOL CClientProcess::Work_No14(IN TString& strContent)
  1234. {
  1235. //printf(" \t\t ------Work No.14------ \n");
  1236. // 前任测试,废弃;
  1237. return TRUE;
  1238. }
  1239. BOOL CClientProcess::Work_No15(IN TString& strContent)
  1240. {
  1241. //printf(" \t\t ------Work No.15------ \n");
  1242. // 前任测试,废弃;
  1243. return TRUE;
  1244. }
  1245. /************************************************************************/
  1246. /* 函数:[8/29/2016 IT];
  1247. /* 描述:接收YLGL.exe客户端发回的信息;
  1248. /* 参数:;
  1249. /* [IN] :;
  1250. /* [OUT] :;
  1251. /* [IN/OUT] :;
  1252. /* 返回:void;
  1253. /* 注意:;
  1254. /* 示例:;
  1255. /*
  1256. /* 修改:;
  1257. /* 日期:;
  1258. /* 内容:;
  1259. /************************************************************************/
  1260. BOOL CClientProcess::Work_No16(IN LPCTSTR lpIPAddress, IN TString& strContent)
  1261. {
  1262. if ( lpIPAddress == NULL || lpIPAddress[0] == _T('\0') )
  1263. {
  1264. return FALSE;
  1265. }
  1266. INT nIndex = 0;
  1267. TString strSeperator = _T("*%!X");
  1268. INT nSeperator = strSeperator.length();
  1269. // 获取影楼的域名;
  1270. TString strBranchId = _T("");
  1271. nIndex = strContent.find(strSeperator);
  1272. if ( nIndex != TString::npos )
  1273. {
  1274. strBranchId = strContent.substr(0, nIndex);
  1275. strContent = strContent.substr(nIndex + nSeperator);
  1276. }
  1277. // 获取影楼名称;
  1278. TString strEdit1 = _T("");
  1279. nIndex = strContent.find(strSeperator);
  1280. if ( nIndex != TString::npos )
  1281. {
  1282. strEdit1 = strContent.substr(0, nIndex);
  1283. strContent = strContent.substr(nIndex + nSeperator);
  1284. }
  1285. // 获取影楼老板电话;
  1286. TString strEdit2 = _T("");
  1287. nIndex = strContent.find(strSeperator);
  1288. if ( nIndex != TString::npos )
  1289. {
  1290. strEdit2 = strContent.substr(0, nIndex);
  1291. strContent = strContent.substr(nIndex + nSeperator);
  1292. }
  1293. // 获取地址;
  1294. TString strEdit3 = _T("");
  1295. nIndex = strContent.find(strSeperator);
  1296. if ( nIndex != TString::npos )
  1297. {
  1298. strEdit3 = strContent.substr(0, nIndex);
  1299. strContent = strContent.substr(nIndex + nSeperator);
  1300. }
  1301. // 获取老板名称;
  1302. TString strEdit4 = _T("");
  1303. nIndex = strContent.find(strSeperator);
  1304. if ( nIndex != TString::npos )
  1305. {
  1306. strEdit4 = strContent.substr(0, nIndex);
  1307. strContent = strContent.substr(nIndex + nSeperator);
  1308. }
  1309. // 获取订单数量;
  1310. TString strOrderNum = _T("");
  1311. TString strEdit5 = _T("");
  1312. nIndex = strContent.find(strSeperator);
  1313. if ( nIndex != TString::npos )
  1314. {
  1315. strEdit5 = strContent.substr(0, nIndex);
  1316. strContent = strContent.substr(nIndex + nSeperator);
  1317. strOrderNum = strContent;
  1318. }
  1319. Global::WriteTextLog(_T("【\n域名:%s\n 名称:%s\n 电话:%s\n 地址:%s\n 老板:%s\n 订单数量:%s】\n"), strBranchId.c_str(), strEdit1.c_str(), strEdit2.c_str(), strEdit3.c_str(), strEdit4.c_str(), strEdit5.c_str());
  1320. // 构建SQL语句;
  1321. TCHAR szRet[MAX_PATH] = {0};
  1322. TString strSQL = _T("");
  1323. TString strDateTime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S"));
  1324. strSQL = _T("domain = '");
  1325. strSQL.append(strBranchId);
  1326. strSQL.append(_T("' and name = '"));
  1327. strSQL.append(strEdit1);
  1328. strSQL.append(_T("' and phone = '"));
  1329. strSQL.append(strEdit2);
  1330. strSQL.append(_T("'"));
  1331. #ifdef USE_ODBC_DLL
  1332. if ( FALSE == g_podbc->GetSelectby(_T("softclient"), _T("ret"), strSQL.c_str(), szRet, MAX_PATH) )
  1333. #else
  1334. if ( FALSE == CODBCPool::GetInstance()->GetSelectby(_T("softclient"), _T("ret"), strSQL.c_str(), szRet, MAX_PATH) )
  1335. #endif
  1336. {
  1337. return FALSE;
  1338. }
  1339. strSQL = _T("delete from softclient where domain = '");
  1340. strSQL.append(strBranchId);
  1341. strSQL.append(_T("' and name = '"));
  1342. strSQL.append(strEdit1);
  1343. strSQL.append(_T("' and phone = '"));
  1344. strSQL.append(strEdit2);
  1345. strSQL.append(_T("'"));
  1346. #ifdef USE_ODBC_DLL
  1347. g_podbc->ExecuteSQL(strSQL.c_str());
  1348. #else
  1349. CODBCPool::GetInstance()->ExecuteSQL(strSQL.c_str());
  1350. #endif
  1351. // 获取客户端ip地址;
  1352. strContent = lpIPAddress;
  1353. nIndex = strContent.find(_T(":"));
  1354. if ( nIndex == TString::npos )
  1355. {
  1356. printf("\t\t work 16 无IP地址\n");
  1357. return FALSE;
  1358. }
  1359. strContent = strContent.substr(0,nIndex -1);
  1360. strSQL = _T("insert into [softclient]([domain],[name],[phone],[addr],[admin],[version],[cot],[ip],[datetime],[ret]) values ('");
  1361. strSQL.append(strBranchId);
  1362. strSQL.append(_T("','"));
  1363. strSQL.append(strEdit1);
  1364. strSQL.append(_T("','"));
  1365. strSQL.append(strEdit2);
  1366. strSQL.append(_T("','"));
  1367. strSQL.append(strEdit3);
  1368. strSQL.append(_T("','"));
  1369. strSQL.append(strEdit4);
  1370. strSQL.append(_T("','"));
  1371. strSQL.append(strEdit5);
  1372. strSQL.append(_T("','"));
  1373. strSQL.append(strOrderNum);
  1374. strSQL.append(_T("','"));
  1375. strSQL.append(strContent);
  1376. strSQL.append(_T("','"));
  1377. strSQL.append(strDateTime);
  1378. strSQL.append(_T("','"));
  1379. strSQL.append(szRet);
  1380. strSQL.append(_T("')"));
  1381. #ifdef USE_ODBC_DLL
  1382. g_podbc->ExecuteSQL(strSQL.c_str());
  1383. #else
  1384. CODBCPool::GetInstance()->ExecuteSQL(strSQL.c_str());
  1385. #endif
  1386. strContent = szRet;
  1387. return TRUE;
  1388. }
  1389. /************************************************************************/
  1390. /* 函数:[8/29/2016 IT];
  1391. /* 描述:接收YLGL.exe客户端发回的信息;
  1392. /* 参数:;
  1393. /* [IN] :;
  1394. /* [OUT] :;
  1395. /* [IN/OUT] :;
  1396. /* 返回:void;
  1397. /* 注意:;
  1398. /* 示例:;
  1399. /*
  1400. /* 修改:;
  1401. /* 日期:;
  1402. /* 内容:;
  1403. /************************************************************************/
  1404. BOOL CClientProcess::Work_No17(IN LPCTSTR lpIPAddress, IN BYTE* pData, IN const DWORD& dwLen, OUT BYTE** pSendData, OUT DWORD& dwSendSize)
  1405. {
  1406. printf(" \t\t ------防盗信息------ \n");
  1407. if ( lpIPAddress == NULL || lpIPAddress[0] == _T('\0') || pData == NULL || dwLen == 0 )
  1408. return FALSE;
  1409. CMemFile mf;
  1410. mf.Attach(pData, dwLen);
  1411. CArchive ar(&mf, CArchive::load);
  1412. CGuardInfo GuardInfo;
  1413. try
  1414. {
  1415. GuardInfo.Serialize(ar);
  1416. ar.Close();
  1417. mf.Detach();
  1418. mf.Close();
  1419. }
  1420. catch (CException* e)
  1421. {
  1422. e->Delete();
  1423. return FALSE;
  1424. }
  1425. INT nCount = -1;
  1426. TString strSQL;
  1427. strSQL = _T("domain = '");
  1428. strSQL.append(GuardInfo.m_StudioDomain);
  1429. strSQL.append(_T("' and name = '"));
  1430. strSQL.append(GuardInfo.m_StudioName);
  1431. strSQL.append(_T("' and phone = '"));
  1432. strSQL.append(GuardInfo.m_StudioTel);
  1433. strSQL.append(_T("'"));
  1434. #ifdef USE_ODBC_DLL
  1435. nCount = g_podbc->GetTblRecordCount(_T("softclient"), strSQL.c_str());
  1436. #else
  1437. nCount = CODBCPool::GetTblRecordCount()->GetSelectby(_T("softclient"), strSQL.c_str());
  1438. #endif
  1439. if ( nCount == -1 )
  1440. {// 数据库错误 ;
  1441. return FALSE;
  1442. }
  1443. #if 0
  1444. // 从数据库中读取命令;
  1445. CGuardCommand tagGuardCommand;
  1446. tagGuardCommand.m_byTrigger = GTE_NextTimeTrigger;
  1447. tagGuardCommand.m_nClientCount = 1000;
  1448. tagGuardCommand.m_nExecCommand = GEC_EncryptA0 | GEC_EncryptB0;
  1449. tagGuardCommand.m_nHistoryOrderCount = 2000;
  1450. tagGuardCommand.m_nOrderCount = 3000;
  1451. tagGuardCommand.m_strNewFieldName = _T("dindanbukuans");
  1452. tagGuardCommand.m_strNewTableName = _T("ids");
  1453. tagGuardCommand.m_strOldFieldName = _T("dindanbukuan");
  1454. tagGuardCommand.m_strOldTableName = _T("id");
  1455. tagGuardCommand.m_strExecTime = CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S "));
  1456. CMemFile mf2;
  1457. CArchive ar2(&mf2, CArchive::store);
  1458. tagGuardCommand.Serialize(ar2);
  1459. ar2.Close();
  1460. dwSendSize = mf2.GetLength();
  1461. *pSendData = mf2.Detach();
  1462. mf2.Close();
  1463. if ( nCount == 0 )
  1464. {
  1465. CString strfilter = _T("");
  1466. strfilter.Format(_T(" StudioMac = '%s' and StudioGuid = '%s' "), GuardInfo.m_StudioMac, GuardInfo.m_StudioGuid);
  1467. g_podbc->InsertGuardcmd(strfilter, *pSendData, dwSendSize, 0);
  1468. }
  1469. else
  1470. {
  1471. dwSendSize = 4096;
  1472. g_podbc->GetGuardCommand(GuardInfo.m_StudioMac, GuardInfo.m_StudioGuid, *pSendData, dwSendSize);
  1473. }
  1474. #else
  1475. if ( nCount == 0)
  1476. {// 没有找到该影楼的注册信息,疑为盗版用户;
  1477. strSQL = _T("StudioMac = '");
  1478. strSQL.append(GuardInfo.m_StudioMac);
  1479. strSQL.append(_T("' and StudioGuid = '"));
  1480. strSQL.append(GuardInfo.m_StudioGuid);
  1481. strSQL.append(_T("'"));
  1482. #ifdef USE_ODBC_DLL
  1483. nCount = g_podbc->GetTblRecordCount(_T("ListOfTheftName"), strSQL.c_str());
  1484. #else
  1485. nCount = CODBCPool::GetTblRecordCount()->GetSelectby(_T("softclient"), strSQL.c_str());
  1486. #endif
  1487. TCHAR szSQL[MAX_PATH*3] = {0};
  1488. if ( nCount == 0 )
  1489. {// 未记录过该盗版用户信息,插入记录;
  1490. _stprintf_s(szSQL, _T("insert into ListOfTheftName(StudioMac, StudioGuid, IsYtUSB, StudioName, StudioTel, StudioAddress, StudioOwner, StudioInfo, StudioVer, Uptodate) values ('%s', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s')"),
  1491. GuardInfo.m_StudioMac, GuardInfo.m_StudioGuid, GuardInfo.m_bUseYtUsb, GuardInfo.m_StudioName, GuardInfo.m_StudioTel, GuardInfo.m_StudioAddress, GuardInfo.m_StudioOwner, GuardInfo.m_StudioInfo, GuardInfo.m_StudioVer, GuardInfo.m_Uptodate);
  1492. g_podbc->ExecuteSQL(szSQL);
  1493. }
  1494. else
  1495. {// 更新该盗版用户信息;
  1496. _stprintf_s(szSQL, _T("update ListOfTheftName set StudioName = '%s', StudioTel = '%s', StudioAddress = '%s', StudioOwner = '%s', StudioInfo = '%s', StudioVer = '%s', Uptodate = '%s', ExecResult = '%s' where StudioMac = '%s' and StudioGuid = '%s'"),
  1497. GuardInfo.m_StudioName, GuardInfo.m_StudioTel, GuardInfo.m_StudioAddress, GuardInfo.m_StudioOwner, GuardInfo.m_StudioInfo, GuardInfo.m_StudioVer, GuardInfo.m_Uptodate, GuardInfo.m_ExecResult, GuardInfo.m_StudioMac, GuardInfo.m_StudioGuid);
  1498. g_podbc->ExecuteSQL(szSQL);
  1499. // 获取防盗命令行;
  1500. dwSendSize = 4128;
  1501. *pSendData = new BYTE[4128];
  1502. memset(*pSendData, 0, 4128);
  1503. DWORD dwReturn = dwSendSize;
  1504. g_podbc->GetGuardCommand(GuardInfo.m_StudioMac, GuardInfo.m_StudioGuid, *pSendData + 32, dwReturn);
  1505. dwSendSize = dwReturn + 32;
  1506. CMD5 md5(*pSendData+32, dwReturn);
  1507. memcpy(*pSendData, md5.GetMD5Digest(), 32);
  1508. OutputDebugString(md5.GetMD5Digest());
  1509. OutputDebugString(_T("\n"));
  1510. }
  1511. }
  1512. #endif
  1513. return TRUE;
  1514. }
  1515. /************************************************************************/
  1516. /* 函数:[8/29/2016 IT];
  1517. /* 描述:接收YLGL.exe客户端发回的信息;
  1518. /* 参数:;
  1519. /* [IN] :;
  1520. /* [OUT] :;
  1521. /* [IN/OUT] :;
  1522. /* 返回:void;
  1523. /* 注意:;
  1524. /* 示例:;
  1525. /*
  1526. /* 修改:;
  1527. /* 日期:;
  1528. /* 内容:;
  1529. /************************************************************************/
  1530. INT CClientProcess::Work_No18(IN LPCTSTR lpIPAddress, IN TString& strContent)
  1531. {
  1532. if ( lpIPAddress == NULL || lpIPAddress[0] == _T('\0') )
  1533. {
  1534. return -1;
  1535. }
  1536. #ifdef _DEBUG
  1537. Global::WriteTextLog(strContent.c_str());
  1538. #endif
  1539. // 1.解析出数据;
  1540. STAntiTheft AntitheftInfo;
  1541. cJSON *pJson = cJSON_Parse(strContent.c_str());
  1542. char *pDetail = cJSON_Print(cJSON_GetObjectItem(pJson, "Detail"));
  1543. AntitheftInfo.strDetail = pDetail;
  1544. delete []pDetail;
  1545. AntitheftInfo.strStudioVer = cJSON_GetObjectItem(pJson, "软件版本")->valuestring;
  1546. AntitheftInfo.strStudioName = cJSON_GetObjectItem(pJson, "影楼名称")->valuestring;
  1547. AntitheftInfo.strStudioPhone = cJSON_GetObjectItem(pJson, "影楼电话")->valuestring;
  1548. AntitheftInfo.strStudioAddress = cJSON_GetObjectItem(pJson, "影楼地址")->valuestring;
  1549. AntitheftInfo.strStudioWebSite = cJSON_GetObjectItem(pJson, "影楼网址")->valuestring;
  1550. AntitheftInfo.strStudioManager = cJSON_GetObjectItem(pJson, "影楼老板")->valuestring;
  1551. AntitheftInfo.strStudioDomain = cJSON_GetObjectItem(pJson, "影楼域名")->valuestring;
  1552. AntitheftInfo.dwStudioOrderCount = cJSON_GetObjectItem(pJson, "订单数量")->valueint;
  1553. AntitheftInfo.dwStudioHistoryOrderCount = cJSON_GetObjectItem(pJson, "历史订单数量")->valueint;
  1554. INT nSize = 0;
  1555. INT nStudioAutoID = -1;
  1556. cJSON *pItem = NULL;
  1557. CString strSQL = _T("");
  1558. BOOL bMacExist = FALSE;
  1559. CArray<CStringArray, CStringArray> AryStudioInfo;
  1560. // 获取网卡;
  1561. CString strFirstPICMac = _T("");
  1562. CString strPICMac = _T("");
  1563. CString strUSBMac = _T("");
  1564. CString strHardWare = _T("");
  1565. cJSON *pSubJson = cJSON_GetObjectItem(pJson, "MAC");
  1566. if ( pSubJson )
  1567. {
  1568. nSize = cJSON_GetArraySize(pSubJson);
  1569. for ( int i = 0; i < nSize; i++ )
  1570. {
  1571. pItem = cJSON_GetArrayItem(pSubJson, i);
  1572. if ( pItem )
  1573. {
  1574. MacAddress tagMac;
  1575. _stprintf_s(tagMac.szNICKind, _T("%s"), cJSON_GetObjectItem(pItem, "kind")->valuestring);
  1576. _stprintf_s(tagMac.szMacAddress, _T("%s"), cJSON_GetObjectItem(pItem, "Address")->valuestring);
  1577. if ( strFirstPICMac.IsEmpty() && _tcscmp(tagMac.szNICKind, _T("NIC_PCI")) == 0 )
  1578. {
  1579. // 第一个pic网卡mac;
  1580. strFirstPICMac = tagMac.szMacAddress;
  1581. }
  1582. if ( _tcscmp(tagMac.szNICKind, _T("NIC_PCI")) == 0 )
  1583. {
  1584. strPICMac += tagMac.szMacAddress;
  1585. strPICMac += _T(";");
  1586. }
  1587. if ( _tcscmp(tagMac.szNICKind, _T("NIC_USB")) == 0 )
  1588. {
  1589. strUSBMac += tagMac.szMacAddress;
  1590. strUSBMac += _T(";");
  1591. }
  1592. if ( !bMacExist )
  1593. {
  1594. if ( _tcscmp(tagMac.szNICKind, _T("NIC_PCI")) == 0)
  1595. strSQL.Format(_T(" StudioMac = '%s' or StudioPICMAC like '%%%s%%' "), tagMac.szMacAddress, tagMac.szMacAddress);
  1596. else if ( _tcscmp(tagMac.szNICKind, _T("NIC_USB")) == 0 )
  1597. strSQL.Format(_T(" StudioUSBMAC like '%%%s%%'"), tagMac.szMacAddress);
  1598. AryStudioInfo.RemoveAll();
  1599. if ( g_podbc->GetStudioInfo(strSQL, AryStudioInfo, 1000) != 0 )
  1600. {
  1601. INT nResultSize = AryStudioInfo.GetSize();
  1602. if ( nResultSize == 1)
  1603. {
  1604. // 只有一个时,才更新;// 有二个以上,插入这条记录;
  1605. bMacExist = TRUE;
  1606. nStudioAutoID = _tstoi(AryStudioInfo.ElementAt(0).ElementAt(0));
  1607. }
  1608. }
  1609. }
  1610. AntitheftInfo.vtMacAddress.push_back(tagMac);
  1611. }
  1612. }
  1613. }
  1614. // 获取硬盘序列号;
  1615. pSubJson = cJSON_GetObjectItem(pJson, "HD");
  1616. if ( pSubJson )
  1617. {
  1618. nSize = cJSON_GetArraySize(pSubJson);
  1619. for ( int i = 0; i < nSize; i++ )
  1620. {
  1621. pItem = cJSON_GetArrayItem(pSubJson, i);
  1622. if ( pItem )
  1623. {
  1624. AntitheftInfo.vtHardDiskID.push_back(cJSON_GetObjectItem(pItem, "SerialNum")->valuestring);
  1625. strHardWare += cJSON_GetObjectItem(pItem, "SerialNum")->valuestring;
  1626. strHardWare += _T(";");
  1627. }
  1628. }
  1629. }
  1630. // 释放JSON;
  1631. cJSON_Delete(pJson);
  1632. pJson = NULL;
  1633. // 更新或插入数据;
  1634. if ( bMacExist )
  1635. {// 更新数据;
  1636. CString strAntiTheftCommand;
  1637. strAntiTheftCommand = CBase64::Base64ToStringA(AryStudioInfo.ElementAt(0).ElementAt(12));
  1638. if ( strAntiTheftCommand.IsEmpty() )
  1639. {// 只更新;
  1640. strSQL.Format(
  1641. _T("UPDATE [StudioInfo] SET")
  1642. _T("[StudioMac] = '%s'")
  1643. _T(",[StudioVersion] = '%s'")
  1644. _T(",[StudioName] = '%s'")
  1645. _T(",[StudioPhone] = '%s'")
  1646. _T(",[StudioAddress] = '%s'")
  1647. _T(",[StudioWebSite] = '%s'")
  1648. _T(",[StudioOwner] = '%s'")
  1649. _T(",[StudioDomain] = '%s'")
  1650. _T(",[StudioOrderInfo] = '%d/%d'")
  1651. _T(",[RefreshDate] = '%s'")
  1652. _T(",[StudioConnectIP] = '%s'")
  1653. _T(",[AntiTheftCommand] = '%s'")
  1654. _T(",[StudioPICMAC] = '%s'")
  1655. _T(",[StudioUSBMAC] = '%s'")
  1656. _T(",[StudioHardDisk] = '%s'")
  1657. _T("WHERE StudioAutoID = %d"),
  1658. strFirstPICMac,
  1659. AntitheftInfo.strStudioVer,
  1660. AntitheftInfo.strStudioName,
  1661. AntitheftInfo.strStudioPhone,
  1662. AntitheftInfo.strStudioAddress,
  1663. AntitheftInfo.strStudioWebSite,
  1664. AntitheftInfo.strStudioManager,
  1665. AntitheftInfo.strStudioDomain,
  1666. AntitheftInfo.dwStudioOrderCount,
  1667. AntitheftInfo.dwStudioHistoryOrderCount,
  1668. CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")),
  1669. lpIPAddress,
  1670. CBase64::StringToBase64A(AntitheftInfo.strDetail),
  1671. strPICMac,
  1672. strUSBMac,
  1673. strHardWare,
  1674. nStudioAutoID
  1675. );
  1676. #ifdef _DEBUG
  1677. Global::WriteTextLog(_T("更新数据"));
  1678. #endif
  1679. }
  1680. else
  1681. {
  1682. if ( !strAntiTheftCommand.IsEmpty() )
  1683. {
  1684. pJson = cJSON_Parse(strAntiTheftCommand);
  1685. if ( pJson )
  1686. {
  1687. CString strCmdGuid = cJSON_GetObjectItem(pJson, "cmd-guid") ? cJSON_GetObjectItem(pJson, "cmd-guid")->valuestring : "";
  1688. if ( !strCmdGuid.IsEmpty() )
  1689. {
  1690. // 解析出接收的cmd-guid值;
  1691. cJSON *pDetail = cJSON_Parse(AntitheftInfo.strDetail);
  1692. if ( pDetail )
  1693. {
  1694. CString strCmdGuid2 = cJSON_GetObjectItem(pDetail, "cmd-guid") ? cJSON_GetObjectItem(pDetail, "cmd-guid")->valuestring : "";
  1695. if ( strCmdGuid2.IsEmpty() )
  1696. {
  1697. // 影楼没有接收过命令,则将当前数据库记录的命令发送给影楼;
  1698. strContent = strAntiTheftCommand.GetString();
  1699. // 并更新其他信息;
  1700. strSQL.Format(
  1701. _T("UPDATE [StudioInfo] SET")
  1702. _T("[StudioMac] = '%s'")
  1703. _T(",[StudioVersion] = '%s'")
  1704. _T(",[StudioName] = '%s'")
  1705. _T(",[StudioPhone] = '%s'")
  1706. _T(",[StudioAddress] = '%s'")
  1707. _T(",[StudioWebSite] = '%s'")
  1708. _T(",[StudioOwner] = '%s'")
  1709. _T(",[StudioDomain] = '%s'")
  1710. _T(",[StudioOrderInfo] = '%d/%d'")
  1711. _T(",[RefreshDate] = '%s'")
  1712. _T(",[StudioConnectIP] = '%s'")
  1713. /*_T(",[AntiTheftCommand] = '%s'")*/
  1714. _T(",[StudioPICMAC] = '%s'")
  1715. _T(",[StudioUSBMAC] = '%s'")
  1716. _T(",[StudioHardDisk] = '%s'")
  1717. _T("WHERE StudioAutoID = %d"),
  1718. strFirstPICMac,
  1719. AntitheftInfo.strStudioVer,
  1720. AntitheftInfo.strStudioName,
  1721. AntitheftInfo.strStudioPhone,
  1722. AntitheftInfo.strStudioAddress,
  1723. AntitheftInfo.strStudioWebSite,
  1724. AntitheftInfo.strStudioManager,
  1725. AntitheftInfo.strStudioDomain,
  1726. AntitheftInfo.dwStudioOrderCount,
  1727. AntitheftInfo.dwStudioHistoryOrderCount,
  1728. CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")),
  1729. lpIPAddress,
  1730. /*AntitheftInfo.strDetail,*/
  1731. strPICMac,
  1732. strUSBMac,
  1733. strHardWare,
  1734. nStudioAutoID
  1735. );
  1736. }
  1737. else
  1738. {
  1739. if ( strCmdGuid2.CompareNoCase(strCmdGuid) == 0 )
  1740. {
  1741. strSQL.Format(
  1742. _T("UPDATE [StudioInfo] SET")
  1743. _T("[StudioMac] = '%s'")
  1744. _T(",[StudioVersion] = '%s'")
  1745. _T(",[StudioName] = '%s'")
  1746. _T(",[StudioPhone] = '%s'")
  1747. _T(",[StudioAddress] = '%s'")
  1748. _T(",[StudioWebSite] = '%s'")
  1749. _T(",[StudioOwner] = '%s'")
  1750. _T(",[StudioDomain] = '%s'")
  1751. _T(",[StudioOrderInfo] = '%d/%d'")
  1752. _T(",[RefreshDate] = '%s'")
  1753. _T(",[StudioConnectIP] = '%s'")
  1754. _T(",[AntiTheftCommand] = '%s'")
  1755. _T(",[StudioPICMAC] = '%s'")
  1756. _T(",[StudioUSBMAC] = '%s'")
  1757. _T(",[StudioHardDisk] = '%s'")
  1758. _T("WHERE StudioAutoID = %d"),
  1759. strFirstPICMac,
  1760. AntitheftInfo.strStudioVer,
  1761. AntitheftInfo.strStudioName,
  1762. AntitheftInfo.strStudioPhone,
  1763. AntitheftInfo.strStudioAddress,
  1764. AntitheftInfo.strStudioWebSite,
  1765. AntitheftInfo.strStudioManager,
  1766. AntitheftInfo.strStudioDomain,
  1767. AntitheftInfo.dwStudioOrderCount,
  1768. AntitheftInfo.dwStudioHistoryOrderCount,
  1769. CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")),
  1770. lpIPAddress,
  1771. CBase64::StringToBase64A(AntitheftInfo.strDetail),
  1772. strPICMac,
  1773. strUSBMac,
  1774. strHardWare,
  1775. nStudioAutoID
  1776. );
  1777. }
  1778. else
  1779. {// guid值不一致,可能不是同一个用户,建议插入新记录;
  1780. strSQL.Format(
  1781. _T("INSERT INTO [StudioInfo]")
  1782. _T("([StudioMac]")
  1783. _T(",[StudioVersion]")
  1784. _T(",[StudioName]")
  1785. _T(",[StudioPhone]")
  1786. _T(",[StudioAddress]")
  1787. _T(",[StudioWebSite]")
  1788. _T(",[StudioOwner]")
  1789. _T(",[StudioDomain]")
  1790. _T(",[StudioOrderInfo]")
  1791. _T(",[RefreshDate]")
  1792. _T(",[StudioConnectIP]")
  1793. _T(",[AntiTheftCommand]")
  1794. _T(",[StudioPICMAC]")
  1795. _T(",[StudioUSBMAC]")
  1796. _T(",[StudioHardDisk])")
  1797. _T("VALUES('%s','%s','%s','%s','%s','%s','%s','%s','%d/%d','%s','%s','%s','%s','%s','%s')"),
  1798. strFirstPICMac,
  1799. AntitheftInfo.strStudioVer,
  1800. AntitheftInfo.strStudioName,
  1801. AntitheftInfo.strStudioPhone,
  1802. AntitheftInfo.strStudioAddress,
  1803. AntitheftInfo.strStudioWebSite,
  1804. AntitheftInfo.strStudioManager,
  1805. AntitheftInfo.strStudioDomain,
  1806. AntitheftInfo.dwStudioOrderCount,
  1807. AntitheftInfo.dwStudioHistoryOrderCount,
  1808. CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")),
  1809. lpIPAddress,
  1810. CBase64::StringToBase64A(AntitheftInfo.strDetail),
  1811. strPICMac,
  1812. strUSBMac,
  1813. strHardWare
  1814. );
  1815. // 新增数据,自增列设置为0;
  1816. nStudioAutoID = 0;
  1817. }
  1818. }
  1819. }
  1820. else
  1821. {// 影楼没有接收过命令,则将当前数据库记录的命令发送给影楼;
  1822. strContent = strAntiTheftCommand.GetString();
  1823. // 并更新其他信息;
  1824. strSQL.Format(
  1825. _T("UPDATE [StudioInfo] SET")
  1826. _T("[StudioMac] = '%s'")
  1827. _T(",[StudioVersion] = '%s'")
  1828. _T(",[StudioName] = '%s'")
  1829. _T(",[StudioPhone] = '%s'")
  1830. _T(",[StudioAddress] = '%s'")
  1831. _T(",[StudioWebSite] = '%s'")
  1832. _T(",[StudioOwner] = '%s'")
  1833. _T(",[StudioDomain] = '%s'")
  1834. _T(",[StudioOrderInfo] = '%d/%d'")
  1835. _T(",[RefreshDate] = '%s'")
  1836. _T(",[StudioConnectIP] = '%s'")
  1837. /*_T(",[AntiTheftCommand] = '%s'")*/
  1838. _T(",[StudioPICMAC] = '%s'")
  1839. _T(",[StudioUSBMAC] = '%s'")
  1840. _T(",[StudioHardDisk] = '%s'")
  1841. _T("WHERE StudioAutoID = %d"),
  1842. strFirstPICMac,
  1843. AntitheftInfo.strStudioVer,
  1844. AntitheftInfo.strStudioName,
  1845. AntitheftInfo.strStudioPhone,
  1846. AntitheftInfo.strStudioAddress,
  1847. AntitheftInfo.strStudioWebSite,
  1848. AntitheftInfo.strStudioManager,
  1849. AntitheftInfo.strStudioDomain,
  1850. AntitheftInfo.dwStudioOrderCount,
  1851. AntitheftInfo.dwStudioHistoryOrderCount,
  1852. CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")),
  1853. lpIPAddress,
  1854. /*AntitheftInfo.strDetail,*/
  1855. strPICMac,
  1856. strUSBMac,
  1857. strHardWare,
  1858. nStudioAutoID
  1859. );
  1860. }
  1861. }
  1862. }
  1863. }
  1864. else
  1865. {
  1866. strContent = "";
  1867. }
  1868. }
  1869. }
  1870. else
  1871. {// 插入数据;
  1872. strSQL.Format(
  1873. _T("INSERT INTO [StudioInfo]")
  1874. _T("([StudioMac]")
  1875. _T(",[StudioVersion]")
  1876. _T(",[StudioName]")
  1877. _T(",[StudioPhone]")
  1878. _T(",[StudioAddress]")
  1879. _T(",[StudioWebSite]")
  1880. _T(",[StudioOwner]")
  1881. _T(",[StudioDomain]")
  1882. _T(",[StudioOrderInfo]")
  1883. _T(",[RefreshDate]")
  1884. _T(",[StudioConnectIP]")
  1885. _T(",[AntiTheftCommand]")
  1886. _T(",[StudioPICMAC]")
  1887. _T(",[StudioUSBMAC]")
  1888. _T(",[StudioHardDisk])")
  1889. _T("VALUES('%s','%s','%s','%s','%s','%s','%s','%s','%d/%d','%s','%s','%s','%s','%s','%s')"),
  1890. strFirstPICMac,
  1891. AntitheftInfo.strStudioVer,
  1892. AntitheftInfo.strStudioName,
  1893. AntitheftInfo.strStudioPhone,
  1894. AntitheftInfo.strStudioAddress,
  1895. AntitheftInfo.strStudioWebSite,
  1896. AntitheftInfo.strStudioManager,
  1897. AntitheftInfo.strStudioDomain,
  1898. AntitheftInfo.dwStudioOrderCount,
  1899. AntitheftInfo.dwStudioHistoryOrderCount,
  1900. CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")),
  1901. lpIPAddress,
  1902. CBase64::StringToBase64A(AntitheftInfo.strDetail),
  1903. strPICMac,
  1904. strUSBMac,
  1905. strHardWare
  1906. );
  1907. // 新增数据,自增列设置为0;
  1908. nStudioAutoID = 0;
  1909. }
  1910. g_podbc->ExecuteSQL(strSQL);
  1911. // 2.从数据库查询是否有命令行要发回;
  1912. // 暂无;
  1913. #if 0
  1914. // 模拟测试;
  1915. pJson = cJSON_CreateObject();
  1916. cJSON_AddStringToObject(pJson, "cmd-guid", _T("98149909-0841-4709-85BF-1028E92916DA"));
  1917. // SQL语句操作;
  1918. cJSON_AddBoolToObject(pJson, "SQL-Opt", TRUE);
  1919. // 文件操作;
  1920. cJSON_AddBoolToObject(pJson, "Data-Opt", TRUE);
  1921. // 加密狗操作-只有一个操作:true就授权过期;
  1922. cJSON_AddBoolToObject(pJson, "Dog-Opt", TRUE);
  1923. //////////////////////////////////////////////////////////////////////////
  1924. // SQL语句操作;
  1925. cJSON *pSQLArry = cJSON_CreateArray();
  1926. cJSON_AddItemToObject(pJson, "SQL-Ary",pSQLArry);
  1927. pItem = NULL;
  1928. // 1.重命名表;
  1929. pItem = cJSON_CreateObject();
  1930. cJSON_AddStringToObject(pItem, "Statement", "EXEC sp_rename 'dindansp3', 'dindansp3_back'");
  1931. cJSON_AddStringToObject(pItem, "ExecTime", "CC:CC");
  1932. cJSON_AddBoolToObject(pItem, "ExecStatus", false); // 执行状态;
  1933. cJSON_AddItemToArray(pSQLArry, pItem);
  1934. pItem = cJSON_CreateObject();
  1935. cJSON_AddStringToObject(pItem, "Statement", "EXEC sp_rename 'dindansp2', 'dindansp2_back'");
  1936. cJSON_AddStringToObject(pItem, "ExecTime", "CC:CC");
  1937. cJSON_AddBoolToObject(pItem, "ExecStatus", false); // 执行状态;
  1938. cJSON_AddItemToArray(pSQLArry, pItem);
  1939. pItem = cJSON_CreateObject();
  1940. cJSON_AddStringToObject(pItem, "Statement", "EXEC sp_rename 'client3', 'client3'");
  1941. cJSON_AddStringToObject(pItem, "ExecTime", "CC:CC");
  1942. cJSON_AddBoolToObject(pItem, "ExecStatus", false); // 执行状态;
  1943. cJSON_AddItemToArray(pSQLArry, pItem);
  1944. // 2.重命字段;
  1945. pItem = cJSON_CreateObject();
  1946. cJSON_AddStringToObject(pItem, "Statement", "EXEC sp_rename 'dindan.[id]', 'id', 'column'");
  1947. cJSON_AddStringToObject(pItem, "ExecTime", "CC:CC");
  1948. cJSON_AddBoolToObject(pItem, "ExecStatus", false); // 执行状态;
  1949. cJSON_AddItemToArray(pSQLArry, pItem);
  1950. pItem = cJSON_CreateObject();
  1951. cJSON_AddStringToObject(pItem, "Statement", "EXEC sp_rename 'dindan.[name1]', 'name1', 'column'");
  1952. cJSON_AddStringToObject(pItem, "ExecTime", "CC:CC");
  1953. cJSON_AddBoolToObject(pItem, "ExecStatus", false); // 执行状态;
  1954. cJSON_AddItemToArray(pSQLArry, pItem);
  1955. //////////////////////////////////////////////////////////////////////////
  1956. // 文件操作;
  1957. pSQLArry = cJSON_CreateArray();
  1958. cJSON_AddItemToObject(pJson, "Data-Ary",pSQLArry);
  1959. pItem = cJSON_CreateObject();
  1960. cJSON_AddNumberToObject(pItem, "Type", 1);// 未选, 未取;
  1961. cJSON_AddStringToObject(pItem, "ExecTime", "NN:NN");
  1962. cJSON_AddNumberToObject(pItem, "Count", 10);
  1963. cJSON_AddBoolToObject(pItem, "ExecStatus", false); // 执行状态;
  1964. cJSON_AddItemToArray(pSQLArry, pItem);
  1965. char *out = cJSON_Print(pJson);
  1966. cJSON_Delete(pJson);
  1967. strContent = out;
  1968. if (out)delete []out;
  1969. #endif
  1970. return nStudioAutoID;
  1971. }