CHttpBll.cpp 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578
  1. #include "CHttpBll.h"
  2. #include <QCryptographicHash>
  3. #include <QTextCodec>
  4. #include "logproc.h"
  5. std::shared_ptr<CHttpBll> g_httpBllPtr = nullptr;
  6. CHttpBll::CHttpBll()
  7. {
  8. sKey = "";
  9. sToken = "";
  10. }
  11. QString CHttpBll::getAuthorization(QString sUri, QString sTimeStamp)
  12. {
  13. if(sToken != "")
  14. {
  15. QString sAuthorization = "post&" +
  16. sUri + "&" + sTimeStamp + "&" + sToken;
  17. QByteArray sha1 = QCryptographicHash::hash(sAuthorization.toLatin1(), QCryptographicHash::Sha1);
  18. QByteArray shaResult = sha1;
  19. sAuthorization = "Token " + sKey + ":" + shaResult.toBase64().data();
  20. return sAuthorization;
  21. // return sAccessToken;
  22. }
  23. return "";
  24. }
  25. QString CHttpBll::getToken()
  26. {
  27. return sToken;
  28. }
  29. QString CHttpBll::getKey()
  30. {
  31. return sKey;
  32. }
  33. void CHttpBll::requestProc(CHttpRequestPackage requestPkg)
  34. {
  35. // QString sTimeStamp = QString::number(g_AppInfo->timestamp());
  36. // requestPkg.sHeadList.push_back(QString::fromLocal8Bit("platform,%1").arg("WEB"));
  37. // requestPkg.sHeadList.push_back(QString::fromLocal8Bit("deviceId,%1").arg(g_AppInfo->sMachineId));
  38. // requestPkg.sHeadList.push_back(QString::fromLocal8Bit("time,%1").arg(sTimeStamp));
  39. requestPkg.sHeadList.push_back(QString::fromLocal8Bit("Referer,%1").arg(requestPkg.sUri));
  40. requestPkg.sHeadList.push_back(QString::fromLocal8Bit("User-Agent,%1").arg("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) electron-exam-shell/1.9.1 Chrome/58.0.3029.110 Electron/1.7.16 Safari/537.36"));
  41. if(sToken != "")
  42. {
  43. requestPkg.sHeadList.push_back(QString::fromLocal8Bit("key,%1").arg(sKey));
  44. requestPkg.sHeadList.push_back(QString::fromLocal8Bit("token,%1").arg(sToken));
  45. // requestPkg.sHeadList.push_back(QString::fromLocal8Bit("Authorization,%1").arg(getAuthorization(requestPkg.sUri, sTimeStamp)));
  46. }
  47. __int64 nStartTime = g_appInfoPtr->serverMTime();
  48. initHeads(requestPkg);
  49. QString sErrorMsg = "";
  50. std::string sResponse = "";
  51. int nCode = 0;
  52. if (requestPkg.nHttpType == HttpType::htDownload)
  53. {
  54. requestPkg.sUri = requestPkg.sUri.replace("\\", "/");
  55. if (!downLoadFile(requestPkg.sUri.toLocal8Bit().data(), requestPkg.sCommonStr.toLocal8Bit().data(), nCode))
  56. {
  57. --requestPkg.nRetryCount;
  58. if(requestPkg.nRetryCount > 0)
  59. {
  60. downLoad(requestPkg);
  61. return;
  62. }
  63. sErrorMsg = QString::fromLocal8Bit("%1下载失败!").arg(requestPkg.sUri);
  64. }
  65. }
  66. if(requestPkg.nHttpType == HttpType::htPost)
  67. {
  68. if(!doPost(requestPkg, sResponse, nCode))
  69. {
  70. sErrorMsg = QString::fromLocal8Bit("接口%1调用失败!").arg(requestPkg.sUri);
  71. }
  72. }
  73. else if(requestPkg.nHttpType == HttpType::htGet || requestPkg.nHttpType == HttpType::htGetUrl)
  74. {
  75. if(!doGet(requestPkg, sResponse, nCode))
  76. {
  77. sErrorMsg = QString::fromLocal8Bit("接口%1调用失败!").arg(requestPkg.sUri);
  78. }
  79. }
  80. else if (requestPkg.nHttpType == HttpType::htPut)
  81. {
  82. if (!doPut(requestPkg, sResponse, nCode))
  83. {
  84. sErrorMsg = QString::fromLocal8Bit("接口%1调用失败!").arg(requestPkg.sUri);
  85. }
  86. }
  87. __int64 nEndTime = g_appInfoPtr->serverMTime();
  88. myServerLog()<< requestPkg.sUri << ":resCode," << nCode<<"response:"<<sResponse.c_str() << "requestTime(ms):" << nEndTime - nStartTime;
  89. myDebug() << requestPkg.sUri << ":"<< sResponse.c_str();
  90. if (nCode != 200)
  91. {
  92. try
  93. {
  94. Json::Reader reader;
  95. Json::Value jsonRoot = Json::Value::null;
  96. if (reader.parse(sResponse, jsonRoot))
  97. {
  98. if (jsonRoot.isMember("desc"))
  99. {
  100. sErrorMsg = jsonRoot["desc"].asString().c_str();
  101. }
  102. }
  103. }
  104. catch (const std::exception &e)
  105. {
  106. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  107. }
  108. }
  109. if (nCode == 403)
  110. {
  111. emit sgnTokenExpired();
  112. return;
  113. }
  114. switch(requestPkg.nRequestType)
  115. {
  116. case RequestType::rtUpgrade://客户端版本升级接口
  117. {
  118. CUpgrade upgrade;
  119. upgrade.nCode = nCode;
  120. if(sErrorMsg != "" || nCode !=200)
  121. {
  122. upgrade.sMessage = sErrorMsg;
  123. }
  124. else
  125. {
  126. genUpgrade(&upgrade, sResponse);
  127. }
  128. emit sgnUpgrade(upgrade);
  129. }
  130. break;
  131. case RequestType::rtSysNotice://客户端版本升级接口
  132. {
  133. CSysNotice sn;
  134. sn.nCode = nCode;
  135. if(sErrorMsg != "" || nCode !=200)
  136. {
  137. sn.sMessage = sErrorMsg;
  138. }
  139. else
  140. {
  141. genSysNotice(&sn, sResponse);
  142. }
  143. emit sgnSysNotice(sn);
  144. }
  145. break;
  146. case RequestType::rtGetSoftwareConfig:
  147. {
  148. CGetSoftwareConfig gsc;
  149. gsc.nCode = nCode;
  150. if(sErrorMsg != "" || nCode !=200)
  151. {
  152. gsc.sMessage = sErrorMsg;
  153. }
  154. else
  155. {
  156. genSoftwareConfig(&gsc, sResponse);
  157. }
  158. emit sgnGetSoftwareConfig(gsc);
  159. }
  160. break;
  161. case RequestType::rtDownLoadFile:
  162. {
  163. CDownLoadFileInfo dfi;
  164. dfi.sFileName = requestPkg.sCommonStr;
  165. dfi.sModuleName = requestPkg.sCommonStr1;
  166. dfi.sAdditionStr = requestPkg.sAdditionStr;
  167. dfi.nCode = nCode;
  168. if (sErrorMsg != "" || nCode != 200)
  169. {
  170. dfi.sMessage = sErrorMsg;
  171. }
  172. emit sgnDownLoadFile(dfi);
  173. }
  174. break;
  175. case RequestType::rtStudentClientConfig:
  176. {
  177. CStudentClientConfig scc;
  178. scc.nCode = nCode;
  179. if (sErrorMsg != "" || nCode != 200)
  180. {
  181. scc.sMessage = sErrorMsg;
  182. }
  183. else
  184. {
  185. genStudentClientConfig(&scc, sResponse);
  186. }
  187. emit sgnStudentClientConfig(scc);
  188. }
  189. break;
  190. case RequestType::rtLoginLimit:
  191. {
  192. CLoginLimit ll;
  193. ll.nCode = nCode;
  194. if (sErrorMsg != "" || nCode != 200)
  195. {
  196. ll.sMessage = sErrorMsg;
  197. }
  198. else
  199. {
  200. genLoginLimit(&ll, sResponse);
  201. }
  202. emit sgnLoginLimit(ll);
  203. }
  204. break;
  205. case RequestType::rtLogin://登录
  206. {
  207. CLoginInfo li;
  208. li.nCode = nCode;
  209. if(sErrorMsg != "" || nCode != 200)
  210. {
  211. li.sMessage = sErrorMsg;
  212. }
  213. else
  214. {
  215. genLoginInfo(&li, sResponse);
  216. }
  217. emit sgnLoginInfo(li);
  218. }
  219. break;
  220. case RequestType::rtLogout:
  221. {
  222. CLogout logout;
  223. logout.nCode = nCode;
  224. if (sErrorMsg != "" || nCode != 200)
  225. {
  226. logout.sMessage = sErrorMsg;
  227. }
  228. else
  229. {
  230. genLogout(&logout, sResponse);
  231. }
  232. emit sgnLogout(logout);
  233. }
  234. break;
  235. case RequestType::rtAgreement:
  236. {
  237. CAgreement agm;
  238. agm.nCode = nCode;
  239. if (sErrorMsg != "" || nCode != 200)
  240. {
  241. agm.sMessage = sErrorMsg;
  242. }
  243. else
  244. {
  245. genAgreement(&agm, sResponse);
  246. }
  247. emit sgnAgreement(agm);
  248. }
  249. break;
  250. case RequestType::rtGetStudentInfoBySession:
  251. {
  252. CGetStudentInfoBySession gsibs;
  253. gsibs.nCode = nCode;
  254. if (sErrorMsg != "" || nCode != 200)
  255. {
  256. gsibs.sMessage = sErrorMsg;
  257. }
  258. else
  259. {
  260. genGetStudentInfoBySession(&gsibs, sResponse);
  261. }
  262. emit sgnGetStudentInfoBySession(gsibs);
  263. }
  264. break;
  265. case RequestType::rtSpecialtyNameList:
  266. {
  267. CSpecialtyNameList snl;
  268. snl.nCode = nCode;
  269. if (sErrorMsg != "" || nCode != 200)
  270. {
  271. snl.sMessage = sErrorMsg;
  272. }
  273. else
  274. {
  275. genSpecialtyNameList(&snl, sResponse);
  276. }
  277. emit sgnSpecialtyNameList(snl);
  278. }
  279. break;
  280. case RequestType::rtCheckExamInProgress:
  281. {
  282. CCheckExamInProgress ceip;
  283. ceip.nCode = nCode;
  284. ceip.sEnterType = requestPkg.sCommonStr;
  285. if (sErrorMsg != "" || nCode != 200)
  286. {
  287. ceip.sMessage = sErrorMsg;
  288. }
  289. else
  290. {
  291. genCheckExamInProgress(&ceip, sResponse);
  292. }
  293. emit sgnCheckExamInProgress(ceip);
  294. }
  295. break;
  296. case RequestType::rtGetStudentClientMenu:
  297. {
  298. CGetStudentClientMenu gcm;
  299. gcm.nCode = nCode;
  300. if (sErrorMsg != "" || nCode != 200)
  301. {
  302. gcm.sMessage = sErrorMsg;
  303. }
  304. else
  305. {
  306. genGetStudentClientMenu(&gcm, sResponse);
  307. }
  308. emit sgnGetStudentClientMenu(gcm);
  309. }
  310. break;
  311. case RequestType::rtAppDownLoadUrl:
  312. {
  313. CAppDownLoadUrl adlu;
  314. adlu.nCode = nCode;
  315. if (sErrorMsg != "" || nCode != 200)
  316. {
  317. adlu.sMessage = sErrorMsg;
  318. }
  319. else
  320. {
  321. genAppDownLoadUrl(&adlu, sResponse);
  322. }
  323. emit sgnAppDownLoadUrl(adlu);
  324. }
  325. break;
  326. case RequestType::rtGetUserNoticeList:
  327. {
  328. CGetUserNoticeList gunl;
  329. gunl.nCode = nCode;
  330. if (sErrorMsg != "" || nCode != 200)
  331. {
  332. gunl.sMessage = sErrorMsg;
  333. }
  334. else
  335. {
  336. genGetUserNoticeList(&gunl, sResponse);
  337. }
  338. emit sgnGetUserNoticeList(gunl);
  339. }
  340. break;
  341. case RequestType::rtUpdateNoticeReadStatus:
  342. {
  343. CUpdateNoticeReadStatus unrs;
  344. unrs.nCode = nCode;
  345. unrs.sIds = requestPkg.sCommonStr;
  346. if (sErrorMsg != "" || nCode != 200)
  347. {
  348. unrs.sMessage = sErrorMsg;
  349. }
  350. emit sgnUpdateNoticeReadStatus(unrs);
  351. }
  352. break;
  353. case RequestType::rtQueryExamList:
  354. {
  355. CQueryExamList qel;
  356. qel.nCode = nCode;
  357. if (sErrorMsg != "" || nCode != 200)
  358. {
  359. qel.sMessage = sErrorMsg;
  360. }
  361. else
  362. {
  363. genQueryExamList(&qel, sResponse);
  364. }
  365. emit sgnQueryExamList(qel);
  366. }
  367. break;
  368. case RequestType::rtQueryExamEndList:
  369. {
  370. CQueryExamEndList qeel;
  371. qeel.nCode = nCode;
  372. if (sErrorMsg != "" || nCode != 200)
  373. {
  374. qeel.sMessage = sErrorMsg;
  375. }
  376. else
  377. {
  378. genQueryExamEndList(&qeel, sResponse);
  379. }
  380. emit sgnQueryExamEndList(qeel);
  381. }
  382. break;
  383. case RequestType::rtQueryHomeworkList:
  384. {
  385. CQueryHomeworkList qhl;
  386. qhl.nCode = nCode;
  387. if (sErrorMsg != "" || nCode != 200)
  388. {
  389. qhl.sMessage = sErrorMsg;
  390. }
  391. else
  392. {
  393. genQueryHomeworkList(&qhl, sResponse);
  394. }
  395. emit sgnQueryHomeworkList(qhl);
  396. }
  397. break;
  398. case RequestType::rtQueryBatchList:
  399. {
  400. CQueryBatchList qbl;
  401. qbl.nCode = nCode;
  402. if (sErrorMsg != "" || nCode != 200)
  403. {
  404. qbl.sMessage = sErrorMsg;
  405. }
  406. else
  407. {
  408. genQueryBatchList(&qbl, sResponse);
  409. }
  410. emit sgnQueryBatchList(qbl);
  411. }
  412. break;
  413. case RequestType::rtQueryPracticeCourseList:
  414. {
  415. CQueryPracticeCourseList qpcl;
  416. qpcl.nCode = nCode;
  417. if (sErrorMsg != "" || nCode != 200)
  418. {
  419. qpcl.sMessage = sErrorMsg;
  420. }
  421. else
  422. {
  423. genQueryPracticeCourseList(&qpcl, sResponse);
  424. }
  425. emit sgnQueryPracticeCourseList(qpcl);
  426. }
  427. break;
  428. case RequestType::rtQueryPracticeRecordList:
  429. {
  430. CQueryPracticeRecordList qprl;
  431. qprl.nCode = nCode;
  432. if (sErrorMsg != "" || nCode != 200)
  433. {
  434. qprl.sMessage = sErrorMsg;
  435. }
  436. else
  437. {
  438. genQueryPracticeRecordList(&qprl, sResponse);
  439. }
  440. emit sgnQueryPracticeRecordList(qprl);
  441. }
  442. break;
  443. case RequestType::rtGetPracticeDetailInfo:
  444. {
  445. CGetPracticeDetailInfo gpdi;
  446. gpdi.nCode = nCode;
  447. if (sErrorMsg != "" || nCode != 200)
  448. {
  449. gpdi.sMessage = sErrorMsg;
  450. }
  451. else
  452. {
  453. genGetPracticeDetailInfo(&gpdi, sResponse);
  454. }
  455. emit sgnGetPracticeDetailInfo(gpdi);
  456. }
  457. break;
  458. case RequestType::rtFindExamRecordDataEntity:
  459. {
  460. CFindExamRecordDataEntity ferde;
  461. ferde.nCode = nCode;
  462. if (sErrorMsg != "" || nCode != 200)
  463. {
  464. ferde.sMessage = sErrorMsg;
  465. }
  466. else
  467. {
  468. genFindExamRecordDataEntity(&ferde, sResponse);
  469. }
  470. emit sgnFindExamRecordDataEntity(ferde);
  471. }
  472. break;
  473. case RequestType::rtGetCourseInfo:
  474. {
  475. CGetCourseInfo gci;
  476. gci.nCode = nCode;
  477. if (sErrorMsg != "" || nCode != 200)
  478. {
  479. gci.sMessage = sErrorMsg;
  480. }
  481. else
  482. {
  483. genGetCourseInfo(&gci, sResponse);
  484. }
  485. emit sgnGetCourseInfo(gci);
  486. }
  487. break;
  488. case RequestType::rtGetExamRecordQuestions:
  489. {
  490. CGetExamRecordQuestions gerq;
  491. gerq.nCode = nCode;
  492. if (sErrorMsg != "" || nCode != 200)
  493. {
  494. gerq.sMessage = sErrorMsg;
  495. }
  496. else
  497. {
  498. genGetExamRecordQuestions(&gerq, sResponse);
  499. }
  500. emit sgnGetExamRecordQuestions(gerq);
  501. }
  502. break;
  503. case RequestType::rtGetQuestion:
  504. {
  505. CGetQuestion gq;
  506. gq.nCode = nCode;
  507. if (sErrorMsg != "" || nCode != 200)
  508. {
  509. gq.sMessage = sErrorMsg;
  510. }
  511. else
  512. {
  513. genGetQuestion(&gq, sResponse);
  514. }
  515. emit sgnGetQuestion(gq);
  516. }
  517. break;
  518. case RequestType::rtGetOfflineCourse:
  519. {
  520. CGetOfflineCourse goc;
  521. goc.nCode = nCode;
  522. if (sErrorMsg != "" || nCode != 200)
  523. {
  524. goc.sMessage = sErrorMsg;
  525. }
  526. else
  527. {
  528. genGetOfflineCourse(&goc, sResponse);
  529. }
  530. emit sgnGetOfflineCourse(goc);
  531. }
  532. break;
  533. case RequestType::rtGetOffLineExamAnswerSheet:
  534. {
  535. CGetOffLineExamAnswerSheet goeas;
  536. goeas.nCode = nCode;
  537. if (sErrorMsg != "" || nCode != 200)
  538. {
  539. goeas.sMessage = sErrorMsg;
  540. }
  541. else
  542. {
  543. genGetOffLineExamAnswerSheet(&goeas, sResponse);
  544. }
  545. emit sgnGetOffLineExamAnswerSheet(goeas);
  546. }
  547. break;
  548. case RequestType::rtStartOfflineExam:
  549. {
  550. CStartOfflineExam soe;
  551. soe.nCode = nCode;
  552. soe.nRow = requestPkg.sCommonStr.toInt();
  553. if (sErrorMsg != "" || nCode != 200)
  554. {
  555. soe.sMessage = sErrorMsg;
  556. }
  557. emit sgnStartOfflineExam(soe);
  558. }
  559. break;
  560. case RequestType::rtGetOffLineExamPaper:
  561. {
  562. CGetOffLineExamPaper goep;
  563. goep.nCode = nCode;
  564. if (sErrorMsg != "" || nCode != 200)
  565. {
  566. goep.sMessage = sErrorMsg;
  567. }
  568. else
  569. {
  570. QFile file(requestPkg.sCommonStr);
  571. if (file.open(QIODevice::WriteOnly))
  572. {
  573. qint64 nLen = file.write(sResponse.c_str(), sResponse.length());
  574. file.close();
  575. if (nLen != sResponse.length())
  576. {
  577. goep.nCode = 0;
  578. goep.sMessage = QString::fromLocal8Bit("保存试卷失败");
  579. }
  580. }
  581. else
  582. {
  583. goep.nCode = 0;
  584. goep.sMessage = QString::fromLocal8Bit("创建试卷失败");
  585. }
  586. genGetOffLineExamPaper(&goep, sResponse);
  587. }
  588. emit sgnGetOffLineExamPaper(goep);
  589. }
  590. break;
  591. case RequestType::rtPreviewOffLineExamPaper:
  592. {
  593. CPreviewOffLineExamPaper poep;
  594. poep.nCode = nCode;
  595. poep.nRow = requestPkg.sCommonStr.toInt();
  596. if (sErrorMsg != "" || nCode != 200)
  597. {
  598. poep.sMessage = sErrorMsg;
  599. }
  600. else
  601. {
  602. genPreviewOffLineExamPaper(&poep, sResponse);
  603. }
  604. emit sgnPreviewOffLineExamPaper(poep);
  605. }
  606. break;
  607. case RequestType::rtSubmitOfflinePaper:
  608. {
  609. CSubmitOfflinePaper sop;
  610. sop.nCode = nCode;
  611. if (sErrorMsg != "" || nCode != 200)
  612. {
  613. sop.sMessage = sErrorMsg;
  614. }
  615. emit sgnSubmitOfflinePaper(sop);
  616. }
  617. break;
  618. case RequestType::rtQueryObjectiveScoreList:
  619. {
  620. CQueryObjectiveScoreList qosl;
  621. qosl.nCode = nCode;
  622. qosl.sExamStudentId = requestPkg.sCommonStr;
  623. if (sErrorMsg != "" || nCode != 200)
  624. {
  625. qosl.sMessage = sErrorMsg;
  626. }
  627. else
  628. {
  629. genQueryObjectiveScoreList(&qosl, sResponse);
  630. }
  631. emit sgnQueryObjectiveScoreList(qosl);
  632. }
  633. break;
  634. case RequestType::rtEditPassword:
  635. {
  636. CEditPassword ep;
  637. ep.nCode = nCode;
  638. if (sErrorMsg != "" || nCode != 200)
  639. {
  640. ep.sMessage = sErrorMsg;
  641. }
  642. else
  643. {
  644. genEditPassword(&ep, sResponse);
  645. }
  646. emit sgnEditPassword(ep);
  647. }
  648. break;
  649. case RequestType::rtStartExamLimit:
  650. {
  651. CStartExamLimit sel;
  652. sel.nCode = nCode;
  653. if (sErrorMsg != "" || nCode != 200)
  654. {
  655. sel.sMessage = sErrorMsg;
  656. }
  657. else
  658. {
  659. genStartExamLimit(&sel, sResponse);
  660. }
  661. emit sgnStartExamLimit(sel);
  662. }
  663. break;
  664. case RequestType::rtIpLimit:
  665. {
  666. CIpLimit il;
  667. il.nCode = nCode;
  668. if (sErrorMsg != "" || nCode != 200)
  669. {
  670. il.sMessage = sErrorMsg;
  671. }
  672. else
  673. {
  674. genIpLimit(&il, sResponse);
  675. }
  676. emit sgnIpLimit(il);
  677. }
  678. break;
  679. case RequestType::rtGetExamProperty:
  680. {
  681. CGetExamProperty ep;
  682. ep.nCode = nCode;
  683. ep.sType = requestPkg.sCommonStr;
  684. if (sErrorMsg != "" || nCode != 200)
  685. {
  686. ep.sMessage = sErrorMsg;
  687. }
  688. else
  689. {
  690. genGetExamProperty(&ep, sResponse);
  691. }
  692. emit sgnGetExamProperty(ep);
  693. }
  694. break;
  695. case RequestType::rtFaceCheckEnabled:
  696. {
  697. CFaceCheckEnabled fce;
  698. fce.nCode = nCode;
  699. if (sErrorMsg != "" || nCode != 200)
  700. {
  701. fce.sMessage = sErrorMsg;
  702. }
  703. else
  704. {
  705. genFaceCheckEnabled(&fce, sResponse);
  706. }
  707. emit sgnFaceCheckEnabled(fce);
  708. }
  709. break;
  710. case RequestType::rtLivenessEnabled:
  711. {
  712. CLivenessEnabled le;
  713. le.nCode = nCode;
  714. if (sErrorMsg != "" || nCode != 200)
  715. {
  716. le.sMessage = sErrorMsg;
  717. }
  718. else
  719. {
  720. genLivenessEnabled(&le, sResponse);
  721. }
  722. emit sgnLivenessEnabled(le);
  723. }
  724. break;
  725. case RequestType::rtStartExam:
  726. {
  727. CStartExam se;
  728. se.nCode = nCode;
  729. if (sErrorMsg != "" || nCode != 200)
  730. {
  731. se.sMessage = sErrorMsg;
  732. }
  733. else
  734. {
  735. genStartExam(&se, sResponse);
  736. }
  737. emit sgnStartExam(se);
  738. }
  739. break;
  740. case RequestType::rtGetExamRecordPaperStruct:
  741. {
  742. CGetExamRecordPaperStruct eps;
  743. eps.nCode = nCode;
  744. if (sErrorMsg != "" || nCode != 200)
  745. {
  746. eps.sMessage = sErrorMsg;
  747. }
  748. else
  749. {
  750. genGetExamRecordPaperStruct(&eps, sResponse);
  751. }
  752. emit sgnGetExamRecordPaperStruct(eps);
  753. }
  754. break;
  755. case RequestType::rtGetExamById:
  756. {
  757. CGetExamById examInfo;
  758. examInfo.nCode = nCode;
  759. if (sErrorMsg != "" || nCode != 200)
  760. {
  761. examInfo.sMessage = sErrorMsg;
  762. }
  763. else
  764. {
  765. genGetExamById(&examInfo, sResponse);
  766. }
  767. emit sgnGetExamById(examInfo);
  768. }
  769. break;
  770. case RequestType::rtWeiXinAnswerEnabled:
  771. {
  772. CWeiXinAnswerEnabled wxae;
  773. wxae.nCode = nCode;
  774. if (sErrorMsg != "" || nCode != 200)
  775. {
  776. wxae.sMessage = sErrorMsg;
  777. }
  778. else
  779. {
  780. genWeiXinAnswerEnabled(&wxae, sResponse);
  781. }
  782. emit sgnWeiXinAnswerEnabled(wxae);
  783. }
  784. break;
  785. case RequestType::rtGetWXQrCode:
  786. {
  787. CGetWXQrCode wxc;
  788. wxc.nCode = nCode;
  789. if (sErrorMsg != "" || nCode != 200)
  790. {
  791. wxc.sMessage = sErrorMsg;
  792. }
  793. else
  794. {
  795. genGetWXQrCode(&wxc, sResponse);
  796. }
  797. emit sgnGetWXQrCode(wxc);
  798. }
  799. break;
  800. case RequestType::rtSaveUploadedFileAcknowledgeStatus:
  801. {
  802. CSaveUploadedFileAcknowledgeStatus sufs;
  803. sufs.nCode = nCode;
  804. sufs.sFileUrl = requestPkg.sCommonStr;
  805. if (sErrorMsg != "" || nCode != 200)
  806. {
  807. sufs.sMessage = sErrorMsg;
  808. }
  809. emit sgnSaveUploadedFileAcknowledgeStatus(sufs);
  810. }
  811. break;
  812. case RequestType::rtFindExamQuestionList:
  813. {
  814. CFindExamQuestionList feql;
  815. feql.nCode = nCode;
  816. if (sErrorMsg != "" || nCode != 200)
  817. {
  818. feql.sMessage = sErrorMsg;
  819. }
  820. else
  821. {
  822. genFindExamQuestionList(&feql, sResponse);
  823. }
  824. emit sgnFindExamQuestionList(feql);
  825. }
  826. break;
  827. case RequestType::rtGetQuestionContent:
  828. {
  829. CGetQuestionContent gqc;
  830. QStringList sl = requestPkg.sCommonStr.split(",");
  831. if (sl.count() == 2)
  832. {
  833. gqc.sQuestionId = sl[0];
  834. gqc.sOrder = sl[1];
  835. }
  836. gqc.nCode = nCode;
  837. if (sErrorMsg != "" || nCode != 200)
  838. {
  839. gqc.sMessage = sErrorMsg;
  840. }
  841. else
  842. {
  843. genGetQuestionContent(&gqc, sResponse);
  844. }
  845. emit sgnGetQuestionContent(gqc);
  846. }
  847. break;
  848. case RequestType::rtStartAnswer:
  849. {
  850. CStartAnswer sa;
  851. sa.nCode = nCode;
  852. if (sErrorMsg != "" || nCode != 200)
  853. {
  854. sa.sMessage = sErrorMsg;
  855. }
  856. else
  857. {
  858. genStartAnswer(&sa, sResponse);
  859. }
  860. emit sgnStartAnswer(sa);
  861. }
  862. break;
  863. case RequestType::rtExamHeartbeat:
  864. {
  865. CExamHeartbeat ehb;
  866. ehb.nCode = nCode;
  867. if (sErrorMsg != "" || nCode != 200)
  868. {
  869. ehb.sMessage = sErrorMsg;
  870. }
  871. else
  872. {
  873. genExamHeartbeat(&ehb, sResponse);
  874. }
  875. emit sgnExamHeartbeat(ehb);
  876. }
  877. break;
  878. case RequestType::rtSubmitQuestionAnswer:
  879. {
  880. CSubmitQuestionAnswer sqa;
  881. sqa.nCode = nCode;
  882. QStringList list = requestPkg.sCommonStr.split(",");
  883. if(list.count() == 2)
  884. {
  885. sqa.nOrder = list[0].toInt();
  886. sqa.nVersion = list[1].toInt();
  887. }
  888. if (sErrorMsg != "" || nCode != 200)
  889. {
  890. sqa.sMessage = sErrorMsg;
  891. }
  892. emit sgnSubmitQuestionAnswer(sqa);
  893. }
  894. break;
  895. case RequestType::rtEndExam:
  896. {
  897. CEndExam ee;
  898. ee.nCode = nCode;
  899. ee.sModuleName = requestPkg.sCommonStr;
  900. ee.bForce = requestPkg.sAdditionStr == "1";
  901. if (sErrorMsg != "" || nCode != 200)
  902. {
  903. ee.sMessage = sErrorMsg;
  904. }
  905. emit sgnEndExam(ee);
  906. }
  907. break;
  908. case RequestType::rtProcessUpload:
  909. {
  910. CProcessUpload pu;
  911. pu.sCommonStr = requestPkg.sCommonStr;
  912. pu.nCode = nCode;
  913. if (sErrorMsg != "" || nCode != 200)
  914. {
  915. pu.sMessage = sErrorMsg;
  916. }
  917. else
  918. {
  919. genProcessUpload(&pu, sResponse);
  920. }
  921. emit sgnProcessUpload(pu);
  922. }
  923. break;
  924. case RequestType::rtSaveFaceCompareResult:
  925. {
  926. CBaseResponsePackage res;
  927. res.nCode = nCode;
  928. if (sErrorMsg != "" || nCode != 200)
  929. {
  930. res.sMessage = sErrorMsg;
  931. }
  932. emit sgnSaveFaceCompareResult(res);
  933. }
  934. break;
  935. case RequestType::rtSaveFaceCaptureResult:
  936. {
  937. CBaseResponsePackage res;
  938. res.nCode = nCode;
  939. if (sErrorMsg != "" || nCode != 200)
  940. {
  941. res.sMessage = sErrorMsg;
  942. }
  943. emit sgnSaveFaceCaptureResult(res);
  944. }
  945. break;
  946. case RequestType::rtSaveFaceLiveVerifyResult:
  947. {
  948. CBaseResponsePackage res;
  949. res.nCode = nCode;
  950. if (sErrorMsg != "" || nCode != 200)
  951. {
  952. res.sMessage = sErrorMsg;
  953. }
  954. emit sgnSaveFaceLiveVerifyResult(res);
  955. }
  956. break;
  957. case RequestType::rtStartFaceLiveVerify:
  958. {
  959. CStartFaceLiveVerify sflv;
  960. sflv.nCode = nCode;
  961. if (sErrorMsg != "" || nCode != 200)
  962. {
  963. sflv.sMessage = sErrorMsg;
  964. }
  965. else
  966. {
  967. genStartFaceLiveVerify(&sflv, sResponse);
  968. }
  969. emit sgnStartFaceLiveVerify(sflv);
  970. }
  971. break;
  972. case RequestType::rtGetOrgPropertiesByGroupWithoutCache:
  973. {
  974. CGetOrgPropertiesByGroupWithoutCache gop;
  975. gop.nCode = nCode;
  976. if (sErrorMsg != "" || nCode != 200)
  977. {
  978. gop.sMessage = sErrorMsg;
  979. }
  980. else
  981. {
  982. genGetOrgPropertiesByGroupWithoutCache(&gop, sResponse);
  983. }
  984. emit sgnGetOrgPropertiesByGroupWithoutCache(gop);
  985. }
  986. break;
  987. case RequestType::rtGetEndExamInfo:
  988. {
  989. CGetEndExamInfo geei;
  990. geei.nCode = nCode;
  991. if (sErrorMsg != "" || nCode != 200)
  992. {
  993. geei.sMessage = sErrorMsg;
  994. }
  995. else
  996. {
  997. genGetEndExamInfo(&geei, sResponse);
  998. }
  999. emit sgnGetEndExamInfo(geei);
  1000. }
  1001. break;
  1002. default:
  1003. break;
  1004. }
  1005. }
  1006. void CHttpBll::genUpgrade(CUpgrade *pUpgrade, const std::string &sResponse)
  1007. {
  1008. try
  1009. {
  1010. Json::Reader reader;
  1011. Json::Value jsonRoot = Json::Value::null;
  1012. if(!reader.parse(sResponse, jsonRoot))
  1013. {
  1014. pUpgrade->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1015. myDebug() << pUpgrade->sMessage << sResponse.c_str();
  1016. }
  1017. pUpgrade->sVersion = jsonRoot["version"].asString().c_str();
  1018. pUpgrade->nBuild = jsonRoot["build"].asInt();
  1019. pUpgrade->sContent = jsonRoot["content"].asString().c_str();
  1020. pUpgrade->bForce = jsonRoot["force"].asBool();
  1021. pUpgrade->sUpgradeUrl = jsonRoot["downUrl"].asString().c_str();
  1022. }
  1023. catch (const std::exception &e)
  1024. {
  1025. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1026. }
  1027. }
  1028. void CHttpBll::genAgreement(CAgreement *pAgreement, const std::string &sResponse)
  1029. {
  1030. try
  1031. {
  1032. std::string sRes = sResponse;
  1033. if (sResponse.length() > 3 && sResponse[0] == -17 &&
  1034. sResponse[1] == -69 &&
  1035. sResponse[2] == -65)
  1036. {
  1037. sRes = sResponse.substr(3, sResponse.length() -3);
  1038. }
  1039. Json::Reader reader;
  1040. Json::Value jsonRoot = Json::Value::null;
  1041. if(!reader.parse(sRes, jsonRoot))
  1042. {
  1043. pAgreement->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1044. myDebug() << pAgreement->sMessage << sResponse.c_str();
  1045. }
  1046. pAgreement->sTitle = jsonRoot["title"].asString().c_str();
  1047. pAgreement->nStaySeconds = jsonRoot["staySeconds"].asInt();
  1048. pAgreement->sContent = jsonRoot["content"].toStyledString().c_str();
  1049. }
  1050. catch (const std::exception &e)
  1051. {
  1052. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1053. }
  1054. }
  1055. void CHttpBll::genStudentClientConfig(CStudentClientConfig *pStudentClientConfig, const std::string &sResponse)
  1056. {
  1057. try
  1058. {
  1059. Json::Reader reader;
  1060. Json::Value jsonRoot = Json::Value::null;
  1061. if (!reader.parse(sResponse, jsonRoot))
  1062. {
  1063. pStudentClientConfig->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1064. myDebug() << pStudentClientConfig->sMessage << sResponse.c_str();
  1065. }
  1066. pStudentClientConfig->sCusMenuLogoFileUrl = jsonRoot["CUS_MENU_LOGO_FILE_URL"].asString().c_str();
  1067. pStudentClientConfig->sIdentityNumberLoginAlias = jsonRoot["IDENTITY_NUMBER_LOGIN_ALIAS"].asString().c_str();
  1068. pStudentClientConfig->bIsCustomMenuLogo = QVariant(jsonRoot["IS_CUSTOM_MENU_LOGO"].asString().c_str()).toBool();
  1069. QString loginType = jsonRoot["LOGIN_TYPE"].asString().c_str();
  1070. QStringList ltList = loginType.split(",");
  1071. for (QString sType : ltList)
  1072. {
  1073. if (sType == "STUDENT_CODE")
  1074. {
  1075. pStudentClientConfig->bStudentCodeLogin = true;
  1076. }
  1077. else if (sType == "IDENTITY_NUMBER")
  1078. {
  1079. pStudentClientConfig->bIdentifyNumberLogin = true;
  1080. }
  1081. }
  1082. pStudentClientConfig->sLogoFileUrl = jsonRoot["LOGO_FILE_URL"].asString().c_str();
  1083. pStudentClientConfig->sStudentClientBgPictureUrl = jsonRoot["STUDENT_CLIENT_BG_PICTURE_URL"].asString().c_str();
  1084. pStudentClientConfig->sOeStudentSysName = jsonRoot["OE_STUDENT_SYS_NAME"].asString().c_str();
  1085. QString preventCheating = jsonRoot["PREVENT_CHEATING_CONFIG"].asString().c_str();
  1086. QStringList pcList = preventCheating.split(",");
  1087. for (QString sType : pcList)
  1088. {
  1089. if (sType == "DISABLE_REMOTE_ASSISTANCE")
  1090. {
  1091. pStudentClientConfig->bDisableRemoteAssistance = true;
  1092. }
  1093. else if (sType == "FULL_SCREEN_TOP")
  1094. {
  1095. pStudentClientConfig->bFullScreenTop = true;
  1096. }
  1097. else if (sType == "DISABLE_MULTISCREEN")
  1098. {
  1099. pStudentClientConfig->bDisableMutiScreen = true;
  1100. }
  1101. else if (sType == "DISABLE_VIRTUAL_CAMERA")
  1102. {
  1103. pStudentClientConfig->bDisableVirtualCamera = true;
  1104. }
  1105. }
  1106. pStudentClientConfig->sRootOrgId = jsonRoot["ROOT_ORG_ID"].asString().c_str();// " : "0",
  1107. pStudentClientConfig->bShowQmthLogo = QVariant(jsonRoot["SHOW_QMTH_LOGO"].asString().c_str()).toBool();// " : "false",
  1108. pStudentClientConfig->bShowStudentClientAppQrcode = QVariant(jsonRoot["SHOW_STUDENT_CLIENT_APP_QRCODE"].asString().c_str()).toBool();// " : "true",
  1109. pStudentClientConfig->sStudentCodeLoginAlias = jsonRoot["STUDENT_CODE_LOGIN_ALIAS"].asString().c_str(); // " : "学号登录34s"
  1110. }
  1111. catch (const std::exception &e)
  1112. {
  1113. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1114. }
  1115. }
  1116. void CHttpBll::genSysNotice(CSysNotice *pSysNotice, const std::string &sResponse)
  1117. {
  1118. try
  1119. {
  1120. Json::Reader reader;
  1121. Json::Value jsonRoot = Json::Value::null;
  1122. if (!reader.parse(sResponse, jsonRoot))
  1123. {
  1124. pSysNotice->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1125. myDebug() << pSysNotice->sMessage << sResponse.c_str();
  1126. }
  1127. pSysNotice->nId = jsonRoot["id"].asInt64();
  1128. pSysNotice->nRootOrgId = jsonRoot["rootOrgId"].asInt64();
  1129. pSysNotice->sContent = jsonRoot["content"].asString().c_str();
  1130. pSysNotice->sStartTime = jsonRoot["startTime"].asString().c_str();
  1131. pSysNotice->sEndTime = jsonRoot["endTime"].asString().c_str();
  1132. pSysNotice->sTitle = jsonRoot["title"].asString().c_str();
  1133. pSysNotice->bEnable = jsonRoot["enable"].asBool();
  1134. }
  1135. catch (const std::exception &e)
  1136. {
  1137. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1138. }
  1139. }
  1140. void CHttpBll::genSoftwareConfig(CGetSoftwareConfig *pSoftwareConfig, const std::string &sResponse)
  1141. {
  1142. if(!sResponse.empty())
  1143. {
  1144. pSoftwareConfig->sSoftwareConfig = std::string(sResponse.rbegin()+32, sResponse.rend()).c_str();
  1145. }
  1146. }
  1147. void CHttpBll::genLoginLimit(CLoginLimit *pLoginLimit, const std::string &sResponse)
  1148. {
  1149. try
  1150. {
  1151. Json::Reader reader;
  1152. Json::Value jsonRoot = Json::Value::null;
  1153. if (!reader.parse(sResponse, jsonRoot))
  1154. {
  1155. pLoginLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1156. myDebug() << pLoginLimit->sMessage << sResponse.c_str();
  1157. }
  1158. pLoginLimit->nCount = jsonRoot["count"].asInt64();
  1159. pLoginLimit->bPass = jsonRoot["pass"].asBool();
  1160. }
  1161. catch (const std::exception &e)
  1162. {
  1163. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1164. }
  1165. }
  1166. void CHttpBll::genLoginInfo(CLoginInfo *pLoginInfo, const std::string &sResponse)
  1167. {
  1168. try
  1169. {
  1170. Json::Reader reader;
  1171. Json::Value jsonRoot = Json::Value::null;
  1172. if (!reader.parse(sResponse, jsonRoot))
  1173. {
  1174. pLoginInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1175. myDebug() << pLoginInfo->sMessage << sResponse.c_str();
  1176. }
  1177. // pLoginInfo->nCode = jsonRoot["code"].asInt();
  1178. if (jsonRoot["code"].asString() != "200")
  1179. {
  1180. pLoginInfo->nCode = 0;
  1181. }
  1182. pLoginInfo->sMessage = jsonRoot["desc"].asString().c_str();
  1183. sKey = jsonRoot["content"]["key"].asString().c_str();
  1184. sToken = jsonRoot["content"]["token"].asString().c_str();
  1185. pLoginInfo->sUserType = jsonRoot["content"]["userType"].asString().c_str();
  1186. pLoginInfo->nUserId = jsonRoot["content"]["userId"].asInt64();
  1187. pLoginInfo->sDisplayName = jsonRoot["content"]["displayName"].asString().c_str();
  1188. pLoginInfo->nRootOrgId = jsonRoot["content"]["rootOrgId"].asInt64();
  1189. pLoginInfo->sRootOrgName = jsonRoot["content"]["rootOrgName"].asString().c_str();
  1190. pLoginInfo->sCreationTime = jsonRoot["content"]["creationTime"].asString().c_str();
  1191. pLoginInfo->sClientIp = jsonRoot["content"]["clientIp"].asString().c_str();
  1192. pLoginInfo->nSessionTimeout = jsonRoot["content"]["sessionTimeout"].asInt64();
  1193. pLoginInfo->bPasswordWeak = jsonRoot["content"]["passwordWeak"].asBool();
  1194. }
  1195. catch (const std::exception &e)
  1196. {
  1197. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1198. }
  1199. }
  1200. void CHttpBll::genLogout(CLogout *pLogout, const std::string &sResponse)
  1201. {
  1202. }
  1203. void CHttpBll::genEditPassword(CEditPassword *pEditPassword, const std::string &sResponse)
  1204. {
  1205. }
  1206. void CHttpBll::genGetStudentClientMenu(CGetStudentClientMenu *pGetStudentClientMenu, const std::string &sResponse)
  1207. {
  1208. try
  1209. {
  1210. Json::Reader reader;
  1211. Json::Value jsonRoot = Json::Value::null;
  1212. if (!reader.parse(sResponse, jsonRoot))
  1213. {
  1214. pGetStudentClientMenu->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1215. myDebug() << pGetStudentClientMenu->sMessage << sResponse.c_str();
  1216. }
  1217. int nSize = jsonRoot.size();
  1218. for (int i = 0; i < nSize; ++i)
  1219. {
  1220. Json::Value jMenuItem = jsonRoot[i];
  1221. CStudentClientMenu scm;
  1222. scm.nId = jMenuItem["id"].asInt64();
  1223. scm.sCode = jMenuItem["code"].asString().c_str();
  1224. scm.sName = jMenuItem["name"].asString().c_str();
  1225. pGetStudentClientMenu->vMenus.push_back(scm);
  1226. }
  1227. }
  1228. catch (const std::exception &e)
  1229. {
  1230. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1231. }
  1232. }
  1233. void CHttpBll::genGetStudentInfoBySession(CGetStudentInfoBySession *pGetStudentInfoBySession, const std::string &sResponse)
  1234. {
  1235. try
  1236. {
  1237. Json::Reader reader;
  1238. Json::Value jsonRoot = Json::Value::null;
  1239. if (!reader.parse(sResponse, jsonRoot))
  1240. {
  1241. pGetStudentInfoBySession->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1242. myDebug() << pGetStudentInfoBySession->sMessage << sResponse.c_str();
  1243. }
  1244. pGetStudentInfoBySession->nId = jsonRoot["id"].asInt64();
  1245. pGetStudentInfoBySession->sName = jsonRoot["name"].asString().c_str();
  1246. pGetStudentInfoBySession->nOrgId = jsonRoot["orgId"].asInt64();
  1247. pGetStudentInfoBySession->sOrgCode = jsonRoot["orgCode"].asString().c_str();
  1248. pGetStudentInfoBySession->sOrgName = jsonRoot["orgName"].asString().c_str();
  1249. QString sStudentCode = "";
  1250. int nSize = jsonRoot["studentCodeList"].size();
  1251. for (int i = 0; i < nSize; ++i)
  1252. {
  1253. if (sStudentCode.isEmpty())
  1254. {
  1255. sStudentCode = jsonRoot["studentCodeList"][i].asString().c_str();
  1256. }
  1257. else
  1258. {
  1259. sStudentCode = sStudentCode + "," + jsonRoot["studentCodeList"][i].asString().c_str();
  1260. }
  1261. }
  1262. pGetStudentInfoBySession->sStudentCode = sStudentCode;
  1263. pGetStudentInfoBySession->sIdentityNumber = jsonRoot["identityNumber"].asString().c_str();
  1264. pGetStudentInfoBySession->sPhotoPath = jsonRoot["photoPath"].asString().c_str();
  1265. pGetStudentInfoBySession->bEnable = jsonRoot["enable"].asBool();
  1266. }
  1267. catch (const std::exception &e)
  1268. {
  1269. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1270. }
  1271. }
  1272. void CHttpBll::genSpecialtyNameList(CSpecialtyNameList *pSpecialtyNameList, const std::string &sResponse)
  1273. {
  1274. try
  1275. {
  1276. Json::Reader reader;
  1277. Json::Value jsonRoot = Json::Value::null;
  1278. if (!reader.parse(sResponse, jsonRoot))
  1279. {
  1280. pSpecialtyNameList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1281. myDebug() << pSpecialtyNameList->sMessage << sResponse.c_str();
  1282. }
  1283. QString sSpecialtyName = "";
  1284. int nSize = jsonRoot.size();
  1285. for (int i = 0; i < nSize; ++i)
  1286. {
  1287. if (sSpecialtyName.isEmpty())
  1288. {
  1289. sSpecialtyName = jsonRoot[i].asString().c_str();
  1290. }
  1291. else
  1292. {
  1293. sSpecialtyName = sSpecialtyName + "," + jsonRoot[i].asString().c_str();
  1294. }
  1295. }
  1296. pSpecialtyNameList->sSpecialtyName = sSpecialtyName;
  1297. }
  1298. catch (const std::exception &e)
  1299. {
  1300. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1301. }
  1302. }
  1303. void CHttpBll::genGetUserNoticeList(CGetUserNoticeList *pGetUserNoticeList, const std::string &sResponse)
  1304. {
  1305. try
  1306. {
  1307. Json::Reader reader;
  1308. Json::Value jsonRoot = Json::Value::null;
  1309. if (!reader.parse(sResponse, jsonRoot))
  1310. {
  1311. pGetUserNoticeList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1312. myDebug() << pGetUserNoticeList->sMessage << sResponse.c_str();
  1313. }
  1314. int nSize = jsonRoot.size();
  1315. for (int i = 0; i < nSize; ++i)
  1316. {
  1317. Json::Value jNoticeItem = jsonRoot[i];
  1318. CNoticeInfo ni;
  1319. ni.nId = jNoticeItem["id"].asInt64();
  1320. ni.sTitle = jNoticeItem["title"].asString().c_str();
  1321. ni.sContent = jNoticeItem["content"].asString().c_str();
  1322. ni.sPublisher = jNoticeItem["publisher"].asString().c_str();
  1323. ni.sPublishTime = jNoticeItem["publishTime"].asString().c_str();
  1324. ni.bHasRead = jNoticeItem["hasRead"].asBool();
  1325. ni.bHasRecalled = jNoticeItem["hasRecalled"].isNull() ? false : jNoticeItem["hasRecalled"].asBool();
  1326. pGetUserNoticeList->vNoticeList.push_back(ni);
  1327. }
  1328. }
  1329. catch (const std::exception &e)
  1330. {
  1331. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1332. }
  1333. }
  1334. void CHttpBll::genAppDownLoadUrl(CAppDownLoadUrl *pAppDownLoadUrl, const std::string &sResponse)
  1335. {
  1336. pAppDownLoadUrl->sUrl = sResponse.c_str();
  1337. }
  1338. void CHttpBll::genAppEnabled(CAppEnabled *pAppEnabled, const std::string &sResponse)
  1339. {
  1340. try
  1341. {
  1342. pAppEnabled->bEnable = QVariant(sResponse.c_str()).toBool();
  1343. }
  1344. catch (const std::exception &e)
  1345. {
  1346. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1347. }
  1348. }
  1349. void CHttpBll::genQueryBatchList(CQueryBatchList *pQueryBatchList, const std::string &sResponse)
  1350. {
  1351. try
  1352. {
  1353. Json::Reader reader;
  1354. Json::Value jsonRoot = Json::Value::null;
  1355. if (!reader.parse(sResponse, jsonRoot))
  1356. {
  1357. pQueryBatchList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1358. myDebug() << pQueryBatchList->sMessage << sResponse.c_str();
  1359. }
  1360. int nSize = jsonRoot.size();
  1361. for (int i = 0; i < nSize; ++i)
  1362. {
  1363. Json::Value jBatchItem = jsonRoot[i];
  1364. CBatchInfo bi;
  1365. bi.nId = jBatchItem["id"].asInt64();
  1366. bi.sName = jBatchItem["name"].asString().c_str();
  1367. bi.sExamType = jBatchItem["examType"].asString().c_str();
  1368. pQueryBatchList->vBatchList.push_back(bi);
  1369. }
  1370. }
  1371. catch (const std::exception &e)
  1372. {
  1373. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1374. }
  1375. }
  1376. void CHttpBll::genGetExamProperty(CGetExamProperty *pGetExamProperty, const std::string &sResponse)
  1377. {
  1378. try
  1379. {
  1380. Json::Reader reader;
  1381. Json::Value jsonRoot = Json::Value::null;
  1382. if (!reader.parse(sResponse, jsonRoot))
  1383. {
  1384. pGetExamProperty->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1385. myDebug() << pGetExamProperty->sMessage << sResponse.c_str();
  1386. }
  1387. if (jsonRoot.isMember("BEFORE_EXAM_REMARK"))
  1388. {
  1389. pGetExamProperty->sBeforeExamRemark = jsonRoot["BEFORE_EXAM_REMARK"].asString().c_str();
  1390. }
  1391. if (jsonRoot.isMember("CHECK_ENVIRONMENT"))
  1392. {
  1393. pGetExamProperty->bCheckEnvironment = QVariant(jsonRoot["CHECK_ENVIRONMENT"].asString().c_str()).toBool();
  1394. }
  1395. if (jsonRoot.isMember("WARN_THRESHOLD"))
  1396. {
  1397. pGetExamProperty->nWarnThreshold = QVariant(jsonRoot["WARN_THRESHOLD"].asString().c_str()).toInt();
  1398. }
  1399. if (jsonRoot.isMember("IS_FACE_CHECK"))
  1400. {
  1401. pGetExamProperty->bIsFaceCheck = QVariant(jsonRoot["IS_FACE_CHECK"].asString().c_str()).toBool();
  1402. }
  1403. if (jsonRoot.isMember("SNAPSHOT_INTERVAL"))
  1404. {
  1405. pGetExamProperty->nSnapshotInterval = QVariant(jsonRoot["SNAPSHOT_INTERVAL"].asString().c_str()).toInt();
  1406. }
  1407. if (jsonRoot.isMember("FACE_VERIFY_START_MINUTE"))
  1408. {
  1409. pGetExamProperty->nFaceVerifyStartMinute = QVariant(jsonRoot["FACE_VERIFY_START_MINUTE"].asString().c_str()).toInt();
  1410. }
  1411. if (jsonRoot.isMember("FACE_VERIFY_END_MINUTE"))
  1412. {
  1413. pGetExamProperty->nFaceVerifyEndMinute = QVariant(jsonRoot["FACE_VERIFY_END_MINUTE"].asString().c_str()).toInt();
  1414. }
  1415. if (jsonRoot.isMember("IS_STRANGER_ENABLE"))
  1416. {
  1417. pGetExamProperty->bIsStrangerEnable = QVariant(jsonRoot["IS_STRANGER_ENABLE"].asString().c_str()).toBool();
  1418. }
  1419. if (jsonRoot.isMember("PRACTICE_TYPE"))
  1420. {
  1421. pGetExamProperty->sPracticeType = jsonRoot["PRACTICE_TYPE"].asString().c_str();
  1422. }
  1423. if (jsonRoot.isMember("FREEZE_TIME"))
  1424. {
  1425. pGetExamProperty->nFreezeTime = QVariant(jsonRoot["FREEZE_TIME"].asString().c_str()).toInt();
  1426. }
  1427. if (jsonRoot.isMember("AFTER_EXAM_REMARK"))
  1428. {
  1429. pGetExamProperty->sAfterExamRemark = jsonRoot["AFTER_EXAM_REMARK"].asString().c_str();
  1430. }
  1431. if (jsonRoot.isMember("IS_OBJ_SCORE_VIEW"))
  1432. {
  1433. pGetExamProperty->bIsObjScoreView = QVariant(jsonRoot["IS_OBJ_SCORE_VIEW"].asString().c_str()).toBool();
  1434. }
  1435. if (jsonRoot.isMember("SHOW_CHEATING_REMARK"))
  1436. {
  1437. pGetExamProperty->bShowCheatingRemark = QVariant(jsonRoot["SHOW_CHEATING_REMARK"].asString().c_str()).toBool();
  1438. }
  1439. if (jsonRoot.isMember("CHEATING_REMARK"))
  1440. {
  1441. pGetExamProperty->sCheatingRemark = jsonRoot["CHEATING_REMARK"].asString().c_str();
  1442. }
  1443. if (jsonRoot.isMember("IS_FACE_VERIFY_BEFORE"))
  1444. {
  1445. pGetExamProperty->bIsLivenessBefore = QVariant(jsonRoot["IS_FACE_VERIFY_BEFORE"].asString().c_str()).toBool();
  1446. }
  1447. if (jsonRoot.isMember("OFFLINE_UPLOAD_FILE_TYPE"))
  1448. {
  1449. QString sFileType = jsonRoot["OFFLINE_UPLOAD_FILE_TYPE"].asString().c_str();
  1450. Json::Reader reader;
  1451. Json::Value jFileType = Json::Value::null;
  1452. if (!reader.parse(sFileType.toStdString(), jFileType))
  1453. {
  1454. pGetExamProperty->sMessage = QString::fromLocal8Bit("解析文件类型异常!");
  1455. pGetExamProperty->nCode = 0;
  1456. }
  1457. int nSize = jFileType.size();
  1458. for (int i = 0; i < nSize; ++i)
  1459. {
  1460. pGetExamProperty->vOfflineUploadFileType.push_back(jFileType[i].asString().c_str());
  1461. }
  1462. }
  1463. }
  1464. catch (const std::exception &e)
  1465. {
  1466. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1467. }
  1468. }
  1469. void CHttpBll::genStartExamLimit(CStartExamLimit *pStartExamLimit, const std::string &sResponse)
  1470. {
  1471. try
  1472. {
  1473. Json::Reader reader;
  1474. Json::Value jsonRoot = Json::Value::null;
  1475. if (!reader.parse(sResponse, jsonRoot))
  1476. {
  1477. pStartExamLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1478. myDebug() << pStartExamLimit->sMessage << sResponse.c_str();
  1479. }
  1480. pStartExamLimit->nCount = jsonRoot["count"].asInt();
  1481. pStartExamLimit->bPass = jsonRoot["pass"].asBool();
  1482. }
  1483. catch (const std::exception &e)
  1484. {
  1485. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1486. }
  1487. }
  1488. void CHttpBll::genIpLimit(CIpLimit *pIpLimit, const std::string &sResponse)
  1489. {
  1490. try
  1491. {
  1492. Json::Reader reader;
  1493. Json::Value jsonRoot = Json::Value::null;
  1494. if (!reader.parse(sResponse, jsonRoot))
  1495. {
  1496. pIpLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1497. myDebug() << pIpLimit->sMessage << sResponse.c_str();
  1498. }
  1499. pIpLimit->bLimited = jsonRoot["limited"].asBool();
  1500. }
  1501. catch (const std::exception &e)
  1502. {
  1503. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1504. }
  1505. }
  1506. void CHttpBll::genStartExam(CStartExam *pStartExam, const std::string &sResponse)
  1507. {
  1508. try
  1509. {
  1510. Json::Reader reader;
  1511. Json::Value jsonRoot = Json::Value::null;
  1512. if (!reader.parse(sResponse, jsonRoot))
  1513. {
  1514. pStartExam->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1515. myDebug() << pStartExam->sMessage << sResponse.c_str();
  1516. }
  1517. pStartExam->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  1518. pStartExam->sCourseName = jsonRoot["courseName"].asString().c_str();
  1519. pStartExam->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  1520. pStartExam->nFaceVerifyMinute = jsonRoot["faceVerifyMinute"].asInt();
  1521. pStartExam->sStudentCode = jsonRoot["studentCode"].asString().c_str();
  1522. pStartExam->sStudentName = jsonRoot["studentName"].asString().c_str();
  1523. }
  1524. catch (const std::exception &e)
  1525. {
  1526. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1527. }
  1528. }
  1529. void CHttpBll::genFaceCheckEnabled(CFaceCheckEnabled *pFaceCheckEnabled, const std::string &sResponse)
  1530. {
  1531. try
  1532. {
  1533. pFaceCheckEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
  1534. }
  1535. catch (const std::exception &e)
  1536. {
  1537. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1538. }
  1539. }
  1540. void CHttpBll::genLivenessEnabled(CLivenessEnabled *pLivenessEnabled, const std::string &sResponse)
  1541. {
  1542. try
  1543. {
  1544. pLivenessEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
  1545. }
  1546. catch (const std::exception &e)
  1547. {
  1548. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1549. }
  1550. }
  1551. void CHttpBll::genWeiXinAnswerEnabled(CWeiXinAnswerEnabled *pWeiXinAnswerEnabled, const std::string &sResponse)
  1552. {
  1553. try
  1554. {
  1555. pWeiXinAnswerEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
  1556. }
  1557. catch (const std::exception &e)
  1558. {
  1559. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1560. }
  1561. }
  1562. void CHttpBll::genGetExamById(CGetExamById *pGetExamById, const std::string &sResponse)
  1563. {
  1564. try
  1565. {
  1566. Json::Reader reader;
  1567. Json::Value jsonRoot = Json::Value::null;
  1568. if (!reader.parse(sResponse, jsonRoot))
  1569. {
  1570. pGetExamById->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1571. myDebug() << pGetExamById->sMessage << sResponse.c_str();
  1572. }
  1573. pGetExamById->nId = jsonRoot["id"].asInt64();
  1574. pGetExamById->sCode = jsonRoot["code"].asString().c_str();
  1575. pGetExamById->nRootOrgId = jsonRoot["rootOrgId"].asInt64();
  1576. pGetExamById->sBeginTime = jsonRoot["beginTime"].asString().c_str();
  1577. pGetExamById->sEndTime = jsonRoot["endTime"].asString().c_str();
  1578. pGetExamById->sName = jsonRoot["name"].asString().c_str();
  1579. pGetExamById->sExamType = jsonRoot["examType"].asString().c_str();
  1580. pGetExamById->nDuration = jsonRoot["duration"].asInt64();
  1581. pGetExamById->bEnable = jsonRoot["enable"].asBool();
  1582. pGetExamById->bStarted = jsonRoot["started"].asBool();
  1583. pGetExamById->bIpLimitSettingsEnabled = jsonRoot["ipLimitSettingsEnabled"].asBool();
  1584. }
  1585. catch (const std::exception &e)
  1586. {
  1587. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1588. }
  1589. }
  1590. void CHttpBll::genStartAnswer(CStartAnswer *pStartAnswer, const std::string &sResponse)
  1591. {
  1592. try
  1593. {
  1594. Json::Reader reader;
  1595. Json::Value jsonRoot = Json::Value::null;
  1596. if (!reader.parse(sResponse, jsonRoot))
  1597. {
  1598. pStartAnswer->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1599. myDebug() << pStartAnswer->sMessage << sResponse.c_str();
  1600. }
  1601. pStartAnswer->nDuration = jsonRoot["duration"].asInt64();
  1602. pStartAnswer->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  1603. pStartAnswer->nUsedExamSeconds = jsonRoot["usedExamSeconds"].asInt64();
  1604. }
  1605. catch (const std::exception &e)
  1606. {
  1607. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1608. }
  1609. }
  1610. void CHttpBll::genGetQuestion(CGetQuestion *pGetQuestion, const std::string &sResponse)
  1611. {
  1612. try
  1613. {
  1614. Json::Reader reader;
  1615. Json::Value jsonRoot = Json::Value::null;
  1616. if (!reader.parse(sResponse, jsonRoot))
  1617. {
  1618. pGetQuestion->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1619. myDebug() << pGetQuestion->sMessage << sResponse.c_str();
  1620. }
  1621. pGetQuestion->sId = jsonRoot["id"].asString().c_str();
  1622. pGetQuestion->sBody = jsonRoot["masterVersion"]["body"].isNull() ? "" : jsonRoot["masterVersion"]["body"].asString().c_str();
  1623. pGetQuestion->sVersion = jsonRoot["masterVersion"]["version"].asString().c_str();
  1624. pGetQuestion->bhasAudios = jsonRoot["masterVersion"]["hasAudios"].asBool();
  1625. int nSize = jsonRoot["masterVersion"]["questionUnitList"].size();
  1626. for (int i = 0; i < nSize; ++i)
  1627. {
  1628. Json::Value jQuestionItem = jsonRoot["masterVersion"]["questionUnitList"][i];
  1629. CSubQuestion sq;
  1630. sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1631. sq.sBody = jQuestionItem["body"].asString().c_str();
  1632. //sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1633. int nOptionSize = jQuestionItem["questionOptionList"].size();
  1634. for (int j = 0; j < nOptionSize; ++j)
  1635. {
  1636. Json::Value jOption = jQuestionItem["questionOptionList"][j];
  1637. COption o;
  1638. o.sBody = jOption["body"].asString().c_str();
  1639. sq.vOptions.push_back(o);
  1640. }
  1641. int nAnswerSize = jQuestionItem["rightAnswer"].size();
  1642. for (int k = 0; k < nAnswerSize; ++k)
  1643. {
  1644. Json::Value jAnswer = jQuestionItem["rightAnswer"][k];
  1645. sq.vRightAnswer.push_back(jAnswer.asString().c_str());
  1646. }
  1647. pGetQuestion->vSubQuestion.push_back(sq);
  1648. }
  1649. }
  1650. catch (const std::exception &e)
  1651. {
  1652. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1653. }
  1654. }
  1655. void CHttpBll::genGetQuestionContent(CGetQuestionContent *pGetQuestionContent, const std::string &sResponse)
  1656. {
  1657. try
  1658. {
  1659. Json::Reader reader;
  1660. Json::Value jsonRoot = Json::Value::null;
  1661. if (!reader.parse(sResponse, jsonRoot))
  1662. {
  1663. pGetQuestionContent->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1664. myDebug() << pGetQuestionContent->sMessage << sResponse.c_str();
  1665. }
  1666. pGetQuestionContent->sBody = jsonRoot["body"].isNull() ? "" : jsonRoot["body"].asString().c_str();
  1667. pGetQuestionContent->sVersion = jsonRoot["version"].asString().c_str();
  1668. pGetQuestionContent->bhasAudios = jsonRoot["hasAudios"].asBool();
  1669. int nSize = jsonRoot["questionUnitList"].size();
  1670. for (int i = 0; i < nSize; ++i)
  1671. {
  1672. Json::Value jQuestionItem = jsonRoot["questionUnitList"][i];
  1673. CSubQuestion sq;
  1674. sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1675. sq.sBody = jQuestionItem["body"].asString().c_str();
  1676. sq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  1677. int nOptionSize = jQuestionItem["questionOptionList"].size();
  1678. for (int j = 0; j < nOptionSize; ++j)
  1679. {
  1680. Json::Value jOption = jQuestionItem["questionOptionList"][j];
  1681. COption o;
  1682. o.sBody = jOption["body"].asString().c_str();
  1683. sq.vOptions.push_back(o);
  1684. }
  1685. for (int jq = 0; jq < jQuestionItem["optionPermutation"].size(); ++jq)
  1686. {
  1687. Json::Value Item = jQuestionItem["optionPermutation"][jq];
  1688. sq.voptionPermutation.push_back(Item.asInt());
  1689. }
  1690. int nAnswerSize = jQuestionItem["rightAnswer"].size();
  1691. for (int k = 0; k < nAnswerSize; ++k)
  1692. {
  1693. Json::Value jAnswer = jQuestionItem["rightAnswer"][k];
  1694. sq.vRightAnswer.push_back(jAnswer.asString().c_str());
  1695. }
  1696. pGetQuestionContent->vSubQuestion.push_back(sq);
  1697. }
  1698. }
  1699. catch (const std::exception &e)
  1700. {
  1701. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1702. }
  1703. }
  1704. void CHttpBll::genExamCourseInfo(const Json::Value &jExamItem, CExamCourseInfo &eci)
  1705. {
  1706. try
  1707. {
  1708. eci.nAllowExamCount = jExamItem["allowExamCount"].asInt();
  1709. eci.bAppExamEnabled = jExamItem["appExamEnabled"].asBool();
  1710. eci.sCourseCode = jExamItem["courseCode"].asString().c_str();
  1711. eci.nCourseId = jExamItem["courseId"].asInt64();
  1712. eci.sCourseLevel = jExamItem["courseLevel"].asString().c_str();
  1713. eci.sCourseName = jExamItem["courseName"].asString().c_str();
  1714. eci.sEndTime = jExamItem["endTime"].asString().c_str();
  1715. eci.bExamCycleEnabled = jExamItem["examCycleEnabled"].asBool();
  1716. int nWeekSize = jExamItem["examCycleWeek"].size();
  1717. for(int i =0; i < nWeekSize; ++i)
  1718. {
  1719. eci.vExamCycleWeek.push_back(jExamItem["examCycleWeek"][i].asInt());
  1720. }
  1721. int nCycleTimeRangeSize = jExamItem["examCycleTimeRange"].size();
  1722. for(int i = 0; i < nCycleTimeRangeSize; ++i)
  1723. {
  1724. Json::Value jTimeRange = jExamItem["examCycleTimeRange"][i]["timeRange"];
  1725. int nTimeRangeSize = jTimeRange.size();
  1726. QStringList sTimeRangeList;
  1727. for(int j = 0; j < nTimeRangeSize; ++j)
  1728. {
  1729. sTimeRangeList<<jTimeRange[j].asString().c_str();
  1730. }
  1731. eci.sExamCycleTimeRange<<sTimeRangeList.join("~");
  1732. }
  1733. //eci.sCourseCode = jExamItem["examCycleTimeRange"].asString().c_str();
  1734. //eci.sCourseCode = jExamItem["examCycleWeek"].asString().c_str();
  1735. eci.nExamId = jExamItem["examId"].asInt64();
  1736. eci.sExamName = jExamItem["examName"].asString().c_str();
  1737. eci.sExamStatus = jExamItem["examStatus"].asString().c_str();
  1738. eci.nExamStudentId = jExamItem["examStudentId"].asInt64();
  1739. eci.bFaceCheck = jExamItem["faceCheck"].asBool();
  1740. eci.bFaceEnable = jExamItem["faceEnable"].asBool();
  1741. eci.sIdentityNumber = jExamItem["identityNumber"].asString().c_str();
  1742. eci.bIsFinished = jExamItem["isFinished"].asBool();
  1743. eci.bIsObjScoreView = jExamItem["isObjScoreView"].asBool();
  1744. eci.bIsPhotoUpload = jExamItem["isPhotoUpload"].asBool();
  1745. eci.nOrgId = jExamItem["orgId"].asInt64();
  1746. eci.sOrgName = jExamItem["orgName"].asString().c_str();
  1747. eci.nPaperMins = jExamItem["paperMins"].asInt();
  1748. eci.nRootOrgId = jExamItem["rootOrgId"].asInt64();
  1749. eci.sSpecialtyLevel = jExamItem["specialtyLevel"].asString().c_str();
  1750. eci.sSpecialtyName = jExamItem["specialtyName"].asString().c_str();
  1751. eci.sStartTime = jExamItem["startTime"].asString().c_str();
  1752. eci.sStudentCode = jExamItem["studentCode"].asString().c_str();
  1753. eci.sStudentName = jExamItem["studentName"].asString().c_str();
  1754. }
  1755. catch (const std::exception &e)
  1756. {
  1757. myServerLog()<<",exception error"<<e.what();
  1758. }
  1759. }
  1760. void CHttpBll::genQueryExamList(CQueryExamList *pQueryExamList, const std::string &sResponse)
  1761. {
  1762. try
  1763. {
  1764. Json::Reader reader;
  1765. Json::Value jsonRoot = Json::Value::null;
  1766. if (!reader.parse(sResponse, jsonRoot))
  1767. {
  1768. pQueryExamList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1769. myDebug() << pQueryExamList->sMessage << sResponse.c_str();
  1770. }
  1771. int nExamSize = jsonRoot.size();
  1772. for (int i = 0; i < nExamSize; ++i)
  1773. {
  1774. Json::Value jExamItem = jsonRoot[i];
  1775. CExamCourseInfo eci;
  1776. genExamCourseInfo(jExamItem, eci);
  1777. pQueryExamList->vOnlieExamList.push_back(eci);
  1778. }
  1779. }
  1780. catch (const std::exception &e)
  1781. {
  1782. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1783. }
  1784. }
  1785. void CHttpBll::genQueryExamEndList(CQueryExamEndList *pQueryExamEndList, const std::string &sResponse)
  1786. {
  1787. try
  1788. {
  1789. Json::Reader reader;
  1790. Json::Value jsonRoot = Json::Value::null;
  1791. if (!reader.parse(sResponse, jsonRoot))
  1792. {
  1793. pQueryExamEndList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1794. myDebug() << pQueryExamEndList->sMessage << sResponse.c_str();
  1795. }
  1796. int nExamSize = jsonRoot.size();
  1797. for (int i = 0; i < nExamSize; ++i)
  1798. {
  1799. Json::Value jExamItem = jsonRoot[i];
  1800. CExamCourseInfo eci;
  1801. genExamCourseInfo(jExamItem, eci);
  1802. pQueryExamEndList->vOnlieEndExamList.push_back(eci);
  1803. }
  1804. }
  1805. catch (const std::exception &e)
  1806. {
  1807. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1808. }
  1809. }
  1810. void CHttpBll::genQueryObjectiveScoreList(CQueryObjectiveScoreList *pQueryObjectiveScoreList, const std::string &sResponse)
  1811. {
  1812. try
  1813. {
  1814. Json::Reader reader;
  1815. Json::Value jsonRoot = Json::Value::null;
  1816. if (!reader.parse(sResponse, jsonRoot))
  1817. {
  1818. pQueryObjectiveScoreList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1819. myDebug() << pQueryObjectiveScoreList->sMessage << sResponse.c_str();
  1820. }
  1821. int nScoreSize = jsonRoot.size();
  1822. for (int i = 0; i < nScoreSize; ++i)
  1823. {
  1824. Json::Value jScore = jsonRoot[i];
  1825. CObjectiveScore os;
  1826. os.sEndTime = jScore["endTime"].asString().c_str();
  1827. os.nExamOrder = jScore["examOrder"].asInt();
  1828. os.nExamRecordDataId = jScore["examRecordDataId"].asInt64();
  1829. os.bIsAuditing = jScore["isAuditing"].asBool();
  1830. os.bIsExamEnded = jScore["isExamEnded"].asBool();
  1831. os.bIsIllegality = jScore["isIllegality"].asBool();
  1832. os.fObjectiveScore = jScore["objectiveScore"].asDouble();
  1833. os.sStartTime = jScore["startTime"].asString().c_str();
  1834. pQueryObjectiveScoreList->vObjectiveScore.push_back(os);
  1835. }
  1836. }
  1837. catch (const std::exception &e)
  1838. {
  1839. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1840. }
  1841. }
  1842. void CHttpBll::genQueryHomeworkList(CQueryHomeworkList *pQueryHomeworkList, const std::string &sResponse)
  1843. {
  1844. try
  1845. {
  1846. Json::Reader reader;
  1847. Json::Value jsonRoot = Json::Value::null;
  1848. if (!reader.parse(sResponse, jsonRoot))
  1849. {
  1850. pQueryHomeworkList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1851. myDebug() << pQueryHomeworkList->sMessage << sResponse.c_str();
  1852. }
  1853. int nExamSize = jsonRoot.size();
  1854. for (int i = 0; i < nExamSize; ++i)
  1855. {
  1856. Json::Value jExamItem = jsonRoot[i];
  1857. CExamCourseInfo eci;
  1858. genExamCourseInfo(jExamItem, eci);
  1859. pQueryHomeworkList->vHomeworkExamList.push_back(eci);
  1860. }
  1861. }
  1862. catch (const std::exception &e)
  1863. {
  1864. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1865. }
  1866. }
  1867. void CHttpBll::genQueryPracticeCourseList(CQueryPracticeCourseList *pQueryPracticeCourseList, const std::string &sResponse)
  1868. {
  1869. try
  1870. {
  1871. Json::Reader reader;
  1872. Json::Value jsonRoot = Json::Value::null;
  1873. if (!reader.parse(sResponse, jsonRoot))
  1874. {
  1875. pQueryPracticeCourseList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1876. myDebug() << pQueryPracticeCourseList->sMessage << sResponse.c_str();
  1877. }
  1878. int nExamSize = jsonRoot.size();
  1879. for (int i = 0; i < nExamSize; ++i)
  1880. {
  1881. Json::Value jExamItem = jsonRoot[i];
  1882. CPracticeCourseInfo pci;
  1883. pci.fAveObjectiveAccuracy = jExamItem["aveObjectiveAccuracy"].asDouble();
  1884. pci.sCourseCode = jExamItem["courseCode"].asString().c_str();
  1885. pci.sCourseName = jExamItem["courseName"].asString().c_str();
  1886. pci.sEndTime = jExamItem["endTime"].asString().c_str();
  1887. pci.bExamCycleEnabled = jExamItem["examCycleEnabled"].asBool();
  1888. //pci.sExamCycleTimeRange = jExamItem["examCycleTimeRange"].asDouble();
  1889. //pci.sExamCycleWeek = jExamItem["examCycleWeek"].asDouble();
  1890. int nWeekSize = jExamItem["examCycleWeek"].size();
  1891. for(int i = 0; i < nWeekSize; ++i)
  1892. {
  1893. pci.vExamCycleWeek.push_back(jExamItem["examCycleWeek"][i].asInt());
  1894. }
  1895. int nCycleTimeRangeSize = jExamItem["examCycleTimeRange"].size();
  1896. for(int i = 0; i < nCycleTimeRangeSize; ++i)
  1897. {
  1898. Json::Value jTimeRange = jExamItem["examCycleTimeRange"][i]["timeRange"];
  1899. int nTimeRangeSize = jTimeRange.size();
  1900. QStringList sTimeRangeList;
  1901. for(int j = 0; j < nTimeRangeSize; ++j)
  1902. {
  1903. sTimeRangeList<<jTimeRange[j].asString().c_str();
  1904. }
  1905. pci.sExamCycleTimeRange<<sTimeRangeList.join("~");
  1906. }
  1907. pci.nExamId = jExamItem["examId"].asInt64();
  1908. pci.sExamName = jExamItem["examName"].asString().c_str();
  1909. pci.nExamStudentId = jExamItem["examStudentId"].asInt64();
  1910. pci.sExamType = jExamItem["examType"].asString().c_str();
  1911. pci.fMaxObjectiveAccuracy = jExamItem["maxObjectiveAccuracy"].asDouble();
  1912. pci.nPracticeCount = jExamItem["practiceCount"].asInt();
  1913. pci.fRecentObjectiveAccuracy = jExamItem["recentObjectiveAccuracy"].asDouble();
  1914. pci.sStartTime = jExamItem["startTime"].asString().c_str();
  1915. pci.sStudentCode = jExamItem["studentCode"].asString().c_str();
  1916. pci.sStudentName = jExamItem["studentName"].asString().c_str();
  1917. pQueryPracticeCourseList->vPracticeCourseInfo.push_back(pci);
  1918. }
  1919. }
  1920. catch (const std::exception &e)
  1921. {
  1922. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1923. }
  1924. }
  1925. void CHttpBll::genQueryPracticeRecordList(CQueryPracticeRecordList *pQueryPracticeRecordList, const std::string &sResponse)
  1926. {
  1927. try
  1928. {
  1929. Json::Reader reader;
  1930. Json::Value jsonRoot = Json::Value::null;
  1931. if (!reader.parse(sResponse, jsonRoot))
  1932. {
  1933. pQueryPracticeRecordList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1934. myDebug() << pQueryPracticeRecordList->sMessage << sResponse.c_str();
  1935. }
  1936. int nSize = jsonRoot.size();
  1937. for (int i = 0; i < nSize; ++i)
  1938. {
  1939. Json::Value jPracticeItem = jsonRoot[i];
  1940. CPracticeRecord pr;
  1941. pr.sCourseCode = jPracticeItem["courseCode"].asString().c_str();
  1942. pr.sCourseName = jPracticeItem["courseName"].asString().c_str();
  1943. pr.sEndTime = jPracticeItem["endTime"].asString().c_str();
  1944. pr.sExamName = jPracticeItem["examName"].asString().c_str();
  1945. pr.nFailQuestionNum = jPracticeItem["failQuestionNum"].asInt();
  1946. pr.nId = jPracticeItem["id"].asInt64();
  1947. pr.nNotAnsweredCount = jPracticeItem["notAnsweredCount"].asInt();
  1948. pr.fObjectiveAccuracy = jPracticeItem["objectiveAccuracy"].asDouble();
  1949. pr.nObjectiveNum = jPracticeItem["objectiveNum"].asInt();
  1950. pr.sStartTime = jPracticeItem["startTime"].asString().c_str();
  1951. pr.nSuccQuestionNum = jPracticeItem["succQuestionNum"].asInt();
  1952. pr.nTotalQuestionCount = jPracticeItem["totalQuestionCount"].asInt();
  1953. pr.nUsedExamTime = jPracticeItem["usedExamTime"].asInt64();
  1954. pQueryPracticeRecordList->vPracticeRecordList.push_back(pr);
  1955. }
  1956. }
  1957. catch (const std::exception &e)
  1958. {
  1959. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1960. }
  1961. }
  1962. void CHttpBll::genGetPracticeDetailInfo(CGetPracticeDetailInfo *pGetPracticeDetailInfo, const std::string &sResponse)
  1963. {
  1964. try
  1965. {
  1966. Json::Reader reader;
  1967. Json::Value jsonRoot = Json::Value::null;
  1968. if (!reader.parse(sResponse, jsonRoot))
  1969. {
  1970. pGetPracticeDetailInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1971. myDebug() << pGetPracticeDetailInfo->sMessage << sResponse.c_str();
  1972. }
  1973. pGetPracticeDetailInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  1974. pGetPracticeDetailInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
  1975. pGetPracticeDetailInfo->nId = jsonRoot["id"].asInt64();
  1976. pGetPracticeDetailInfo->fObjectiveAccuracy = jsonRoot["objectiveAccuracy"].asDouble();
  1977. int nSize = jsonRoot["paperStructInfos"].size();
  1978. for (int i = 0; i < nSize; ++i)
  1979. {
  1980. Json::Value jPaperStructInfo = jsonRoot["paperStructInfos"][i];
  1981. CPracticePaperStructInfo ppsi;
  1982. ppsi.nCount = jPaperStructInfo["count"].asInt();
  1983. ppsi.nFailQuestionNum = jPaperStructInfo["failQuestionNum"].asInt();
  1984. ppsi.nIndex = jPaperStructInfo["index"].asInt();
  1985. ppsi.nNotAnsweredCount = jPaperStructInfo["notAnsweredCount"].asInt();
  1986. ppsi.nQuestionCount = jPaperStructInfo["questionCount"].asInt();
  1987. ppsi.sQuestionType = jPaperStructInfo["questionType"].asString().c_str();
  1988. ppsi.sScore = jPaperStructInfo["score"].asString().c_str();
  1989. ppsi.nSuccQuestionNum = jPaperStructInfo["succQuestionNum"].asInt();
  1990. ppsi.sTitle = jPaperStructInfo["title"].asString().c_str();
  1991. ppsi.fTotalScore = jPaperStructInfo["totalScore"].asDouble();
  1992. pGetPracticeDetailInfo->vPracticePaperStructList.push_back(ppsi);
  1993. }
  1994. }
  1995. catch (const std::exception &e)
  1996. {
  1997. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1998. }
  1999. }
  2000. void CHttpBll::genFindExamRecordDataEntity(CFindExamRecordDataEntity *pFindExamRecordDataEntity, const std::string &sResponse)
  2001. {
  2002. try
  2003. {
  2004. Json::Reader reader;
  2005. Json::Value jsonRoot = Json::Value::null;
  2006. if (!reader.parse(sResponse, jsonRoot))
  2007. {
  2008. pFindExamRecordDataEntity->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2009. myDebug() << pFindExamRecordDataEntity->sMessage << sResponse.c_str();
  2010. }
  2011. pFindExamRecordDataEntity->nExamId = jsonRoot["examRecord"]["examId"].asInt64();
  2012. pFindExamRecordDataEntity->sPaperType = jsonRoot["examRecord"]["paperType"].asString().c_str();
  2013. }
  2014. catch (const std::exception &e)
  2015. {
  2016. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2017. }
  2018. }
  2019. void CHttpBll::genGetExamRecordQuestions(CGetExamRecordQuestions *pGetExamRecordQuestions, const std::string &sResponse)
  2020. {
  2021. try
  2022. {
  2023. Json::Reader reader;
  2024. Json::Value jsonRoot = Json::Value::null;
  2025. if (!reader.parse(sResponse, jsonRoot))
  2026. {
  2027. pGetExamRecordQuestions->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2028. myDebug() << pGetExamRecordQuestions->sMessage << sResponse.c_str();
  2029. }
  2030. int nSize = jsonRoot["examQuestionEntities"].size();
  2031. for (int i = 0; i < nSize; ++i)
  2032. {
  2033. Json::Value jQuestionItem = jsonRoot["examQuestionEntities"][i];
  2034. CAnsweredQuestion aq;
  2035. aq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  2036. aq.sAudioPlayTimes = jQuestionItem["audioPlayTimes"].isNull() ? "" : jQuestionItem["audioPlayTimes"].asString().c_str();
  2037. aq.sCorrectAnswer = jQuestionItem["correctAnswer"].isNull() ? "" : jQuestionItem["correctAnswer"].asString().c_str();
  2038. //aq.sExamQuestionTempId = jQuestionItem["examQuestionTempId"].asString().c_str();
  2039. aq.nExamRecordDataId = jQuestionItem["examRecordDataId"].asInt64();
  2040. aq.bIsAnswer = jQuestionItem["isAnswer"].asBool();
  2041. //aq.bIsInMongo = jQuestionItem["isInMongo"].asBool();
  2042. aq.bIsSign = jQuestionItem["isSign"].asBool();
  2043. aq.nMainNumber = jQuestionItem["mainNumber"].asInt();
  2044. int nOptionSize = jQuestionItem["optionPermutation"].size();
  2045. for (int j = 0; j < nOptionSize; ++j)
  2046. {
  2047. aq.vOptionPermutation.push_back(jQuestionItem["optionPermutation"][i].asInt());
  2048. }
  2049. aq.nOrder = jQuestionItem["order"].asInt();
  2050. aq.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  2051. aq.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  2052. aq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  2053. aq.sStudentAnswer = jQuestionItem["studentAnswer"].asString().c_str();
  2054. aq.fStudentScore = jQuestionItem["studentScore"].asDouble();
  2055. pGetExamRecordQuestions->vExamRecordQuestions.push_back(aq);
  2056. }
  2057. }
  2058. catch (const std::exception &e)
  2059. {
  2060. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2061. }
  2062. }
  2063. void CHttpBll::genGetOfflineCourse(CGetOfflineCourse *pGetOfflineCourse, const std::string &sResponse)
  2064. {
  2065. try
  2066. {
  2067. Json::Reader reader;
  2068. Json::Value jsonRoot = Json::Value::null;
  2069. if (!reader.parse(sResponse, jsonRoot))
  2070. {
  2071. pGetOfflineCourse->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2072. myDebug() << pGetOfflineCourse->sMessage << sResponse.c_str();
  2073. }
  2074. int nSize = jsonRoot.size();
  2075. for (int i = 0; i < nSize; ++i)
  2076. {
  2077. Json::Value jCourseInfo = jsonRoot[i];
  2078. COfflineCourseInfo oci;
  2079. oci.sCourseCode = jCourseInfo["courseCode"].asString().c_str();
  2080. oci.sCourseLevel = jCourseInfo["courseLevel"].asString().c_str();
  2081. oci.sCourseName = jCourseInfo["courseName"].asString().c_str();
  2082. oci.sEndTime = jCourseInfo["endTime"].asString().c_str();
  2083. oci.nExamId = jCourseInfo["examId"].asInt64();
  2084. oci.sExamName = jCourseInfo["examName"].asString().c_str();
  2085. oci.nExamRecordDataId = jCourseInfo["examRecordDataId"].asInt64();
  2086. oci.nExamStudentId = jCourseInfo["examStudentId"].asInt64();
  2087. oci.bIsvalid = jCourseInfo["isvalid"].asBool();
  2088. oci.sOrgName = jCourseInfo["orgName"].asString().c_str();
  2089. oci.sPaperId = jCourseInfo["paperId"].asString().c_str();
  2090. oci.sSpecialtyName = jCourseInfo["specialtyName"].asString().c_str();
  2091. oci.sStartTime = jCourseInfo["startTime"].asString().c_str();
  2092. oci.sStatus = jCourseInfo["status"].asString().c_str();
  2093. oci.sStudentCode = jCourseInfo["studentCode"].asString().c_str();
  2094. oci.sStudentName = jCourseInfo["studentName"].asString().c_str();
  2095. int nFileSize = jCourseInfo["offlineFiles"].size();
  2096. for (int j = 0; j < nFileSize; ++j)
  2097. {
  2098. Json::Value jFileItem = jCourseInfo["offlineFiles"][j];
  2099. COfflineFileInfo ofi;
  2100. ofi.nExamRecordDataId = jFileItem["examRecordDataId"].asInt64();
  2101. ofi.sFileType = jFileItem["fileType"].asString().c_str();
  2102. ofi.nId = jFileItem["id"].asInt64();
  2103. ofi.sOfflineFileName = jFileItem["offlineFileName"].asString().c_str();
  2104. ofi.sOfflineFileUrl = jFileItem["offlineFileUrl"].asString().c_str();
  2105. ofi.sOriginalFileName = jFileItem["originalFileName"].asString().c_str();
  2106. ofi.sProperties = jFileItem["properties"].asString().c_str();
  2107. ofi.sSuffix = jFileItem["suffix"].asString().c_str();
  2108. oci.vOfflineFileInfo.push_back(ofi);
  2109. }
  2110. pGetOfflineCourse->vOfflineCourseInfo.push_back(oci);
  2111. }
  2112. }
  2113. catch (const std::exception &e)
  2114. {
  2115. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2116. }
  2117. }
  2118. void CHttpBll::genGetOffLineExamAnswerSheet(CGetOffLineExamAnswerSheet *pGetOffLineExamAnswerSheet, const std::string &sResponse)
  2119. {
  2120. pGetOffLineExamAnswerSheet->sAnswerSheetUrl = sResponse.c_str();
  2121. }
  2122. void CHttpBll::genGetOffLineExamPaper(CGetOffLineExamPaper *pGetOffLineExamPaper, const std::string &sResponse)
  2123. {
  2124. }
  2125. void CHttpBll::genPreviewOffLineExamPaper(CPreviewOffLineExamPaper *pPreviewOffLineExamPaper, const std::string &sResponse)
  2126. {
  2127. pPreviewOffLineExamPaper->sUrl = sResponse.c_str();
  2128. }
  2129. void CHttpBll::genCheckExamInProgress(CCheckExamInProgress *pCheckExamInProgress, const std::string &sResponse)
  2130. {
  2131. try
  2132. {
  2133. Json::Reader reader;
  2134. Json::Value jsonRoot = Json::Value::null;
  2135. if (!reader.parse(sResponse, jsonRoot))
  2136. {
  2137. pCheckExamInProgress->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2138. myDebug() << pCheckExamInProgress->sMessage << sResponse.c_str();
  2139. }
  2140. if (jsonRoot["data"].isNull())
  2141. {
  2142. pCheckExamInProgress->bHasExamInProgress = false;
  2143. }
  2144. else
  2145. {
  2146. pCheckExamInProgress->bHasExamInProgress = true;
  2147. pCheckExamInProgress->nInterruptNum = jsonRoot["data"]["interruptNum"].asInt();
  2148. pCheckExamInProgress->nMaxInterruptNum = jsonRoot["data"]["maxInterruptNum"].asInt();
  2149. pCheckExamInProgress->bIsExceed = jsonRoot["data"]["isExceed"].asBool();
  2150. pCheckExamInProgress->nExamRecordDataId = jsonRoot["data"]["examRecordDataId"].asInt64();
  2151. pCheckExamInProgress->nExamId = jsonRoot["data"]["examId"].asInt64();
  2152. pCheckExamInProgress->nUsedTime = jsonRoot["data"]["usedTime"].asInt64();
  2153. pCheckExamInProgress->nFaceVerifyMinute = jsonRoot["data"]["faceVerifyMinute"].asInt();
  2154. pCheckExamInProgress->sExamType = jsonRoot["data"]["examType"].asString().c_str();
  2155. }
  2156. }
  2157. catch (const std::exception &e)
  2158. {
  2159. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2160. }
  2161. }
  2162. void CHttpBll::genGetCourseInfo(CGetCourseInfo *pGetCourseInfo, const std::string &sResponse)
  2163. {
  2164. try
  2165. {
  2166. Json::Reader reader;
  2167. Json::Value jsonRoot = Json::Value::null;
  2168. if (!reader.parse(sResponse, jsonRoot))
  2169. {
  2170. pGetCourseInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2171. myDebug() << pGetCourseInfo->sMessage << sResponse.c_str();
  2172. }
  2173. pGetCourseInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
  2174. pGetCourseInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  2175. }
  2176. catch (const std::exception &e)
  2177. {
  2178. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2179. }
  2180. }
  2181. void CHttpBll::genExamHeartbeat(CExamHeartbeat *pExamHeartbeat, const std::string &sResponse)
  2182. {
  2183. pExamHeartbeat->nLeftTime = QString(sResponse.c_str()).toLongLong();
  2184. }
  2185. void CHttpBll::genFindExamQuestionList(CFindExamQuestionList *pFindExamQuestionList, const std::string &sResponse)
  2186. {
  2187. try
  2188. {
  2189. Json::Reader reader;
  2190. Json::Value jsonRoot = Json::Value::null;
  2191. if (!reader.parse(sResponse, jsonRoot))
  2192. {
  2193. pFindExamQuestionList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2194. myDebug() << pFindExamQuestionList->sMessage << sResponse.c_str();
  2195. }
  2196. int nSize = jsonRoot.size();
  2197. for (int i = 0; i < nSize; ++i)
  2198. {
  2199. Json::Value jQuestionItem = jsonRoot[i];
  2200. CAnsweredQuestion aq;
  2201. aq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  2202. aq.sAudioPlayTimes = jQuestionItem["audioPlayTimes"].isNull() ? "" :jQuestionItem["audioPlayTimes"].asString().c_str();
  2203. aq.sCorrectAnswer = jQuestionItem["correctAnswer"].isNull() ? "" : jQuestionItem["correctAnswer"].asString().c_str();
  2204. aq.sExamQuestionTempId = jQuestionItem["examQuestionTempId"].asString().c_str();
  2205. aq.nExamRecordDataId = jQuestionItem["examRecordDataId"].asInt64();
  2206. aq.bIsAnswer = jQuestionItem["isAnswer"].asBool();
  2207. aq.bIsInMongo = jQuestionItem["isInMongo"].asBool();
  2208. aq.bIsSign = jQuestionItem["isSign"].asBool();
  2209. aq.nMainNumber = jQuestionItem["mainNumber"].asInt();
  2210. int nOptionSize = jQuestionItem["optionPermutation"].size();
  2211. for (int j = 0; j < nOptionSize; ++j)
  2212. {
  2213. aq.vOptionPermutation.push_back(jQuestionItem["optionPermutation"][i].asInt());
  2214. }
  2215. aq.nOrder = jQuestionItem["order"].asInt();
  2216. aq.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  2217. aq.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  2218. aq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  2219. aq.sStudentAnswer = jQuestionItem["studentAnswer"].asString().c_str();
  2220. aq.fStudentScore = jQuestionItem["studentScore"].asDouble();
  2221. pFindExamQuestionList->vAnsweredQuestion.push_back(aq);
  2222. }
  2223. }
  2224. catch (const std::exception &e)
  2225. {
  2226. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2227. }
  2228. }
  2229. void CHttpBll::genGetExamRecordPaperStruct(CGetExamRecordPaperStruct *pGetExamRecordPaperStruct, const std::string &sResponse)
  2230. {
  2231. try
  2232. {
  2233. Json::Reader reader;
  2234. Json::Value jsonRoot = Json::Value::null;
  2235. if (!reader.parse(sResponse, jsonRoot))
  2236. {
  2237. pGetExamRecordPaperStruct->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2238. myDebug() << pGetExamRecordPaperStruct->sMessage << sResponse.c_str();
  2239. }
  2240. pGetExamRecordPaperStruct->sPaperId = jsonRoot["id"].asString().c_str();
  2241. pGetExamRecordPaperStruct->sPaperName = jsonRoot["defaultPaper"]["name"].asString().c_str();
  2242. pGetExamRecordPaperStruct->bFullyObjective = jsonRoot["defaultPaper"]["fullyObjective"].asBool();
  2243. int nGroupSize = jsonRoot["defaultPaper"]["questionGroupList"].size();
  2244. int nOrder = 1;
  2245. for (int i = 0; i < nGroupSize; ++i)
  2246. {
  2247. Json::Value jGroupItem = jsonRoot["defaultPaper"]["questionGroupList"][i];
  2248. CPaperGroupStruct pgs;
  2249. pgs.sGroupName = jGroupItem["groupName"].asString().c_str();
  2250. pgs.fGroupScore = jGroupItem["groupScore"].asDouble();
  2251. pgs.nNumber = i + 1;
  2252. int nQuestionSize = jGroupItem["questionWrapperList"].size();
  2253. int nShowIndex = 1;
  2254. int nTotalSubquestion = 0;
  2255. for (int j = 0; j < nQuestionSize; ++j)
  2256. {
  2257. Json::Value jQuestionItem = jGroupItem["questionWrapperList"][j];
  2258. CQuestionStruct qs;
  2259. qs.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  2260. qs.sVersion = jQuestionItem["version"].asString().c_str();
  2261. qs.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  2262. qs.nLimitedPlayTimes = jQuestionItem["limitedPlayTimes"].asInt();
  2263. qs.nPlayedTimes = jQuestionItem["playedTimes"].asInt();
  2264. qs.nTimeLimit = jQuestionItem["timeLimit"].asInt();
  2265. int mSubQuestionSize = jQuestionItem["questionUnitWrapperList"].size();
  2266. nTotalSubquestion += mSubQuestionSize;
  2267. for (int k = 0; k < mSubQuestionSize; ++k)
  2268. {
  2269. Json::Value jSubQuestionItem = jQuestionItem["questionUnitWrapperList"][k];
  2270. CSubQuestionStruct sqs;
  2271. sqs.sQuestionType = jSubQuestionItem["questionType"].asString().c_str();
  2272. sqs.sAnswerType = jSubQuestionItem["answerType"].asString().c_str();
  2273. sqs.fQuestionScore = jSubQuestionItem["questionScore"].asDouble();
  2274. sqs.nLimitedPlayTimes = qs.nLimitedPlayTimes;
  2275. for (int jq = 0; jq < jSubQuestionItem["optionPermutation"].size(); ++jq)
  2276. {
  2277. Json::Value Item = jSubQuestionItem["optionPermutation"][jq];
  2278. sqs.voptionPermutation.push_back(Item.asInt());
  2279. }
  2280. sqs.nShowNumber = nShowIndex;
  2281. sqs.nOrder = nOrder;
  2282. nShowIndex++;
  2283. nOrder++;
  2284. qs.vSubQuestionStruct.push_back(sqs);
  2285. }
  2286. pgs.vQuestionStruct.push_back(qs);
  2287. }
  2288. pgs.nTotalSubquestion = nTotalSubquestion;
  2289. pGetExamRecordPaperStruct->vPaperGroupStruct.push_back(pgs);
  2290. }
  2291. }
  2292. catch (const std::exception &e)
  2293. {
  2294. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2295. }
  2296. }
  2297. void CHttpBll::genGetEndExamInfo(CGetEndExamInfo *pGetEndExamInfo, const std::string &sResponse)
  2298. {
  2299. try
  2300. {
  2301. if (sResponse == "")
  2302. {
  2303. pGetEndExamInfo->bIsCalculate = true;
  2304. return;
  2305. }
  2306. Json::Reader reader;
  2307. Json::Value jsonRoot = Json::Value::null;
  2308. if (!reader.parse(sResponse, jsonRoot))
  2309. {
  2310. pGetEndExamInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2311. myDebug() << pGetEndExamInfo->sMessage << sResponse.c_str();
  2312. }
  2313. pGetEndExamInfo->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  2314. pGetEndExamInfo->bIsWarn = jsonRoot["isWarn"].asBool();
  2315. pGetEndExamInfo->fObjectiveAccuracy = jsonRoot["objectiveAccuracy"].asDouble();
  2316. pGetEndExamInfo->fObjectiveScore = jsonRoot["objectiveScore"].asInt64();
  2317. }
  2318. catch (const std::exception &e)
  2319. {
  2320. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2321. }
  2322. }
  2323. void CHttpBll::genGetWXQrCode(CGetWXQrCode *pGetWXQrCode, const std::string &sResponse)
  2324. {
  2325. pGetWXQrCode->sUrl = sResponse.c_str();
  2326. }
  2327. void CHttpBll::genProcessUpload(CProcessUpload *pProcessUpload, const std::string &sResponse)
  2328. {
  2329. try
  2330. {
  2331. Json::Reader reader;
  2332. Json::Value jsonRoot = Json::Value::null;
  2333. if (!reader.parse(sResponse, jsonRoot))
  2334. {
  2335. pProcessUpload->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2336. myDebug() << pProcessUpload->sMessage << sResponse.c_str();
  2337. }
  2338. pProcessUpload->sFileUrl = jsonRoot["fileUrl"].asString().c_str();
  2339. }
  2340. catch (const std::exception &e)
  2341. {
  2342. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2343. }
  2344. }
  2345. void CHttpBll::genGetOrgPropertiesByGroupWithoutCache(CGetOrgPropertiesByGroupWithoutCache *pOrgProperties, const std::string &sResponse)
  2346. {
  2347. try
  2348. {
  2349. Json::Reader reader;
  2350. Json::Value jsonRoot = Json::Value::null;
  2351. if (!reader.parse(sResponse, jsonRoot))
  2352. {
  2353. pOrgProperties->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2354. myDebug() << pOrgProperties->sMessage << sResponse.c_str();
  2355. }
  2356. pOrgProperties->nActionNum = QVariant(jsonRoot["ACTION_NUM"].asString().c_str()).toInt();
  2357. pOrgProperties->sActionOptions = jsonRoot["ACTION_OPTIONS"].asString().c_str();
  2358. pOrgProperties->sActionOrder = jsonRoot["ACTION_ORDER"].asString().c_str();
  2359. pOrgProperties->nActionDuration = QVariant(jsonRoot["ACTION_DURATION"].asString().c_str()).toInt();
  2360. pOrgProperties->nActionAlert = QVariant(jsonRoot["ACTION_ALERT"].asString().c_str()).toInt();
  2361. pOrgProperties->nAllActionDuration = QVariant(jsonRoot["ALL_ACTION_DURATION"].asString().c_str()).toInt();
  2362. }
  2363. catch (const std::exception &e)
  2364. {
  2365. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2366. }
  2367. }
  2368. void CHttpBll::genStartFaceLiveVerify(CStartFaceLiveVerify *pStartFaceLiveVerify, const std::string &sResponse)
  2369. {
  2370. try
  2371. {
  2372. Json::Reader reader;
  2373. Json::Value jsonRoot = Json::Value::null;
  2374. if (!reader.parse(sResponse, jsonRoot))
  2375. {
  2376. pStartFaceLiveVerify->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2377. myDebug() << pStartFaceLiveVerify->sMessage << sResponse.c_str();
  2378. }
  2379. pStartFaceLiveVerify->nFaceLiveVerifyId = jsonRoot["faceLiveVerifyId"].asInt64();
  2380. pStartFaceLiveVerify->nStartMinute = jsonRoot["startMinute"].asInt();
  2381. pStartFaceLiveVerify->nTimes = jsonRoot["times"].asInt();
  2382. }
  2383. catch (const std::exception &e)
  2384. {
  2385. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2386. }
  2387. }