CHttpBll.cpp 69 KB

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