12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270 |
- #include "CHttpBll.h"
- #include <QCryptographicHash>
- #include <QTextCodec>
- #include "logproc.h"
- std::shared_ptr<CHttpBll> g_httpBllPtr = nullptr;
- CHttpBll::CHttpBll()
- {
- sKey = "";
- sToken = "";
- }
- QString CHttpBll::getAuthorization(QString sUri, QString sTimeStamp)
- {
- if(sToken != "")
- {
- QString sAuthorization = "post&" +
- sUri + "&" + sTimeStamp + "&" + sToken;
- QByteArray sha1 = QCryptographicHash::hash(sAuthorization.toLatin1(), QCryptographicHash::Sha1);
- QByteArray shaResult = sha1;
- sAuthorization = "Token " + sKey + ":" + shaResult.toBase64().data();
- return sAuthorization;
- // return sAccessToken;
- }
- return "";
- }
- QString CHttpBll::getToken()
- {
- return sToken;
- }
- QString CHttpBll::getKey()
- {
- return sKey;
- }
- void CHttpBll::requestProc(CHttpRequestPackage requestPkg)
- {
-
- // QString sTimeStamp = QString::number(g_AppInfo->timestamp());
- // requestPkg.sHeadList.push_back(QString::fromLocal8Bit("platform,%1").arg("WEB"));
- // requestPkg.sHeadList.push_back(QString::fromLocal8Bit("deviceId,%1").arg(g_AppInfo->sMachineId));
- // requestPkg.sHeadList.push_back(QString::fromLocal8Bit("time,%1").arg(sTimeStamp));
- requestPkg.sHeadList.push_back(QString::fromLocal8Bit("Referer,%1").arg(requestPkg.sUri));
- 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"));
- if(sToken != "")
- {
- requestPkg.sHeadList.push_back(QString::fromLocal8Bit("key,%1").arg(sKey));
- requestPkg.sHeadList.push_back(QString::fromLocal8Bit("token,%1").arg(sToken));
- // requestPkg.sHeadList.push_back(QString::fromLocal8Bit("Authorization,%1").arg(getAuthorization(requestPkg.sUri, sTimeStamp)));
- }
- __int64 nStartTime = g_appInfoPtr->serverMTime();
- initHeads(requestPkg);
- QString sErrorMsg = "";
- std::string sResponse = "";
- int nCode = 0;
- if (requestPkg.nHttpType == HttpType::htDownload)
- {
- requestPkg.sUri = requestPkg.sUri.replace("\\", "/");
- if (!downLoadFile(requestPkg.sUri.toLocal8Bit().data(), requestPkg.sCommonStr.toLocal8Bit().data(), nCode))
- {
- --requestPkg.nRetryCount;
- if(requestPkg.nRetryCount > 0)
- {
- downLoad(requestPkg);
- return;
- }
- sErrorMsg = QString::fromLocal8Bit("%1下载失败!").arg(requestPkg.sUri);
- }
- }
- if(requestPkg.nHttpType == HttpType::htPost)
- {
- if(!doPost(requestPkg, sResponse, nCode))
- {
- sErrorMsg = QString::fromLocal8Bit("接口%1调用失败!").arg(requestPkg.sUri);
- }
- }
- else if(requestPkg.nHttpType == HttpType::htGet || requestPkg.nHttpType == HttpType::htGetUrl)
- {
- if(!doGet(requestPkg, sResponse, nCode))
- {
- sErrorMsg = QString::fromLocal8Bit("接口%1调用失败!").arg(requestPkg.sUri);
- }
- }
- else if (requestPkg.nHttpType == HttpType::htPut)
- {
- if (!doPut(requestPkg, sResponse, nCode))
- {
- sErrorMsg = QString::fromLocal8Bit("接口%1调用失败!").arg(requestPkg.sUri);
- }
- }
- __int64 nEndTime = g_appInfoPtr->serverMTime();
- myServerLog()<< requestPkg.sUri << ":resCode," << nCode<<"response:"<<sResponse.c_str() << "requestTime(ms):" << nEndTime - nStartTime;
- myDebug() << requestPkg.sUri << ":"<< sResponse.c_str();
- if (nCode != 200)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (reader.parse(sResponse, jsonRoot))
- {
- if (jsonRoot.isMember("desc"))
- {
- sErrorMsg = jsonRoot["desc"].asString().c_str();
- }
- }
- }
- if (nCode == 403)
- {
- emit sgnTokenExpired();
- return;
- }
- switch(requestPkg.nRequestType)
- {
- case RequestType::rtUpgrade://客户端版本升级接口
- {
- CUpgrade upgrade;
- upgrade.nCode = nCode;
- if(sErrorMsg != "" || nCode !=200)
- {
- upgrade.sMessage = sErrorMsg;
- }
- else
- {
- genUpgrade(&upgrade, sResponse);
- }
- emit sgnUpgrade(upgrade);
- }
- break;
- case RequestType::rtSysNotice://客户端版本升级接口
- {
- CSysNotice sn;
- sn.nCode = nCode;
- if(sErrorMsg != "" || nCode !=200)
- {
- sn.sMessage = sErrorMsg;
- }
- else
- {
- genSysNotice(&sn, sResponse);
- }
- emit sgnSysNotice(sn);
- }
- break;
- case RequestType::rtGetSoftwareConfig:
- {
- CGetSoftwareConfig gsc;
- gsc.nCode = nCode;
- if(sErrorMsg != "" || nCode !=200)
- {
- gsc.sMessage = sErrorMsg;
- }
- else
- {
- genSoftwareConfig(&gsc, sResponse);
- }
- emit sgnGetSoftwareConfig(gsc);
- }
- break;
- case RequestType::rtDownLoadFile:
- {
- CDownLoadFileInfo dfi;
- dfi.sFileName = requestPkg.sCommonStr;
- dfi.sModuleName = requestPkg.sCommonStr1;
- dfi.sAdditionStr = requestPkg.sAdditionStr;
- dfi.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- dfi.sMessage = sErrorMsg;
- }
- emit sgnDownLoadFile(dfi);
- }
- break;
- case RequestType::rtStudentClientConfig:
- {
- CStudentClientConfig scc;
- scc.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- scc.sMessage = sErrorMsg;
- }
- else
- {
- genStudentClientConfig(&scc, sResponse);
- }
- emit sgnStudentClientConfig(scc);
- }
- break;
- case RequestType::rtLoginLimit:
- {
- CLoginLimit ll;
- ll.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- ll.sMessage = sErrorMsg;
- }
- else
- {
- genLoginLimit(&ll, sResponse);
- }
- emit sgnLoginLimit(ll);
- }
- break;
- case RequestType::rtLogin://登录
- {
- CLoginInfo li;
- li.nCode = nCode;
- if(sErrorMsg != "" || nCode != 200)
- {
- li.sMessage = sErrorMsg;
- }
- else
- {
- genLoginInfo(&li, sResponse);
- }
- emit sgnLoginInfo(li);
- }
- break;
- case RequestType::rtLogout:
- {
- CLogout logout;
- logout.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- logout.sMessage = sErrorMsg;
- }
- else
- {
- genLogout(&logout, sResponse);
- }
- emit sgnLogout(logout);
- }
- break;
- case RequestType::rtAgreement:
- {
- CAgreement agm;
- agm.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- agm.sMessage = sErrorMsg;
- }
- else
- {
- genAgreement(&agm, sResponse);
- }
- emit sgnAgreement(agm);
- }
- break;
- case RequestType::rtGetStudentInfoBySession:
- {
- CGetStudentInfoBySession gsibs;
- gsibs.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gsibs.sMessage = sErrorMsg;
- }
- else
- {
- genGetStudentInfoBySession(&gsibs, sResponse);
- }
- emit sgnGetStudentInfoBySession(gsibs);
- }
- break;
- case RequestType::rtSpecialtyNameList:
- {
- CSpecialtyNameList snl;
- snl.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- snl.sMessage = sErrorMsg;
- }
- else
- {
- genSpecialtyNameList(&snl, sResponse);
- }
- emit sgnSpecialtyNameList(snl);
- }
- break;
- case RequestType::rtCheckExamInProgress:
- {
- CCheckExamInProgress ceip;
- ceip.nCode = nCode;
- ceip.sEnterType = requestPkg.sCommonStr;
- if (sErrorMsg != "" || nCode != 200)
- {
- ceip.sMessage = sErrorMsg;
- }
- else
- {
- genCheckExamInProgress(&ceip, sResponse);
- }
- emit sgnCheckExamInProgress(ceip);
- }
- break;
- case RequestType::rtGetStudentClientMenu:
- {
- CGetStudentClientMenu gcm;
- gcm.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gcm.sMessage = sErrorMsg;
- }
- else
- {
- genGetStudentClientMenu(&gcm, sResponse);
- }
- emit sgnGetStudentClientMenu(gcm);
- }
- break;
- case RequestType::rtAppDownLoadUrl:
- {
- CAppDownLoadUrl adlu;
- adlu.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- adlu.sMessage = sErrorMsg;
- }
- else
- {
- genAppDownLoadUrl(&adlu, sResponse);
- }
- emit sgnAppDownLoadUrl(adlu);
- }
- break;
- case RequestType::rtGetUserNoticeList:
- {
- CGetUserNoticeList gunl;
- gunl.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gunl.sMessage = sErrorMsg;
- }
- else
- {
- genGetUserNoticeList(&gunl, sResponse);
- }
- emit sgnGetUserNoticeList(gunl);
- }
- break;
- case RequestType::rtUpdateNoticeReadStatus:
- {
- CUpdateNoticeReadStatus unrs;
- unrs.nCode = nCode;
- unrs.sIds = requestPkg.sCommonStr;
- if (sErrorMsg != "" || nCode != 200)
- {
- unrs.sMessage = sErrorMsg;
- }
- emit sgnUpdateNoticeReadStatus(unrs);
- }
- break;
- case RequestType::rtQueryExamList:
- {
- CQueryExamList qel;
- qel.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- qel.sMessage = sErrorMsg;
- }
- else
- {
- genQueryExamList(&qel, sResponse);
- }
- emit sgnQueryExamList(qel);
- }
- break;
- case RequestType::rtQueryExamEndList:
- {
- CQueryExamEndList qeel;
- qeel.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- qeel.sMessage = sErrorMsg;
- }
- else
- {
- genQueryExamEndList(&qeel, sResponse);
- }
- emit sgnQueryExamEndList(qeel);
- }
- break;
- case RequestType::rtQueryHomeworkList:
- {
- CQueryHomeworkList qhl;
- qhl.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- qhl.sMessage = sErrorMsg;
- }
- else
- {
- genQueryHomeworkList(&qhl, sResponse);
- }
- emit sgnQueryHomeworkList(qhl);
- }
- break;
-
- case RequestType::rtQueryBatchList:
- {
- CQueryBatchList qbl;
- qbl.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- qbl.sMessage = sErrorMsg;
- }
- else
- {
- genQueryBatchList(&qbl, sResponse);
- }
- emit sgnQueryBatchList(qbl);
- }
- break;
- case RequestType::rtQueryPracticeCourseList:
- {
- CQueryPracticeCourseList qpcl;
- qpcl.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- qpcl.sMessage = sErrorMsg;
- }
- else
- {
- genQueryPracticeCourseList(&qpcl, sResponse);
- }
- emit sgnQueryPracticeCourseList(qpcl);
- }
- break;
- case RequestType::rtQueryPracticeRecordList:
- {
- CQueryPracticeRecordList qprl;
- qprl.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- qprl.sMessage = sErrorMsg;
- }
- else
- {
- genQueryPracticeRecordList(&qprl, sResponse);
- }
- emit sgnQueryPracticeRecordList(qprl);
- }
- break;
- case RequestType::rtGetPracticeDetailInfo:
- {
- CGetPracticeDetailInfo gpdi;
- gpdi.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gpdi.sMessage = sErrorMsg;
- }
- else
- {
- genGetPracticeDetailInfo(&gpdi, sResponse);
- }
- emit sgnGetPracticeDetailInfo(gpdi);
- }
- break;
- case RequestType::rtFindExamRecordDataEntity:
- {
- CFindExamRecordDataEntity ferde;
- ferde.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- ferde.sMessage = sErrorMsg;
- }
- else
- {
- genFindExamRecordDataEntity(&ferde, sResponse);
- }
- emit sgnFindExamRecordDataEntity(ferde);
- }
- break;
- case RequestType::rtGetCourseInfo:
- {
- CGetCourseInfo gci;
- gci.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gci.sMessage = sErrorMsg;
- }
- else
- {
- genGetCourseInfo(&gci, sResponse);
- }
- emit sgnGetCourseInfo(gci);
- }
- break;
- case RequestType::rtGetExamRecordQuestions:
- {
- CGetExamRecordQuestions gerq;
- gerq.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gerq.sMessage = sErrorMsg;
- }
- else
- {
- genGetExamRecordQuestions(&gerq, sResponse);
- }
- emit sgnGetExamRecordQuestions(gerq);
- }
- break;
- case RequestType::rtGetQuestion:
- {
- CGetQuestion gq;
- gq.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gq.sMessage = sErrorMsg;
- }
- else
- {
- genGetQuestion(&gq, sResponse);
- }
- emit sgnGetQuestion(gq);
- }
- break;
- case RequestType::rtGetOfflineCourse:
- {
- CGetOfflineCourse goc;
- goc.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- goc.sMessage = sErrorMsg;
- }
- else
- {
- genGetOfflineCourse(&goc, sResponse);
- }
- emit sgnGetOfflineCourse(goc);
- }
- break;
- case RequestType::rtGetOffLineExamAnswerSheet:
- {
- CGetOffLineExamAnswerSheet goeas;
- goeas.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- goeas.sMessage = sErrorMsg;
- }
- else
- {
- genGetOffLineExamAnswerSheet(&goeas, sResponse);
- }
- emit sgnGetOffLineExamAnswerSheet(goeas);
- }
- break;
- case RequestType::rtStartOfflineExam:
- {
- CStartOfflineExam soe;
- soe.nCode = nCode;
- soe.nRow = requestPkg.sCommonStr.toInt();
- if (sErrorMsg != "" || nCode != 200)
- {
- soe.sMessage = sErrorMsg;
- }
-
- emit sgnStartOfflineExam(soe);
- }
- break;
- case RequestType::rtGetOffLineExamPaper:
- {
- CGetOffLineExamPaper goep;
- goep.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- goep.sMessage = sErrorMsg;
- }
- else
- {
- QFile file(requestPkg.sCommonStr);
- if (file.open(QIODevice::WriteOnly))
- {
- qint64 nLen = file.write(sResponse.c_str(), sResponse.length());
- file.close();
- if (nLen != sResponse.length())
- {
- goep.nCode = 0;
- goep.sMessage = QString::fromLocal8Bit("保存试卷失败");
- }
- }
- else
- {
- goep.nCode = 0;
- goep.sMessage = QString::fromLocal8Bit("创建试卷失败");
- }
- genGetOffLineExamPaper(&goep, sResponse);
- }
- emit sgnGetOffLineExamPaper(goep);
- }
- break;
- case RequestType::rtPreviewOffLineExamPaper:
- {
- CPreviewOffLineExamPaper poep;
- poep.nCode = nCode;
- poep.nRow = requestPkg.sCommonStr.toInt();
- if (sErrorMsg != "" || nCode != 200)
- {
- poep.sMessage = sErrorMsg;
- }
- else
- {
- genPreviewOffLineExamPaper(&poep, sResponse);
- }
- emit sgnPreviewOffLineExamPaper(poep);
- }
- break;
- case RequestType::rtSubmitOfflinePaper:
- {
- CSubmitOfflinePaper sop;
- sop.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- sop.sMessage = sErrorMsg;
- }
- emit sgnSubmitOfflinePaper(sop);
- }
- break;
- case RequestType::rtQueryObjectiveScoreList:
- {
- CQueryObjectiveScoreList qosl;
- qosl.nCode = nCode;
- qosl.sExamStudentId = requestPkg.sCommonStr;
- if (sErrorMsg != "" || nCode != 200)
- {
- qosl.sMessage = sErrorMsg;
- }
- else
- {
- genQueryObjectiveScoreList(&qosl, sResponse);
- }
- emit sgnQueryObjectiveScoreList(qosl);
- }
- break;
- case RequestType::rtEditPassword:
- {
- CEditPassword ep;
- ep.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- ep.sMessage = sErrorMsg;
-
-
- }
- else
- {
- genEditPassword(&ep, sResponse);
- }
- emit sgnEditPassword(ep);
- }
- break;
- case RequestType::rtStartExamLimit:
- {
- CStartExamLimit sel;
- sel.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- sel.sMessage = sErrorMsg;
- }
- else
- {
- genStartExamLimit(&sel, sResponse);
- }
- emit sgnStartExamLimit(sel);
- }
- break;
- case RequestType::rtIpLimit:
- {
- CIpLimit il;
- il.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- il.sMessage = sErrorMsg;
- }
- else
- {
- genIpLimit(&il, sResponse);
- }
- emit sgnIpLimit(il);
- }
- break;
- case RequestType::rtGetExamProperty:
- {
- CGetExamProperty ep;
- ep.nCode = nCode;
- ep.sType = requestPkg.sCommonStr;
- if (sErrorMsg != "" || nCode != 200)
- {
- ep.sMessage = sErrorMsg;
- }
- else
- {
- genGetExamProperty(&ep, sResponse);
- }
- emit sgnGetExamProperty(ep);
- }
- break;
- case RequestType::rtFaceCheckEnabled:
- {
- CFaceCheckEnabled fce;
- fce.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- fce.sMessage = sErrorMsg;
- }
- else
- {
- genFaceCheckEnabled(&fce, sResponse);
- }
- emit sgnFaceCheckEnabled(fce);
- }
- break;
-
- case RequestType::rtLivenessEnabled:
- {
- CLivenessEnabled le;
- le.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- le.sMessage = sErrorMsg;
- }
- else
- {
- genLivenessEnabled(&le, sResponse);
- }
- emit sgnLivenessEnabled(le);
- }
- break;
- case RequestType::rtStartExam:
- {
- CStartExam se;
- se.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- se.sMessage = sErrorMsg;
- }
- else
- {
- genStartExam(&se, sResponse);
- }
- emit sgnStartExam(se);
- }
- break;
- case RequestType::rtGetExamRecordPaperStruct:
- {
- CGetExamRecordPaperStruct eps;
- eps.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- eps.sMessage = sErrorMsg;
- }
- else
- {
- genGetExamRecordPaperStruct(&eps, sResponse);
- }
- emit sgnGetExamRecordPaperStruct(eps);
- }
- break;
- case RequestType::rtGetExamById:
- {
- CGetExamById examInfo;
- examInfo.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- examInfo.sMessage = sErrorMsg;
- }
- else
- {
- genGetExamById(&examInfo, sResponse);
- }
- emit sgnGetExamById(examInfo);
- }
- break;
- case RequestType::rtWeiXinAnswerEnabled:
- {
- CWeiXinAnswerEnabled wxae;
- wxae.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- wxae.sMessage = sErrorMsg;
- }
- else
- {
- genWeiXinAnswerEnabled(&wxae, sResponse);
- }
- emit sgnWeiXinAnswerEnabled(wxae);
- }
- break;
- case RequestType::rtGetWXQrCode:
- {
- CGetWXQrCode wxc;
- wxc.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- wxc.sMessage = sErrorMsg;
- }
- else
- {
- genGetWXQrCode(&wxc, sResponse);
- }
- emit sgnGetWXQrCode(wxc);
- }
- break;
- case RequestType::rtSaveUploadedFileAcknowledgeStatus:
- {
- CSaveUploadedFileAcknowledgeStatus sufs;
- sufs.nCode = nCode;
- sufs.sFileUrl = requestPkg.sCommonStr;
- if (sErrorMsg != "" || nCode != 200)
- {
- sufs.sMessage = sErrorMsg;
- }
-
- emit sgnSaveUploadedFileAcknowledgeStatus(sufs);
- }
- break;
-
- case RequestType::rtFindExamQuestionList:
- {
- CFindExamQuestionList feql;
- feql.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- feql.sMessage = sErrorMsg;
- }
- else
- {
- genFindExamQuestionList(&feql, sResponse);
- }
- emit sgnFindExamQuestionList(feql);
- }
- break;
- case RequestType::rtGetQuestionContent:
- {
- CGetQuestionContent gqc;
- QStringList sl = requestPkg.sCommonStr.split(",");
- if (sl.count() == 2)
- {
- gqc.sQuestionId = sl[0];
- gqc.sOrder = sl[1];
- }
- gqc.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gqc.sMessage = sErrorMsg;
- }
- else
- {
- genGetQuestionContent(&gqc, sResponse);
- }
- emit sgnGetQuestionContent(gqc);
- }
- break;
- case RequestType::rtStartAnswer:
- {
- CStartAnswer sa;
- sa.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- sa.sMessage = sErrorMsg;
- }
- else
- {
- genStartAnswer(&sa, sResponse);
- }
- emit sgnStartAnswer(sa);
- }
- break;
- case RequestType::rtExamHeartbeat:
- {
- CExamHeartbeat ehb;
- ehb.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- ehb.sMessage = sErrorMsg;
- }
- else
- {
- genExamHeartbeat(&ehb, sResponse);
- }
- emit sgnExamHeartbeat(ehb);
- }
- break;
- case RequestType::rtSubmitQuestionAnswer:
- {
- CSubmitQuestionAnswer sqa;
- sqa.nCode = nCode;
- QStringList list = requestPkg.sCommonStr.split(",");
- if(list.count() == 2)
- {
- sqa.nOrder = list[0].toInt();
- sqa.nVersion = list[1].toInt();
- }
- if (sErrorMsg != "" || nCode != 200)
- {
- sqa.sMessage = sErrorMsg;
- }
- emit sgnSubmitQuestionAnswer(sqa);
- }
- break;
-
- case RequestType::rtEndExam:
- {
- CEndExam ee;
- ee.nCode = nCode;
- ee.sModuleName = requestPkg.sCommonStr;
- if (sErrorMsg != "" || nCode != 200)
- {
- ee.sMessage = sErrorMsg;
- }
- emit sgnEndExam(ee);
- }
- break;
- case RequestType::rtProcessUpload:
- {
- CProcessUpload pu;
- pu.sCommonStr = requestPkg.sCommonStr;
- pu.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- pu.sMessage = sErrorMsg;
- }
- else
- {
- genProcessUpload(&pu, sResponse);
- }
- emit sgnProcessUpload(pu);
- }
- break;
-
- case RequestType::rtSaveFaceCompareResult:
- {
- CBaseResponsePackage res;
- res.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- res.sMessage = sErrorMsg;
- }
- emit sgnSaveFaceCompareResult(res);
- }
- break;
-
- case RequestType::rtSaveFaceCaptureResult:
- {
- CBaseResponsePackage res;
- res.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- res.sMessage = sErrorMsg;
- }
- emit sgnSaveFaceCaptureResult(res);
- }
- break;
- case RequestType::rtSaveFaceLiveVerifyResult:
- {
- CBaseResponsePackage res;
- res.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- res.sMessage = sErrorMsg;
- }
- emit sgnSaveFaceLiveVerifyResult(res);
- }
- break;
- case RequestType::rtStartFaceLiveVerify:
- {
- CStartFaceLiveVerify sflv;
- sflv.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- sflv.sMessage = sErrorMsg;
- }
- else
- {
- genStartFaceLiveVerify(&sflv, sResponse);
- }
- emit sgnStartFaceLiveVerify(sflv);
- }
- break;
- case RequestType::rtGetOrgPropertiesByGroupWithoutCache:
- {
- CGetOrgPropertiesByGroupWithoutCache gop;
- gop.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- gop.sMessage = sErrorMsg;
- }
- else
- {
- genGetOrgPropertiesByGroupWithoutCache(&gop, sResponse);
- }
- emit sgnGetOrgPropertiesByGroupWithoutCache(gop);
- }
- break;
- case RequestType::rtGetEndExamInfo:
- {
- CGetEndExamInfo geei;
- geei.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- geei.sMessage = sErrorMsg;
- }
- else
- {
- genGetEndExamInfo(&geei, sResponse);
- }
- emit sgnGetEndExamInfo(geei);
- }
- break;
- default:
- break;
- }
- }
- void CHttpBll::genUpgrade(CUpgrade *pUpgrade, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if(!reader.parse(sResponse, jsonRoot))
- {
- pUpgrade->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pUpgrade->sMessage << sResponse.c_str();
- }
- pUpgrade->sVersion = jsonRoot["version"].asString().c_str();
- pUpgrade->nBuild = jsonRoot["build"].asInt();
- pUpgrade->sContent = jsonRoot["content"].asString().c_str();
- pUpgrade->bForce = jsonRoot["force"].asBool();
- pUpgrade->sUpgradeUrl = jsonRoot["downUrl"].asString().c_str();
- }
- void CHttpBll::genAgreement(CAgreement *pAgreement, const std::string &sResponse)
- {
- std::string sRes = sResponse;
- if (sResponse.length() > 3 && sResponse[0] == -17 &&
- sResponse[1] == -69 &&
- sResponse[2] == -65)
- {
- sRes = sResponse.substr(3, sResponse.length() -3);
- }
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if(!reader.parse(sRes, jsonRoot))
- {
- pAgreement->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pAgreement->sMessage << sResponse.c_str();
- }
- pAgreement->sTitle = jsonRoot["title"].asString().c_str();
- pAgreement->nStaySeconds = jsonRoot["staySeconds"].asInt();
- pAgreement->sContent = jsonRoot["content"].toStyledString().c_str();
- }
- void CHttpBll::genStudentClientConfig(CStudentClientConfig *pStudentClientConfig, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStudentClientConfig->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pStudentClientConfig->sMessage << sResponse.c_str();
- }
-
- pStudentClientConfig->sCusMenuLogoFileUrl = jsonRoot["CUS_MENU_LOGO_FILE_URL"].asString().c_str();
- pStudentClientConfig->sIdentityNumberLoginAlias = jsonRoot["IDENTITY_NUMBER_LOGIN_ALIAS"].asString().c_str();
- pStudentClientConfig->bIsCustomMenuLogo = QVariant(jsonRoot["IS_CUSTOM_MENU_LOGO"].asString().c_str()).toBool();
- QString loginType = jsonRoot["LOGIN_TYPE"].asString().c_str();
- QStringList ltList = loginType.split(",");
- for (QString sType : ltList)
- {
- if (sType == "STUDENT_CODE")
- {
- pStudentClientConfig->bStudentCodeLogin = true;
- }
- else if (sType == "IDENTITY_NUMBER")
- {
- pStudentClientConfig->bIdentifyNumberLogin = true;
- }
- }
-
- pStudentClientConfig->sLogoFileUrl = jsonRoot["LOGO_FILE_URL"].asString().c_str();
- pStudentClientConfig->sStudentClientBgPictureUrl = jsonRoot["STUDENT_CLIENT_BG_PICTURE_URL"].asString().c_str();
- pStudentClientConfig->sOeStudentSysName = jsonRoot["OE_STUDENT_SYS_NAME"].asString().c_str();
- QString preventCheating = jsonRoot["PREVENT_CHEATING_CONFIG"].asString().c_str();
- QStringList pcList = preventCheating.split(",");
- for (QString sType : pcList)
- {
- if (sType == "DISABLE_REMOTE_ASSISTANCE")
- {
- pStudentClientConfig->bDisableRemoteAssistance = true;
- }
- else if (sType == "FULL_SCREEN_TOP")
- {
- pStudentClientConfig->bFullScreenTop = true;
- }
- else if (sType == "DISABLE_MULTISCREEN")
- {
- pStudentClientConfig->bDisableMutiScreen = true;
- }
- else if (sType == "DISABLE_VIRTUAL_CAMERA")
- {
- pStudentClientConfig->bDisableVirtualCamera = true;
- }
- }
-
- pStudentClientConfig->sRootOrgId = jsonRoot["ROOT_ORG_ID"].asString().c_str();// " : "0",
- pStudentClientConfig->bShowQmthLogo = QVariant(jsonRoot["SHOW_QMTH_LOGO"].asString().c_str()).toBool();// " : "false",
- pStudentClientConfig->bShowStudentClientAppQrcode = QVariant(jsonRoot["SHOW_STUDENT_CLIENT_APP_QRCODE"].asString().c_str()).toBool();// " : "true",
- pStudentClientConfig->sStudentCodeLoginAlias = jsonRoot["STUDENT_CODE_LOGIN_ALIAS"].asString().c_str(); // " : "学号登录34s"
- }
- void CHttpBll::genSysNotice(CSysNotice *pSysNotice, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pSysNotice->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pSysNotice->sMessage << sResponse.c_str();
- }
- pSysNotice->nId = jsonRoot["id"].asInt64();
- pSysNotice->nRootOrgId = jsonRoot["rootOrgId"].asInt64();
- pSysNotice->sContent = jsonRoot["content"].asString().c_str();
- pSysNotice->sStartTime = jsonRoot["startTime"].asString().c_str();
- pSysNotice->sEndTime = jsonRoot["endTime"].asString().c_str();
- pSysNotice->sTitle = jsonRoot["title"].asString().c_str();
- pSysNotice->bEnable = jsonRoot["enable"].asBool();
- }
- void CHttpBll::genSoftwareConfig(CGetSoftwareConfig *pSoftwareConfig, const std::string &sResponse)
- {
- pSoftwareConfig->sSoftwareConfig = std::string(sResponse.rbegin()+32, sResponse.rend()).c_str();
- }
- void CHttpBll::genLoginLimit(CLoginLimit *pLoginLimit, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pLoginLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pLoginLimit->sMessage << sResponse.c_str();
- }
- pLoginLimit->nCount = jsonRoot["count"].asInt64();
- pLoginLimit->bPass = jsonRoot["pass"].asBool();
- }
- void CHttpBll::genLoginInfo(CLoginInfo *pLoginInfo, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pLoginInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pLoginInfo->sMessage << sResponse.c_str();
- }
- // pLoginInfo->nCode = jsonRoot["code"].asInt();
- if (jsonRoot["code"].asString() != "200")
- {
- pLoginInfo->nCode = 0;
- }
- pLoginInfo->sMessage = jsonRoot["desc"].asString().c_str();
- sKey = jsonRoot["content"]["key"].asString().c_str();
- sToken = jsonRoot["content"]["token"].asString().c_str();
- pLoginInfo->sUserType = jsonRoot["content"]["userType"].asString().c_str();
- pLoginInfo->nUserId = jsonRoot["content"]["userId"].asInt64();
- pLoginInfo->sDisplayName = jsonRoot["content"]["displayName"].asString().c_str();
- pLoginInfo->nRootOrgId = jsonRoot["content"]["rootOrgId"].asInt64();
- pLoginInfo->sRootOrgName = jsonRoot["content"]["rootOrgName"].asString().c_str();
- pLoginInfo->sCreationTime = jsonRoot["content"]["creationTime"].asString().c_str();
- pLoginInfo->sClientIp = jsonRoot["content"]["clientIp"].asString().c_str();
- pLoginInfo->nSessionTimeout = jsonRoot["content"]["sessionTimeout"].asInt64();
- pLoginInfo->bPasswordWeak = jsonRoot["content"]["passwordWeak"].asBool();
- }
- void CHttpBll::genLogout(CLogout *pLogout, const std::string &sResponse)
- {
- }
- void CHttpBll::genEditPassword(CEditPassword *pEditPassword, const std::string &sResponse)
- {
- }
- void CHttpBll::genGetStudentClientMenu(CGetStudentClientMenu *pGetStudentClientMenu, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetStudentClientMenu->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetStudentClientMenu->sMessage << sResponse.c_str();
- }
-
- int nSize = jsonRoot.size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jMenuItem = jsonRoot[i];
- CStudentClientMenu scm;
- scm.nId = jMenuItem["id"].asInt64();
- scm.sCode = jMenuItem["code"].asString().c_str();
- scm.sName = jMenuItem["name"].asString().c_str();
- pGetStudentClientMenu->vMenus.push_back(scm);
- }
- }
- void CHttpBll::genGetStudentInfoBySession(CGetStudentInfoBySession *pGetStudentInfoBySession, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetStudentInfoBySession->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetStudentInfoBySession->sMessage << sResponse.c_str();
- }
- pGetStudentInfoBySession->nId = jsonRoot["id"].asInt64();
- pGetStudentInfoBySession->sName = jsonRoot["name"].asString().c_str();
- pGetStudentInfoBySession->nOrgId = jsonRoot["orgId"].asInt64();
- pGetStudentInfoBySession->sOrgCode = jsonRoot["orgCode"].asString().c_str();
- pGetStudentInfoBySession->sOrgName = jsonRoot["orgName"].asString().c_str();
-
- QString sStudentCode = "";
- int nSize = jsonRoot["studentCodeList"].size();
- for (int i = 0; i < nSize; ++i)
- {
- if (sStudentCode.isEmpty())
- {
- sStudentCode = jsonRoot["studentCodeList"][i].asString().c_str();
- }
- else
- {
- sStudentCode = sStudentCode + "," + jsonRoot["studentCodeList"][i].asString().c_str();
- }
- }
- pGetStudentInfoBySession->sStudentCode = sStudentCode;
- pGetStudentInfoBySession->sIdentityNumber = jsonRoot["identityNumber"].asString().c_str();
- pGetStudentInfoBySession->sPhotoPath = jsonRoot["photoPath"].asString().c_str();
- pGetStudentInfoBySession->bEnable = jsonRoot["enable"].asBool();
- }
- void CHttpBll::genSpecialtyNameList(CSpecialtyNameList *pSpecialtyNameList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pSpecialtyNameList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pSpecialtyNameList->sMessage << sResponse.c_str();
- }
- QString sSpecialtyName = "";
- int nSize = jsonRoot.size();
- for (int i = 0; i < nSize; ++i)
- {
- if (sSpecialtyName.isEmpty())
- {
- sSpecialtyName = jsonRoot[i].asString().c_str();
- }
- else
- {
- sSpecialtyName = sSpecialtyName + "," + jsonRoot[i].asString().c_str();
- }
- }
- pSpecialtyNameList->sSpecialtyName = sSpecialtyName;
- }
- void CHttpBll::genGetUserNoticeList(CGetUserNoticeList *pGetUserNoticeList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetUserNoticeList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetUserNoticeList->sMessage << sResponse.c_str();
- }
- int nSize = jsonRoot.size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jNoticeItem = jsonRoot[i];
- CNoticeInfo ni;
- ni.nId = jNoticeItem["id"].asInt64();
- ni.sTitle = jNoticeItem["title"].asString().c_str();
- ni.sContent = jNoticeItem["content"].asString().c_str();
- ni.sPublisher = jNoticeItem["publisher"].asString().c_str();
- ni.sPublishTime = jNoticeItem["publishTime"].asString().c_str();
- ni.bHasRead = jNoticeItem["hasRead"].asBool();
- ni.bHasRecalled = jNoticeItem["hasRecalled"].isNull() ? false : jNoticeItem["hasRecalled"].asBool();
- pGetUserNoticeList->vNoticeList.push_back(ni);
- }
- }
- void CHttpBll::genAppDownLoadUrl(CAppDownLoadUrl *pAppDownLoadUrl, const std::string &sResponse)
- {
- pAppDownLoadUrl->sUrl = sResponse.c_str();
- }
- void CHttpBll::genAppEnabled(CAppEnabled *pAppEnabled, const std::string &sResponse)
- {
- pAppEnabled->bEnable = QVariant(sResponse.c_str()).toBool();
- }
- void CHttpBll::genQueryBatchList(CQueryBatchList *pQueryBatchList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryBatchList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pQueryBatchList->sMessage << sResponse.c_str();
- }
- int nSize = jsonRoot.size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jBatchItem = jsonRoot[i];
- CBatchInfo bi;
- bi.nId = jBatchItem["id"].asInt64();
- bi.sName = jBatchItem["name"].asString().c_str();
- bi.sExamType = jBatchItem["examType"].asString().c_str();
- pQueryBatchList->vBatchList.push_back(bi);
- }
- }
- void CHttpBll::genGetExamProperty(CGetExamProperty *pGetExamProperty, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetExamProperty->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetExamProperty->sMessage << sResponse.c_str();
- }
- if (jsonRoot.isMember("BEFORE_EXAM_REMARK"))
- {
- pGetExamProperty->sBeforeExamRemark = jsonRoot["BEFORE_EXAM_REMARK"].asString().c_str();
- }
- if (jsonRoot.isMember("CHECK_ENVIRONMENT"))
- {
- pGetExamProperty->bCheckEnvironment = QVariant(jsonRoot["CHECK_ENVIRONMENT"].asString().c_str()).toBool();
- }
-
- if (jsonRoot.isMember("WARN_THRESHOLD"))
- {
- pGetExamProperty->nWarnThreshold = QVariant(jsonRoot["WARN_THRESHOLD"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("IS_FACE_CHECK"))
- {
- pGetExamProperty->bIsFaceCheck = QVariant(jsonRoot["IS_FACE_CHECK"].asString().c_str()).toBool();
- }
- if (jsonRoot.isMember("SNAPSHOT_INTERVAL"))
- {
- pGetExamProperty->nSnapshotInterval = QVariant(jsonRoot["SNAPSHOT_INTERVAL"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("FACE_VERIFY_START_MINUTE"))
- {
- pGetExamProperty->nFaceVerifyStartMinute = QVariant(jsonRoot["FACE_VERIFY_START_MINUTE"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("FACE_VERIFY_END_MINUTE"))
- {
- pGetExamProperty->nFaceVerifyEndMinute = QVariant(jsonRoot["FACE_VERIFY_END_MINUTE"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("IS_STRANGER_ENABLE"))
- {
- pGetExamProperty->bIsStrangerEnable = QVariant(jsonRoot["IS_STRANGER_ENABLE"].asString().c_str()).toBool();
- }
- if (jsonRoot.isMember("PRACTICE_TYPE"))
- {
- pGetExamProperty->sPracticeType = jsonRoot["PRACTICE_TYPE"].asString().c_str();
- }
- if (jsonRoot.isMember("FREEZE_TIME"))
- {
- pGetExamProperty->nFreezeTime = QVariant(jsonRoot["FREEZE_TIME"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("AFTER_EXAM_REMARK"))
- {
- pGetExamProperty->sAfterExamRemark = jsonRoot["AFTER_EXAM_REMARK"].asString().c_str();
- }
- if (jsonRoot.isMember("IS_OBJ_SCORE_VIEW"))
- {
- pGetExamProperty->bIsObjScoreView = QVariant(jsonRoot["IS_OBJ_SCORE_VIEW"].asString().c_str()).toBool();
- }
- if (jsonRoot.isMember("SHOW_CHEATING_REMARK"))
- {
- pGetExamProperty->bShowCheatingRemark = QVariant(jsonRoot["SHOW_CHEATING_REMARK"].asString().c_str()).toBool();
- }
- if (jsonRoot.isMember("CHEATING_REMARK"))
- {
- pGetExamProperty->sCheatingRemark = jsonRoot["CHEATING_REMARK"].asString().c_str();
- }
- if (jsonRoot.isMember("OFFLINE_UPLOAD_FILE_TYPE"))
- {
- QString sFileType = jsonRoot["OFFLINE_UPLOAD_FILE_TYPE"].asString().c_str();
- Json::Reader reader;
- Json::Value jFileType = Json::Value::null;
- if (!reader.parse(sFileType.toStdString(), jFileType))
- {
- pGetExamProperty->sMessage = QString::fromLocal8Bit("解析文件类型异常!");
- pGetExamProperty->nCode = 0;
- }
- int nSize = jFileType.size();
- for (int i = 0; i < nSize; ++i)
- {
- pGetExamProperty->vOfflineUploadFileType.push_back(jFileType[i].asString().c_str());
- }
- }
- }
- void CHttpBll::genStartExamLimit(CStartExamLimit *pStartExamLimit, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStartExamLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pStartExamLimit->sMessage << sResponse.c_str();
- }
- pStartExamLimit->nCount = jsonRoot["count"].asInt();
- pStartExamLimit->bPass = jsonRoot["pass"].asBool();
- }
- void CHttpBll::genIpLimit(CIpLimit *pIpLimit, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pIpLimit->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pIpLimit->sMessage << sResponse.c_str();
- }
- pIpLimit->bLimited = jsonRoot["limited"].asBool();
- }
- void CHttpBll::genStartExam(CStartExam *pStartExam, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStartExam->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pStartExam->sMessage << sResponse.c_str();
- }
- pStartExam->sCourseCode = jsonRoot["courseCode"].asString().c_str();
- pStartExam->sCourseName = jsonRoot["courseName"].asString().c_str();
- pStartExam->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
- pStartExam->nFaceVerifyMinute = jsonRoot["faceVerifyMinute"].asInt();
- pStartExam->sStudentCode = jsonRoot["studentCode"].asString().c_str();
- pStartExam->sStudentName = jsonRoot["studentName"].asString().c_str();
- }
- void CHttpBll::genFaceCheckEnabled(CFaceCheckEnabled *pFaceCheckEnabled, const std::string &sResponse)
- {
- pFaceCheckEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
- }
- void CHttpBll::genLivenessEnabled(CLivenessEnabled *pLivenessEnabled, const std::string &sResponse)
- {
- pLivenessEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
- }
- void CHttpBll::genWeiXinAnswerEnabled(CWeiXinAnswerEnabled *pWeiXinAnswerEnabled, const std::string &sResponse)
- {
- pWeiXinAnswerEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
- }
- void CHttpBll::genGetExamById(CGetExamById *pGetExamById, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetExamById->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetExamById->sMessage << sResponse.c_str();
- }
- pGetExamById->nId = jsonRoot["id"].asInt64();
- pGetExamById->sCode = jsonRoot["code"].asString().c_str();
- pGetExamById->nRootOrgId = jsonRoot["rootOrgId"].asInt64();
- pGetExamById->sBeginTime = jsonRoot["beginTime"].asString().c_str();
- pGetExamById->sEndTime = jsonRoot["endTime"].asString().c_str();
- pGetExamById->sName = jsonRoot["name"].asString().c_str();
- pGetExamById->sExamType = jsonRoot["examType"].asString().c_str();
- pGetExamById->nDuration = jsonRoot["duration"].asInt64();
- pGetExamById->bEnable = jsonRoot["enable"].asBool();
- pGetExamById->bStarted = jsonRoot["started"].asBool();
- pGetExamById->bIpLimitSettingsEnabled = jsonRoot["ipLimitSettingsEnabled"].asBool();
- }
- void CHttpBll::genStartAnswer(CStartAnswer *pStartAnswer, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStartAnswer->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pStartAnswer->sMessage << sResponse.c_str();
- }
- pStartAnswer->nDuration = jsonRoot["duration"].asInt64();
- pStartAnswer->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
- pStartAnswer->nUsedExamSeconds = jsonRoot["usedExamSeconds"].asInt64();
- }
- void CHttpBll::genGetQuestion(CGetQuestion *pGetQuestion, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetQuestion->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetQuestion->sMessage << sResponse.c_str();
- }
- pGetQuestion->sId = jsonRoot["id"].asString().c_str();
- pGetQuestion->sBody = jsonRoot["masterVersion"]["body"].isNull() ? "" : jsonRoot["masterVersion"]["body"].asString().c_str();
- pGetQuestion->sVersion = jsonRoot["masterVersion"]["version"].asString().c_str();
- pGetQuestion->bhasAudios = jsonRoot["masterVersion"]["hasAudios"].asBool();
- int nSize = jsonRoot["masterVersion"]["questionUnitList"].size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jQuestionItem = jsonRoot["masterVersion"]["questionUnitList"][i];
- CSubQuestion sq;
- sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
- sq.sBody = jQuestionItem["body"].asString().c_str();
- //sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
- int nOptionSize = jQuestionItem["questionOptionList"].size();
- for (int j = 0; j < nOptionSize; ++j)
- {
- Json::Value jOption = jQuestionItem["questionOptionList"][j];
- COption o;
- o.sBody = jOption["body"].asString().c_str();
- sq.vOptions.push_back(o);
- }
- int nAnswerSize = jQuestionItem["rightAnswer"].size();
- for (int k = 0; k < nAnswerSize; ++k)
- {
- Json::Value jAnswer = jQuestionItem["rightAnswer"][k];
- sq.vRightAnswer.push_back(jAnswer.asString().c_str());
- }
- pGetQuestion->vSubQuestion.push_back(sq);
- }
- }
- void CHttpBll::genGetQuestionContent(CGetQuestionContent *pGetQuestionContent, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetQuestionContent->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetQuestionContent->sMessage << sResponse.c_str();
- }
- pGetQuestionContent->sBody = jsonRoot["body"].isNull() ? "" : jsonRoot["body"].asString().c_str();
- pGetQuestionContent->sVersion = jsonRoot["version"].asString().c_str();
- pGetQuestionContent->bhasAudios = jsonRoot["hasAudios"].asBool();
- int nSize = jsonRoot["questionUnitList"].size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jQuestionItem = jsonRoot["questionUnitList"][i];
- CSubQuestion sq;
- sq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
- sq.sBody = jQuestionItem["body"].asString().c_str();
- sq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
- int nOptionSize = jQuestionItem["questionOptionList"].size();
- for (int j = 0; j < nOptionSize; ++j)
- {
- Json::Value jOption = jQuestionItem["questionOptionList"][j];
- COption o;
- o.sBody = jOption["body"].asString().c_str();
- sq.vOptions.push_back(o);
- }
-
- for (int jq = 0; jq < jQuestionItem["optionPermutation"].size(); ++jq)
- {
- Json::Value Item = jQuestionItem["optionPermutation"][jq];
- sq.voptionPermutation.push_back(Item.asInt());
- }
- int nAnswerSize = jQuestionItem["rightAnswer"].size();
- for (int k = 0; k < nAnswerSize; ++k)
- {
- Json::Value jAnswer = jQuestionItem["rightAnswer"][k];
- sq.vRightAnswer.push_back(jAnswer.asString().c_str());
- }
- pGetQuestionContent->vSubQuestion.push_back(sq);
- }
- }
- void CHttpBll::genExamCourseInfo(const Json::Value &jExamItem, CExamCourseInfo &eci)
- {
- eci.nAllowExamCount = jExamItem["allowExamCount"].asInt();
- eci.bAppExamEnabled = jExamItem["appExamEnabled"].asBool();
- eci.sCourseCode = jExamItem["courseCode"].asString().c_str();
- eci.nCourseId = jExamItem["courseId"].asInt64();
- eci.sCourseLevel = jExamItem["courseLevel"].asString().c_str();
- eci.sCourseName = jExamItem["courseName"].asString().c_str();
- eci.sEndTime = jExamItem["endTime"].asString().c_str();
- eci.bExamCycleEnabled = jExamItem["examCycleEnabled"].asBool();
- int nWeekSize = jExamItem["examCycleWeek"].size();
- for(int i =0; i < nWeekSize; ++i)
- {
- eci.vExamCycleWeek.push_back(jExamItem["examCycleWeek"][i].asInt());
- }
- int nCycleTimeRangeSize = jExamItem["examCycleTimeRange"].size();
- for(int i = 0; i < nCycleTimeRangeSize; ++i)
- {
- Json::Value jTimeRange = jExamItem["examCycleTimeRange"][i]["timeRange"];
- int nTimeRangeSize = jTimeRange.size();
- QStringList sTimeRangeList;
- for(int j = 0; j < nTimeRangeSize; ++j)
- {
- sTimeRangeList<<jTimeRange[j].asString().c_str();
- }
- eci.sExamCycleTimeRange<<sTimeRangeList.join("~");
- }
- //eci.sCourseCode = jExamItem["examCycleTimeRange"].asString().c_str();
- //eci.sCourseCode = jExamItem["examCycleWeek"].asString().c_str();
- eci.nExamId = jExamItem["examId"].asInt64();
- eci.sExamName = jExamItem["examName"].asString().c_str();
- eci.sExamStatus = jExamItem["examStatus"].asString().c_str();
- eci.nExamStudentId = jExamItem["examStudentId"].asInt64();
- eci.bFaceCheck = jExamItem["faceCheck"].asBool();
- eci.bFaceEnable = jExamItem["faceEnable"].asBool();
- eci.sIdentityNumber = jExamItem["identityNumber"].asString().c_str();
- eci.bIsFinished = jExamItem["isFinished"].asBool();
- eci.bIsObjScoreView = jExamItem["isObjScoreView"].asString().c_str();
- eci.bIsPhotoUpload = jExamItem["isPhotoUpload"].asBool();
- eci.nOrgId = jExamItem["orgId"].asInt64();
- eci.sOrgName = jExamItem["orgName"].asString().c_str();
- eci.nPaperMins = jExamItem["paperMins"].asInt();
- eci.nRootOrgId = jExamItem["rootOrgId"].asInt64();
- eci.sSpecialtyLevel = jExamItem["specialtyLevel"].asString().c_str();
- eci.sSpecialtyName = jExamItem["specialtyName"].asString().c_str();
- eci.sStartTime = jExamItem["startTime"].asString().c_str();
- eci.sStudentCode = jExamItem["studentCode"].asString().c_str();
- eci.sStudentName = jExamItem["studentName"].asString().c_str();
- }
- void CHttpBll::genQueryExamList(CQueryExamList *pQueryExamList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryExamList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pQueryExamList->sMessage << sResponse.c_str();
- }
- int nExamSize = jsonRoot.size();
- for (int i = 0; i < nExamSize; ++i)
- {
- Json::Value jExamItem = jsonRoot[i];
- CExamCourseInfo eci;
- genExamCourseInfo(jExamItem, eci);
- pQueryExamList->vOnlieExamList.push_back(eci);
- }
- }
- void CHttpBll::genQueryExamEndList(CQueryExamEndList *pQueryExamEndList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryExamEndList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pQueryExamEndList->sMessage << sResponse.c_str();
- }
- int nExamSize = jsonRoot.size();
- for (int i = 0; i < nExamSize; ++i)
- {
- Json::Value jExamItem = jsonRoot[i];
- CExamCourseInfo eci;
- genExamCourseInfo(jExamItem, eci);
- pQueryExamEndList->vOnlieEndExamList.push_back(eci);
- }
- }
- void CHttpBll::genQueryObjectiveScoreList(CQueryObjectiveScoreList *pQueryObjectiveScoreList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryObjectiveScoreList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pQueryObjectiveScoreList->sMessage << sResponse.c_str();
- }
- int nScoreSize = jsonRoot.size();
- for (int i = 0; i < nScoreSize; ++i)
- {
- Json::Value jScore = jsonRoot[i];
- CObjectiveScore os;
- os.sEndTime = jScore["endTime"].asString().c_str();
- os.nExamOrder = jScore["examOrder"].asInt();
- os.nExamRecordDataId = jScore["examRecordDataId"].asInt64();
- os.bIsAuditing = jScore["isAuditing"].asBool();
- os.bIsExamEnded = jScore["isExamEnded"].asBool();
- os.bIsIllegality = jScore["isIllegality"].asBool();
- os.fObjectiveScore = jScore["objectiveScore"].asDouble();
- os.sStartTime = jScore["startTime"].asString().c_str();
- pQueryObjectiveScoreList->vObjectiveScore.push_back(os);
- }
- }
- void CHttpBll::genQueryHomeworkList(CQueryHomeworkList *pQueryHomeworkList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryHomeworkList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pQueryHomeworkList->sMessage << sResponse.c_str();
- }
- int nExamSize = jsonRoot.size();
- for (int i = 0; i < nExamSize; ++i)
- {
- Json::Value jExamItem = jsonRoot[i];
- CExamCourseInfo eci;
- genExamCourseInfo(jExamItem, eci);
- pQueryHomeworkList->vHomeworkExamList.push_back(eci);
- }
- }
- void CHttpBll::genQueryPracticeCourseList(CQueryPracticeCourseList *pQueryPracticeCourseList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryPracticeCourseList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pQueryPracticeCourseList->sMessage << sResponse.c_str();
- }
- int nExamSize = jsonRoot.size();
- for (int i = 0; i < nExamSize; ++i)
- {
- Json::Value jExamItem = jsonRoot[i];
- CPracticeCourseInfo pci;
- pci.fAveObjectiveAccuracy = jExamItem["aveObjectiveAccuracy"].asDouble();
- pci.sCourseCode = jExamItem["courseCode"].asString().c_str();
- pci.sCourseName = jExamItem["courseName"].asString().c_str();
- pci.sEndTime = jExamItem["endTime"].asString().c_str();
- pci.bExamCycleEnabled = jExamItem["examCycleEnabled"].asBool();
- //pci.sExamCycleTimeRange = jExamItem["examCycleTimeRange"].asDouble();
- //pci.sExamCycleWeek = jExamItem["examCycleWeek"].asDouble();
- int nWeekSize = jExamItem["examCycleWeek"].size();
- for(int i = 0; i < nWeekSize; ++i)
- {
- pci.vExamCycleWeek.push_back(jExamItem["examCycleWeek"][i].asInt());
- }
- int nCycleTimeRangeSize = jExamItem["examCycleTimeRange"].size();
- for(int i = 0; i < nCycleTimeRangeSize; ++i)
- {
- Json::Value jTimeRange = jExamItem["examCycleTimeRange"][i]["timeRange"];
- int nTimeRangeSize = jTimeRange.size();
- QStringList sTimeRangeList;
- for(int j = 0; j < nTimeRangeSize; ++j)
- {
- sTimeRangeList<<jTimeRange[j].asString().c_str();
- }
- pci.sExamCycleTimeRange<<sTimeRangeList.join("~");
- }
- pci.nExamId = jExamItem["examId"].asInt64();
- pci.sExamName = jExamItem["examName"].asString().c_str();
- pci.nExamStudentId = jExamItem["examStudentId"].asInt64();
- pci.sExamType = jExamItem["examType"].asString().c_str();
- pci.fMaxObjectiveAccuracy = jExamItem["maxObjectiveAccuracy"].asDouble();
- pci.nPracticeCount = jExamItem["practiceCount"].asInt();
- pci.fRecentObjectiveAccuracy = jExamItem["recentObjectiveAccuracy"].asDouble();
- pci.sStartTime = jExamItem["startTime"].asString().c_str();
- pci.sStudentCode = jExamItem["studentCode"].asString().c_str();
- pci.sStudentName = jExamItem["studentName"].asString().c_str();
- pQueryPracticeCourseList->vPracticeCourseInfo.push_back(pci);
- }
- }
- void CHttpBll::genQueryPracticeRecordList(CQueryPracticeRecordList *pQueryPracticeRecordList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryPracticeRecordList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pQueryPracticeRecordList->sMessage << sResponse.c_str();
- }
- int nSize = jsonRoot.size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jPracticeItem = jsonRoot[i];
- CPracticeRecord pr;
- pr.sCourseCode = jPracticeItem["courseCode"].asString().c_str();
- pr.sCourseName = jPracticeItem["courseName"].asString().c_str();
- pr.sEndTime = jPracticeItem["endTime"].asString().c_str();
- pr.sExamName = jPracticeItem["examName"].asString().c_str();
- pr.nFailQuestionNum = jPracticeItem["failQuestionNum"].asInt();
- pr.nId = jPracticeItem["id"].asInt64();
- pr.nNotAnsweredCount = jPracticeItem["notAnsweredCount"].asInt();
- pr.fObjectiveAccuracy = jPracticeItem["objectiveAccuracy"].asDouble();
- pr.nObjectiveNum = jPracticeItem["objectiveNum"].asInt();
- pr.sStartTime = jPracticeItem["startTime"].asString().c_str();
- pr.nSuccQuestionNum = jPracticeItem["succQuestionNum"].asInt();
- pr.nTotalQuestionCount = jPracticeItem["totalQuestionCount"].asInt();
- pr.nUsedExamTime = jPracticeItem["usedExamTime"].asInt64();
- pQueryPracticeRecordList->vPracticeRecordList.push_back(pr);
- }
- }
- void CHttpBll::genGetPracticeDetailInfo(CGetPracticeDetailInfo *pGetPracticeDetailInfo, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetPracticeDetailInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetPracticeDetailInfo->sMessage << sResponse.c_str();
- }
- pGetPracticeDetailInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
- pGetPracticeDetailInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
- pGetPracticeDetailInfo->nId = jsonRoot["id"].asInt64();
- pGetPracticeDetailInfo->fObjectiveAccuracy = jsonRoot["objectiveAccuracy"].asDouble();
- int nSize = jsonRoot["paperStructInfos"].size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jPaperStructInfo = jsonRoot["paperStructInfos"][i];
- CPracticePaperStructInfo ppsi;
- ppsi.nCount = jPaperStructInfo["count"].asInt();
- ppsi.nFailQuestionNum = jPaperStructInfo["failQuestionNum"].asInt();
- ppsi.nIndex = jPaperStructInfo["index"].asInt();
- ppsi.nNotAnsweredCount = jPaperStructInfo["notAnsweredCount"].asInt();
- ppsi.nQuestionCount = jPaperStructInfo["questionCount"].asInt();
- ppsi.sQuestionType = jPaperStructInfo["questionType"].asString().c_str();
- ppsi.sScore = jPaperStructInfo["score"].asString().c_str();
- ppsi.nSuccQuestionNum = jPaperStructInfo["succQuestionNum"].asInt();
- ppsi.sTitle = jPaperStructInfo["title"].asString().c_str();
- ppsi.fTotalScore = jPaperStructInfo["totalScore"].asDouble();
- pGetPracticeDetailInfo->vPracticePaperStructList.push_back(ppsi);
- }
- }
- void CHttpBll::genFindExamRecordDataEntity(CFindExamRecordDataEntity *pFindExamRecordDataEntity, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pFindExamRecordDataEntity->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pFindExamRecordDataEntity->sMessage << sResponse.c_str();
- }
-
- pFindExamRecordDataEntity->nExamId = jsonRoot["examRecord"]["examId"].asInt64();
- pFindExamRecordDataEntity->sPaperType = jsonRoot["examRecord"]["paperType"].asString().c_str();
- }
- void CHttpBll::genGetExamRecordQuestions(CGetExamRecordQuestions *pGetExamRecordQuestions, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetExamRecordQuestions->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetExamRecordQuestions->sMessage << sResponse.c_str();
- }
- int nSize = jsonRoot["examQuestionEntities"].size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jQuestionItem = jsonRoot["examQuestionEntities"][i];
- CAnsweredQuestion aq;
- aq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
- aq.sAudioPlayTimes = jQuestionItem["audioPlayTimes"].isNull() ? "" : jQuestionItem["audioPlayTimes"].asString().c_str();
- aq.sCorrectAnswer = jQuestionItem["correctAnswer"].isNull() ? "" : jQuestionItem["correctAnswer"].asString().c_str();
- //aq.sExamQuestionTempId = jQuestionItem["examQuestionTempId"].asString().c_str();
- aq.nExamRecordDataId = jQuestionItem["examRecordDataId"].asInt64();
- aq.bIsAnswer = jQuestionItem["isAnswer"].asBool();
- //aq.bIsInMongo = jQuestionItem["isInMongo"].asBool();
- aq.bIsSign = jQuestionItem["isSign"].asBool();
- aq.nMainNumber = jQuestionItem["mainNumber"].asInt();
- int nOptionSize = jQuestionItem["optionPermutation"].size();
- for (int j = 0; j < nOptionSize; ++j)
- {
- aq.vOptionPermutation.push_back(jQuestionItem["optionPermutation"][i].asInt());
- }
- aq.nOrder = jQuestionItem["order"].asInt();
- aq.sQuestionId = jQuestionItem["questionId"].asString().c_str();
- aq.fQuestionScore = jQuestionItem["questionScore"].asDouble();
- aq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
- aq.sStudentAnswer = jQuestionItem["studentAnswer"].asString().c_str();
- aq.fStudentScore = jQuestionItem["studentScore"].asDouble();
- pGetExamRecordQuestions->vExamRecordQuestions.push_back(aq);
- }
- }
- void CHttpBll::genGetOfflineCourse(CGetOfflineCourse *pGetOfflineCourse, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetOfflineCourse->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetOfflineCourse->sMessage << sResponse.c_str();
- }
- int nSize = jsonRoot.size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jCourseInfo = jsonRoot[i];
- COfflineCourseInfo oci;
- oci.sCourseCode = jCourseInfo["courseCode"].asString().c_str();
- oci.sCourseLevel = jCourseInfo["courseLevel"].asString().c_str();
- oci.sCourseName = jCourseInfo["courseName"].asString().c_str();
- oci.sEndTime = jCourseInfo["endTime"].asString().c_str();
- oci.nExamId = jCourseInfo["examId"].asInt64();
- oci.sExamName = jCourseInfo["examName"].asString().c_str();
- oci.nExamRecordDataId = jCourseInfo["examRecordDataId"].asInt64();
- oci.nExamStudentId = jCourseInfo["examStudentId"].asInt64();
- oci.bIsvalid = jCourseInfo["isvalid"].asBool();
- oci.sOrgName = jCourseInfo["orgName"].asString().c_str();
- oci.sPaperId = jCourseInfo["paperId"].asString().c_str();
- oci.sSpecialtyName = jCourseInfo["specialtyName"].asString().c_str();
- oci.sStartTime = jCourseInfo["startTime"].asString().c_str();
- oci.sStatus = jCourseInfo["status"].asString().c_str();
- oci.sStudentCode = jCourseInfo["studentCode"].asString().c_str();
- oci.sStudentName = jCourseInfo["studentName"].asString().c_str();
- int nFileSize = jCourseInfo["offlineFiles"].size();
- for (int j = 0; j < nFileSize; ++j)
- {
- Json::Value jFileItem = jCourseInfo["offlineFiles"][j];
- COfflineFileInfo ofi;
- ofi.nExamRecordDataId = jFileItem["examRecordDataId"].asInt64();
- ofi.sFileType = jFileItem["fileType"].asString().c_str();
- ofi.nId = jFileItem["id"].asInt64();
- ofi.sOfflineFileName = jFileItem["offlineFileName"].asString().c_str();
- ofi.sOfflineFileUrl = jFileItem["offlineFileUrl"].asString().c_str();
- ofi.sOriginalFileName = jFileItem["originalFileName"].asString().c_str();
- ofi.sProperties = jFileItem["properties"].asString().c_str();
- ofi.sSuffix = jFileItem["suffix"].asString().c_str();
- oci.vOfflineFileInfo.push_back(ofi);
- }
- pGetOfflineCourse->vOfflineCourseInfo.push_back(oci);
- }
- }
- void CHttpBll::genGetOffLineExamAnswerSheet(CGetOffLineExamAnswerSheet *pGetOffLineExamAnswerSheet, const std::string &sResponse)
- {
- pGetOffLineExamAnswerSheet->sAnswerSheetUrl = sResponse.c_str();
- }
- void CHttpBll::genGetOffLineExamPaper(CGetOffLineExamPaper *pGetOffLineExamPaper, const std::string &sResponse)
- {
-
- }
- void CHttpBll::genPreviewOffLineExamPaper(CPreviewOffLineExamPaper *pPreviewOffLineExamPaper, const std::string &sResponse)
- {
- pPreviewOffLineExamPaper->sUrl = sResponse.c_str();
- }
- void CHttpBll::genCheckExamInProgress(CCheckExamInProgress *pCheckExamInProgress, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pCheckExamInProgress->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pCheckExamInProgress->sMessage << sResponse.c_str();
- }
- if (jsonRoot["data"].isNull())
- {
- pCheckExamInProgress->bHasExamInProgress = false;
- }
- else
- {
- pCheckExamInProgress->bHasExamInProgress = true;
- pCheckExamInProgress->nInterruptNum = jsonRoot["data"]["interruptNum"].asInt();
- pCheckExamInProgress->nMaxInterruptNum = jsonRoot["data"]["maxInterruptNum"].asInt();
- pCheckExamInProgress->bIsExceed = jsonRoot["data"]["isExceed"].asBool();
- pCheckExamInProgress->nExamRecordDataId = jsonRoot["data"]["examRecordDataId"].asInt64();
- pCheckExamInProgress->nExamId = jsonRoot["data"]["examId"].asInt64();
- pCheckExamInProgress->nUsedTime = jsonRoot["data"]["usedTime"].asInt64();
- pCheckExamInProgress->nFaceVerifyMinute = jsonRoot["data"]["faceVerifyMinute"].asInt();
- pCheckExamInProgress->sExamType = jsonRoot["data"]["examType"].asString().c_str();
- }
- }
- void CHttpBll::genGetCourseInfo(CGetCourseInfo *pGetCourseInfo, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetCourseInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetCourseInfo->sMessage << sResponse.c_str();
- }
- pGetCourseInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
- pGetCourseInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
- }
- void CHttpBll::genExamHeartbeat(CExamHeartbeat *pExamHeartbeat, const std::string &sResponse)
- {
- pExamHeartbeat->nLeftTime = QString(sResponse.c_str()).toLongLong();
- }
- void CHttpBll::genFindExamQuestionList(CFindExamQuestionList *pFindExamQuestionList, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pFindExamQuestionList->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pFindExamQuestionList->sMessage << sResponse.c_str();
- }
- int nSize = jsonRoot.size();
- for (int i = 0; i < nSize; ++i)
- {
- Json::Value jQuestionItem = jsonRoot[i];
- CAnsweredQuestion aq;
- aq.sAnswerType = jQuestionItem["answerType"].asString().c_str();
- aq.sAudioPlayTimes = jQuestionItem["audioPlayTimes"].isNull() ? "" :jQuestionItem["audioPlayTimes"].asString().c_str();
- aq.sCorrectAnswer = jQuestionItem["correctAnswer"].isNull() ? "" : jQuestionItem["correctAnswer"].asString().c_str();
- aq.sExamQuestionTempId = jQuestionItem["examQuestionTempId"].asString().c_str();
- aq.nExamRecordDataId = jQuestionItem["examRecordDataId"].asInt64();
- aq.bIsAnswer = jQuestionItem["isAnswer"].asBool();
- aq.bIsInMongo = jQuestionItem["isInMongo"].asBool();
- aq.bIsSign = jQuestionItem["isSign"].asBool();
- aq.nMainNumber = jQuestionItem["mainNumber"].asInt();
- int nOptionSize = jQuestionItem["optionPermutation"].size();
- for (int j = 0; j < nOptionSize; ++j)
- {
- aq.vOptionPermutation.push_back(jQuestionItem["optionPermutation"][i].asInt());
- }
- aq.nOrder = jQuestionItem["order"].asInt();
- aq.sQuestionId = jQuestionItem["questionId"].asString().c_str();
- aq.fQuestionScore = jQuestionItem["questionScore"].asDouble();
- aq.sQuestionType = jQuestionItem["questionType"].asString().c_str();
- aq.sStudentAnswer = jQuestionItem["studentAnswer"].asString().c_str();
- aq.fStudentScore = jQuestionItem["studentScore"].asDouble();
- pFindExamQuestionList->vAnsweredQuestion.push_back(aq);
- }
- }
- void CHttpBll::genGetExamRecordPaperStruct(CGetExamRecordPaperStruct *pGetExamRecordPaperStruct, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetExamRecordPaperStruct->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetExamRecordPaperStruct->sMessage << sResponse.c_str();
- }
- pGetExamRecordPaperStruct->sPaperId = jsonRoot["id"].asString().c_str();
- pGetExamRecordPaperStruct->sPaperName = jsonRoot["defaultPaper"]["name"].asString().c_str();
- pGetExamRecordPaperStruct->bFullyObjective = jsonRoot["defaultPaper"]["fullyObjective"].asBool();
- int nGroupSize = jsonRoot["defaultPaper"]["questionGroupList"].size();
- int nOrder = 1;
- for (int i = 0; i < nGroupSize; ++i)
- {
- Json::Value jGroupItem = jsonRoot["defaultPaper"]["questionGroupList"][i];
- CPaperGroupStruct pgs;
- pgs.sGroupName = jGroupItem["groupName"].asString().c_str();
- pgs.fGroupScore = jGroupItem["groupScore"].asDouble();
- pgs.nNumber = i + 1;
- int nQuestionSize = jGroupItem["questionWrapperList"].size();
- int nShowIndex = 1;
- int nTotalSubquestion = 0;
- for (int j = 0; j < nQuestionSize; ++j)
- {
- Json::Value jQuestionItem = jGroupItem["questionWrapperList"][j];
- CQuestionStruct qs;
- qs.sQuestionId = jQuestionItem["questionId"].asString().c_str();
- qs.sVersion = jQuestionItem["version"].asString().c_str();
- qs.fQuestionScore = jQuestionItem["questionScore"].asDouble();
- qs.nLimitedPlayTimes = jQuestionItem["limitedPlayTimes"].asInt();
- qs.nPlayedTimes = jQuestionItem["playedTimes"].asInt();
- qs.nTimeLimit = jQuestionItem["timeLimit"].asInt();
- int mSubQuestionSize = jQuestionItem["questionUnitWrapperList"].size();
- nTotalSubquestion += mSubQuestionSize;
- for (int k = 0; k < mSubQuestionSize; ++k)
- {
- Json::Value jSubQuestionItem = jQuestionItem["questionUnitWrapperList"][k];
- CSubQuestionStruct sqs;
- sqs.sQuestionType = jSubQuestionItem["questionType"].asString().c_str();
- sqs.sAnswerType = jSubQuestionItem["answerType"].asString().c_str();
- sqs.fQuestionScore = jSubQuestionItem["questionScore"].asDouble();
- sqs.nLimitedPlayTimes = qs.nLimitedPlayTimes;
-
- for (int jq = 0; jq < jSubQuestionItem["optionPermutation"].size(); ++jq)
- {
- Json::Value Item = jSubQuestionItem["optionPermutation"][jq];
- sqs.voptionPermutation.push_back(Item.asInt());
- }
- sqs.nShowNumber = nShowIndex;
- sqs.nOrder = nOrder;
- nShowIndex++;
- nOrder++;
- qs.vSubQuestionStruct.push_back(sqs);
- }
- pgs.vQuestionStruct.push_back(qs);
- }
- pgs.nTotalSubquestion = nTotalSubquestion;
- pGetExamRecordPaperStruct->vPaperGroupStruct.push_back(pgs);
- }
- }
- void CHttpBll::genGetEndExamInfo(CGetEndExamInfo *pGetEndExamInfo, const std::string &sResponse)
- {
- if (sResponse == "")
- {
- pGetEndExamInfo->bIsCalculate = true;
- return;
- }
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetEndExamInfo->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pGetEndExamInfo->sMessage << sResponse.c_str();
- }
-
- pGetEndExamInfo->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
- pGetEndExamInfo->bIsWarn = jsonRoot["isWarn"].asBool();
- pGetEndExamInfo->fObjectiveAccuracy = jsonRoot["objectiveAccuracy"].asDouble();
- pGetEndExamInfo->fObjectiveScore = jsonRoot["objectiveScore"].asInt64();
-
-
- }
- void CHttpBll::genGetWXQrCode(CGetWXQrCode *pGetWXQrCode, const std::string &sResponse)
- {
- pGetWXQrCode->sUrl = sResponse.c_str();
- }
- void CHttpBll::genProcessUpload(CProcessUpload *pProcessUpload, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pProcessUpload->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pProcessUpload->sMessage << sResponse.c_str();
- }
- pProcessUpload->sFileUrl = jsonRoot["fileUrl"].asString().c_str();
- }
- void CHttpBll::genGetOrgPropertiesByGroupWithoutCache(CGetOrgPropertiesByGroupWithoutCache *pOrgProperties, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pOrgProperties->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pOrgProperties->sMessage << sResponse.c_str();
- }
- pOrgProperties->nActionNum = QVariant(jsonRoot["ACTION_NUM"].asString().c_str()).toInt();
- pOrgProperties->sActionOptions = jsonRoot["ACTION_OPTIONS"].asString().c_str();
- pOrgProperties->sActionOrder = jsonRoot["ACTION_ORDER"].asString().c_str();
- pOrgProperties->nActionDuration = QVariant(jsonRoot["ACTION_DURATION"].asString().c_str()).toInt();
- pOrgProperties->nActionAlert = QVariant(jsonRoot["ACTION_ALERT"].asString().c_str()).toInt();
-
- }
- void CHttpBll::genStartFaceLiveVerify(CStartFaceLiveVerify *pStartFaceLiveVerify, const std::string &sResponse)
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStartFaceLiveVerify->sMessage = QString::fromLocal8Bit("解析后台返回环境信息json异常!");
- myDebug() << pStartFaceLiveVerify->sMessage << sResponse.c_str();
- }
- pStartFaceLiveVerify->nFaceLiveVerifyId = jsonRoot["faceLiveVerifyId"].asInt64();
- pStartFaceLiveVerify->nStartMinute = jsonRoot["startMinute"].asInt();
- pStartFaceLiveVerify->nTimes = jsonRoot["times"].asInt();
- }
|