CHttpBll.cpp 87 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691
  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. if (jsonRoot.isMember("SHOW_INFO"))
  1174. {
  1175. QString sShowInfo = jsonRoot["SHOW_INFO"].asString().c_str();
  1176. pStudentClientConfig->bShowStudentName = sShowInfo.indexOf("STU_NAME") >= 0;
  1177. pStudentClientConfig->bShowStudentCode = sShowInfo.indexOf("STU_CODE") >= 0;
  1178. pStudentClientConfig->bShowStudentIdentity = sShowInfo.indexOf("IDENTITY_NUMBER") >= 0;
  1179. }
  1180. }
  1181. catch (const std::exception &e)
  1182. {
  1183. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1184. }
  1185. }
  1186. void CHttpBll::genSysNotice(CSysNotice *pSysNotice, const std::string &sResponse)
  1187. {
  1188. try
  1189. {
  1190. Json::Reader reader;
  1191. Json::Value jsonRoot = Json::Value::null;
  1192. if (!reader.parse(sResponse, jsonRoot))
  1193. {
  1194. pSysNotice->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1195. myDebug() << pSysNotice->sMessage << sResponse.c_str();
  1196. }
  1197. pSysNotice->nId = jsonRoot["id"].asInt64();
  1198. pSysNotice->nRootOrgId = jsonRoot["rootOrgId"].asInt64();
  1199. pSysNotice->sContent = jsonRoot["content"].asString().c_str();
  1200. pSysNotice->sStartTime = jsonRoot["startTime"].asString().c_str();
  1201. pSysNotice->sEndTime = jsonRoot["endTime"].asString().c_str();
  1202. pSysNotice->sTitle = jsonRoot["title"].asString().c_str();
  1203. pSysNotice->bEnable = jsonRoot["enable"].asBool();
  1204. }
  1205. catch (const std::exception &e)
  1206. {
  1207. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1208. }
  1209. }
  1210. void CHttpBll::genSoftwareConfig(CGetSoftwareConfig *pSoftwareConfig, const std::string &sResponse)
  1211. {
  1212. if(!sResponse.empty())
  1213. {
  1214. pSoftwareConfig->sSoftwareConfig = std::string(sResponse.rbegin()+32, sResponse.rend()).c_str();
  1215. }
  1216. }
  1217. void CHttpBll::genLoginLimit(CLoginLimit *pLoginLimit, const std::string &sResponse)
  1218. {
  1219. try
  1220. {
  1221. Json::Reader reader;
  1222. Json::Value jsonRoot = Json::Value::null;
  1223. if (!reader.parse(sResponse, jsonRoot))
  1224. {
  1225. pLoginLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1226. myDebug() << pLoginLimit->sMessage << sResponse.c_str();
  1227. }
  1228. pLoginLimit->nCount = jsonRoot["count"].asInt64();
  1229. pLoginLimit->bPass = jsonRoot["pass"].asBool();
  1230. }
  1231. catch (const std::exception &e)
  1232. {
  1233. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1234. }
  1235. }
  1236. void CHttpBll::genLoginInfo(CLoginInfo *pLoginInfo, const std::string &sResponse)
  1237. {
  1238. try
  1239. {
  1240. Json::Reader reader;
  1241. Json::Value jsonRoot = Json::Value::null;
  1242. if (!reader.parse(sResponse, jsonRoot))
  1243. {
  1244. pLoginInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1245. myDebug() << pLoginInfo->sMessage << sResponse.c_str();
  1246. }
  1247. // pLoginInfo->nCode = jsonRoot["code"].asInt();
  1248. if (jsonRoot["code"].asString() != "200")
  1249. {
  1250. pLoginInfo->nCode = 0;
  1251. }
  1252. pLoginInfo->sMessage = jsonRoot["desc"].asString().c_str();
  1253. sKey = jsonRoot["content"]["key"].asString().c_str();
  1254. sToken = jsonRoot["content"]["token"].asString().c_str();
  1255. pLoginInfo->sUserType = jsonRoot["content"]["userType"].asString().c_str();
  1256. pLoginInfo->nUserId = jsonRoot["content"]["userId"].asInt64();
  1257. pLoginInfo->sDisplayName = jsonRoot["content"]["displayName"].asString().c_str();
  1258. pLoginInfo->nRootOrgId = jsonRoot["content"]["rootOrgId"].asInt64();
  1259. pLoginInfo->sRootOrgName = jsonRoot["content"]["rootOrgName"].asString().c_str();
  1260. pLoginInfo->sCreationTime = jsonRoot["content"]["creationTime"].asString().c_str();
  1261. pLoginInfo->sClientIp = jsonRoot["content"]["clientIp"].asString().c_str();
  1262. pLoginInfo->nSessionTimeout = jsonRoot["content"]["sessionTimeout"].asInt64();
  1263. pLoginInfo->bPasswordWeak = jsonRoot["content"]["passwordWeak"].asBool();
  1264. }
  1265. catch (const std::exception &e)
  1266. {
  1267. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1268. }
  1269. }
  1270. void CHttpBll::genLogout(CLogout *pLogout, const std::string &sResponse)
  1271. {
  1272. }
  1273. void CHttpBll::genEditPassword(CEditPassword *pEditPassword, const std::string &sResponse)
  1274. {
  1275. }
  1276. void CHttpBll::genGetStudentClientMenu(CGetStudentClientMenu *pGetStudentClientMenu, const std::string &sResponse)
  1277. {
  1278. try
  1279. {
  1280. Json::Reader reader;
  1281. Json::Value jsonRoot = Json::Value::null;
  1282. if (!reader.parse(sResponse, jsonRoot))
  1283. {
  1284. pGetStudentClientMenu->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1285. myDebug() << pGetStudentClientMenu->sMessage << sResponse.c_str();
  1286. }
  1287. int nSize = jsonRoot.size();
  1288. for (int i = 0; i < nSize; ++i)
  1289. {
  1290. Json::Value jMenuItem = jsonRoot[i];
  1291. CStudentClientMenu scm;
  1292. scm.nId = jMenuItem["id"].asInt64();
  1293. scm.sCode = jMenuItem["code"].asString().c_str();
  1294. scm.sName = jMenuItem["name"].asString().c_str();
  1295. pGetStudentClientMenu->vMenus.push_back(scm);
  1296. }
  1297. }
  1298. catch (const std::exception &e)
  1299. {
  1300. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1301. }
  1302. }
  1303. void CHttpBll::genGetStudentInfoBySession(CGetStudentInfoBySession *pGetStudentInfoBySession, const std::string &sResponse)
  1304. {
  1305. try
  1306. {
  1307. Json::Reader reader;
  1308. Json::Value jsonRoot = Json::Value::null;
  1309. if (!reader.parse(sResponse, jsonRoot))
  1310. {
  1311. pGetStudentInfoBySession->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1312. myDebug() << pGetStudentInfoBySession->sMessage << sResponse.c_str();
  1313. }
  1314. pGetStudentInfoBySession->nId = jsonRoot["id"].asInt64();
  1315. pGetStudentInfoBySession->sName = jsonRoot["name"].asString().c_str();
  1316. pGetStudentInfoBySession->nOrgId = jsonRoot["orgId"].asInt64();
  1317. pGetStudentInfoBySession->sOrgCode = jsonRoot["orgCode"].asString().c_str();
  1318. pGetStudentInfoBySession->sOrgName = jsonRoot["orgName"].asString().c_str();
  1319. QString sStudentCode = "";
  1320. int nSize = jsonRoot["studentCodeList"].size();
  1321. for (int i = 0; i < nSize; ++i)
  1322. {
  1323. if (sStudentCode.isEmpty())
  1324. {
  1325. sStudentCode = jsonRoot["studentCodeList"][i].asString().c_str();
  1326. }
  1327. else
  1328. {
  1329. sStudentCode = sStudentCode + "," + jsonRoot["studentCodeList"][i].asString().c_str();
  1330. }
  1331. }
  1332. pGetStudentInfoBySession->sStudentCode = sStudentCode;
  1333. pGetStudentInfoBySession->sIdentityNumber = jsonRoot["identityNumber"].asString().c_str();
  1334. pGetStudentInfoBySession->sPhotoPath = jsonRoot["photoPath"].asString().c_str();
  1335. pGetStudentInfoBySession->bEnable = jsonRoot["enable"].asBool();
  1336. }
  1337. catch (const std::exception &e)
  1338. {
  1339. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1340. }
  1341. }
  1342. void CHttpBll::genSpecialtyNameList(CSpecialtyNameList *pSpecialtyNameList, const std::string &sResponse)
  1343. {
  1344. try
  1345. {
  1346. Json::Reader reader;
  1347. Json::Value jsonRoot = Json::Value::null;
  1348. if (!reader.parse(sResponse, jsonRoot))
  1349. {
  1350. pSpecialtyNameList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1351. myDebug() << pSpecialtyNameList->sMessage << sResponse.c_str();
  1352. }
  1353. QString sSpecialtyName = "";
  1354. int nSize = jsonRoot.size();
  1355. for (int i = 0; i < nSize; ++i)
  1356. {
  1357. if (sSpecialtyName.isEmpty())
  1358. {
  1359. sSpecialtyName = jsonRoot[i].asString().c_str();
  1360. }
  1361. else
  1362. {
  1363. sSpecialtyName = sSpecialtyName + "," + jsonRoot[i].asString().c_str();
  1364. }
  1365. }
  1366. pSpecialtyNameList->sSpecialtyName = sSpecialtyName;
  1367. }
  1368. catch (const std::exception &e)
  1369. {
  1370. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1371. }
  1372. }
  1373. void CHttpBll::genGetUserNoticeList(CGetUserNoticeList *pGetUserNoticeList, const std::string &sResponse)
  1374. {
  1375. try
  1376. {
  1377. Json::Reader reader;
  1378. Json::Value jsonRoot = Json::Value::null;
  1379. if (!reader.parse(sResponse, jsonRoot))
  1380. {
  1381. pGetUserNoticeList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1382. myDebug() << pGetUserNoticeList->sMessage << sResponse.c_str();
  1383. }
  1384. int nSize = jsonRoot.size();
  1385. for (int i = 0; i < nSize; ++i)
  1386. {
  1387. Json::Value jNoticeItem = jsonRoot[i];
  1388. CNoticeInfo ni;
  1389. ni.nId = jNoticeItem["id"].asInt64();
  1390. ni.sTitle = jNoticeItem["title"].asString().c_str();
  1391. ni.sContent = jNoticeItem["content"].asString().c_str();
  1392. ni.sPublisher = jNoticeItem["publisher"].asString().c_str();
  1393. ni.sPublishTime = jNoticeItem["publishTime"].asString().c_str();
  1394. ni.bHasRead = jNoticeItem["hasRead"].asBool();
  1395. ni.bHasRecalled = jNoticeItem["hasRecalled"].isNull() ? false : jNoticeItem["hasRecalled"].asBool();
  1396. pGetUserNoticeList->vNoticeList.push_back(ni);
  1397. }
  1398. }
  1399. catch (const std::exception &e)
  1400. {
  1401. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1402. }
  1403. }
  1404. void CHttpBll::genAppDownLoadUrl(CAppDownLoadUrl *pAppDownLoadUrl, const std::string &sResponse)
  1405. {
  1406. pAppDownLoadUrl->sUrl = sResponse.c_str();
  1407. }
  1408. void CHttpBll::genAppEnabled(CAppEnabled *pAppEnabled, const std::string &sResponse)
  1409. {
  1410. try
  1411. {
  1412. pAppEnabled->bEnable = QVariant(sResponse.c_str()).toBool();
  1413. }
  1414. catch (const std::exception &e)
  1415. {
  1416. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1417. }
  1418. }
  1419. void CHttpBll::genQueryBatchList(CQueryBatchList *pQueryBatchList, const std::string &sResponse)
  1420. {
  1421. try
  1422. {
  1423. Json::Reader reader;
  1424. Json::Value jsonRoot = Json::Value::null;
  1425. if (!reader.parse(sResponse, jsonRoot))
  1426. {
  1427. pQueryBatchList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1428. myDebug() << pQueryBatchList->sMessage << sResponse.c_str();
  1429. }
  1430. int nSize = jsonRoot.size();
  1431. for (int i = 0; i < nSize; ++i)
  1432. {
  1433. Json::Value jBatchItem = jsonRoot[i];
  1434. CBatchInfo bi;
  1435. bi.nId = jBatchItem["id"].asInt64();
  1436. bi.sName = jBatchItem["name"].asString().c_str();
  1437. bi.sExamType = jBatchItem["examType"].asString().c_str();
  1438. pQueryBatchList->vBatchList.push_back(bi);
  1439. }
  1440. }
  1441. catch (const std::exception &e)
  1442. {
  1443. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1444. }
  1445. }
  1446. void CHttpBll::genGetExamProperty(CGetExamProperty *pGetExamProperty, const std::string &sResponse)
  1447. {
  1448. try
  1449. {
  1450. Json::Reader reader;
  1451. Json::Value jsonRoot = Json::Value::null;
  1452. if (!reader.parse(sResponse, jsonRoot))
  1453. {
  1454. pGetExamProperty->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1455. myDebug() << pGetExamProperty->sMessage << sResponse.c_str();
  1456. }
  1457. if (jsonRoot.isMember("BEFORE_EXAM_REMARK"))
  1458. {
  1459. pGetExamProperty->sBeforeExamRemark = jsonRoot["BEFORE_EXAM_REMARK"].asString().c_str();
  1460. }
  1461. if (jsonRoot.isMember("CHECK_ENVIRONMENT"))
  1462. {
  1463. pGetExamProperty->bCheckEnvironment = QVariant(jsonRoot["CHECK_ENVIRONMENT"].asString().c_str()).toBool();
  1464. }
  1465. // if (jsonRoot.isMember("PC_CLIENT_FACE_THRESHOLD"))
  1466. // {
  1467. // pGetExamProperty->nFaceThreshold = QVariant(jsonRoot["PC_CLIENT_FACE_THRESHOLD"].asString().c_str()).toInt();
  1468. // }
  1469. if (jsonRoot.isMember("IS_FACE_CHECK"))
  1470. {
  1471. pGetExamProperty->bIsFaceCheck = QVariant(jsonRoot["IS_FACE_CHECK"].asString().c_str()).toBool();
  1472. }
  1473. if (jsonRoot.isMember("SNAPSHOT_INTERVAL"))
  1474. {
  1475. pGetExamProperty->nSnapshotInterval = QVariant(jsonRoot["SNAPSHOT_INTERVAL"].asString().c_str()).toInt();
  1476. }
  1477. if (jsonRoot.isMember("FACE_VERIFY_START_MINUTE"))
  1478. {
  1479. pGetExamProperty->nFaceVerifyStartMinute = QVariant(jsonRoot["FACE_VERIFY_START_MINUTE"].asString().c_str()).toInt();
  1480. }
  1481. if (jsonRoot.isMember("FACE_VERIFY_END_MINUTE"))
  1482. {
  1483. pGetExamProperty->nFaceVerifyEndMinute = QVariant(jsonRoot["FACE_VERIFY_END_MINUTE"].asString().c_str()).toInt();
  1484. }
  1485. if (jsonRoot.isMember("IS_STRANGER_ENABLE"))
  1486. {
  1487. pGetExamProperty->bIsStrangerEnable = QVariant(jsonRoot["IS_STRANGER_ENABLE"].asString().c_str()).toBool();
  1488. }
  1489. if (jsonRoot.isMember("PRACTICE_TYPE"))
  1490. {
  1491. pGetExamProperty->sPracticeType = jsonRoot["PRACTICE_TYPE"].asString().c_str();
  1492. }
  1493. if (jsonRoot.isMember("FREEZE_TIME"))
  1494. {
  1495. pGetExamProperty->nFreezeTime = QVariant(jsonRoot["FREEZE_TIME"].asString().c_str()).toInt();
  1496. }
  1497. if (jsonRoot.isMember("AFTER_EXAM_REMARK"))
  1498. {
  1499. pGetExamProperty->sAfterExamRemark = jsonRoot["AFTER_EXAM_REMARK"].asString().c_str();
  1500. }
  1501. if (jsonRoot.isMember("IS_OBJ_SCORE_VIEW"))
  1502. {
  1503. pGetExamProperty->bIsObjScoreView = QVariant(jsonRoot["IS_OBJ_SCORE_VIEW"].asString().c_str()).toBool();
  1504. }
  1505. if (jsonRoot.isMember("SHOW_CHEATING_REMARK"))
  1506. {
  1507. pGetExamProperty->bShowCheatingRemark = QVariant(jsonRoot["SHOW_CHEATING_REMARK"].asString().c_str()).toBool();
  1508. }
  1509. if (jsonRoot.isMember("CHEATING_REMARK"))
  1510. {
  1511. pGetExamProperty->sCheatingRemark = jsonRoot["CHEATING_REMARK"].asString().c_str();
  1512. }
  1513. if (jsonRoot.isMember("IS_FACE_VERIFY_BEFORE"))
  1514. {
  1515. pGetExamProperty->bIsLivenessBefore = QVariant(jsonRoot["IS_FACE_VERIFY_BEFORE"].asString().c_str()).toBool();
  1516. }
  1517. if (jsonRoot.isMember("OFFLINE_UPLOAD_FILE_TYPE"))
  1518. {
  1519. QString sFileType = jsonRoot["OFFLINE_UPLOAD_FILE_TYPE"].asString().c_str();
  1520. Json::Reader reader;
  1521. Json::Value jFileType = Json::Value::null;
  1522. if (!reader.parse(sFileType.toStdString(), jFileType))
  1523. {
  1524. pGetExamProperty->sMessage = QString::fromLocal8Bit("解析文件类型异常!");
  1525. pGetExamProperty->nCode = 0;
  1526. }
  1527. int nSize = jFileType.size();
  1528. for (int i = 0; i < nSize; ++i)
  1529. {
  1530. pGetExamProperty->vOfflineUploadFileType.push_back(jFileType[i].asString().c_str());
  1531. }
  1532. }
  1533. if(jsonRoot.isMember("SHOW_MULTIPLE_CHOICE_WARNING"))
  1534. {
  1535. pGetExamProperty->bMutipleAnserCountTips = QVariant(jsonRoot["SHOW_MULTIPLE_CHOICE_WARNING"].asString().c_str()).toBool();
  1536. }
  1537. }
  1538. catch (const std::exception &e)
  1539. {
  1540. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1541. }
  1542. }
  1543. void CHttpBll::genStartExamLimit(CStartExamLimit *pStartExamLimit, const std::string &sResponse)
  1544. {
  1545. try
  1546. {
  1547. Json::Reader reader;
  1548. Json::Value jsonRoot = Json::Value::null;
  1549. if (!reader.parse(sResponse, jsonRoot))
  1550. {
  1551. pStartExamLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1552. myDebug() << pStartExamLimit->sMessage << sResponse.c_str();
  1553. }
  1554. pStartExamLimit->nCount = jsonRoot["count"].asInt();
  1555. pStartExamLimit->bPass = jsonRoot["pass"].asBool();
  1556. }
  1557. catch (const std::exception &e)
  1558. {
  1559. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1560. }
  1561. }
  1562. void CHttpBll::genIpLimit(CIpLimit *pIpLimit, const std::string &sResponse)
  1563. {
  1564. try
  1565. {
  1566. Json::Reader reader;
  1567. Json::Value jsonRoot = Json::Value::null;
  1568. if (!reader.parse(sResponse, jsonRoot))
  1569. {
  1570. pIpLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1571. myDebug() << pIpLimit->sMessage << sResponse.c_str();
  1572. }
  1573. pIpLimit->bLimited = jsonRoot["limited"].asBool();
  1574. }
  1575. catch (const std::exception &e)
  1576. {
  1577. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1578. }
  1579. }
  1580. void CHttpBll::genStartExam(CStartExam *pStartExam, const std::string &sResponse)
  1581. {
  1582. try
  1583. {
  1584. Json::Reader reader;
  1585. Json::Value jsonRoot = Json::Value::null;
  1586. if (!reader.parse(sResponse, jsonRoot))
  1587. {
  1588. pStartExam->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1589. myDebug() << pStartExam->sMessage << sResponse.c_str();
  1590. }
  1591. pStartExam->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  1592. pStartExam->sCourseName = jsonRoot["courseName"].asString().c_str();
  1593. pStartExam->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  1594. pStartExam->nFaceVerifyMinute = jsonRoot["faceVerifyMinute"].asInt();
  1595. pStartExam->sStudentCode = jsonRoot["studentCode"].asString().c_str();
  1596. pStartExam->sStudentName = jsonRoot["studentName"].asString().c_str();
  1597. }
  1598. catch (const std::exception &e)
  1599. {
  1600. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1601. }
  1602. }
  1603. void CHttpBll::genFaceCheckEnabled(CFaceCheckEnabled *pFaceCheckEnabled, const std::string &sResponse)
  1604. {
  1605. try
  1606. {
  1607. pFaceCheckEnabled->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::genLivenessEnabled(CLivenessEnabled *pLivenessEnabled, const std::string &sResponse)
  1615. {
  1616. try
  1617. {
  1618. pLivenessEnabled->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::genWeiXinAnswerEnabled(CWeiXinAnswerEnabled *pWeiXinAnswerEnabled, const std::string &sResponse)
  1626. {
  1627. try
  1628. {
  1629. pWeiXinAnswerEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
  1630. }
  1631. catch (const std::exception &e)
  1632. {
  1633. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1634. }
  1635. }
  1636. void CHttpBll::genGetExamById(CGetExamById *pGetExamById, const std::string &sResponse)
  1637. {
  1638. try
  1639. {
  1640. Json::Reader reader;
  1641. Json::Value jsonRoot = Json::Value::null;
  1642. if (!reader.parse(sResponse, jsonRoot))
  1643. {
  1644. pGetExamById->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1645. myDebug() << pGetExamById->sMessage << sResponse.c_str();
  1646. }
  1647. pGetExamById->nId = jsonRoot["id"].asInt64();
  1648. pGetExamById->sCode = jsonRoot["code"].asString().c_str();
  1649. pGetExamById->nRootOrgId = jsonRoot["rootOrgId"].asInt64();
  1650. pGetExamById->sBeginTime = jsonRoot["beginTime"].asString().c_str();
  1651. pGetExamById->sEndTime = jsonRoot["endTime"].asString().c_str();
  1652. pGetExamById->sName = jsonRoot["name"].asString().c_str();
  1653. pGetExamById->sExamType = jsonRoot["examType"].asString().c_str();
  1654. pGetExamById->nDuration = jsonRoot["duration"].asInt64();
  1655. pGetExamById->bEnable = jsonRoot["enable"].asBool();
  1656. pGetExamById->bStarted = jsonRoot["started"].asBool();
  1657. pGetExamById->bIpLimitSettingsEnabled = jsonRoot["ipLimitSettingsEnabled"].asBool();
  1658. }
  1659. catch (const std::exception &e)
  1660. {
  1661. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1662. }
  1663. }
  1664. void CHttpBll::genStartAnswer(CStartAnswer *pStartAnswer, const std::string &sResponse)
  1665. {
  1666. try
  1667. {
  1668. Json::Reader reader;
  1669. Json::Value jsonRoot = Json::Value::null;
  1670. if (!reader.parse(sResponse, jsonRoot))
  1671. {
  1672. pStartAnswer->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1673. myDebug() << pStartAnswer->sMessage << sResponse.c_str();
  1674. }
  1675. pStartAnswer->nDuration = jsonRoot["duration"].asInt64();
  1676. pStartAnswer->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  1677. pStartAnswer->nUsedExamSeconds = jsonRoot["usedExamSeconds"].asInt64();
  1678. }
  1679. catch (const std::exception &e)
  1680. {
  1681. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1682. }
  1683. }
  1684. void CHttpBll::genGetQuestion(CGetQuestion *pGetQuestion, const std::string &sResponse)
  1685. {
  1686. try
  1687. {
  1688. Json::Reader reader;
  1689. Json::Value jsonRoot = Json::Value::null;
  1690. if (!reader.parse(sResponse, jsonRoot))
  1691. {
  1692. pGetQuestion->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1693. myDebug() << pGetQuestion->sMessage << sResponse.c_str();
  1694. }
  1695. pGetQuestion->sId = jsonRoot["id"].asString().c_str();
  1696. pGetQuestion->sBody = jsonRoot["masterVersion"]["body"].isNull() ? "" : jsonRoot["masterVersion"]["body"].asString().c_str();
  1697. pGetQuestion->sVersion = jsonRoot["masterVersion"]["version"].asString().c_str();
  1698. pGetQuestion->bhasAudios = jsonRoot["masterVersion"]["hasAudios"].asBool();
  1699. int nSize = jsonRoot["masterVersion"]["questionUnitList"].size();
  1700. for (int i = 0; i < nSize; ++i)
  1701. {
  1702. Json::Value jQuestionItem = jsonRoot["masterVersion"]["questionUnitList"][i];
  1703. CSubQuestion sq;
  1704. sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1705. sq.sBody = jQuestionItem["body"].asString().c_str();
  1706. //sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1707. int nOptionSize = jQuestionItem["questionOptionList"].size();
  1708. for (int j = 0; j < nOptionSize; ++j)
  1709. {
  1710. Json::Value jOption = jQuestionItem["questionOptionList"][j];
  1711. COption o;
  1712. o.sBody = jOption["body"].asString().c_str();
  1713. sq.vOptions.push_back(o);
  1714. }
  1715. int nAnswerSize = jQuestionItem["rightAnswer"].size();
  1716. for (int k = 0; k < nAnswerSize; ++k)
  1717. {
  1718. Json::Value jAnswer = jQuestionItem["rightAnswer"][k];
  1719. sq.vRightAnswer.push_back(jAnswer.asString().c_str());
  1720. }
  1721. pGetQuestion->vSubQuestion.push_back(sq);
  1722. }
  1723. }
  1724. catch (const std::exception &e)
  1725. {
  1726. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1727. }
  1728. }
  1729. void CHttpBll::genGetQuestionContent(CGetQuestionContent *pGetQuestionContent, const std::string &sResponse)
  1730. {
  1731. try
  1732. {
  1733. Json::Reader reader;
  1734. Json::Value jsonRoot = Json::Value::null;
  1735. if (!reader.parse(sResponse, jsonRoot))
  1736. {
  1737. pGetQuestionContent->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1738. myDebug() << pGetQuestionContent->sMessage << sResponse.c_str();
  1739. }
  1740. pGetQuestionContent->sBody = jsonRoot["body"].isNull() ? "" : jsonRoot["body"].asString().c_str();
  1741. pGetQuestionContent->sVersion = jsonRoot["version"].asString().c_str();
  1742. pGetQuestionContent->bhasAudios = jsonRoot["hasAudios"].asBool();
  1743. int nSize = jsonRoot["questionUnitList"].size();
  1744. for (int i = 0; i < nSize; ++i)
  1745. {
  1746. Json::Value jQuestionItem = jsonRoot["questionUnitList"][i];
  1747. CSubQuestion sq;
  1748. sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  1749. sq.sBody = jQuestionItem["body"].asString().c_str();
  1750. sq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  1751. int nOptionSize = jQuestionItem["questionOptionList"].size();
  1752. for (int j = 0; j < nOptionSize; ++j)
  1753. {
  1754. Json::Value jOption = jQuestionItem["questionOptionList"][j];
  1755. COption o;
  1756. o.sBody = jOption["body"].asString().c_str();
  1757. sq.vOptions.push_back(o);
  1758. }
  1759. for (int jq = 0; jq < jQuestionItem["optionPermutation"].size(); ++jq)
  1760. {
  1761. Json::Value Item = jQuestionItem["optionPermutation"][jq];
  1762. sq.voptionPermutation.push_back(Item.asInt());
  1763. }
  1764. int nAnswerSize = jQuestionItem["rightAnswer"].size();
  1765. for (int k = 0; k < nAnswerSize; ++k)
  1766. {
  1767. Json::Value jAnswer = jQuestionItem["rightAnswer"][k];
  1768. sq.vRightAnswer.push_back(jAnswer.asString().c_str());
  1769. }
  1770. pGetQuestionContent->vSubQuestion.push_back(sq);
  1771. }
  1772. }
  1773. catch (const std::exception &e)
  1774. {
  1775. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1776. }
  1777. }
  1778. void CHttpBll::genExamCourseInfo(const Json::Value &jExamItem, CExamCourseInfo &eci)
  1779. {
  1780. try
  1781. {
  1782. eci.nAllowExamCount = jExamItem["allowExamCount"].asInt();
  1783. eci.bAppExamEnabled = jExamItem["appExamEnabled"].asBool();
  1784. eci.sCourseCode = jExamItem["courseCode"].asString().c_str();
  1785. eci.nCourseId = jExamItem["courseId"].asInt64();
  1786. eci.sCourseLevel = jExamItem["courseLevel"].asString().c_str();
  1787. eci.sCourseName = jExamItem["courseName"].asString().c_str();
  1788. eci.sEndTime = jExamItem["endTime"].asString().c_str();
  1789. eci.bExamCycleEnabled = jExamItem["examCycleEnabled"].asBool();
  1790. int nWeekSize = jExamItem["examCycleWeek"].size();
  1791. for(int i =0; i < nWeekSize; ++i)
  1792. {
  1793. eci.vExamCycleWeek.push_back(jExamItem["examCycleWeek"][i].asInt());
  1794. }
  1795. int nCycleTimeRangeSize = jExamItem["examCycleTimeRange"].size();
  1796. for(int i = 0; i < nCycleTimeRangeSize; ++i)
  1797. {
  1798. Json::Value jTimeRange = jExamItem["examCycleTimeRange"][i]["timeRange"];
  1799. int nTimeRangeSize = jTimeRange.size();
  1800. QStringList sTimeRangeList;
  1801. for(int j = 0; j < nTimeRangeSize; ++j)
  1802. {
  1803. sTimeRangeList<<jTimeRange[j].asString().c_str();
  1804. }
  1805. eci.sExamCycleTimeRange<<sTimeRangeList.join("~");
  1806. }
  1807. //eci.sCourseCode = jExamItem["examCycleTimeRange"].asString().c_str();
  1808. //eci.sCourseCode = jExamItem["examCycleWeek"].asString().c_str();
  1809. eci.nExamId = jExamItem["examId"].asInt64();
  1810. eci.sExamName = jExamItem["examName"].asString().c_str();
  1811. eci.sExamStatus = jExamItem["examStatus"].asString().c_str();
  1812. eci.nExamStudentId = jExamItem["examStudentId"].asInt64();
  1813. eci.bFaceCheck = jExamItem["faceCheck"].asBool();
  1814. eci.bFaceEnable = jExamItem["faceEnable"].asBool();
  1815. eci.sIdentityNumber = jExamItem["identityNumber"].asString().c_str();
  1816. eci.bIsFinished = jExamItem["isFinished"].asBool();
  1817. eci.bIsObjScoreView = jExamItem["isObjScoreView"].asBool();
  1818. eci.bIsPhotoUpload = jExamItem["isPhotoUpload"].asBool();
  1819. eci.nOrgId = jExamItem["orgId"].asInt64();
  1820. eci.sOrgName = jExamItem["orgName"].asString().c_str();
  1821. eci.nPaperMins = jExamItem["paperMins"].asInt();
  1822. eci.nRootOrgId = jExamItem["rootOrgId"].asInt64();
  1823. eci.sSpecialtyLevel = jExamItem["specialtyLevel"].asString().c_str();
  1824. eci.sSpecialtyName = jExamItem["specialtyName"].asString().c_str();
  1825. eci.sStartTime = jExamItem["startTime"].asString().c_str();
  1826. eci.sStudentCode = jExamItem["studentCode"].asString().c_str();
  1827. eci.sStudentName = jExamItem["studentName"].asString().c_str();
  1828. }
  1829. catch (const std::exception &e)
  1830. {
  1831. myServerLog()<<",exception error"<<e.what();
  1832. }
  1833. }
  1834. void CHttpBll::genQueryExamList(CQueryExamList *pQueryExamList, const std::string &sResponse)
  1835. {
  1836. try
  1837. {
  1838. Json::Reader reader;
  1839. Json::Value jsonRoot = Json::Value::null;
  1840. if (!reader.parse(sResponse, jsonRoot))
  1841. {
  1842. pQueryExamList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1843. myDebug() << pQueryExamList->sMessage << sResponse.c_str();
  1844. }
  1845. int nExamSize = jsonRoot.size();
  1846. for (int i = 0; i < nExamSize; ++i)
  1847. {
  1848. Json::Value jExamItem = jsonRoot[i];
  1849. CExamCourseInfo eci;
  1850. genExamCourseInfo(jExamItem, eci);
  1851. pQueryExamList->vOnlieExamList.push_back(eci);
  1852. }
  1853. }
  1854. catch (const std::exception &e)
  1855. {
  1856. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1857. }
  1858. }
  1859. void CHttpBll::genQueryExamEndList(CQueryExamEndList *pQueryExamEndList, const std::string &sResponse)
  1860. {
  1861. try
  1862. {
  1863. Json::Reader reader;
  1864. Json::Value jsonRoot = Json::Value::null;
  1865. if (!reader.parse(sResponse, jsonRoot))
  1866. {
  1867. pQueryExamEndList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1868. myDebug() << pQueryExamEndList->sMessage << sResponse.c_str();
  1869. }
  1870. int nExamSize = jsonRoot.size();
  1871. for (int i = 0; i < nExamSize; ++i)
  1872. {
  1873. Json::Value jExamItem = jsonRoot[i];
  1874. CExamCourseInfo eci;
  1875. genExamCourseInfo(jExamItem, eci);
  1876. pQueryExamEndList->vOnlieEndExamList.push_back(eci);
  1877. }
  1878. }
  1879. catch (const std::exception &e)
  1880. {
  1881. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1882. }
  1883. }
  1884. void CHttpBll::genQueryObjectiveScoreList(CQueryObjectiveScoreList *pQueryObjectiveScoreList, const std::string &sResponse)
  1885. {
  1886. try
  1887. {
  1888. Json::Reader reader;
  1889. Json::Value jsonRoot = Json::Value::null;
  1890. if (!reader.parse(sResponse, jsonRoot))
  1891. {
  1892. pQueryObjectiveScoreList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1893. myDebug() << pQueryObjectiveScoreList->sMessage << sResponse.c_str();
  1894. }
  1895. int nScoreSize = jsonRoot.size();
  1896. for (int i = 0; i < nScoreSize; ++i)
  1897. {
  1898. Json::Value jScore = jsonRoot[i];
  1899. CObjectiveScore os;
  1900. os.sEndTime = jScore["endTime"].asString().c_str();
  1901. os.nExamOrder = jScore["examOrder"].asInt();
  1902. os.nExamRecordDataId = jScore["examRecordDataId"].asInt64();
  1903. os.bIsAuditing = jScore["isAuditing"].asBool();
  1904. os.bIsExamEnded = jScore["isExamEnded"].asBool();
  1905. os.bIsIllegality = jScore["isIllegality"].asBool();
  1906. os.fObjectiveScore = jScore["objectiveScore"].asDouble();
  1907. os.sStartTime = jScore["startTime"].asString().c_str();
  1908. pQueryObjectiveScoreList->vObjectiveScore.push_back(os);
  1909. }
  1910. }
  1911. catch (const std::exception &e)
  1912. {
  1913. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1914. }
  1915. }
  1916. void CHttpBll::genQueryHomeworkList(CQueryHomeworkList *pQueryHomeworkList, const std::string &sResponse)
  1917. {
  1918. try
  1919. {
  1920. Json::Reader reader;
  1921. Json::Value jsonRoot = Json::Value::null;
  1922. if (!reader.parse(sResponse, jsonRoot))
  1923. {
  1924. pQueryHomeworkList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1925. myDebug() << pQueryHomeworkList->sMessage << sResponse.c_str();
  1926. }
  1927. int nExamSize = jsonRoot.size();
  1928. for (int i = 0; i < nExamSize; ++i)
  1929. {
  1930. Json::Value jExamItem = jsonRoot[i];
  1931. CExamCourseInfo eci;
  1932. genExamCourseInfo(jExamItem, eci);
  1933. pQueryHomeworkList->vHomeworkExamList.push_back(eci);
  1934. }
  1935. }
  1936. catch (const std::exception &e)
  1937. {
  1938. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1939. }
  1940. }
  1941. void CHttpBll::genQueryPracticeCourseList(CQueryPracticeCourseList *pQueryPracticeCourseList, const std::string &sResponse)
  1942. {
  1943. try
  1944. {
  1945. Json::Reader reader;
  1946. Json::Value jsonRoot = Json::Value::null;
  1947. if (!reader.parse(sResponse, jsonRoot))
  1948. {
  1949. pQueryPracticeCourseList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  1950. myDebug() << pQueryPracticeCourseList->sMessage << sResponse.c_str();
  1951. }
  1952. int nExamSize = jsonRoot.size();
  1953. for (int i = 0; i < nExamSize; ++i)
  1954. {
  1955. Json::Value jExamItem = jsonRoot[i];
  1956. CPracticeCourseInfo pci;
  1957. pci.fAveObjectiveAccuracy = jExamItem["aveObjectiveAccuracy"].asDouble();
  1958. pci.sCourseCode = jExamItem["courseCode"].asString().c_str();
  1959. pci.sCourseName = jExamItem["courseName"].asString().c_str();
  1960. pci.sEndTime = jExamItem["endTime"].asString().c_str();
  1961. pci.bExamCycleEnabled = jExamItem["examCycleEnabled"].asBool();
  1962. //pci.sExamCycleTimeRange = jExamItem["examCycleTimeRange"].asDouble();
  1963. //pci.sExamCycleWeek = jExamItem["examCycleWeek"].asDouble();
  1964. int nWeekSize = jExamItem["examCycleWeek"].size();
  1965. for(int i = 0; i < nWeekSize; ++i)
  1966. {
  1967. pci.vExamCycleWeek.push_back(jExamItem["examCycleWeek"][i].asInt());
  1968. }
  1969. int nCycleTimeRangeSize = jExamItem["examCycleTimeRange"].size();
  1970. for(int i = 0; i < nCycleTimeRangeSize; ++i)
  1971. {
  1972. Json::Value jTimeRange = jExamItem["examCycleTimeRange"][i]["timeRange"];
  1973. int nTimeRangeSize = jTimeRange.size();
  1974. QStringList sTimeRangeList;
  1975. for(int j = 0; j < nTimeRangeSize; ++j)
  1976. {
  1977. sTimeRangeList<<jTimeRange[j].asString().c_str();
  1978. }
  1979. pci.sExamCycleTimeRange<<sTimeRangeList.join("~");
  1980. }
  1981. pci.nExamId = jExamItem["examId"].asInt64();
  1982. pci.sExamName = jExamItem["examName"].asString().c_str();
  1983. pci.nExamStudentId = jExamItem["examStudentId"].asInt64();
  1984. pci.sExamType = jExamItem["examType"].asString().c_str();
  1985. pci.fMaxObjectiveAccuracy = jExamItem["maxObjectiveAccuracy"].asDouble();
  1986. pci.nPracticeCount = jExamItem["practiceCount"].asInt();
  1987. pci.fRecentObjectiveAccuracy = jExamItem["recentObjectiveAccuracy"].asDouble();
  1988. pci.sStartTime = jExamItem["startTime"].asString().c_str();
  1989. pci.sStudentCode = jExamItem["studentCode"].asString().c_str();
  1990. pci.sStudentName = jExamItem["studentName"].asString().c_str();
  1991. pQueryPracticeCourseList->vPracticeCourseInfo.push_back(pci);
  1992. }
  1993. }
  1994. catch (const std::exception &e)
  1995. {
  1996. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  1997. }
  1998. }
  1999. void CHttpBll::genQueryPracticeRecordList(CQueryPracticeRecordList *pQueryPracticeRecordList, const std::string &sResponse)
  2000. {
  2001. try
  2002. {
  2003. Json::Reader reader;
  2004. Json::Value jsonRoot = Json::Value::null;
  2005. if (!reader.parse(sResponse, jsonRoot))
  2006. {
  2007. pQueryPracticeRecordList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2008. myDebug() << pQueryPracticeRecordList->sMessage << sResponse.c_str();
  2009. }
  2010. int nSize = jsonRoot.size();
  2011. for (int i = 0; i < nSize; ++i)
  2012. {
  2013. Json::Value jPracticeItem = jsonRoot[i];
  2014. CPracticeRecord pr;
  2015. pr.sCourseCode = jPracticeItem["courseCode"].asString().c_str();
  2016. pr.sCourseName = jPracticeItem["courseName"].asString().c_str();
  2017. pr.sEndTime = jPracticeItem["endTime"].asString().c_str();
  2018. pr.sExamName = jPracticeItem["examName"].asString().c_str();
  2019. pr.nFailQuestionNum = jPracticeItem["failQuestionNum"].asInt();
  2020. pr.nId = jPracticeItem["id"].asInt64();
  2021. pr.nNotAnsweredCount = jPracticeItem["notAnsweredCount"].asInt();
  2022. pr.fObjectiveAccuracy = jPracticeItem["objectiveAccuracy"].asDouble();
  2023. pr.nObjectiveNum = jPracticeItem["objectiveNum"].asInt();
  2024. pr.sStartTime = jPracticeItem["startTime"].asString().c_str();
  2025. pr.nSuccQuestionNum = jPracticeItem["succQuestionNum"].asInt();
  2026. pr.nTotalQuestionCount = jPracticeItem["totalQuestionCount"].asInt();
  2027. pr.nUsedExamTime = jPracticeItem["usedExamTime"].asInt64();
  2028. pQueryPracticeRecordList->vPracticeRecordList.push_back(pr);
  2029. }
  2030. }
  2031. catch (const std::exception &e)
  2032. {
  2033. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2034. }
  2035. }
  2036. void CHttpBll::genGetPracticeDetailInfo(CGetPracticeDetailInfo *pGetPracticeDetailInfo, const std::string &sResponse)
  2037. {
  2038. try
  2039. {
  2040. Json::Reader reader;
  2041. Json::Value jsonRoot = Json::Value::null;
  2042. if (!reader.parse(sResponse, jsonRoot))
  2043. {
  2044. pGetPracticeDetailInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2045. myDebug() << pGetPracticeDetailInfo->sMessage << sResponse.c_str();
  2046. }
  2047. pGetPracticeDetailInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  2048. pGetPracticeDetailInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
  2049. pGetPracticeDetailInfo->nId = jsonRoot["id"].asInt64();
  2050. pGetPracticeDetailInfo->fObjectiveAccuracy = jsonRoot["objectiveAccuracy"].asDouble();
  2051. int nSize = jsonRoot["paperStructInfos"].size();
  2052. for (int i = 0; i < nSize; ++i)
  2053. {
  2054. Json::Value jPaperStructInfo = jsonRoot["paperStructInfos"][i];
  2055. CPracticePaperStructInfo ppsi;
  2056. ppsi.nCount = jPaperStructInfo["count"].asInt();
  2057. ppsi.nFailQuestionNum = jPaperStructInfo["failQuestionNum"].asInt();
  2058. ppsi.nIndex = jPaperStructInfo["index"].asInt();
  2059. ppsi.nNotAnsweredCount = jPaperStructInfo["notAnsweredCount"].asInt();
  2060. ppsi.nQuestionCount = jPaperStructInfo["questionCount"].asInt();
  2061. ppsi.sQuestionType = jPaperStructInfo["questionType"].asString().c_str();
  2062. ppsi.sScore = jPaperStructInfo["score"].asString().c_str();
  2063. ppsi.nSuccQuestionNum = jPaperStructInfo["succQuestionNum"].asInt();
  2064. ppsi.sTitle = jPaperStructInfo["title"].asString().c_str();
  2065. ppsi.fTotalScore = jPaperStructInfo["totalScore"].asDouble();
  2066. pGetPracticeDetailInfo->vPracticePaperStructList.push_back(ppsi);
  2067. }
  2068. }
  2069. catch (const std::exception &e)
  2070. {
  2071. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2072. }
  2073. }
  2074. void CHttpBll::genFindExamRecordDataEntity(CFindExamRecordDataEntity *pFindExamRecordDataEntity, const std::string &sResponse)
  2075. {
  2076. try
  2077. {
  2078. Json::Reader reader;
  2079. Json::Value jsonRoot = Json::Value::null;
  2080. if (!reader.parse(sResponse, jsonRoot))
  2081. {
  2082. pFindExamRecordDataEntity->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2083. myDebug() << pFindExamRecordDataEntity->sMessage << sResponse.c_str();
  2084. }
  2085. pFindExamRecordDataEntity->nExamId = jsonRoot["examRecord"]["examId"].asInt64();
  2086. pFindExamRecordDataEntity->sPaperType = jsonRoot["examRecord"]["paperType"].asString().c_str();
  2087. }
  2088. catch (const std::exception &e)
  2089. {
  2090. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2091. }
  2092. }
  2093. void CHttpBll::genGetExamRecordQuestions(CGetExamRecordQuestions *pGetExamRecordQuestions, const std::string &sResponse)
  2094. {
  2095. try
  2096. {
  2097. Json::Reader reader;
  2098. Json::Value jsonRoot = Json::Value::null;
  2099. if (!reader.parse(sResponse, jsonRoot))
  2100. {
  2101. pGetExamRecordQuestions->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2102. myDebug() << pGetExamRecordQuestions->sMessage << sResponse.c_str();
  2103. }
  2104. int nSize = jsonRoot["examQuestionEntities"].size();
  2105. for (int i = 0; i < nSize; ++i)
  2106. {
  2107. Json::Value jQuestionItem = jsonRoot["examQuestionEntities"][i];
  2108. CAnsweredQuestion aq;
  2109. aq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  2110. aq.sAudioPlayTimes = jQuestionItem["audioPlayTimes"].isNull() ? "" : jQuestionItem["audioPlayTimes"].asString().c_str();
  2111. aq.sCorrectAnswer = jQuestionItem["correctAnswer"].isNull() ? "" : jQuestionItem["correctAnswer"].asString().c_str();
  2112. //aq.sExamQuestionTempId = jQuestionItem["examQuestionTempId"].asString().c_str();
  2113. aq.nExamRecordDataId = jQuestionItem["examRecordDataId"].asInt64();
  2114. aq.bIsAnswer = jQuestionItem["isAnswer"].asBool();
  2115. //aq.bIsInMongo = jQuestionItem["isInMongo"].asBool();
  2116. aq.bIsSign = jQuestionItem["isSign"].asBool();
  2117. aq.nMainNumber = jQuestionItem["mainNumber"].asInt();
  2118. int nOptionSize = jQuestionItem["optionPermutation"].size();
  2119. for (int j = 0; j < nOptionSize; ++j)
  2120. {
  2121. aq.vOptionPermutation.push_back(jQuestionItem["optionPermutation"][i].asInt());
  2122. }
  2123. aq.nOrder = jQuestionItem["order"].asInt();
  2124. aq.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  2125. aq.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  2126. aq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  2127. aq.sStudentAnswer = jQuestionItem["studentAnswer"].asString().c_str();
  2128. aq.fStudentScore = jQuestionItem["studentScore"].asDouble();
  2129. pGetExamRecordQuestions->vExamRecordQuestions.push_back(aq);
  2130. }
  2131. }
  2132. catch (const std::exception &e)
  2133. {
  2134. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2135. }
  2136. }
  2137. void CHttpBll::genGetOfflineCourse(CGetOfflineCourse *pGetOfflineCourse, const std::string &sResponse)
  2138. {
  2139. try
  2140. {
  2141. Json::Reader reader;
  2142. Json::Value jsonRoot = Json::Value::null;
  2143. if (!reader.parse(sResponse, jsonRoot))
  2144. {
  2145. pGetOfflineCourse->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2146. myDebug() << pGetOfflineCourse->sMessage << sResponse.c_str();
  2147. }
  2148. int nSize = jsonRoot.size();
  2149. for (int i = 0; i < nSize; ++i)
  2150. {
  2151. Json::Value jCourseInfo = jsonRoot[i];
  2152. COfflineCourseInfo oci;
  2153. oci.sCourseCode = jCourseInfo["courseCode"].asString().c_str();
  2154. oci.sCourseLevel = jCourseInfo["courseLevel"].asString().c_str();
  2155. oci.sCourseName = jCourseInfo["courseName"].asString().c_str();
  2156. oci.sEndTime = jCourseInfo["endTime"].asString().c_str();
  2157. oci.nExamId = jCourseInfo["examId"].asInt64();
  2158. oci.sExamName = jCourseInfo["examName"].asString().c_str();
  2159. oci.nExamRecordDataId = jCourseInfo["examRecordDataId"].asInt64();
  2160. oci.nExamStudentId = jCourseInfo["examStudentId"].asInt64();
  2161. oci.bIsvalid = jCourseInfo["isvalid"].asBool();
  2162. oci.sOrgName = jCourseInfo["orgName"].asString().c_str();
  2163. oci.sPaperId = jCourseInfo["paperId"].asString().c_str();
  2164. oci.sSpecialtyName = jCourseInfo["specialtyName"].asString().c_str();
  2165. oci.sStartTime = jCourseInfo["startTime"].asString().c_str();
  2166. oci.sStatus = jCourseInfo["status"].asString().c_str();
  2167. oci.sStudentCode = jCourseInfo["studentCode"].asString().c_str();
  2168. oci.sStudentName = jCourseInfo["studentName"].asString().c_str();
  2169. int nFileSize = jCourseInfo["offlineFiles"].size();
  2170. for (int j = 0; j < nFileSize; ++j)
  2171. {
  2172. Json::Value jFileItem = jCourseInfo["offlineFiles"][j];
  2173. COfflineFileInfo ofi;
  2174. ofi.nExamRecordDataId = jFileItem["examRecordDataId"].asInt64();
  2175. ofi.sFileType = jFileItem["fileType"].asString().c_str();
  2176. ofi.nId = jFileItem["id"].asInt64();
  2177. ofi.sOfflineFileName = jFileItem["offlineFileName"].asString().c_str();
  2178. ofi.sOfflineFileUrl = jFileItem["offlineFileUrl"].asString().c_str();
  2179. ofi.sOriginalFileName = jFileItem["originalFileName"].asString().c_str();
  2180. ofi.sProperties = jFileItem["properties"].asString().c_str();
  2181. ofi.sSuffix = jFileItem["suffix"].asString().c_str();
  2182. oci.vOfflineFileInfo.push_back(ofi);
  2183. }
  2184. pGetOfflineCourse->vOfflineCourseInfo.push_back(oci);
  2185. }
  2186. }
  2187. catch (const std::exception &e)
  2188. {
  2189. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2190. }
  2191. }
  2192. void CHttpBll::genGetOffLineExamAnswerSheet(CGetOffLineExamAnswerSheet *pGetOffLineExamAnswerSheet, const std::string &sResponse)
  2193. {
  2194. pGetOffLineExamAnswerSheet->sAnswerSheetUrl = sResponse.c_str();
  2195. }
  2196. void CHttpBll::genGetOffLineExamPaper(CGetOffLineExamPaper *pGetOffLineExamPaper, const std::string &sResponse)
  2197. {
  2198. }
  2199. void CHttpBll::genPreviewOffLineExamPaper(CPreviewOffLineExamPaper *pPreviewOffLineExamPaper, const std::string &sResponse)
  2200. {
  2201. pPreviewOffLineExamPaper->sUrl = sResponse.c_str();
  2202. }
  2203. void CHttpBll::genCheckExamInProgress(CCheckExamInProgress *pCheckExamInProgress, const std::string &sResponse)
  2204. {
  2205. try
  2206. {
  2207. Json::Reader reader;
  2208. Json::Value jsonRoot = Json::Value::null;
  2209. if (!reader.parse(sResponse, jsonRoot))
  2210. {
  2211. pCheckExamInProgress->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2212. myDebug() << pCheckExamInProgress->sMessage << sResponse.c_str();
  2213. }
  2214. if (jsonRoot["data"].isNull())
  2215. {
  2216. pCheckExamInProgress->bHasExamInProgress = false;
  2217. }
  2218. else
  2219. {
  2220. pCheckExamInProgress->bHasExamInProgress = true;
  2221. pCheckExamInProgress->nInterruptNum = jsonRoot["data"]["interruptNum"].asInt();
  2222. pCheckExamInProgress->nMaxInterruptNum = jsonRoot["data"]["maxInterruptNum"].asInt();
  2223. pCheckExamInProgress->bIsExceed = jsonRoot["data"]["isExceed"].asBool();
  2224. pCheckExamInProgress->nExamRecordDataId = jsonRoot["data"]["examRecordDataId"].asInt64();
  2225. pCheckExamInProgress->nExamId = jsonRoot["data"]["examId"].asInt64();
  2226. pCheckExamInProgress->nUsedTime = jsonRoot["data"]["usedTime"].asInt64();
  2227. pCheckExamInProgress->nFaceVerifyMinute = jsonRoot["data"]["faceVerifyMinute"].asInt();
  2228. pCheckExamInProgress->sExamType = jsonRoot["data"]["examType"].asString().c_str();
  2229. }
  2230. }
  2231. catch (const std::exception &e)
  2232. {
  2233. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2234. }
  2235. }
  2236. void CHttpBll::genGetCourseInfo(CGetCourseInfo *pGetCourseInfo, const std::string &sResponse)
  2237. {
  2238. try
  2239. {
  2240. Json::Reader reader;
  2241. Json::Value jsonRoot = Json::Value::null;
  2242. if (!reader.parse(sResponse, jsonRoot))
  2243. {
  2244. pGetCourseInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2245. myDebug() << pGetCourseInfo->sMessage << sResponse.c_str();
  2246. }
  2247. pGetCourseInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
  2248. pGetCourseInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
  2249. }
  2250. catch (const std::exception &e)
  2251. {
  2252. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2253. }
  2254. }
  2255. void CHttpBll::genExamHeartbeat(CExamHeartbeat *pExamHeartbeat, const std::string &sResponse)
  2256. {
  2257. pExamHeartbeat->nLeftTime = QString(sResponse.c_str()).toLongLong();
  2258. }
  2259. void CHttpBll::genFindExamQuestionList(CFindExamQuestionList *pFindExamQuestionList, const std::string &sResponse)
  2260. {
  2261. try
  2262. {
  2263. Json::Reader reader;
  2264. Json::Value jsonRoot = Json::Value::null;
  2265. if (!reader.parse(sResponse, jsonRoot))
  2266. {
  2267. pFindExamQuestionList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2268. myDebug() << pFindExamQuestionList->sMessage << sResponse.c_str();
  2269. }
  2270. int nSize = jsonRoot.size();
  2271. for (int i = 0; i < nSize; ++i)
  2272. {
  2273. Json::Value jQuestionItem = jsonRoot[i];
  2274. CAnsweredQuestion aq;
  2275. aq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
  2276. aq.sAudioPlayTimes = jQuestionItem["audioPlayTimes"].isNull() ? "" :jQuestionItem["audioPlayTimes"].asString().c_str();
  2277. aq.sCorrectAnswer = jQuestionItem["correctAnswer"].isNull() ? "" : jQuestionItem["correctAnswer"].asString().c_str();
  2278. aq.sExamQuestionTempId = jQuestionItem["examQuestionTempId"].asString().c_str();
  2279. aq.nExamRecordDataId = jQuestionItem["examRecordDataId"].asInt64();
  2280. aq.bIsAnswer = jQuestionItem["isAnswer"].asBool();
  2281. aq.bIsInMongo = jQuestionItem["isInMongo"].asBool();
  2282. aq.bIsSign = jQuestionItem["isSign"].asBool();
  2283. aq.nMainNumber = jQuestionItem["mainNumber"].asInt();
  2284. int nOptionSize = jQuestionItem["optionPermutation"].size();
  2285. for (int j = 0; j < nOptionSize; ++j)
  2286. {
  2287. aq.vOptionPermutation.push_back(jQuestionItem["optionPermutation"][i].asInt());
  2288. }
  2289. aq.nOrder = jQuestionItem["order"].asInt();
  2290. aq.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  2291. aq.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  2292. aq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
  2293. aq.sStudentAnswer = jQuestionItem["studentAnswer"].asString().c_str();
  2294. aq.fStudentScore = jQuestionItem["studentScore"].asDouble();
  2295. pFindExamQuestionList->vAnsweredQuestion.push_back(aq);
  2296. }
  2297. }
  2298. catch (const std::exception &e)
  2299. {
  2300. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2301. }
  2302. }
  2303. void CHttpBll::genGetExamRecordPaperStruct(CGetExamRecordPaperStruct *pGetExamRecordPaperStruct, const std::string &sResponse)
  2304. {
  2305. try
  2306. {
  2307. Json::Reader reader;
  2308. Json::Value jsonRoot = Json::Value::null;
  2309. if (!reader.parse(sResponse, jsonRoot))
  2310. {
  2311. pGetExamRecordPaperStruct->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2312. myDebug() << pGetExamRecordPaperStruct->sMessage << sResponse.c_str();
  2313. }
  2314. pGetExamRecordPaperStruct->sPaperId = jsonRoot["id"].asString().c_str();
  2315. pGetExamRecordPaperStruct->sPaperName = jsonRoot["defaultPaper"]["name"].asString().c_str();
  2316. pGetExamRecordPaperStruct->bFullyObjective = jsonRoot["defaultPaper"]["fullyObjective"].asBool();
  2317. int nGroupSize = jsonRoot["defaultPaper"]["questionGroupList"].size();
  2318. int nOrder = 1;
  2319. for (int i = 0; i < nGroupSize; ++i)
  2320. {
  2321. Json::Value jGroupItem = jsonRoot["defaultPaper"]["questionGroupList"][i];
  2322. CPaperGroupStruct pgs;
  2323. pgs.sGroupName = jGroupItem["groupName"].asString().c_str();
  2324. pgs.fGroupScore = jGroupItem["groupScore"].asDouble();
  2325. pgs.nNumber = i + 1;
  2326. int nQuestionSize = jGroupItem["questionWrapperList"].size();
  2327. int nShowIndex = 1;
  2328. int nTotalSubquestion = 0;
  2329. for (int j = 0; j < nQuestionSize; ++j)
  2330. {
  2331. Json::Value jQuestionItem = jGroupItem["questionWrapperList"][j];
  2332. CQuestionStruct qs;
  2333. qs.sQuestionId = jQuestionItem["questionId"].asString().c_str();
  2334. qs.sVersion = jQuestionItem["version"].asString().c_str();
  2335. qs.fQuestionScore = jQuestionItem["questionScore"].asDouble();
  2336. qs.nLimitedPlayTimes = jQuestionItem["limitedPlayTimes"].asInt();
  2337. qs.nPlayedTimes = jQuestionItem["playedTimes"].asInt();
  2338. qs.nTimeLimit = jQuestionItem["timeLimit"].asInt();
  2339. int mSubQuestionSize = jQuestionItem["questionUnitWrapperList"].size();
  2340. nTotalSubquestion += mSubQuestionSize;
  2341. for (int k = 0; k < mSubQuestionSize; ++k)
  2342. {
  2343. Json::Value jSubQuestionItem = jQuestionItem["questionUnitWrapperList"][k];
  2344. CSubQuestionStruct sqs;
  2345. sqs.sQuestionType = jSubQuestionItem["questionType"].asString().c_str();
  2346. sqs.sAnswerType = jSubQuestionItem["answerType"].asString().c_str();
  2347. sqs.fQuestionScore = jSubQuestionItem["questionScore"].asDouble();
  2348. sqs.nLimitedPlayTimes = qs.nLimitedPlayTimes;
  2349. for (int jq = 0; jq < jSubQuestionItem["optionPermutation"].size(); ++jq)
  2350. {
  2351. Json::Value Item = jSubQuestionItem["optionPermutation"][jq];
  2352. sqs.voptionPermutation.push_back(Item.asInt());
  2353. }
  2354. sqs.nShowNumber = nShowIndex;
  2355. sqs.nOrder = nOrder;
  2356. nShowIndex++;
  2357. nOrder++;
  2358. qs.vSubQuestionStruct.push_back(sqs);
  2359. }
  2360. pgs.vQuestionStruct.push_back(qs);
  2361. }
  2362. pgs.nTotalSubquestion = nTotalSubquestion;
  2363. pGetExamRecordPaperStruct->vPaperGroupStruct.push_back(pgs);
  2364. }
  2365. }
  2366. catch (const std::exception &e)
  2367. {
  2368. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2369. }
  2370. }
  2371. void CHttpBll::genGetEndExamInfo(CGetEndExamInfo *pGetEndExamInfo, const std::string &sResponse)
  2372. {
  2373. try
  2374. {
  2375. if (sResponse == "")
  2376. {
  2377. pGetEndExamInfo->bIsCalculate = true;
  2378. return;
  2379. }
  2380. Json::Reader reader;
  2381. Json::Value jsonRoot = Json::Value::null;
  2382. if (!reader.parse(sResponse, jsonRoot))
  2383. {
  2384. pGetEndExamInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2385. myDebug() << pGetEndExamInfo->sMessage << sResponse.c_str();
  2386. }
  2387. pGetEndExamInfo->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
  2388. pGetEndExamInfo->bIsWarn = jsonRoot["isWarn"].asBool();
  2389. pGetEndExamInfo->fObjectiveAccuracy = jsonRoot["objectiveAccuracy"].asDouble();
  2390. pGetEndExamInfo->fObjectiveScore = jsonRoot["objectiveScore"].asInt64();
  2391. }
  2392. catch (const std::exception &e)
  2393. {
  2394. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2395. }
  2396. }
  2397. void CHttpBll::genGetWXQrCode(CGetWXQrCode *pGetWXQrCode, const std::string &sResponse)
  2398. {
  2399. pGetWXQrCode->sUrl = sResponse.c_str();
  2400. }
  2401. //void CHttpBll::genProcessUpload(CProcessUpload *pProcessUpload, const std::string &sResponse)
  2402. //{
  2403. // try
  2404. // {
  2405. // Json::Reader reader;
  2406. // Json::Value jsonRoot = Json::Value::null;
  2407. // if (!reader.parse(sResponse, jsonRoot))
  2408. // {
  2409. // pProcessUpload->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2410. // myDebug() << pProcessUpload->sMessage << sResponse.c_str();
  2411. // }
  2412. // pProcessUpload->sFileUrl = jsonRoot["fileUrl"].asString().c_str();
  2413. // }
  2414. // catch (const std::exception &e)
  2415. // {
  2416. // myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2417. // }
  2418. //}
  2419. void CHttpBll::genGetOrgPropertiesByGroupWithoutCache(CGetOrgPropertiesByGroupWithoutCache *pOrgProperties, const std::string &sResponse)
  2420. {
  2421. try
  2422. {
  2423. Json::Reader reader;
  2424. Json::Value jsonRoot = Json::Value::null;
  2425. if (!reader.parse(sResponse, jsonRoot))
  2426. {
  2427. pOrgProperties->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2428. myDebug() << pOrgProperties->sMessage << sResponse.c_str();
  2429. }
  2430. pOrgProperties->nActionNum = QVariant(jsonRoot["ACTION_NUM"].asString().c_str()).toInt();
  2431. pOrgProperties->sActionOptions = jsonRoot["ACTION_OPTIONS"].asString().c_str();
  2432. pOrgProperties->sActionOrder = jsonRoot["ACTION_ORDER"].asString().c_str();
  2433. pOrgProperties->nActionDuration = QVariant(jsonRoot["ACTION_DURATION"].asString().c_str()).toInt();
  2434. pOrgProperties->nActionAlert = QVariant(jsonRoot["ACTION_ALERT"].asString().c_str()).toInt();
  2435. pOrgProperties->nAllActionDuration = QVariant(jsonRoot["ALL_ACTION_DURATION"].asString().c_str()).toInt();
  2436. if(jsonRoot.isMember("PC_CLIENT_FACE_THRESHOLD"))
  2437. {
  2438. pOrgProperties->nFaceThreshold = QVariant(jsonRoot["PC_CLIENT_FACE_THRESHOLD"].asString().c_str()).toInt();
  2439. }
  2440. }
  2441. catch (const std::exception &e)
  2442. {
  2443. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2444. }
  2445. }
  2446. void CHttpBll::genStartFaceLiveVerify(CStartFaceLiveVerify *pStartFaceLiveVerify, const std::string &sResponse)
  2447. {
  2448. try
  2449. {
  2450. Json::Reader reader;
  2451. Json::Value jsonRoot = Json::Value::null;
  2452. if (!reader.parse(sResponse, jsonRoot))
  2453. {
  2454. pStartFaceLiveVerify->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2455. myDebug() << pStartFaceLiveVerify->sMessage << sResponse.c_str();
  2456. }
  2457. pStartFaceLiveVerify->nFaceLiveVerifyId = jsonRoot["faceLiveVerifyId"].asInt64();
  2458. pStartFaceLiveVerify->nStartMinute = jsonRoot["startMinute"].asInt();
  2459. pStartFaceLiveVerify->nTimes = jsonRoot["times"].asInt();
  2460. }
  2461. catch (const std::exception &e)
  2462. {
  2463. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2464. }
  2465. }
  2466. void CHttpBll::genClientExamProcessUploadSign(CClientExamProcessUploadSign *pClientExamProcessUploadSign, const std::string &sResponse)
  2467. {
  2468. try
  2469. {
  2470. Json::Reader reader;
  2471. Json::Value jsonRoot = Json::Value::null;
  2472. if (!reader.parse(sResponse, jsonRoot))
  2473. {
  2474. pClientExamProcessUploadSign->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
  2475. myDebug() << pClientExamProcessUploadSign->sMessage << sResponse.c_str();
  2476. }
  2477. pClientExamProcessUploadSign->sType = jsonRoot["fsType"].asString().c_str();
  2478. pClientExamProcessUploadSign->sAccessUrl = jsonRoot["accessUrl"].asString().c_str();
  2479. pClientExamProcessUploadSign->sSignIdentifier = jsonRoot["signIdentifier"].asString().c_str();
  2480. pClientExamProcessUploadSign->sFormUrl = jsonRoot["formUrl"].asString().c_str();
  2481. pClientExamProcessUploadSign->sOssAcessKeyId = jsonRoot["formParams"]["OSSAccessKeyId"].asString().c_str();
  2482. pClientExamProcessUploadSign->sSignature = jsonRoot["formParams"]["Signature"].asString().c_str();
  2483. pClientExamProcessUploadSign->sKey = jsonRoot["formParams"]["key"].asString().c_str();
  2484. pClientExamProcessUploadSign->sPolicy = jsonRoot["formParams"]["policy"].asString().c_str();
  2485. }
  2486. catch (const std::exception &e)
  2487. {
  2488. myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
  2489. }
  2490. }