CHttpBll.cpp 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270
  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. pSoftwareConfig->sSoftwareConfig = std::string(sResponse.rbegin()+32, sResponse.rend()).c_str();
  1107. }
  1108. void CHttpBll::genLoginLimit(CLoginLimit *pLoginLimit, const std::string &sResponse)
  1109. {
  1110. Json::Reader reader;
  1111. Json::Value jsonRoot = Json::Value::null;
  1112. if (!reader.parse(sResponse, jsonRoot))
  1113. {
  1114. pLoginLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1115. myDebug() << pLoginLimit->sMessage << sResponse.c_str();
  1116. }
  1117. pLoginLimit->nCount = jsonRoot["count"].asInt64();
  1118. pLoginLimit->bPass = jsonRoot["pass"].asBool();
  1119. }
  1120. void CHttpBll::genLoginInfo(CLoginInfo *pLoginInfo, const std::string &sResponse)
  1121. {
  1122. Json::Reader reader;
  1123. Json::Value jsonRoot = Json::Value::null;
  1124. if (!reader.parse(sResponse, jsonRoot))
  1125. {
  1126. pLoginInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1127. myDebug() << pLoginInfo->sMessage << sResponse.c_str();
  1128. }
  1129. // pLoginInfo->nCode = jsonRoot["code"].asInt();
  1130. if (jsonRoot["code"].asString() != "200")
  1131. {
  1132. pLoginInfo->nCode = 0;
  1133. }
  1134. pLoginInfo->sMessage = jsonRoot["desc"].asString().c_str();
  1135. sKey = jsonRoot["content"]["key"].asString().c_str();
  1136. sToken = jsonRoot["content"]["token"].asString().c_str();
  1137. pLoginInfo->sUserType = jsonRoot["content"]["userType"].asString().c_str();
  1138. pLoginInfo->nUserId = jsonRoot["content"]["userId"].asInt64();
  1139. pLoginInfo->sDisplayName = jsonRoot["content"]["displayName"].asString().c_str();
  1140. pLoginInfo->nRootOrgId = jsonRoot["content"]["rootOrgId"].asInt64();
  1141. pLoginInfo->sRootOrgName = jsonRoot["content"]["rootOrgName"].asString().c_str();
  1142. pLoginInfo->sCreationTime = jsonRoot["content"]["creationTime"].asString().c_str();
  1143. pLoginInfo->sClientIp = jsonRoot["content"]["clientIp"].asString().c_str();
  1144. pLoginInfo->nSessionTimeout = jsonRoot["content"]["sessionTimeout"].asInt64();
  1145. pLoginInfo->bPasswordWeak = jsonRoot["content"]["passwordWeak"].asBool();
  1146. }
  1147. void CHttpBll::genLogout(CLogout *pLogout, const std::string &sResponse)
  1148. {
  1149. }
  1150. void CHttpBll::genEditPassword(CEditPassword *pEditPassword, const std::string &sResponse)
  1151. {
  1152. }
  1153. void CHttpBll::genGetStudentClientMenu(CGetStudentClientMenu *pGetStudentClientMenu, const std::string &sResponse)
  1154. {
  1155. Json::Reader reader;
  1156. Json::Value jsonRoot = Json::Value::null;
  1157. if (!reader.parse(sResponse, jsonRoot))
  1158. {
  1159. pGetStudentClientMenu->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1160. myDebug() << pGetStudentClientMenu->sMessage << sResponse.c_str();
  1161. }
  1162. int nSize = jsonRoot.size();
  1163. for (int i = 0; i < nSize; ++i)
  1164. {
  1165. Json::Value jMenuItem = jsonRoot[i];
  1166. CStudentClientMenu scm;
  1167. scm.nId = jMenuItem["id"].asInt64();
  1168. scm.sCode = jMenuItem["code"].asString().c_str();
  1169. scm.sName = jMenuItem["name"].asString().c_str();
  1170. pGetStudentClientMenu->vMenus.push_back(scm);
  1171. }
  1172. }
  1173. void CHttpBll::genGetStudentInfoBySession(CGetStudentInfoBySession *pGetStudentInfoBySession, const std::string &sResponse)
  1174. {
  1175. Json::Reader reader;
  1176. Json::Value jsonRoot = Json::Value::null;
  1177. if (!reader.parse(sResponse, jsonRoot))
  1178. {
  1179. pGetStudentInfoBySession->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1180. myDebug() << pGetStudentInfoBySession->sMessage << sResponse.c_str();
  1181. }
  1182. pGetStudentInfoBySession->nId = jsonRoot["id"].asInt64();
  1183. pGetStudentInfoBySession->sName = jsonRoot["name"].asString().c_str();
  1184. pGetStudentInfoBySession->nOrgId = jsonRoot["orgId"].asInt64();
  1185. pGetStudentInfoBySession->sOrgCode = jsonRoot["orgCode"].asString().c_str();
  1186. pGetStudentInfoBySession->sOrgName = jsonRoot["orgName"].asString().c_str();
  1187. QString sStudentCode = "";
  1188. int nSize = jsonRoot["studentCodeList"].size();
  1189. for (int i = 0; i < nSize; ++i)
  1190. {
  1191. if (sStudentCode.isEmpty())
  1192. {
  1193. sStudentCode = jsonRoot["studentCodeList"][i].asString().c_str();
  1194. }
  1195. else
  1196. {
  1197. sStudentCode = sStudentCode + "," + jsonRoot["studentCodeList"][i].asString().c_str();
  1198. }
  1199. }
  1200. pGetStudentInfoBySession->sStudentCode = sStudentCode;
  1201. pGetStudentInfoBySession->sIdentityNumber = jsonRoot["identityNumber"].asString().c_str();
  1202. pGetStudentInfoBySession->sPhotoPath = jsonRoot["photoPath"].asString().c_str();
  1203. pGetStudentInfoBySession->bEnable = jsonRoot["enable"].asBool();
  1204. }
  1205. void CHttpBll::genSpecialtyNameList(CSpecialtyNameList *pSpecialtyNameList, const std::string &sResponse)
  1206. {
  1207. Json::Reader reader;
  1208. Json::Value jsonRoot = Json::Value::null;
  1209. if (!reader.parse(sResponse, jsonRoot))
  1210. {
  1211. pSpecialtyNameList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1212. myDebug() << pSpecialtyNameList->sMessage << sResponse.c_str();
  1213. }
  1214. QString sSpecialtyName = "";
  1215. int nSize = jsonRoot.size();
  1216. for (int i = 0; i < nSize; ++i)
  1217. {
  1218. if (sSpecialtyName.isEmpty())
  1219. {
  1220. sSpecialtyName = jsonRoot[i].asString().c_str();
  1221. }
  1222. else
  1223. {
  1224. sSpecialtyName = sSpecialtyName + "," + jsonRoot[i].asString().c_str();
  1225. }
  1226. }
  1227. pSpecialtyNameList->sSpecialtyName = sSpecialtyName;
  1228. }
  1229. void CHttpBll::genGetUserNoticeList(CGetUserNoticeList *pGetUserNoticeList, const std::string &sResponse)
  1230. {
  1231. Json::Reader reader;
  1232. Json::Value jsonRoot = Json::Value::null;
  1233. if (!reader.parse(sResponse, jsonRoot))
  1234. {
  1235. pGetUserNoticeList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1236. myDebug() << pGetUserNoticeList->sMessage << sResponse.c_str();
  1237. }
  1238. int nSize = jsonRoot.size();
  1239. for (int i = 0; i < nSize; ++i)
  1240. {
  1241. Json::Value jNoticeItem = jsonRoot[i];
  1242. CNoticeInfo ni;
  1243. ni.nId = jNoticeItem["id"].asInt64();
  1244. ni.sTitle = jNoticeItem["title"].asString().c_str();
  1245. ni.sContent = jNoticeItem["content"].asString().c_str();
  1246. ni.sPublisher = jNoticeItem["publisher"].asString().c_str();
  1247. ni.sPublishTime = jNoticeItem["publishTime"].asString().c_str();
  1248. ni.bHasRead = jNoticeItem["hasRead"].asBool();
  1249. ni.bHasRecalled = jNoticeItem["hasRecalled"].isNull() ? false : jNoticeItem["hasRecalled"].asBool();
  1250. pGetUserNoticeList->vNoticeList.push_back(ni);
  1251. }
  1252. }
  1253. void CHttpBll::genAppDownLoadUrl(CAppDownLoadUrl *pAppDownLoadUrl, const std::string &sResponse)
  1254. {
  1255. pAppDownLoadUrl->sUrl = sResponse.c_str();
  1256. }
  1257. void CHttpBll::genAppEnabled(CAppEnabled *pAppEnabled, const std::string &sResponse)
  1258. {
  1259. pAppEnabled->bEnable = QVariant(sResponse.c_str()).toBool();
  1260. }
  1261. void CHttpBll::genQueryBatchList(CQueryBatchList *pQueryBatchList, const std::string &sResponse)
  1262. {
  1263. Json::Reader reader;
  1264. Json::Value jsonRoot = Json::Value::null;
  1265. if (!reader.parse(sResponse, jsonRoot))
  1266. {
  1267. pQueryBatchList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1268. myDebug() << pQueryBatchList->sMessage << sResponse.c_str();
  1269. }
  1270. int nSize = jsonRoot.size();
  1271. for (int i = 0; i < nSize; ++i)
  1272. {
  1273. Json::Value jBatchItem = jsonRoot[i];
  1274. CBatchInfo bi;
  1275. bi.nId = jBatchItem["id"].asInt64();
  1276. bi.sName = jBatchItem["name"].asString().c_str();
  1277. bi.sExamType = jBatchItem["examType"].asString().c_str();
  1278. pQueryBatchList->vBatchList.push_back(bi);
  1279. }
  1280. }
  1281. void CHttpBll::genGetExamProperty(CGetExamProperty *pGetExamProperty, const std::string &sResponse)
  1282. {
  1283. Json::Reader reader;
  1284. Json::Value jsonRoot = Json::Value::null;
  1285. if (!reader.parse(sResponse, jsonRoot))
  1286. {
  1287. pGetExamProperty->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1288. myDebug() << pGetExamProperty->sMessage << sResponse.c_str();
  1289. }
  1290. if (jsonRoot.isMember("BEFORE_EXAM_REMARK"))
  1291. {
  1292. pGetExamProperty->sBeforeExamRemark = jsonRoot["BEFORE_EXAM_REMARK"].asString().c_str();
  1293. }
  1294. if (jsonRoot.isMember("CHECK_ENVIRONMENT"))
  1295. {
  1296. pGetExamProperty->bCheckEnvironment = QVariant(jsonRoot["CHECK_ENVIRONMENT"].asString().c_str()).toBool();
  1297. }
  1298. if (jsonRoot.isMember("WARN_THRESHOLD"))
  1299. {
  1300. pGetExamProperty->nWarnThreshold = QVariant(jsonRoot["WARN_THRESHOLD"].asString().c_str()).toInt();
  1301. }
  1302. if (jsonRoot.isMember("IS_FACE_CHECK"))
  1303. {
  1304. pGetExamProperty->bIsFaceCheck = QVariant(jsonRoot["IS_FACE_CHECK"].asString().c_str()).toBool();
  1305. }
  1306. if (jsonRoot.isMember("SNAPSHOT_INTERVAL"))
  1307. {
  1308. pGetExamProperty->nSnapshotInterval = QVariant(jsonRoot["SNAPSHOT_INTERVAL"].asString().c_str()).toInt();
  1309. }
  1310. if (jsonRoot.isMember("FACE_VERIFY_START_MINUTE"))
  1311. {
  1312. pGetExamProperty->nFaceVerifyStartMinute = QVariant(jsonRoot["FACE_VERIFY_START_MINUTE"].asString().c_str()).toInt();
  1313. }
  1314. if (jsonRoot.isMember("FACE_VERIFY_END_MINUTE"))
  1315. {
  1316. pGetExamProperty->nFaceVerifyEndMinute = QVariant(jsonRoot["FACE_VERIFY_END_MINUTE"].asString().c_str()).toInt();
  1317. }
  1318. if (jsonRoot.isMember("IS_STRANGER_ENABLE"))
  1319. {
  1320. pGetExamProperty->bIsStrangerEnable = QVariant(jsonRoot["IS_STRANGER_ENABLE"].asString().c_str()).toBool();
  1321. }
  1322. if (jsonRoot.isMember("PRACTICE_TYPE"))
  1323. {
  1324. pGetExamProperty->sPracticeType = jsonRoot["PRACTICE_TYPE"].asString().c_str();
  1325. }
  1326. if (jsonRoot.isMember("FREEZE_TIME"))
  1327. {
  1328. pGetExamProperty->nFreezeTime = QVariant(jsonRoot["FREEZE_TIME"].asString().c_str()).toInt();
  1329. }
  1330. if (jsonRoot.isMember("AFTER_EXAM_REMARK"))
  1331. {
  1332. pGetExamProperty->sAfterExamRemark = jsonRoot["AFTER_EXAM_REMARK"].asString().c_str();
  1333. }
  1334. if (jsonRoot.isMember("IS_OBJ_SCORE_VIEW"))
  1335. {
  1336. pGetExamProperty->bIsObjScoreView = QVariant(jsonRoot["IS_OBJ_SCORE_VIEW"].asString().c_str()).toBool();
  1337. }
  1338. if (jsonRoot.isMember("SHOW_CHEATING_REMARK"))
  1339. {
  1340. pGetExamProperty->bShowCheatingRemark = QVariant(jsonRoot["SHOW_CHEATING_REMARK"].asString().c_str()).toBool();
  1341. }
  1342. if (jsonRoot.isMember("CHEATING_REMARK"))
  1343. {
  1344. pGetExamProperty->sCheatingRemark = jsonRoot["CHEATING_REMARK"].asString().c_str();
  1345. }
  1346. if (jsonRoot.isMember("OFFLINE_UPLOAD_FILE_TYPE"))
  1347. {
  1348. QString sFileType = jsonRoot["OFFLINE_UPLOAD_FILE_TYPE"].asString().c_str();
  1349. Json::Reader reader;
  1350. Json::Value jFileType = Json::Value::null;
  1351. if (!reader.parse(sFileType.toStdString(), jFileType))
  1352. {
  1353. pGetExamProperty->sMessage = QString::fromLocal8Bit("解析文件类型异常!");
  1354. pGetExamProperty->nCode = 0;
  1355. }
  1356. int nSize = jFileType.size();
  1357. for (int i = 0; i < nSize; ++i)
  1358. {
  1359. pGetExamProperty->vOfflineUploadFileType.push_back(jFileType[i].asString().c_str());
  1360. }
  1361. }
  1362. }
  1363. void CHttpBll::genStartExamLimit(CStartExamLimit *pStartExamLimit, const std::string &sResponse)
  1364. {
  1365. Json::Reader reader;
  1366. Json::Value jsonRoot = Json::Value::null;
  1367. if (!reader.parse(sResponse, jsonRoot))
  1368. {
  1369. pStartExamLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1370. myDebug() << pStartExamLimit->sMessage << sResponse.c_str();
  1371. }
  1372. pStartExamLimit->nCount = jsonRoot["count"].asInt();
  1373. pStartExamLimit->bPass = jsonRoot["pass"].asBool();
  1374. }
  1375. void CHttpBll::genIpLimit(CIpLimit *pIpLimit, const std::string &sResponse)
  1376. {
  1377. Json::Reader reader;
  1378. Json::Value jsonRoot = Json::Value::null;
  1379. if (!reader.parse(sResponse, jsonRoot))
  1380. {
  1381. pIpLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1382. myDebug() << pIpLimit->sMessage << sResponse.c_str();
  1383. }
  1384. pIpLimit->bLimited = jsonRoot["limited"].asBool();
  1385. }
  1386. void CHttpBll::genStartExam(CStartExam *pStartExam, const std::string &sResponse)
  1387. {
  1388. Json::Reader reader;
  1389. Json::Value jsonRoot = Json::Value::null;
  1390. if (!reader.parse(sResponse, jsonRoot))
  1391. {
  1392. pStartExam->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1393. myDebug() << pStartExam->sMessage << sResponse.c_str();
  1394. }
  1395. pStartExam->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  1396. pStartExam->sCourseName = jsonRoot["courseName"].asString().c_str();
  1397. pStartExam->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  1398. pStartExam->nFaceVerifyMinute = jsonRoot["faceVerifyMinute"].asInt();
  1399. pStartExam->sStudentCode = jsonRoot["studentCode"].asString().c_str();
  1400. pStartExam->sStudentName = jsonRoot["studentName"].asString().c_str();
  1401. }
  1402. void CHttpBll::genFaceCheckEnabled(CFaceCheckEnabled *pFaceCheckEnabled, const std::string &sResponse)
  1403. {
  1404. pFaceCheckEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
  1405. }
  1406. void CHttpBll::genLivenessEnabled(CLivenessEnabled *pLivenessEnabled, const std::string &sResponse)
  1407. {
  1408. pLivenessEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
  1409. }
  1410. void CHttpBll::genWeiXinAnswerEnabled(CWeiXinAnswerEnabled *pWeiXinAnswerEnabled, const std::string &sResponse)
  1411. {
  1412. pWeiXinAnswerEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
  1413. }
  1414. void CHttpBll::genGetExamById(CGetExamById *pGetExamById, const std::string &sResponse)
  1415. {
  1416. Json::Reader reader;
  1417. Json::Value jsonRoot = Json::Value::null;
  1418. if (!reader.parse(sResponse, jsonRoot))
  1419. {
  1420. pGetExamById->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1421. myDebug() << pGetExamById->sMessage << sResponse.c_str();
  1422. }
  1423. pGetExamById->nId = jsonRoot["id"].asInt64();
  1424. pGetExamById->sCode = jsonRoot["code"].asString().c_str();
  1425. pGetExamById->nRootOrgId = jsonRoot["rootOrgId"].asInt64();
  1426. pGetExamById->sBeginTime = jsonRoot["beginTime"].asString().c_str();
  1427. pGetExamById->sEndTime = jsonRoot["endTime"].asString().c_str();
  1428. pGetExamById->sName = jsonRoot["name"].asString().c_str();
  1429. pGetExamById->sExamType = jsonRoot["examType"].asString().c_str();
  1430. pGetExamById->nDuration = jsonRoot["duration"].asInt64();
  1431. pGetExamById->bEnable = jsonRoot["enable"].asBool();
  1432. pGetExamById->bStarted = jsonRoot["started"].asBool();
  1433. pGetExamById->bIpLimitSettingsEnabled = jsonRoot["ipLimitSettingsEnabled"].asBool();
  1434. }
  1435. void CHttpBll::genStartAnswer(CStartAnswer *pStartAnswer, const std::string &sResponse)
  1436. {
  1437. Json::Reader reader;
  1438. Json::Value jsonRoot = Json::Value::null;
  1439. if (!reader.parse(sResponse, jsonRoot))
  1440. {
  1441. pStartAnswer->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1442. myDebug() << pStartAnswer->sMessage << sResponse.c_str();
  1443. }
  1444. pStartAnswer->nDuration = jsonRoot["duration"].asInt64();
  1445. pStartAnswer->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  1446. pStartAnswer->nUsedExamSeconds = jsonRoot["usedExamSeconds"].asInt64();
  1447. }
  1448. void CHttpBll::genGetQuestion(CGetQuestion *pGetQuestion, const std::string &sResponse)
  1449. {
  1450. Json::Reader reader;
  1451. Json::Value jsonRoot = Json::Value::null;
  1452. if (!reader.parse(sResponse, jsonRoot))
  1453. {
  1454. pGetQuestion->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1455. myDebug() << pGetQuestion->sMessage << sResponse.c_str();
  1456. }
  1457. pGetQuestion->sId = jsonRoot["id"].asString().c_str();
  1458. pGetQuestion->sBody = jsonRoot["masterVersion"]["body"].isNull() ? "" : jsonRoot["masterVersion"]["body"].asString().c_str();
  1459. pGetQuestion->sVersion = jsonRoot["masterVersion"]["version"].asString().c_str();
  1460. pGetQuestion->bhasAudios = jsonRoot["masterVersion"]["hasAudios"].asBool();
  1461. int nSize = jsonRoot["masterVersion"]["questionUnitList"].size();
  1462. for (int i = 0; i < nSize; ++i)
  1463. {
  1464. Json::Value jQuestionItem = jsonRoot["masterVersion"]["questionUnitList"][i];
  1465. CSubQuestion sq;
  1466. sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1467. sq.sBody = jQuestionItem["body"].asString().c_str();
  1468. //sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1469. int nOptionSize = jQuestionItem["questionOptionList"].size();
  1470. for (int j = 0; j < nOptionSize; ++j)
  1471. {
  1472. Json::Value jOption = jQuestionItem["questionOptionList"][j];
  1473. COption o;
  1474. o.sBody = jOption["body"].asString().c_str();
  1475. sq.vOptions.push_back(o);
  1476. }
  1477. int nAnswerSize = jQuestionItem["rightAnswer"].size();
  1478. for (int k = 0; k < nAnswerSize; ++k)
  1479. {
  1480. Json::Value jAnswer = jQuestionItem["rightAnswer"][k];
  1481. sq.vRightAnswer.push_back(jAnswer.asString().c_str());
  1482. }
  1483. pGetQuestion->vSubQuestion.push_back(sq);
  1484. }
  1485. }
  1486. void CHttpBll::genGetQuestionContent(CGetQuestionContent *pGetQuestionContent, const std::string &sResponse)
  1487. {
  1488. Json::Reader reader;
  1489. Json::Value jsonRoot = Json::Value::null;
  1490. if (!reader.parse(sResponse, jsonRoot))
  1491. {
  1492. pGetQuestionContent->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1493. myDebug() << pGetQuestionContent->sMessage << sResponse.c_str();
  1494. }
  1495. pGetQuestionContent->sBody = jsonRoot["body"].isNull() ? "" : jsonRoot["body"].asString().c_str();
  1496. pGetQuestionContent->sVersion = jsonRoot["version"].asString().c_str();
  1497. pGetQuestionContent->bhasAudios = jsonRoot["hasAudios"].asBool();
  1498. int nSize = jsonRoot["questionUnitList"].size();
  1499. for (int i = 0; i < nSize; ++i)
  1500. {
  1501. Json::Value jQuestionItem = jsonRoot["questionUnitList"][i];
  1502. CSubQuestion sq;
  1503. sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1504. sq.sBody = jQuestionItem["body"].asString().c_str();
  1505. sq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  1506. int nOptionSize = jQuestionItem["questionOptionList"].size();
  1507. for (int j = 0; j < nOptionSize; ++j)
  1508. {
  1509. Json::Value jOption = jQuestionItem["questionOptionList"][j];
  1510. COption o;
  1511. o.sBody = jOption["body"].asString().c_str();
  1512. sq.vOptions.push_back(o);
  1513. }
  1514. for (int jq = 0; jq < jQuestionItem["optionPermutation"].size(); ++jq)
  1515. {
  1516. Json::Value Item = jQuestionItem["optionPermutation"][jq];
  1517. sq.voptionPermutation.push_back(Item.asInt());
  1518. }
  1519. int nAnswerSize = jQuestionItem["rightAnswer"].size();
  1520. for (int k = 0; k < nAnswerSize; ++k)
  1521. {
  1522. Json::Value jAnswer = jQuestionItem["rightAnswer"][k];
  1523. sq.vRightAnswer.push_back(jAnswer.asString().c_str());
  1524. }
  1525. pGetQuestionContent->vSubQuestion.push_back(sq);
  1526. }
  1527. }
  1528. void CHttpBll::genExamCourseInfo(const Json::Value &jExamItem, CExamCourseInfo &eci)
  1529. {
  1530. eci.nAllowExamCount = jExamItem["allowExamCount"].asInt();
  1531. eci.bAppExamEnabled = jExamItem["appExamEnabled"].asBool();
  1532. eci.sCourseCode = jExamItem["courseCode"].asString().c_str();
  1533. eci.nCourseId = jExamItem["courseId"].asInt64();
  1534. eci.sCourseLevel = jExamItem["courseLevel"].asString().c_str();
  1535. eci.sCourseName = jExamItem["courseName"].asString().c_str();
  1536. eci.sEndTime = jExamItem["endTime"].asString().c_str();
  1537. eci.bExamCycleEnabled = jExamItem["examCycleEnabled"].asBool();
  1538. int nWeekSize = jExamItem["examCycleWeek"].size();
  1539. for(int i =0; i < nWeekSize; ++i)
  1540. {
  1541. eci.vExamCycleWeek.push_back(jExamItem["examCycleWeek"][i].asInt());
  1542. }
  1543. int nCycleTimeRangeSize = jExamItem["examCycleTimeRange"].size();
  1544. for(int i = 0; i < nCycleTimeRangeSize; ++i)
  1545. {
  1546. Json::Value jTimeRange = jExamItem["examCycleTimeRange"][i]["timeRange"];
  1547. int nTimeRangeSize = jTimeRange.size();
  1548. QStringList sTimeRangeList;
  1549. for(int j = 0; j < nTimeRangeSize; ++j)
  1550. {
  1551. sTimeRangeList<<jTimeRange[j].asString().c_str();
  1552. }
  1553. eci.sExamCycleTimeRange<<sTimeRangeList.join("~");
  1554. }
  1555. //eci.sCourseCode = jExamItem["examCycleTimeRange"].asString().c_str();
  1556. //eci.sCourseCode = jExamItem["examCycleWeek"].asString().c_str();
  1557. eci.nExamId = jExamItem["examId"].asInt64();
  1558. eci.sExamName = jExamItem["examName"].asString().c_str();
  1559. eci.sExamStatus = jExamItem["examStatus"].asString().c_str();
  1560. eci.nExamStudentId = jExamItem["examStudentId"].asInt64();
  1561. eci.bFaceCheck = jExamItem["faceCheck"].asBool();
  1562. eci.bFaceEnable = jExamItem["faceEnable"].asBool();
  1563. eci.sIdentityNumber = jExamItem["identityNumber"].asString().c_str();
  1564. eci.bIsFinished = jExamItem["isFinished"].asBool();
  1565. eci.bIsObjScoreView = jExamItem["isObjScoreView"].asString().c_str();
  1566. eci.bIsPhotoUpload = jExamItem["isPhotoUpload"].asBool();
  1567. eci.nOrgId = jExamItem["orgId"].asInt64();
  1568. eci.sOrgName = jExamItem["orgName"].asString().c_str();
  1569. eci.nPaperMins = jExamItem["paperMins"].asInt();
  1570. eci.nRootOrgId = jExamItem["rootOrgId"].asInt64();
  1571. eci.sSpecialtyLevel = jExamItem["specialtyLevel"].asString().c_str();
  1572. eci.sSpecialtyName = jExamItem["specialtyName"].asString().c_str();
  1573. eci.sStartTime = jExamItem["startTime"].asString().c_str();
  1574. eci.sStudentCode = jExamItem["studentCode"].asString().c_str();
  1575. eci.sStudentName = jExamItem["studentName"].asString().c_str();
  1576. }
  1577. void CHttpBll::genQueryExamList(CQueryExamList *pQueryExamList, const std::string &sResponse)
  1578. {
  1579. Json::Reader reader;
  1580. Json::Value jsonRoot = Json::Value::null;
  1581. if (!reader.parse(sResponse, jsonRoot))
  1582. {
  1583. pQueryExamList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1584. myDebug() << pQueryExamList->sMessage << sResponse.c_str();
  1585. }
  1586. int nExamSize = jsonRoot.size();
  1587. for (int i = 0; i < nExamSize; ++i)
  1588. {
  1589. Json::Value jExamItem = jsonRoot[i];
  1590. CExamCourseInfo eci;
  1591. genExamCourseInfo(jExamItem, eci);
  1592. pQueryExamList->vOnlieExamList.push_back(eci);
  1593. }
  1594. }
  1595. void CHttpBll::genQueryExamEndList(CQueryExamEndList *pQueryExamEndList, const std::string &sResponse)
  1596. {
  1597. Json::Reader reader;
  1598. Json::Value jsonRoot = Json::Value::null;
  1599. if (!reader.parse(sResponse, jsonRoot))
  1600. {
  1601. pQueryExamEndList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1602. myDebug() << pQueryExamEndList->sMessage << sResponse.c_str();
  1603. }
  1604. int nExamSize = jsonRoot.size();
  1605. for (int i = 0; i < nExamSize; ++i)
  1606. {
  1607. Json::Value jExamItem = jsonRoot[i];
  1608. CExamCourseInfo eci;
  1609. genExamCourseInfo(jExamItem, eci);
  1610. pQueryExamEndList->vOnlieEndExamList.push_back(eci);
  1611. }
  1612. }
  1613. void CHttpBll::genQueryObjectiveScoreList(CQueryObjectiveScoreList *pQueryObjectiveScoreList, const std::string &sResponse)
  1614. {
  1615. Json::Reader reader;
  1616. Json::Value jsonRoot = Json::Value::null;
  1617. if (!reader.parse(sResponse, jsonRoot))
  1618. {
  1619. pQueryObjectiveScoreList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1620. myDebug() << pQueryObjectiveScoreList->sMessage << sResponse.c_str();
  1621. }
  1622. int nScoreSize = jsonRoot.size();
  1623. for (int i = 0; i < nScoreSize; ++i)
  1624. {
  1625. Json::Value jScore = jsonRoot[i];
  1626. CObjectiveScore os;
  1627. os.sEndTime = jScore["endTime"].asString().c_str();
  1628. os.nExamOrder = jScore["examOrder"].asInt();
  1629. os.nExamRecordDataId = jScore["examRecordDataId"].asInt64();
  1630. os.bIsAuditing = jScore["isAuditing"].asBool();
  1631. os.bIsExamEnded = jScore["isExamEnded"].asBool();
  1632. os.bIsIllegality = jScore["isIllegality"].asBool();
  1633. os.fObjectiveScore = jScore["objectiveScore"].asDouble();
  1634. os.sStartTime = jScore["startTime"].asString().c_str();
  1635. pQueryObjectiveScoreList->vObjectiveScore.push_back(os);
  1636. }
  1637. }
  1638. void CHttpBll::genQueryHomeworkList(CQueryHomeworkList *pQueryHomeworkList, const std::string &sResponse)
  1639. {
  1640. Json::Reader reader;
  1641. Json::Value jsonRoot = Json::Value::null;
  1642. if (!reader.parse(sResponse, jsonRoot))
  1643. {
  1644. pQueryHomeworkList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1645. myDebug() << pQueryHomeworkList->sMessage << sResponse.c_str();
  1646. }
  1647. int nExamSize = jsonRoot.size();
  1648. for (int i = 0; i < nExamSize; ++i)
  1649. {
  1650. Json::Value jExamItem = jsonRoot[i];
  1651. CExamCourseInfo eci;
  1652. genExamCourseInfo(jExamItem, eci);
  1653. pQueryHomeworkList->vHomeworkExamList.push_back(eci);
  1654. }
  1655. }
  1656. void CHttpBll::genQueryPracticeCourseList(CQueryPracticeCourseList *pQueryPracticeCourseList, const std::string &sResponse)
  1657. {
  1658. Json::Reader reader;
  1659. Json::Value jsonRoot = Json::Value::null;
  1660. if (!reader.parse(sResponse, jsonRoot))
  1661. {
  1662. pQueryPracticeCourseList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1663. myDebug() << pQueryPracticeCourseList->sMessage << sResponse.c_str();
  1664. }
  1665. int nExamSize = jsonRoot.size();
  1666. for (int i = 0; i < nExamSize; ++i)
  1667. {
  1668. Json::Value jExamItem = jsonRoot[i];
  1669. CPracticeCourseInfo pci;
  1670. pci.fAveObjectiveAccuracy = jExamItem["aveObjectiveAccuracy"].asDouble();
  1671. pci.sCourseCode = jExamItem["courseCode"].asString().c_str();
  1672. pci.sCourseName = jExamItem["courseName"].asString().c_str();
  1673. pci.sEndTime = jExamItem["endTime"].asString().c_str();
  1674. pci.bExamCycleEnabled = jExamItem["examCycleEnabled"].asBool();
  1675. //pci.sExamCycleTimeRange = jExamItem["examCycleTimeRange"].asDouble();
  1676. //pci.sExamCycleWeek = jExamItem["examCycleWeek"].asDouble();
  1677. int nWeekSize = jExamItem["examCycleWeek"].size();
  1678. for(int i = 0; i < nWeekSize; ++i)
  1679. {
  1680. pci.vExamCycleWeek.push_back(jExamItem["examCycleWeek"][i].asInt());
  1681. }
  1682. int nCycleTimeRangeSize = jExamItem["examCycleTimeRange"].size();
  1683. for(int i = 0; i < nCycleTimeRangeSize; ++i)
  1684. {
  1685. Json::Value jTimeRange = jExamItem["examCycleTimeRange"][i]["timeRange"];
  1686. int nTimeRangeSize = jTimeRange.size();
  1687. QStringList sTimeRangeList;
  1688. for(int j = 0; j < nTimeRangeSize; ++j)
  1689. {
  1690. sTimeRangeList<<jTimeRange[j].asString().c_str();
  1691. }
  1692. pci.sExamCycleTimeRange<<sTimeRangeList.join("~");
  1693. }
  1694. pci.nExamId = jExamItem["examId"].asInt64();
  1695. pci.sExamName = jExamItem["examName"].asString().c_str();
  1696. pci.nExamStudentId = jExamItem["examStudentId"].asInt64();
  1697. pci.sExamType = jExamItem["examType"].asString().c_str();
  1698. pci.fMaxObjectiveAccuracy = jExamItem["maxObjectiveAccuracy"].asDouble();
  1699. pci.nPracticeCount = jExamItem["practiceCount"].asInt();
  1700. pci.fRecentObjectiveAccuracy = jExamItem["recentObjectiveAccuracy"].asDouble();
  1701. pci.sStartTime = jExamItem["startTime"].asString().c_str();
  1702. pci.sStudentCode = jExamItem["studentCode"].asString().c_str();
  1703. pci.sStudentName = jExamItem["studentName"].asString().c_str();
  1704. pQueryPracticeCourseList->vPracticeCourseInfo.push_back(pci);
  1705. }
  1706. }
  1707. void CHttpBll::genQueryPracticeRecordList(CQueryPracticeRecordList *pQueryPracticeRecordList, const std::string &sResponse)
  1708. {
  1709. Json::Reader reader;
  1710. Json::Value jsonRoot = Json::Value::null;
  1711. if (!reader.parse(sResponse, jsonRoot))
  1712. {
  1713. pQueryPracticeRecordList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1714. myDebug() << pQueryPracticeRecordList->sMessage << sResponse.c_str();
  1715. }
  1716. int nSize = jsonRoot.size();
  1717. for (int i = 0; i < nSize; ++i)
  1718. {
  1719. Json::Value jPracticeItem = jsonRoot[i];
  1720. CPracticeRecord pr;
  1721. pr.sCourseCode = jPracticeItem["courseCode"].asString().c_str();
  1722. pr.sCourseName = jPracticeItem["courseName"].asString().c_str();
  1723. pr.sEndTime = jPracticeItem["endTime"].asString().c_str();
  1724. pr.sExamName = jPracticeItem["examName"].asString().c_str();
  1725. pr.nFailQuestionNum = jPracticeItem["failQuestionNum"].asInt();
  1726. pr.nId = jPracticeItem["id"].asInt64();
  1727. pr.nNotAnsweredCount = jPracticeItem["notAnsweredCount"].asInt();
  1728. pr.fObjectiveAccuracy = jPracticeItem["objectiveAccuracy"].asDouble();
  1729. pr.nObjectiveNum = jPracticeItem["objectiveNum"].asInt();
  1730. pr.sStartTime = jPracticeItem["startTime"].asString().c_str();
  1731. pr.nSuccQuestionNum = jPracticeItem["succQuestionNum"].asInt();
  1732. pr.nTotalQuestionCount = jPracticeItem["totalQuestionCount"].asInt();
  1733. pr.nUsedExamTime = jPracticeItem["usedExamTime"].asInt64();
  1734. pQueryPracticeRecordList->vPracticeRecordList.push_back(pr);
  1735. }
  1736. }
  1737. void CHttpBll::genGetPracticeDetailInfo(CGetPracticeDetailInfo *pGetPracticeDetailInfo, const std::string &sResponse)
  1738. {
  1739. Json::Reader reader;
  1740. Json::Value jsonRoot = Json::Value::null;
  1741. if (!reader.parse(sResponse, jsonRoot))
  1742. {
  1743. pGetPracticeDetailInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1744. myDebug() << pGetPracticeDetailInfo->sMessage << sResponse.c_str();
  1745. }
  1746. pGetPracticeDetailInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  1747. pGetPracticeDetailInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
  1748. pGetPracticeDetailInfo->nId = jsonRoot["id"].asInt64();
  1749. pGetPracticeDetailInfo->fObjectiveAccuracy = jsonRoot["objectiveAccuracy"].asDouble();
  1750. int nSize = jsonRoot["paperStructInfos"].size();
  1751. for (int i = 0; i < nSize; ++i)
  1752. {
  1753. Json::Value jPaperStructInfo = jsonRoot["paperStructInfos"][i];
  1754. CPracticePaperStructInfo ppsi;
  1755. ppsi.nCount = jPaperStructInfo["count"].asInt();
  1756. ppsi.nFailQuestionNum = jPaperStructInfo["failQuestionNum"].asInt();
  1757. ppsi.nIndex = jPaperStructInfo["index"].asInt();
  1758. ppsi.nNotAnsweredCount = jPaperStructInfo["notAnsweredCount"].asInt();
  1759. ppsi.nQuestionCount = jPaperStructInfo["questionCount"].asInt();
  1760. ppsi.sQuestionType = jPaperStructInfo["questionType"].asString().c_str();
  1761. ppsi.sScore = jPaperStructInfo["score"].asString().c_str();
  1762. ppsi.nSuccQuestionNum = jPaperStructInfo["succQuestionNum"].asInt();
  1763. ppsi.sTitle = jPaperStructInfo["title"].asString().c_str();
  1764. ppsi.fTotalScore = jPaperStructInfo["totalScore"].asDouble();
  1765. pGetPracticeDetailInfo->vPracticePaperStructList.push_back(ppsi);
  1766. }
  1767. }
  1768. void CHttpBll::genFindExamRecordDataEntity(CFindExamRecordDataEntity *pFindExamRecordDataEntity, const std::string &sResponse)
  1769. {
  1770. Json::Reader reader;
  1771. Json::Value jsonRoot = Json::Value::null;
  1772. if (!reader.parse(sResponse, jsonRoot))
  1773. {
  1774. pFindExamRecordDataEntity->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1775. myDebug() << pFindExamRecordDataEntity->sMessage << sResponse.c_str();
  1776. }
  1777. pFindExamRecordDataEntity->nExamId = jsonRoot["examRecord"]["examId"].asInt64();
  1778. pFindExamRecordDataEntity->sPaperType = jsonRoot["examRecord"]["paperType"].asString().c_str();
  1779. }
  1780. void CHttpBll::genGetExamRecordQuestions(CGetExamRecordQuestions *pGetExamRecordQuestions, const std::string &sResponse)
  1781. {
  1782. Json::Reader reader;
  1783. Json::Value jsonRoot = Json::Value::null;
  1784. if (!reader.parse(sResponse, jsonRoot))
  1785. {
  1786. pGetExamRecordQuestions->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1787. myDebug() << pGetExamRecordQuestions->sMessage << sResponse.c_str();
  1788. }
  1789. int nSize = jsonRoot["examQuestionEntities"].size();
  1790. for (int i = 0; i < nSize; ++i)
  1791. {
  1792. Json::Value jQuestionItem = jsonRoot["examQuestionEntities"][i];
  1793. CAnsweredQuestion aq;
  1794. aq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  1795. aq.sAudioPlayTimes = jQuestionItem["audioPlayTimes"].isNull() ? "" : jQuestionItem["audioPlayTimes"].asString().c_str();
  1796. aq.sCorrectAnswer = jQuestionItem["correctAnswer"].isNull() ? "" : jQuestionItem["correctAnswer"].asString().c_str();
  1797. //aq.sExamQuestionTempId = jQuestionItem["examQuestionTempId"].asString().c_str();
  1798. aq.nExamRecordDataId = jQuestionItem["examRecordDataId"].asInt64();
  1799. aq.bIsAnswer = jQuestionItem["isAnswer"].asBool();
  1800. //aq.bIsInMongo = jQuestionItem["isInMongo"].asBool();
  1801. aq.bIsSign = jQuestionItem["isSign"].asBool();
  1802. aq.nMainNumber = jQuestionItem["mainNumber"].asInt();
  1803. int nOptionSize = jQuestionItem["optionPermutation"].size();
  1804. for (int j = 0; j < nOptionSize; ++j)
  1805. {
  1806. aq.vOptionPermutation.push_back(jQuestionItem["optionPermutation"][i].asInt());
  1807. }
  1808. aq.nOrder = jQuestionItem["order"].asInt();
  1809. aq.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  1810. aq.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  1811. aq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1812. aq.sStudentAnswer = jQuestionItem["studentAnswer"].asString().c_str();
  1813. aq.fStudentScore = jQuestionItem["studentScore"].asDouble();
  1814. pGetExamRecordQuestions->vExamRecordQuestions.push_back(aq);
  1815. }
  1816. }
  1817. void CHttpBll::genGetOfflineCourse(CGetOfflineCourse *pGetOfflineCourse, const std::string &sResponse)
  1818. {
  1819. Json::Reader reader;
  1820. Json::Value jsonRoot = Json::Value::null;
  1821. if (!reader.parse(sResponse, jsonRoot))
  1822. {
  1823. pGetOfflineCourse->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1824. myDebug() << pGetOfflineCourse->sMessage << sResponse.c_str();
  1825. }
  1826. int nSize = jsonRoot.size();
  1827. for (int i = 0; i < nSize; ++i)
  1828. {
  1829. Json::Value jCourseInfo = jsonRoot[i];
  1830. COfflineCourseInfo oci;
  1831. oci.sCourseCode = jCourseInfo["courseCode"].asString().c_str();
  1832. oci.sCourseLevel = jCourseInfo["courseLevel"].asString().c_str();
  1833. oci.sCourseName = jCourseInfo["courseName"].asString().c_str();
  1834. oci.sEndTime = jCourseInfo["endTime"].asString().c_str();
  1835. oci.nExamId = jCourseInfo["examId"].asInt64();
  1836. oci.sExamName = jCourseInfo["examName"].asString().c_str();
  1837. oci.nExamRecordDataId = jCourseInfo["examRecordDataId"].asInt64();
  1838. oci.nExamStudentId = jCourseInfo["examStudentId"].asInt64();
  1839. oci.bIsvalid = jCourseInfo["isvalid"].asBool();
  1840. oci.sOrgName = jCourseInfo["orgName"].asString().c_str();
  1841. oci.sPaperId = jCourseInfo["paperId"].asString().c_str();
  1842. oci.sSpecialtyName = jCourseInfo["specialtyName"].asString().c_str();
  1843. oci.sStartTime = jCourseInfo["startTime"].asString().c_str();
  1844. oci.sStatus = jCourseInfo["status"].asString().c_str();
  1845. oci.sStudentCode = jCourseInfo["studentCode"].asString().c_str();
  1846. oci.sStudentName = jCourseInfo["studentName"].asString().c_str();
  1847. int nFileSize = jCourseInfo["offlineFiles"].size();
  1848. for (int j = 0; j < nFileSize; ++j)
  1849. {
  1850. Json::Value jFileItem = jCourseInfo["offlineFiles"][j];
  1851. COfflineFileInfo ofi;
  1852. ofi.nExamRecordDataId = jFileItem["examRecordDataId"].asInt64();
  1853. ofi.sFileType = jFileItem["fileType"].asString().c_str();
  1854. ofi.nId = jFileItem["id"].asInt64();
  1855. ofi.sOfflineFileName = jFileItem["offlineFileName"].asString().c_str();
  1856. ofi.sOfflineFileUrl = jFileItem["offlineFileUrl"].asString().c_str();
  1857. ofi.sOriginalFileName = jFileItem["originalFileName"].asString().c_str();
  1858. ofi.sProperties = jFileItem["properties"].asString().c_str();
  1859. ofi.sSuffix = jFileItem["suffix"].asString().c_str();
  1860. oci.vOfflineFileInfo.push_back(ofi);
  1861. }
  1862. pGetOfflineCourse->vOfflineCourseInfo.push_back(oci);
  1863. }
  1864. }
  1865. void CHttpBll::genGetOffLineExamAnswerSheet(CGetOffLineExamAnswerSheet *pGetOffLineExamAnswerSheet, const std::string &sResponse)
  1866. {
  1867. pGetOffLineExamAnswerSheet->sAnswerSheetUrl = sResponse.c_str();
  1868. }
  1869. void CHttpBll::genGetOffLineExamPaper(CGetOffLineExamPaper *pGetOffLineExamPaper, const std::string &sResponse)
  1870. {
  1871. }
  1872. void CHttpBll::genPreviewOffLineExamPaper(CPreviewOffLineExamPaper *pPreviewOffLineExamPaper, const std::string &sResponse)
  1873. {
  1874. pPreviewOffLineExamPaper->sUrl = sResponse.c_str();
  1875. }
  1876. void CHttpBll::genCheckExamInProgress(CCheckExamInProgress *pCheckExamInProgress, const std::string &sResponse)
  1877. {
  1878. Json::Reader reader;
  1879. Json::Value jsonRoot = Json::Value::null;
  1880. if (!reader.parse(sResponse, jsonRoot))
  1881. {
  1882. pCheckExamInProgress->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1883. myDebug() << pCheckExamInProgress->sMessage << sResponse.c_str();
  1884. }
  1885. if (jsonRoot["data"].isNull())
  1886. {
  1887. pCheckExamInProgress->bHasExamInProgress = false;
  1888. }
  1889. else
  1890. {
  1891. pCheckExamInProgress->bHasExamInProgress = true;
  1892. pCheckExamInProgress->nInterruptNum = jsonRoot["data"]["interruptNum"].asInt();
  1893. pCheckExamInProgress->nMaxInterruptNum = jsonRoot["data"]["maxInterruptNum"].asInt();
  1894. pCheckExamInProgress->bIsExceed = jsonRoot["data"]["isExceed"].asBool();
  1895. pCheckExamInProgress->nExamRecordDataId = jsonRoot["data"]["examRecordDataId"].asInt64();
  1896. pCheckExamInProgress->nExamId = jsonRoot["data"]["examId"].asInt64();
  1897. pCheckExamInProgress->nUsedTime = jsonRoot["data"]["usedTime"].asInt64();
  1898. pCheckExamInProgress->nFaceVerifyMinute = jsonRoot["data"]["faceVerifyMinute"].asInt();
  1899. pCheckExamInProgress->sExamType = jsonRoot["data"]["examType"].asString().c_str();
  1900. }
  1901. }
  1902. void CHttpBll::genGetCourseInfo(CGetCourseInfo *pGetCourseInfo, const std::string &sResponse)
  1903. {
  1904. Json::Reader reader;
  1905. Json::Value jsonRoot = Json::Value::null;
  1906. if (!reader.parse(sResponse, jsonRoot))
  1907. {
  1908. pGetCourseInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1909. myDebug() << pGetCourseInfo->sMessage << sResponse.c_str();
  1910. }
  1911. pGetCourseInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
  1912. pGetCourseInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  1913. }
  1914. void CHttpBll::genExamHeartbeat(CExamHeartbeat *pExamHeartbeat, const std::string &sResponse)
  1915. {
  1916. pExamHeartbeat->nLeftTime = QString(sResponse.c_str()).toLongLong();
  1917. }
  1918. void CHttpBll::genFindExamQuestionList(CFindExamQuestionList *pFindExamQuestionList, const std::string &sResponse)
  1919. {
  1920. Json::Reader reader;
  1921. Json::Value jsonRoot = Json::Value::null;
  1922. if (!reader.parse(sResponse, jsonRoot))
  1923. {
  1924. pFindExamQuestionList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1925. myDebug() << pFindExamQuestionList->sMessage << sResponse.c_str();
  1926. }
  1927. int nSize = jsonRoot.size();
  1928. for (int i = 0; i < nSize; ++i)
  1929. {
  1930. Json::Value jQuestionItem = jsonRoot[i];
  1931. CAnsweredQuestion aq;
  1932. aq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  1933. aq.sAudioPlayTimes = jQuestionItem["audioPlayTimes"].isNull() ? "" :jQuestionItem["audioPlayTimes"].asString().c_str();
  1934. aq.sCorrectAnswer = jQuestionItem["correctAnswer"].isNull() ? "" : jQuestionItem["correctAnswer"].asString().c_str();
  1935. aq.sExamQuestionTempId = jQuestionItem["examQuestionTempId"].asString().c_str();
  1936. aq.nExamRecordDataId = jQuestionItem["examRecordDataId"].asInt64();
  1937. aq.bIsAnswer = jQuestionItem["isAnswer"].asBool();
  1938. aq.bIsInMongo = jQuestionItem["isInMongo"].asBool();
  1939. aq.bIsSign = jQuestionItem["isSign"].asBool();
  1940. aq.nMainNumber = jQuestionItem["mainNumber"].asInt();
  1941. int nOptionSize = jQuestionItem["optionPermutation"].size();
  1942. for (int j = 0; j < nOptionSize; ++j)
  1943. {
  1944. aq.vOptionPermutation.push_back(jQuestionItem["optionPermutation"][i].asInt());
  1945. }
  1946. aq.nOrder = jQuestionItem["order"].asInt();
  1947. aq.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  1948. aq.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  1949. aq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1950. aq.sStudentAnswer = jQuestionItem["studentAnswer"].asString().c_str();
  1951. aq.fStudentScore = jQuestionItem["studentScore"].asDouble();
  1952. pFindExamQuestionList->vAnsweredQuestion.push_back(aq);
  1953. }
  1954. }
  1955. void CHttpBll::genGetExamRecordPaperStruct(CGetExamRecordPaperStruct *pGetExamRecordPaperStruct, const std::string &sResponse)
  1956. {
  1957. Json::Reader reader;
  1958. Json::Value jsonRoot = Json::Value::null;
  1959. if (!reader.parse(sResponse, jsonRoot))
  1960. {
  1961. pGetExamRecordPaperStruct->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1962. myDebug() << pGetExamRecordPaperStruct->sMessage << sResponse.c_str();
  1963. }
  1964. pGetExamRecordPaperStruct->sPaperId = jsonRoot["id"].asString().c_str();
  1965. pGetExamRecordPaperStruct->sPaperName = jsonRoot["defaultPaper"]["name"].asString().c_str();
  1966. pGetExamRecordPaperStruct->bFullyObjective = jsonRoot["defaultPaper"]["fullyObjective"].asBool();
  1967. int nGroupSize = jsonRoot["defaultPaper"]["questionGroupList"].size();
  1968. int nOrder = 1;
  1969. for (int i = 0; i < nGroupSize; ++i)
  1970. {
  1971. Json::Value jGroupItem = jsonRoot["defaultPaper"]["questionGroupList"][i];
  1972. CPaperGroupStruct pgs;
  1973. pgs.sGroupName = jGroupItem["groupName"].asString().c_str();
  1974. pgs.fGroupScore = jGroupItem["groupScore"].asDouble();
  1975. pgs.nNumber = i + 1;
  1976. int nQuestionSize = jGroupItem["questionWrapperList"].size();
  1977. int nShowIndex = 1;
  1978. int nTotalSubquestion = 0;
  1979. for (int j = 0; j < nQuestionSize; ++j)
  1980. {
  1981. Json::Value jQuestionItem = jGroupItem["questionWrapperList"][j];
  1982. CQuestionStruct qs;
  1983. qs.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  1984. qs.sVersion = jQuestionItem["version"].asString().c_str();
  1985. qs.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  1986. qs.nLimitedPlayTimes = jQuestionItem["limitedPlayTimes"].asInt();
  1987. qs.nPlayedTimes = jQuestionItem["playedTimes"].asInt();
  1988. qs.nTimeLimit = jQuestionItem["timeLimit"].asInt();
  1989. int mSubQuestionSize = jQuestionItem["questionUnitWrapperList"].size();
  1990. nTotalSubquestion += mSubQuestionSize;
  1991. for (int k = 0; k < mSubQuestionSize; ++k)
  1992. {
  1993. Json::Value jSubQuestionItem = jQuestionItem["questionUnitWrapperList"][k];
  1994. CSubQuestionStruct sqs;
  1995. sqs.sQuestionType = jSubQuestionItem["questionType"].asString().c_str();
  1996. sqs.sAnswerType = jSubQuestionItem["answerType"].asString().c_str();
  1997. sqs.fQuestionScore = jSubQuestionItem["questionScore"].asDouble();
  1998. sqs.nLimitedPlayTimes = qs.nLimitedPlayTimes;
  1999. for (int jq = 0; jq < jSubQuestionItem["optionPermutation"].size(); ++jq)
  2000. {
  2001. Json::Value Item = jSubQuestionItem["optionPermutation"][jq];
  2002. sqs.voptionPermutation.push_back(Item.asInt());
  2003. }
  2004. sqs.nShowNumber = nShowIndex;
  2005. sqs.nOrder = nOrder;
  2006. nShowIndex++;
  2007. nOrder++;
  2008. qs.vSubQuestionStruct.push_back(sqs);
  2009. }
  2010. pgs.vQuestionStruct.push_back(qs);
  2011. }
  2012. pgs.nTotalSubquestion = nTotalSubquestion;
  2013. pGetExamRecordPaperStruct->vPaperGroupStruct.push_back(pgs);
  2014. }
  2015. }
  2016. void CHttpBll::genGetEndExamInfo(CGetEndExamInfo *pGetEndExamInfo, const std::string &sResponse)
  2017. {
  2018. if (sResponse == "")
  2019. {
  2020. pGetEndExamInfo->bIsCalculate = true;
  2021. return;
  2022. }
  2023. Json::Reader reader;
  2024. Json::Value jsonRoot = Json::Value::null;
  2025. if (!reader.parse(sResponse, jsonRoot))
  2026. {
  2027. pGetEndExamInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2028. myDebug() << pGetEndExamInfo->sMessage << sResponse.c_str();
  2029. }
  2030. pGetEndExamInfo->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  2031. pGetEndExamInfo->bIsWarn = jsonRoot["isWarn"].asBool();
  2032. pGetEndExamInfo->fObjectiveAccuracy = jsonRoot["objectiveAccuracy"].asDouble();
  2033. pGetEndExamInfo->fObjectiveScore = jsonRoot["objectiveScore"].asInt64();
  2034. }
  2035. void CHttpBll::genGetWXQrCode(CGetWXQrCode *pGetWXQrCode, const std::string &sResponse)
  2036. {
  2037. pGetWXQrCode->sUrl = sResponse.c_str();
  2038. }
  2039. void CHttpBll::genProcessUpload(CProcessUpload *pProcessUpload, const std::string &sResponse)
  2040. {
  2041. Json::Reader reader;
  2042. Json::Value jsonRoot = Json::Value::null;
  2043. if (!reader.parse(sResponse, jsonRoot))
  2044. {
  2045. pProcessUpload->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2046. myDebug() << pProcessUpload->sMessage << sResponse.c_str();
  2047. }
  2048. pProcessUpload->sFileUrl = jsonRoot["fileUrl"].asString().c_str();
  2049. }
  2050. void CHttpBll::genGetOrgPropertiesByGroupWithoutCache(CGetOrgPropertiesByGroupWithoutCache *pOrgProperties, const std::string &sResponse)
  2051. {
  2052. Json::Reader reader;
  2053. Json::Value jsonRoot = Json::Value::null;
  2054. if (!reader.parse(sResponse, jsonRoot))
  2055. {
  2056. pOrgProperties->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2057. myDebug() << pOrgProperties->sMessage << sResponse.c_str();
  2058. }
  2059. pOrgProperties->nActionNum = QVariant(jsonRoot["ACTION_NUM"].asString().c_str()).toInt();
  2060. pOrgProperties->sActionOptions = jsonRoot["ACTION_OPTIONS"].asString().c_str();
  2061. pOrgProperties->sActionOrder = jsonRoot["ACTION_ORDER"].asString().c_str();
  2062. pOrgProperties->nActionDuration = QVariant(jsonRoot["ACTION_DURATION"].asString().c_str()).toInt();
  2063. pOrgProperties->nActionAlert = QVariant(jsonRoot["ACTION_ALERT"].asString().c_str()).toInt();
  2064. }
  2065. void CHttpBll::genStartFaceLiveVerify(CStartFaceLiveVerify *pStartFaceLiveVerify, const std::string &sResponse)
  2066. {
  2067. Json::Reader reader;
  2068. Json::Value jsonRoot = Json::Value::null;
  2069. if (!reader.parse(sResponse, jsonRoot))
  2070. {
  2071. pStartFaceLiveVerify->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2072. myDebug() << pStartFaceLiveVerify->sMessage << sResponse.c_str();
  2073. }
  2074. pStartFaceLiveVerify->nFaceLiveVerifyId = jsonRoot["faceLiveVerifyId"].asInt64();
  2075. pStartFaceLiveVerify->nStartMinute = jsonRoot["startMinute"].asInt();
  2076. pStartFaceLiveVerify->nTimes = jsonRoot["times"].asInt();
  2077. }