CHttpBll.cpp 86 KB

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