123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727 |
- #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))
- {
- --requestPkg.nRetryCount;
- if(requestPkg.nRetryCount > 0)
- {
- post(requestPkg);
- return;
- }
- sErrorMsg = QString::fromLocal8Bit("接口%1调用失败!").arg(requestPkg.sUri);
- }
- }
- else if(requestPkg.nHttpType == HttpType::htGet || requestPkg.nHttpType == HttpType::htGetUrl)
- {
- if(!doGet(requestPkg, sResponse, nCode))
- {
- --requestPkg.nRetryCount;
- if(requestPkg.nRetryCount > 0)
- {
- get(requestPkg);
- return;
- }
- sErrorMsg = QString::fromLocal8Bit("接口%1调用失败!").arg(requestPkg.sUri);
- }
- }
- else if (requestPkg.nHttpType == HttpType::htPut)
- {
- if (!doPut(requestPkg, sResponse, nCode))
- {
- --requestPkg.nRetryCount;
- if(requestPkg.nRetryCount > 0)
- {
- put(requestPkg);
- return;
- }
- 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 << ":resCode," << nCode<<"response:"<< sResponse.c_str();
- if (nCode != 200)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (reader.parse(sResponse, jsonRoot))
- {
- if (jsonRoot.isMember("desc"))
- {
- sErrorMsg = jsonRoot["desc"].asString().c_str();
- }
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- 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;
- ee.bForce = requestPkg.sAdditionStr == "1";
- 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;
- case RequestType::rtClientExamProcessUploadSign:
- {
- CClientExamProcessUploadSign cepus;
- cepus.sCommonStr = requestPkg.sCommonStr;
- cepus.sFilePath = requestPkg.sCommonStr1;
- cepus.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- cepus.sMessage = sErrorMsg;
- }
- else
- {
- genClientExamProcessUploadSign(&cepus, sResponse);
- }
- emit sgnClientExamProcessUploadSign(cepus);
- }
- break;
- case RequestType::rtUploadFileToAliyun:
- {
- CUploadFileToAliyun ufta;
- ufta.sCommonStr = requestPkg.sCommonStr;
- ufta.sFileUrl = requestPkg.sCommonStr1;
- ufta.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- ufta.sMessage = sErrorMsg;
- }
- emit sgnUploadFileToAliyun(ufta);
- }
- break;
- case RequestType::rtExamControlCheckTime:
- {
- CBaseResponsePackage res;
- res.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- res.sMessage = sErrorMsg;
- }
- emit sgnExamControlCheckTime(res);
- }
- break;
- case RequestType::rtSkipFaceCheckParam:
- {
- CSkipFaceCheckParam res;
- res.nCode = nCode;
- if (sErrorMsg != "" || nCode != 200)
- {
- res.sMessage = sErrorMsg;
- }
- else
- {
- genSkipFaceCheckParam(&res, sResponse);
- }
- emit sgnSkipFaceCheckParam(res);
- }
- break;
- default:
- break;
- }
- }
- void CHttpBll::genUpgrade(CUpgrade *pUpgrade, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if(!reader.parse(sResponse, jsonRoot))
- {
- pUpgrade->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genAgreement(CAgreement *pAgreement, const std::string &sResponse)
- {
- try
- {
- 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("数据请求失败,请检查网络是否正常!");
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genStudentClientConfig(CStudentClientConfig *pStudentClientConfig, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStudentClientConfig->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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;
- }
- else if (sType == "DISABLE_VIRTUAL_MACHINE")
- {
- pStudentClientConfig->bDisableVirtualMachine = true;
- }
- else if(sType == "EXAMING_BLACK_LIST_CHECK")
- {
- pStudentClientConfig->bExamingBlackListCheck = 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"
- if (jsonRoot.isMember("SHOW_INFO"))
- {
- QString sShowInfo = jsonRoot["SHOW_INFO"].asString().c_str();
- pStudentClientConfig->bShowStudentName = sShowInfo.indexOf("STU_NAME") >= 0;
- pStudentClientConfig->bShowStudentCode = sShowInfo.indexOf("STU_CODE") >= 0;
- pStudentClientConfig->bShowStudentIdentity = sShowInfo.indexOf("IDENTITY_NUMBER") >= 0;
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genSysNotice(CSysNotice *pSysNotice, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pSysNotice->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genSoftwareConfig(CGetSoftwareConfig *pSoftwareConfig, const std::string &sResponse)
- {
- if(!sResponse.empty())
- {
- pSoftwareConfig->sSoftwareConfig = std::string(sResponse.rbegin()+32, sResponse.rend()).c_str();
- }
- }
- void CHttpBll::genLoginLimit(CLoginLimit *pLoginLimit, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pLoginLimit->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pLoginLimit->sMessage << sResponse.c_str();
- }
- pLoginLimit->nCount = jsonRoot["count"].asInt64();
- pLoginLimit->bPass = jsonRoot["pass"].asBool();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genLoginInfo(CLoginInfo *pLoginInfo, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pLoginInfo->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- 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)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetStudentClientMenu->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetStudentInfoBySession(CGetStudentInfoBySession *pGetStudentInfoBySession, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetStudentInfoBySession->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genSpecialtyNameList(CSpecialtyNameList *pSpecialtyNameList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pSpecialtyNameList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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;
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetUserNoticeList(CGetUserNoticeList *pGetUserNoticeList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetUserNoticeList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genAppDownLoadUrl(CAppDownLoadUrl *pAppDownLoadUrl, const std::string &sResponse)
- {
- pAppDownLoadUrl->sUrl = sResponse.c_str();
- }
- void CHttpBll::genAppEnabled(CAppEnabled *pAppEnabled, const std::string &sResponse)
- {
- try
- {
- pAppEnabled->bEnable = QVariant(sResponse.c_str()).toBool();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genQueryBatchList(CQueryBatchList *pQueryBatchList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryBatchList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetExamProperty(CGetExamProperty *pGetExamProperty, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetExamProperty->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pGetExamProperty->sMessage << sResponse.c_str();
- }
- if (jsonRoot.isMember("BEFORE_EXAM_REMARK") && jsonRoot["BEFORE_EXAM_REMARK"] != Json::Value::null)
- {
- pGetExamProperty->sBeforeExamRemark = jsonRoot["BEFORE_EXAM_REMARK"].asString().c_str();
- }
- if (jsonRoot.isMember("CHECK_ENVIRONMENT") && jsonRoot["CHECK_ENVIRONMENT"] != Json::Value::null)
- {
- pGetExamProperty->bCheckEnvironment = QVariant(jsonRoot["CHECK_ENVIRONMENT"].asString().c_str()).toBool();
- }
- // if (jsonRoot.isMember("PC_CLIENT_FACE_THRESHOLD"))
- // {
- // pGetExamProperty->nFaceThreshold = QVariant(jsonRoot["PC_CLIENT_FACE_THRESHOLD"].asString().c_str()).toInt();
- // }
- if (jsonRoot.isMember("IS_FACE_CHECK") && jsonRoot["IS_FACE_CHECK"] != Json::Value::null)
- {
- pGetExamProperty->bIsFaceCheck = QVariant(jsonRoot["IS_FACE_CHECK"].asString().c_str()).toBool();
- }
- if (jsonRoot.isMember("SNAPSHOT_INTERVAL") && jsonRoot["SNAPSHOT_INTERVAL"] != Json::Value::null)
- {
- pGetExamProperty->nSnapshotInterval = QVariant(jsonRoot["SNAPSHOT_INTERVAL"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("FACE_VERIFY_START_MINUTE") && jsonRoot["FACE_VERIFY_START_MINUTE"] != Json::Value::null)
- {
- pGetExamProperty->nFaceVerifyStartMinute = QVariant(jsonRoot["FACE_VERIFY_START_MINUTE"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("FACE_VERIFY_END_MINUTE") && jsonRoot["FACE_VERIFY_END_MINUTE"] != Json::Value::null)
- {
- pGetExamProperty->nFaceVerifyEndMinute = QVariant(jsonRoot["FACE_VERIFY_END_MINUTE"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("IS_STRANGER_ENABLE") && jsonRoot["IS_STRANGER_ENABLE"] != Json::Value::null)
- {
- pGetExamProperty->bIsStrangerEnable = QVariant(jsonRoot["IS_STRANGER_ENABLE"].asString().c_str()).toBool();
- }
- if (jsonRoot.isMember("PRACTICE_TYPE") && jsonRoot["PRACTICE_TYPE"] != Json::Value::null)
- {
- pGetExamProperty->sPracticeType = jsonRoot["PRACTICE_TYPE"].asString().c_str();
- }
- if (jsonRoot.isMember("FREEZE_TIME") && jsonRoot["FREEZE_TIME"] != Json::Value::null)
- {
- pGetExamProperty->nFreezeTime = QVariant(jsonRoot["FREEZE_TIME"].asString().c_str()).toInt();
- }
- if (jsonRoot.isMember("AFTER_EXAM_REMARK") && jsonRoot["AFTER_EXAM_REMARK"] != Json::Value::null)
- {
- pGetExamProperty->sAfterExamRemark = jsonRoot["AFTER_EXAM_REMARK"].asString().c_str();
- }
- if (jsonRoot.isMember("IS_OBJ_SCORE_VIEW") && jsonRoot["IS_OBJ_SCORE_VIEW"] != Json::Value::null)
- {
- pGetExamProperty->bIsObjScoreView = QVariant(jsonRoot["IS_OBJ_SCORE_VIEW"].asString().c_str()).toBool();
- }
- if (jsonRoot.isMember("SHOW_CHEATING_REMARK") && jsonRoot["SHOW_CHEATING_REMARK"] != Json::Value::null)
- {
- pGetExamProperty->bShowCheatingRemark = QVariant(jsonRoot["SHOW_CHEATING_REMARK"].asString().c_str()).toBool();
- }
- if (jsonRoot.isMember("CHEATING_REMARK") && jsonRoot["CHEATING_REMARK"] != Json::Value::null)
- {
- pGetExamProperty->sCheatingRemark = jsonRoot["CHEATING_REMARK"].asString().c_str();
- }
- if (jsonRoot.isMember("IS_FACE_VERIFY_BEFORE") && jsonRoot["IS_FACE_VERIFY_BEFORE"] != Json::Value::null)
- {
- pGetExamProperty->bIsLivenessBefore = QVariant(jsonRoot["IS_FACE_VERIFY_BEFORE"].asString().c_str()).toBool();
- }
- 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());
- }
- }
- if(jsonRoot.isMember("FACE_VERIFY_FORCE_EXIT") && jsonRoot["FACE_VERIFY_FORCE_EXIT"] != Json::Value::null)
- {
- pGetExamProperty->bFaceVerifyForceExit = QVariant(jsonRoot["FACE_VERIFY_FORCE_EXIT"].asString().c_str()).toBool();
- }
- if(jsonRoot.isMember("SHOW_MULTIPLE_CHOICE_WARNING") && jsonRoot["SHOW_MULTIPLE_CHOICE_WARNING"] != Json::Value::null)
- {
- pGetExamProperty->bMutipleAnserCountTips = QVariant(jsonRoot["SHOW_MULTIPLE_CHOICE_WARNING"].asString().c_str()).toBool();
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genStartExamLimit(CStartExamLimit *pStartExamLimit, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStartExamLimit->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pStartExamLimit->sMessage << sResponse.c_str();
- }
- pStartExamLimit->nCount = jsonRoot["count"].asInt();
- pStartExamLimit->bPass = jsonRoot["pass"].asBool();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genIpLimit(CIpLimit *pIpLimit, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pIpLimit->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pIpLimit->sMessage << sResponse.c_str();
- }
- pIpLimit->bLimited = jsonRoot["limited"].asBool();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genStartExam(CStartExam *pStartExam, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStartExam->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genFaceCheckEnabled(CFaceCheckEnabled *pFaceCheckEnabled, const std::string &sResponse)
- {
- try
- {
- pFaceCheckEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genLivenessEnabled(CLivenessEnabled *pLivenessEnabled, const std::string &sResponse)
- {
- try
- {
- pLivenessEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genWeiXinAnswerEnabled(CWeiXinAnswerEnabled *pWeiXinAnswerEnabled, const std::string &sResponse)
- {
- try
- {
- pWeiXinAnswerEnabled->bEnabled = QVariant(sResponse.c_str()).toBool();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetExamById(CGetExamById *pGetExamById, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetExamById->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genStartAnswer(CStartAnswer *pStartAnswer, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStartAnswer->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pStartAnswer->sMessage << sResponse.c_str();
- }
- pStartAnswer->nDuration = jsonRoot["duration"].asInt64();
- pStartAnswer->nExamRecordDataId = jsonRoot["examRecordDataId"].asInt64();
- pStartAnswer->nUsedExamSeconds = jsonRoot["usedExamSeconds"].asInt64();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetQuestion(CGetQuestion *pGetQuestion, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetQuestion->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetQuestionContent(CGetQuestionContent *pGetQuestionContent, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetQuestionContent->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genExamCourseInfo(const Json::Value &jExamItem, CExamCourseInfo &eci)
- {
- try
- {
- 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"].asBool();
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genQueryExamList(CQueryExamList *pQueryExamList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryExamList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genQueryExamEndList(CQueryExamEndList *pQueryExamEndList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryExamEndList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genQueryObjectiveScoreList(CQueryObjectiveScoreList *pQueryObjectiveScoreList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryObjectiveScoreList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genQueryHomeworkList(CQueryHomeworkList *pQueryHomeworkList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryHomeworkList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genQueryPracticeCourseList(CQueryPracticeCourseList *pQueryPracticeCourseList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryPracticeCourseList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genQueryPracticeRecordList(CQueryPracticeRecordList *pQueryPracticeRecordList, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pQueryPracticeRecordList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetPracticeDetailInfo(CGetPracticeDetailInfo *pGetPracticeDetailInfo, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetPracticeDetailInfo->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genFindExamRecordDataEntity(CFindExamRecordDataEntity *pFindExamRecordDataEntity, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pFindExamRecordDataEntity->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pFindExamRecordDataEntity->sMessage << sResponse.c_str();
- }
- pFindExamRecordDataEntity->nExamId = jsonRoot["examRecord"]["examId"].asInt64();
- pFindExamRecordDataEntity->sPaperType = jsonRoot["examRecord"]["paperType"].asString().c_str();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetExamRecordQuestions(CGetExamRecordQuestions *pGetExamRecordQuestions, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetExamRecordQuestions->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetOfflineCourse(CGetOfflineCourse *pGetOfflineCourse, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetOfflineCourse->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- 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)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pCheckExamInProgress->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetCourseInfo(CGetCourseInfo *pGetCourseInfo, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetCourseInfo->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pGetCourseInfo->sMessage << sResponse.c_str();
- }
- pGetCourseInfo->sCourseName = jsonRoot["courseName"].asString().c_str();
- pGetCourseInfo->sCourseCode = jsonRoot["courseCode"].asString().c_str();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- 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)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pFindExamQuestionList->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetExamRecordPaperStruct(CGetExamRecordPaperStruct *pGetExamRecordPaperStruct, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetExamRecordPaperStruct->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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);
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genGetEndExamInfo(CGetEndExamInfo *pGetEndExamInfo, const std::string &sResponse)
- {
- try
- {
- if (sResponse == "")
- {
- pGetEndExamInfo->bIsCalculate = true;
- return;
- }
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pGetEndExamInfo->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
-
- }
- void CHttpBll::genGetWXQrCode(CGetWXQrCode *pGetWXQrCode, const std::string &sResponse)
- {
- pGetWXQrCode->sUrl = sResponse.c_str();
- }
- //void CHttpBll::genProcessUpload(CProcessUpload *pProcessUpload, const std::string &sResponse)
- //{
- // try
- // {
- // Json::Reader reader;
- // Json::Value jsonRoot = Json::Value::null;
- // if (!reader.parse(sResponse, jsonRoot))
- // {
- // pProcessUpload->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- // myDebug() << pProcessUpload->sMessage << sResponse.c_str();
- // }
- // pProcessUpload->sFileUrl = jsonRoot["fileUrl"].asString().c_str();
- // }
- // catch (const std::exception &e)
- // {
- // myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- // }
- //}
- void CHttpBll::genGetOrgPropertiesByGroupWithoutCache(CGetOrgPropertiesByGroupWithoutCache *pOrgProperties, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pOrgProperties->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- 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();
- pOrgProperties->nAllActionDuration = QVariant(jsonRoot["ALL_ACTION_DURATION"].asString().c_str()).toInt();
- if(jsonRoot.isMember("PC_CLIENT_FACE_THRESHOLD") && jsonRoot["PC_CLIENT_FACE_THRESHOLD"] != Json::Value::null)
- {
- pOrgProperties->nFaceThreshold = QVariant(jsonRoot["PC_CLIENT_FACE_THRESHOLD"].asString().c_str()).toInt();
- }
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genStartFaceLiveVerify(CStartFaceLiveVerify *pStartFaceLiveVerify, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pStartFaceLiveVerify->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pStartFaceLiveVerify->sMessage << sResponse.c_str();
- }
- pStartFaceLiveVerify->nFaceLiveVerifyId = jsonRoot["faceLiveVerifyId"].asInt64();
- pStartFaceLiveVerify->nStartMinute = jsonRoot["startMinute"].asInt();
- pStartFaceLiveVerify->nTimes = jsonRoot["times"].asInt();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genClientExamProcessUploadSign(CClientExamProcessUploadSign *pClientExamProcessUploadSign, const std::string &sResponse)
- {
- try
- {
- Json::Reader reader;
- Json::Value jsonRoot = Json::Value::null;
- if (!reader.parse(sResponse, jsonRoot))
- {
- pClientExamProcessUploadSign->sMessage = QString::fromLocal8Bit("数据请求失败,请检查网络是否正常!");
- myDebug() << pClientExamProcessUploadSign->sMessage << sResponse.c_str();
- }
- pClientExamProcessUploadSign->sType = jsonRoot["fsType"].asString().c_str();
- pClientExamProcessUploadSign->sAccessUrl = jsonRoot["accessUrl"].asString().c_str();
- pClientExamProcessUploadSign->sSignIdentifier = jsonRoot["signIdentifier"].asString().c_str();
- pClientExamProcessUploadSign->sFormUrl = jsonRoot["formUrl"].asString().c_str();
- pClientExamProcessUploadSign->sOssAcessKeyId = jsonRoot["formParams"]["OSSAccessKeyId"].asString().c_str();
- pClientExamProcessUploadSign->sSignature = jsonRoot["formParams"]["Signature"].asString().c_str();
- pClientExamProcessUploadSign->sKey = jsonRoot["formParams"]["key"].asString().c_str();
- pClientExamProcessUploadSign->sPolicy = jsonRoot["formParams"]["policy"].asString().c_str();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
- void CHttpBll::genSkipFaceCheckParam(CSkipFaceCheckParam *pSkipFaceCheckParam, const std::string &sResponse)
- {
- try
- {
- pSkipFaceCheckParam->bSkipFaceCheck = QVariant(sResponse.c_str()).toBool();
- }
- catch (const std::exception &e)
- {
- myServerLog()<<sResponse.c_str()<<",exception error"<<e.what();
- }
- }
|