StudentMatcher.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. #include "StdAfx.h"
  2. #include "StudentMatcher.h"
  3. #include "..\EvaluationUtil\HttpClient.h"
  4. #include "basic_struct.h"
  5. #include "ServerConfig.h"
  6. #include "rapidjson/document.h"
  7. #include "UploadManager.h"
  8. extern UploadManager* g_upload_manager;
  9. extern int g_my_scan_type;
  10. CStudentMatcher::CStudentMatcher(void)
  11. {
  12. m_hwnd =NULL;
  13. m_bErrorHandle = false;
  14. m_bUseQr = false;
  15. cur_student_paper_id = -1;
  16. m_nOnlineScanType = -1;
  17. }
  18. CStudentMatcher::~CStudentMatcher(void)
  19. {
  20. }
  21. ServiceState CStudentMatcher::OnStarting( void )
  22. {
  23. url_str.Format(_T("%s/coachio/iointerface/getThirdStudentCard"),CServerConfig::server_url);
  24. url_str_dxk.Format(_T("%s/coachio/iointerface_v2/getDuxueStudentCard"), CServerConfig::server_url);
  25. url_str_zxk.Format(_T("%s/coachio/iointerface_v2/getStudentInfoByStudentCards"), CServerConfig::server_url);
  26. return running;
  27. }
  28. std::string ascii2utf8(const string & ascii){
  29. int len_w=MultiByteToWideChar(CP_ACP,0,ascii.c_str(),-1,0,0);
  30. WCHAR * wchar=new WCHAR[len_w];
  31. MultiByteToWideChar(CP_ACP,0,ascii.c_str(),-1,wchar,len_w);
  32. int len_c=WideCharToMultiByte(CP_UTF8,0,wchar,-1,0,0,0,0);
  33. char * chars = new char[len_c];
  34. WideCharToMultiByte(CP_UTF8,0,wchar,-1,chars,len_c,0,0);
  35. string result =chars;
  36. delete []wchar;
  37. delete []chars;
  38. return result;
  39. }
  40. std::string utf82ascii(const string & utf8){
  41. int len_w=MultiByteToWideChar(CP_UTF8,0,utf8.c_str(),-1,0,0);
  42. WCHAR * wchar=new WCHAR[len_w];
  43. MultiByteToWideChar(CP_UTF8,0,utf8.c_str(),-1,wchar,len_w);
  44. int len_c=WideCharToMultiByte(CP_ACP,0,wchar,-1,0,0,0,0);
  45. char * chars = new char[len_c];
  46. WideCharToMultiByte(CP_ACP,0,wchar,-1,chars,len_c,0,0);
  47. string result =chars;
  48. delete []wchar;
  49. delete []chars;
  50. return result;
  51. }
  52. #include<fstream>
  53. #include<iostream>
  54. ServiceState CStudentMatcher::OnRunning(void)
  55. {
  56. ServiceState nextState = IService::OnRunning();
  57. if (nextState == pausing) return nextState;
  58. // if (m_bUseQr){
  59. // return stoping;
  60. // }
  61. char sql5[512];
  62. sprintf_s(sql5, "SELECT sp.student_paper_id, sp.student_code FROM student_paper sp WHERE (sp.paper_state & %d) = %d", EX_KAOHAODAIPIPEI, EX_KAOHAODAIPIPEI);
  63. CppSQLite3Query query = bantch_db->execQuery(sql5);
  64. if (!query.eof()){
  65. string response;
  66. CString postData;
  67. string strStuCode;
  68. m_examId = 16;
  69. CString strPaperId;
  70. readPaperId(strPaperId);
  71. //postData.Format(_T("exam_group_id="));
  72. //postData += strPaperId;
  73. //postData += "&studentCard=";
  74. if (g_my_scan_type == 2)
  75. {
  76. postData += "studentCard=";
  77. }
  78. else
  79. {
  80. postData.Format(_T("exam_group_id="));
  81. postData += strPaperId;
  82. postData += "&studentCard=";
  83. }
  84. // postData.Format(_T("paperIdStr=16670445642153199061&studentCard="));
  85. int studentCount = 0;
  86. std::map<std::string, vector<int>> code_id_map;
  87. while (!query.eof()){
  88. code_id_map[query.getStringField("student_code")].push_back(query.getIntField("student_paper_id"));
  89. if (studentCount > 0){ postData.Append(_T(",")); }
  90. postData.Append(CString(query.getStringField("student_code")));
  91. strStuCode = query.getStringField("student_code");
  92. query.nextRow();
  93. studentCount++;
  94. }
  95. //postData.Append(CString("&cardStatus=0"));
  96. //CString strBarcodeFlag,strBar;
  97. //readBarcodeFlag(strBarcodeFlag);
  98. //strBar = "&barcodeFlag=";
  99. //strBar = strBar + strBarcodeFlag;
  100. //postData.Append(strBar);
  101. if (g_my_scan_type == 2)
  102. {
  103. }
  104. else
  105. {
  106. postData.Append(CString("&cardStatus=0"));
  107. CString strBarcodeFlag, strBar;
  108. readBarcodeFlag(strBarcodeFlag);
  109. strBar = "&barcodeFlag=";
  110. strBar = strBar + strBarcodeFlag;
  111. postData.Append(strBar);
  112. }
  113. rapidjson::Document root;
  114. CHttpClient httpClient;
  115. if (!m_bUseQr || m_strQr.empty()){
  116. httpClient.SetSendHeader(MarkHttpHeaderData());
  117. if (g_my_scan_type == 1)
  118. {
  119. httpClient.HttpPost(url_str_dxk, postData, response);
  120. }
  121. else if (g_my_scan_type == 2)
  122. {
  123. httpClient.HttpPost(url_str_zxk, postData, response);
  124. }
  125. else
  126. {
  127. httpClient.HttpPost(url_str, postData, response);
  128. }
  129. root.Parse(ascii2utf8(response).c_str());
  130. }
  131. Sleep(1000);//休眠1秒
  132. EnterCriticalSection(db_lock);
  133. if (!m_bUseQr){
  134. if (root.IsObject() && root["success"].IsInt() && root["success"].GetInt()){
  135. rapidjson::Value& rows = root["object"];
  136. std::map<std::string, rapidjson::Value> code_obj_map;
  137. for (int i = 0; i < rows.Size(); i++)
  138. {
  139. code_obj_map[utf82ascii(rows[i]["examineeCode"].GetString())] = rows[i];
  140. }
  141. std::map<string, vector<int>>::iterator it;
  142. char * sql = "INSERT INTO student ( student_id, student_code, class_name, school_id, grade_name, student_name, class_id, score_total ,studentCard,schoolStudentCard ) SELECT t.student_id, t.student_code, t.class_name, t.school_id, t.grade_name, t.student_name, t.class_id, t.score_total,t.studentCard ,t.schoolStudentCard FROM ( SELECT :student_id student_id, :student_code student_code, :class_name class_name, :school_id school_id, :grade_name grade_name, :student_name student_name, :class_id class_id, :score_total score_total, :studentCard studentCard , :schoolStudentCard schoolStudentCard ) t LEFT JOIN student s ON s.student_id = t.student_id WHERE s.student_id IS NULL";
  143. CppSQLite3Statement statement = bantch_db->compileStatement(sql);
  144. for (it = code_id_map.begin(); it != code_id_map.end(); ++it)
  145. {
  146. bool bUpload = true;
  147. std::map<std::string, rapidjson::Value>::iterator it2 = code_obj_map.find(it->first);
  148. for (int m = 0; m < it->second.size(); m++)
  149. {
  150. if (it2 == code_obj_map.end()){//不存在该考生
  151. sprintf_s(sql5, "update student_paper set paper_state =paper_state -%d +%d where student_paper_id =%d", EX_KAOHAODAIPIPEI, EX_KAOHAOBUCUNZAI, it->second[m]);
  152. bantch_db->execDML(sql5);
  153. bUpload = false;
  154. }
  155. else{
  156. //检查是否有考号冲突的试卷
  157. sprintf_s(sql5, "select sp.student_paper_id,sp.paper_state,sp.student_id from student_paper sp where sp.student_id = '%s' and sp.student_paper_id!=%d", utf82ascii(it2->second["studentId"].GetString()).c_str(), it->second[m]);
  158. int cur_student_paper_id = it->second[m];
  159. CppSQLite3Query q2 = bantch_db->execQuery(sql5);
  160. vector<int> all_conflict_ids;
  161. vector<int> conflict_ids;
  162. while (!q2.eof()){
  163. long paper_state_t = q2.getInt64Field("paper_state");
  164. all_conflict_ids.push_back(q2.getIntField("student_paper_id"));
  165. if (!(paper_state_t&EX_KAOHAOCHONGTU))
  166. conflict_ids.push_back(q2.getIntField("student_paper_id"));
  167. q2.nextRow();
  168. }
  169. bUpload = all_conflict_ids.empty();
  170. if (!all_conflict_ids.empty()){
  171. CppSQLite3Statement stmt3 = bantch_db->compileStatement("insert into exception (exception_type ,exception_name,page_id,student_paper_id) values(:exception_type ,:exception_name,:page_id,:student_paper_id)");
  172. for (int m = 0; m < conflict_ids.size(); m++){//将与之冲突的试卷标记为考号冲突
  173. sprintf_s(sql5, "update student_paper set paper_state =paper_state|%d ,Is_Covered=0 where student_paper_id=%d", EX_KAOHAOCHONGTU, conflict_ids[m]);
  174. bantch_db->execDML(sql5);
  175. stmt3.bind(":student_paper_id", conflict_ids[m]);
  176. stmt3.bind(":exception_type", SHIFT_KAOHAOCHONGTU);
  177. stmt3.bind(":exception_name", "考号冲突");
  178. stmt3.execDML();
  179. CppSQLite3Statement stmt4 = bantch_db->compileStatement("insert INTO message (student_paper_id , message_type) VALUES (:student_paper_id,:message_type)");
  180. stmt4.bind(":student_paper_id", conflict_ids[m]);
  181. stmt4.bind(":message_type", WM_IDENTIFOR_PAPER_STATE_CHAGED);
  182. stmt4.execDML();
  183. if (m_hwnd != NULL)
  184. ::PostMessage(m_hwnd, WM_IDENTIFOR_PAPER_STATE_CHAGED, (WPARAM)NULL, (LPARAM)conflict_ids[m]);
  185. if (g_upload_manager&&g_upload_manager->IsEanble()){
  186. if (conflict_ids[m] != cur_student_paper_id)
  187. g_upload_manager->UploadOnScanCmd(UPLOAD_ON_SCAN_CMD::CMD_DEL_UPLOAD_REPORT, std::to_string(conflict_ids[m]).c_str());
  188. }
  189. }
  190. stmt3.bind(":student_paper_id", it->second[m]);
  191. stmt3.bind(":exception_type", SHIFT_KAOHAOCHONGTU);
  192. stmt3.bind(":exception_name", "考号冲突");
  193. stmt3.execDML();
  194. }
  195. sprintf_s(sql5, "update student_paper set paper_state =paper_state -%d+%d,student_id ='%s',Is_Covered=0 where student_paper_id =%d",
  196. EX_KAOHAODAIPIPEI,
  197. all_conflict_ids.empty() ? 0 : EX_KAOHAOCHONGTU,
  198. utf82ascii(it2->second["studentId"].GetString()).c_str(),
  199. it->second[m]);
  200. bantch_db->execDML(sql5);
  201. statement.bind(":student_id", utf82ascii(it2->second["studentId"].GetString()).c_str());
  202. statement.bind(":student_code", utf82ascii(it2->second["examineeCode"].GetString()).c_str());
  203. statement.bind(":class_name", utf82ascii(it2->second["clazzName"].GetString()).c_str());
  204. statement.bind(":school_id", it2->second["schoolId"].GetInt());
  205. statement.bind(":grade_name", utf82ascii(it2->second["gradeName"].GetString()).c_str());
  206. statement.bind(":student_name", utf82ascii(it2->second["studentName"].GetString()).c_str());
  207. statement.bind(":class_id", (long long)it2->second["clazzId"].GetInt64());
  208. statement.bind(":score_total", 0);
  209. statement.bind(":studentCard", it2->second["studentCard"].GetString());
  210. statement.bind(":schoolStudentCard", it2->second["schoolStudentCard"].GetString());
  211. statement.execDML();
  212. }
  213. CppSQLite3Statement stmt4 = bantch_db->compileStatement("insert INTO message (student_paper_id , message_type) VALUES (:student_paper_id,:message_type)");
  214. stmt4.bind(":student_paper_id", it->second[m]);
  215. stmt4.bind(":message_type", WM_IDENTIFOR_PAPER_STATE_CHAGED);
  216. stmt4.execDML();
  217. if (m_hwnd != NULL)::PostMessage(m_hwnd, WM_IDENTIFOR_PAPER_STATE_CHAGED, (WPARAM)NULL, (LPARAM)it->second[m]);
  218. if (bUpload&&g_upload_manager){
  219. std::string paper_state_qry_sql = "select paper_state from student_paper where student_paper_id=";
  220. paper_state_qry_sql += std::to_string(it->second[m]);
  221. auto paper_state_qry = bantch_db->execQuery(paper_state_qry_sql.c_str());
  222. if (!paper_state_qry.eof() &&
  223. paper_state_qry.getIntField("paper_state") == 0){
  224. g_upload_manager->UploadOnScanCmd(UPLOAD_ON_SCAN_CMD::CMD_UPLOAD_SUCCESSSJUAN, std::to_string(it->second[m]).c_str());
  225. }
  226. }
  227. }
  228. }
  229. }
  230. else{
  231. std::map<string, vector<int>>::iterator it;
  232. for (it = code_id_map.begin(); it != code_id_map.end(); ++it)
  233. {
  234. for (int m = 0; m < it->second.size(); m++)
  235. {
  236. sprintf_s(sql5, "update student_paper set paper_state =paper_state -%d +%d where student_paper_id =%d", EX_KAOHAODAIPIPEI, EX_KAOHAOBUCUNZAI, it->second[m]);
  237. bantch_db->execDML(sql5);
  238. CppSQLite3Statement stmt4 = bantch_db->compileStatement("insert INTO message (student_paper_id , message_type) VALUES (:student_paper_id,:message_type)");
  239. stmt4.bind(":student_paper_id", it->second[m]);
  240. stmt4.bind(":message_type", WM_IDENTIFOR_PAPER_STATE_CHAGED);
  241. stmt4.execDML();
  242. if (m_hwnd != NULL)::PostMessage(m_hwnd, WM_IDENTIFOR_PAPER_STATE_CHAGED, (WPARAM)NULL, (LPARAM)it->second[m]);
  243. }
  244. }
  245. }
  246. }
  247. else{
  248. std::string _student_code;
  249. std::string _student_id;
  250. if (!m_strQr.empty()){
  251. std::vector< std::string > _out;
  252. split(m_strQr, "@", &_out);
  253. if (_out.size() >= 3){
  254. _student_code = _out[1];
  255. }
  256. }
  257. else{
  258. _student_code = strStuCode;
  259. if (root.IsObject() && root["success"].IsInt() && root["success"].GetInt()){
  260. if (root["object"].IsArray() && root["object"].Size()>0){
  261. _student_id = utf82ascii(root["object"][0]["studentId"].GetString());
  262. }
  263. }
  264. else{
  265. std::map<string, vector<int>>::iterator it;
  266. for (it = code_id_map.begin(); it != code_id_map.end(); ++it)
  267. {
  268. for (int m = 0; m < it->second.size(); m++)
  269. {
  270. sprintf_s(sql5, "update student_paper set paper_state =paper_state -%d +%d where student_paper_id =%d", EX_KAOHAODAIPIPEI, EX_KAOHAOBUCUNZAI, it->second[m]);
  271. bantch_db->execDML(sql5);
  272. CppSQLite3Statement stmt4 = bantch_db->compileStatement("insert INTO message (student_paper_id , message_type) VALUES (:student_paper_id,:message_type)");
  273. stmt4.bind(":student_paper_id", it->second[m]);
  274. stmt4.bind(":message_type", WM_IDENTIFOR_PAPER_STATE_CHAGED);
  275. stmt4.execDML();
  276. if (m_hwnd != NULL)::PostMessage(m_hwnd, WM_IDENTIFOR_PAPER_STATE_CHAGED, (WPARAM)NULL, (LPARAM)it->second[m]);
  277. }
  278. }
  279. LeaveCriticalSection(db_lock);
  280. return running;
  281. }
  282. }
  283. if (!_student_code.empty() && cur_student_paper_id > 0){
  284. //检查是否有考号冲突的试卷
  285. sprintf_s(sql5, "select sp.student_paper_id,sp.paper_state,sp.student_id from student_paper sp where sp.student_code = '%s' and sp.student_paper_id!=%d", _student_code.c_str(), cur_student_paper_id);
  286. CppSQLite3Query q2 = bantch_db->execQuery(sql5);
  287. std::vector<int> all_conflict_ids;
  288. while (!q2.eof()){
  289. long paper_state_t = q2.getInt64Field("paper_state");
  290. all_conflict_ids.push_back(q2.getIntField("student_paper_id"));
  291. q2.nextRow();
  292. }
  293. if (!all_conflict_ids.empty()){
  294. CppSQLite3Statement stmt3 = bantch_db->compileStatement("insert into exception (exception_type ,exception_name,page_id,student_paper_id) values(:exception_type ,:exception_name,:page_id,:student_paper_id)");
  295. for (int m = 0; m < all_conflict_ids.size(); m++){//将与之冲突的试卷标记为考号冲突
  296. sprintf_s(sql5, "update student_paper set paper_state =paper_state|%d,Is_Covered=0 where student_paper_id=%d", EX_KAOHAOCHONGTU, all_conflict_ids[m]);
  297. bantch_db->execDML(sql5);
  298. stmt3.bind(":student_paper_id", all_conflict_ids[m]);
  299. stmt3.bind(":exception_type", SHIFT_KAOHAOCHONGTU);
  300. stmt3.bind(":exception_name", "考号冲突");
  301. stmt3.execDML();
  302. CppSQLite3Statement stmt4 = bantch_db->compileStatement("insert INTO message (student_paper_id , message_type) VALUES (:student_paper_id,:message_type)");
  303. stmt4.bind(":student_paper_id", all_conflict_ids[m]);
  304. stmt4.bind(":message_type", WM_IDENTIFOR_PAPER_STATE_CHAGED);
  305. stmt4.execDML();
  306. if (m_hwnd != NULL)
  307. ::PostMessage(m_hwnd, WM_IDENTIFOR_PAPER_STATE_CHAGED, (WPARAM)NULL, (LPARAM)all_conflict_ids[m]);
  308. if (g_upload_manager&&g_upload_manager->IsEanble()){
  309. if (all_conflict_ids[m] != cur_student_paper_id)
  310. g_upload_manager->UploadOnScanCmd(UPLOAD_ON_SCAN_CMD::CMD_DEL_UPLOAD_REPORT, std::to_string(all_conflict_ids[m]).c_str());
  311. }
  312. }
  313. stmt3.bind(":student_paper_id", cur_student_paper_id);
  314. stmt3.bind(":exception_type", SHIFT_KAOHAOCHONGTU);
  315. stmt3.bind(":exception_name", "考号冲突");
  316. stmt3.execDML();
  317. }
  318. if (_student_id.empty()){
  319. sprintf_s(sql5, "update student_paper set paper_state =paper_state -%d+%d,Is_Covered=0 where student_paper_id =%d",
  320. EX_KAOHAODAIPIPEI,
  321. all_conflict_ids.empty() ? 0 : EX_KAOHAOCHONGTU,
  322. cur_student_paper_id);
  323. }
  324. else{
  325. sprintf_s(sql5, "update student_paper set paper_state =paper_state -%d+%d,student_id ='%s',Is_Covered=0 where student_paper_id =%d",
  326. EX_KAOHAODAIPIPEI,
  327. all_conflict_ids.empty() ? 0 : EX_KAOHAOCHONGTU,
  328. _student_id.c_str(),
  329. cur_student_paper_id);
  330. }
  331. bantch_db->execDML(sql5);
  332. CppSQLite3Statement stmt4 = bantch_db->compileStatement("insert INTO message (student_paper_id , message_type) VALUES (:student_paper_id,:message_type)");
  333. stmt4.bind(":student_paper_id", cur_student_paper_id);
  334. stmt4.bind(":message_type", WM_IDENTIFOR_PAPER_STATE_CHAGED);
  335. stmt4.execDML();
  336. if (m_hwnd != NULL)::PostMessage(m_hwnd, WM_IDENTIFOR_PAPER_STATE_CHAGED, (WPARAM)NULL, (LPARAM)cur_student_paper_id);
  337. }
  338. }
  339. LeaveCriticalSection(db_lock);
  340. }
  341. else if (m_resultHandler->GetServiceSate() == stoped){
  342. return stoping;
  343. }
  344. //休息5秒
  345. Sleep(2 * 1000);
  346. return running;
  347. }
  348. ServiceState CStudentMatcher::OnStoping( void )
  349. {
  350. return stoped;
  351. }
  352. void CStudentMatcher::SetResultHandler( CResultHandler* result_handler )
  353. {
  354. m_resultHandler = result_handler;
  355. }
  356. void CStudentMatcher::setExamId( long examId )
  357. {
  358. m_examId =examId;
  359. }
  360. CString CStudentMatcher::MarkHttpHeaderData()
  361. {
  362. TCHAR FilePath[MAX_PATH];
  363. GetModuleFileName(NULL, FilePath, MAX_PATH);
  364. CString ret;
  365. (_tcsrchr(FilePath, '\\'))[1] = 0;
  366. if (m_bErrorHandle){
  367. lstrcat(FilePath, _T("paperinfo.ini"));
  368. WCHAR JSESSIONID[512];
  369. GetPrivateProfileString(_T("paperinfo"), _T("session"), _T(""), JSESSIONID, 512, FilePath);
  370. ret = JSESSIONID;
  371. }
  372. else{
  373. lstrcat(FilePath, _T("config.ini"));
  374. #ifndef BACK_STAGE
  375. WCHAR SIG[512];
  376. GetPrivateProfileString(_T("SESSIONID"), _T("SIG"), _T(""), SIG, 512, FilePath);
  377. WCHAR TIME[512];
  378. GetPrivateProfileString(_T("SESSIONID"), _T("TIME"), _T(""), TIME, 512, FilePath);
  379. WCHAR ID[512];
  380. GetPrivateProfileString(L"SESSIONID", L"ID", L"", ID, 512, FilePath);
  381. WCHAR JSESSIONID[512];
  382. GetPrivateProfileString(_T("SESSIONID"), _T("JSESSIONID"), _T(""), JSESSIONID, 512, FilePath);
  383. ret.Format(_T("userid=%s&time=%s&sig=%s&session=%s"), ID, TIME, SIG, JSESSIONID);
  384. #else
  385. WCHAR MYCOOK[512];
  386. GetPrivateProfileString(_T("SESSIONID"), _T("MYCOOK"), _T(""), MYCOOK, 512, FilePath);
  387. CString ret;
  388. ret.Format(_T("%s"), MYCOOK);
  389. #endif
  390. }
  391. return ret;
  392. }
  393. bool CStudentMatcher::readPaperId(CString& strPaperId)
  394. {
  395. TCHAR exeFullPath[MAX_PATH];
  396. CString strPath;
  397. GetModuleFileName(NULL, exeFullPath, MAX_PATH);
  398. strPath = (CString)exeFullPath;
  399. int position = strPath.ReverseFind('\\');
  400. strPath = strPath.Left(position + 1);
  401. TCHAR FilePath[MAX_PATH];
  402. GetModuleFileName(NULL, FilePath, MAX_PATH);
  403. (_tcsrchr(FilePath, '\\'))[1] = 0;
  404. lstrcat(FilePath, _T("paperInfo.ini"));
  405. WCHAR PaperId[512];
  406. GetPrivateProfileString(_T("paperinfo"), _T("paper_str"), _T(""), PaperId, 512, FilePath);
  407. strPaperId = PaperId;
  408. return false;
  409. }
  410. bool CStudentMatcher::readBarcodeFlag(CString& strBarcodeFlag)
  411. {
  412. TCHAR exeFullPath[MAX_PATH];
  413. CString strPath;
  414. GetModuleFileName(NULL, exeFullPath, MAX_PATH);
  415. strPath = (CString)exeFullPath;
  416. int position = strPath.ReverseFind('\\');
  417. strPath = strPath.Left(position + 1);
  418. TCHAR FilePath[MAX_PATH];
  419. GetModuleFileName(NULL, FilePath, MAX_PATH);
  420. (_tcsrchr(FilePath, '\\'))[1] = 0;
  421. lstrcat(FilePath, _T("paperInfo.ini"));
  422. WCHAR BarcodeFlag[512];
  423. GetPrivateProfileString(_T("paperinfo"), _T("barcode_flag"), _T("1"), BarcodeFlag, 512, FilePath);
  424. strBarcodeFlag = BarcodeFlag;
  425. return false;
  426. }