ImgUploadManager.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. #include "stdafx.h"
  2. #include "ImgUploadManager.h"
  3. #include "ImgUploader.h"
  4. #include "..\EvaluationUtil\HttpClient.h"
  5. #include "..\EvaluationUtil\IInputFiled.h"
  6. #include "..\EvaluationUtil\FileInputFiled.h"
  7. #include "..\EvaluationUtil\HTTP.h"
  8. #include "..\Identifier\CrossDetector.h"
  9. CImgUploadManager::CImgUploadManager():imgUploader_(new CImgUploader())
  10. {
  11. m_threadPool.init(2, 100);
  12. }
  13. CImgUploadManager::~CImgUploadManager()
  14. {
  15. }
  16. boost::shared_ptr<CImgUploadManager> CImgUploadManager::GetInstance()
  17. {
  18. static boost::shared_ptr<CImgUploadManager> _instance(new CImgUploadManager);
  19. return _instance;
  20. }
  21. int CImgUploadManager::SetHandlerWndForImg(HWND hwnd)
  22. {
  23. return imgUploader_->SetHandlerWnd(hwnd);
  24. }
  25. int CImgUploadManager::StartUploadePaperImg()
  26. {
  27. return imgUploader_->Start();
  28. }
  29. int CImgUploadManager::StopUploadePaperImg()
  30. {
  31. return imgUploader_->Stop();
  32. }
  33. int CImgUploadManager::QueryUploadePaperImg(std::vector<IMG_UPLOAD_TASK>& tasks)
  34. {
  35. return imgUploader_->QueryUploadePaperImg(tasks);
  36. }
  37. int CImgUploadManager::GetCurrentUploadTaskInfo(IMG_UPLOAD_TASK& task)
  38. {
  39. return imgUploader_->GetCurrentUploadTaskInfo(task);
  40. }
  41. int CImgUploadManager::ClearUploadedPaperImg()
  42. {
  43. return imgUploader_->ClearUploadedPaperImg();
  44. }
  45. const boost::shared_ptr<CImgUploader>& CImgUploadManager::GetImgUploader()
  46. {
  47. return imgUploader_;
  48. }
  49. //获取交叉点的方向
  50. void GetDirection(AI_RET_RECT2& aiCross, string strDirection)
  51. {
  52. map<string, int> mapDirect = { { "CROSS_TL", SIGND_TL }, { "CROSS_TR", SIGND_TR }, { "CROSS_TLR", SIGND_TLR },
  53. { "CROSS_BL", SIGND_BL }, { "CROSS_BR", SIGND_BR }, { "CROSS_BLR", SIGND_BLR }, { "CROSS_TBL", SIGND_TBL },
  54. { "CROSS_TBR", SIGND_TBR }, { "CROSS_TBLR", SIGND_TBLR }};
  55. map<string, int>::iterator iter = mapDirect.find(strDirection);
  56. if (iter != mapDirect.end())
  57. {
  58. aiCross.directoin = iter->second;
  59. }
  60. }
  61. int CImgUploadManager::AiReadImgPaper(int subject, int id, std::vector<questionAi> aiVec, const std::vector<CString> imgPath, std::vector<std::vector<AI_RET_RECT2>> &retList)
  62. {
  63. //CHttpClient httpClient;
  64. string response, strUrlStudengCode;
  65. vector<CInputFiled*> inputs;
  66. retList.resize(imgPath.size());
  67. for (int i = 0; i < imgPath.size(); i++)
  68. {
  69. //CFileInputFiled filed(_T("img_data"), _T("600.jpg"), imgPath[i]);
  70. CFileInputFiled *filed = new CFileInputFiled(_T("img_data"), imgPath[i], imgPath[i]);
  71. inputs.push_back(filed);
  72. }
  73. //CFileInputFiled filed(_T("img_data"), _T("600.jpg"), imgPath);
  74. //subject = 18;
  75. CString strSubject;
  76. strSubject.Format(_T("%d"), id);
  77. CInputFiled filed2(_T("subject"), strSubject, INPUT_FILED_VALUE);
  78. //inputs.push_back(&filed);
  79. inputs.push_back(&filed2);
  80. CString strQuestions = _T("{\"questions\":[");
  81. for (int i = 0; i < aiVec.size(); i++)
  82. {
  83. CString str;
  84. CString str1 = CA2T(aiVec[i].stu_no.c_str());
  85. CString str2 = CA2T(aiVec[i].stu_type.c_str());
  86. str.Format(_T("{\"questionID\":%s,\"type\":%s},"), str1, str2);
  87. strQuestions += str;
  88. }
  89. if (aiVec.size() > 0)
  90. strQuestions.Delete(strQuestions.GetLength() - 1);
  91. strQuestions += _T("]}");
  92. CInputFiled filed3(_T("questions"), strQuestions, INPUT_FILED_VALUE);
  93. if (subject == 0)
  94. {
  95. inputs.push_back(&filed3);
  96. }
  97. CString url_str;
  98. //url_str = "http://192.168.1.167:18088/upload_imgs";
  99. //url_str = "http://192.168.1.167:8000/segment/upload_imgs/";
  100. WCHAR url[512];
  101. TCHAR FilePath[MAX_PATH];
  102. GetModuleFileName(NULL, FilePath, MAX_PATH);
  103. (_tcsrchr(FilePath, '\\'))[1] = 0;
  104. lstrcat(FilePath, _T("config.ini"));
  105. if (subject != 0)
  106. GetPrivateProfileString(_T("GLOBAL"), _T("server_url_AI"), _T(""), url, 512, FilePath);
  107. else
  108. GetPrivateProfileString(_T("GLOBAL"), _T("server_url_examPaperCut"), _T(""), url, 512, FilePath);
  109. //url_str = url;
  110. DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, url, -1, NULL, 0, NULL, FALSE);
  111. char *psText;
  112. psText = new char[dwNum];
  113. WideCharToMultiByte(CP_OEMCP, NULL, url, -1, psText, dwNum, NULL, FALSE);
  114. std::string szDst;
  115. szDst = psText;// std::string?3?|ì
  116. delete[]psText;// psText|ì???3y
  117. CHTTP httpClient;
  118. int a = 150000, b = 150000, c = 150000;
  119. httpClient.Init();
  120. httpClient.SetTimeout(a, b, c);
  121. httpClient.SetCodePage(CP_UTF8);
  122. httpClient.PostFile(response, szDst, inputs);
  123. logForDbg(response);
  124. //httpClient.HttpPostFileJpg(url_str, inputs, response);
  125. Json::Features features;
  126. Json::Reader re(features);
  127. Json::Value root;
  128. re.parse(response, root);
  129. for (int i = 0; i < inputs.size(); i++)
  130. {
  131. if (inputs[i]->GetType() == INPUT_FILED_FILE)
  132. {
  133. inputs[i]->Close();
  134. }
  135. }
  136. if (root["is_success"].type() != Json::nullValue)
  137. {
  138. if (root["is_success"].asInt() == 1)
  139. {
  140. Json::Value object_imgs_info = root["imgs_info"];
  141. if (subject != 0)
  142. {
  143. if (!object_imgs_info.isNull() && object_imgs_info.isArray())
  144. {
  145. std::vector<AI_RET_RECT2> rcVec;
  146. int order = 0;
  147. for (int i = 0; i < object_imgs_info.size(); i++)
  148. {
  149. rcVec.clear();
  150. Json::Value object_imgs = object_imgs_info[i];
  151. string strImgName = object_imgs["img_name"].asString();
  152. for (int k = 0; k < imgPath.size(); k++)
  153. {
  154. int nPos = imgPath[k].ReverseFind('/');
  155. CString fileName = imgPath[k].Right(imgPath[k].GetLength() - nPos - 1);
  156. if (strImgName.compare(CT2A(fileName.GetString())) == 0)
  157. {
  158. order = k;
  159. break;
  160. }
  161. }
  162. Json::Value object_regions = object_imgs["regions"];
  163. if (!object_regions.isNull() && object_regions.isArray())
  164. {
  165. for (int j = 0; j < object_regions.size(); j++)
  166. {
  167. Json::Value obj_area = object_regions[j];
  168. string strType = obj_area["class_name"].asString();
  169. if (strType == "exam_number_col_row") //ì?í???o?
  170. {
  171. AI_RET_RECT2 temp;
  172. temp.rect_type = AI_TIANTUKAOHAO;
  173. Json::Value object_location = obj_area["bounding_box"];
  174. temp.x = object_location["xmin"].asInt();
  175. temp.y = object_location["ymin"].asInt();
  176. temp.width = object_location["xmax"].asInt() - temp.x;
  177. temp.height = object_location["ymax"].asInt() - temp.y;
  178. temp.directoin = obj_area["direction"].asInt();
  179. temp.nRows = obj_area["rows"].asInt();
  180. temp.nCols = obj_area["cols"].asInt();
  181. temp.widthH = obj_area["single_width"].asInt();
  182. temp.widthV = obj_area["single_height"].asInt();
  183. temp.outputChar = obj_area["option"].asString();
  184. rcVec.push_back(temp);
  185. }
  186. else if (strType == "bar_code" || strType == "qr_code") //ì?D??? ?t????
  187. {
  188. AI_RET_RECT2 temp;
  189. Json::Value object_location = obj_area["bounding_box"];
  190. temp.rect_type = AI_TIAOXINGMA;
  191. temp.x = object_location["xmin"].asInt();
  192. temp.y = object_location["ymin"].asInt();
  193. temp.width = object_location["xmax"].asInt() - temp.x;
  194. temp.height = object_location["ymax"].asInt() - temp.y;
  195. rcVec.push_back(temp);
  196. }
  197. else if (strType == "choice_m") //????ìa
  198. {
  199. AI_RET_RECT2 temp;
  200. temp.rect_type = AI_XUANZETI;
  201. //temp.tihao = row["number"].asInt();
  202. Json::Value object_location = obj_area["bounding_box"];
  203. temp.x = object_location["xmin"].asInt();
  204. temp.y = object_location["ymin"].asInt();
  205. temp.width = object_location["xmax"].asInt() - temp.x;
  206. temp.height = object_location["ymax"].asInt() - temp.y;
  207. temp.widthH = obj_area["single_width"].asInt();
  208. temp.widthV = obj_area["single_height"].asInt();
  209. //temp.default_points = row["default_points"].asInt();
  210. temp.outputChar = obj_area["option"].asString();
  211. temp.nRows = obj_area["rows"].asInt();
  212. temp.nCols = obj_area["cols"].asInt();
  213. Json::Value object_tihao = obj_area["number"];
  214. bool flag = false;
  215. if (!object_tihao.isNull() && object_tihao.isArray())
  216. {
  217. for (int i = 0; i < object_tihao.size(); i++)
  218. {
  219. if (object_tihao[i].asInt() < 0)
  220. {
  221. flag = true;
  222. break;
  223. }
  224. bool flag2 = false;
  225. for (int j = i + 1; j < object_tihao.size(); j++)
  226. {
  227. if (object_tihao[i].asInt() == object_tihao[j].asInt())
  228. {
  229. flag2 = true;
  230. break;
  231. }
  232. }
  233. if (flag2)
  234. {
  235. flag = true;
  236. break;
  237. }
  238. temp.tihao.push_back(object_tihao[i].asInt());
  239. }
  240. }
  241. if (flag)
  242. temp.tihao.clear();
  243. Json::Value object_points = obj_area["default_points"];
  244. flag = false;
  245. if (!object_points.isNull() && object_points.isArray())
  246. {
  247. for (int i = 0; i < object_points.size(); i++)
  248. {
  249. if (object_points[i].asDouble() < 0)
  250. {
  251. flag = true;
  252. break;
  253. }
  254. temp.default_points.push_back(object_points[i].asDouble());
  255. }
  256. }
  257. if (flag)
  258. temp.default_points.clear();
  259. temp.directoin = obj_area["direction"].asInt();
  260. temp.duoxuanti = obj_area["multiple"].asBool();
  261. if (temp.duoxuanti)
  262. {
  263. Json::Value object_half_points = obj_area["half_default_points"];
  264. flag = false;
  265. for (int i = 0; i < object_half_points.size(); i++)
  266. {
  267. if (object_half_points[i].asDouble() < 0)
  268. {
  269. flag = true;
  270. break;
  271. }
  272. temp.half_points.push_back(object_half_points[i].asDouble());
  273. }
  274. if (flag)
  275. temp.half_points.clear();
  276. }
  277. rcVec.push_back(temp);
  278. }
  279. else if (strType == "cloze") //ì???ìa
  280. {
  281. AI_RET_RECT2 temp;
  282. temp.rect_type = AI_TIANKONGTI;
  283. if (!obj_area["number"].empty())
  284. {
  285. if (obj_area["number"].asInt() > 0)
  286. temp.tihao.push_back(obj_area["number"].asInt());
  287. }
  288. Json::Value object_location = obj_area["bounding_box"];
  289. temp.x = object_location["xmin"].asInt();
  290. temp.y = object_location["ymin"].asInt();
  291. temp.width = object_location["xmax"].asInt() - temp.x;
  292. temp.height = object_location["ymax"].asInt() - temp.y;
  293. if (!obj_area["default_points"].empty())
  294. {
  295. if (obj_area["default_points"].asDouble() > 0)
  296. temp.default_points.push_back(obj_area["default_points"].asDouble());
  297. }
  298. rcVec.push_back(temp);
  299. }
  300. else if (strType == "solve" || "composition" == strType) //?a′eìa
  301. {
  302. AI_RET_RECT2 temp;
  303. temp.rect_type = AI_ZHUGUANTI;
  304. if (!obj_area["number"].empty())
  305. {
  306. if (obj_area["number"].asInt() > 0)
  307. temp.tihao.push_back(obj_area["number"].asInt());
  308. }
  309. Json::Value object_location = obj_area["bounding_box"];
  310. temp.x = object_location["xmin"].asInt();
  311. temp.y = object_location["ymin"].asInt();
  312. temp.width = object_location["xmax"].asInt() - temp.x;
  313. temp.height = object_location["ymax"].asInt() - temp.y;
  314. if (!obj_area["default_points"].empty())
  315. {
  316. if (obj_area["default_points"].asDouble() > 0)
  317. temp.default_points.push_back(obj_area["default_points"].asDouble());
  318. }
  319. temp.showMarkTypeIndex = -1;
  320. temp.isSplit = obj_area["span"].asBool();
  321. temp.unitID = obj_area["span_id"].asInt();
  322. if ("composition" == strType && subject == 9)//ó???
  323. {
  324. temp.showMarkTypeIndex = 1;
  325. temp.postMarkTypeID = 4;
  326. }
  327. else if ("composition" == strType && subject == 8)//ó¢ó?
  328. {
  329. temp.showMarkTypeIndex = 1;
  330. temp.postMarkTypeID = 4;
  331. }
  332. rcVec.push_back(temp);
  333. }
  334. else if (strType == "optional_solve") //??×?ìa
  335. {
  336. AI_RET_RECT2 temp;
  337. temp.rect_type = AI_XUANZUOTI;
  338. //temp.tihao.push_back(obj_area["number"].asInt());
  339. Json::Value object_location = obj_area["bounding_box"];
  340. temp.x = object_location["xmin"].asInt();
  341. temp.y = object_location["ymin"].asInt();
  342. temp.width = object_location["xmax"].asInt() - temp.x;
  343. temp.height = object_location["ymax"].asInt() - temp.y;
  344. //temp.default_points.push_back(obj_area["default_points"].asInt());
  345. Json::Value object_tihao = obj_area["number"];
  346. if (!object_tihao.isNull() && object_tihao.isArray())
  347. {
  348. for (int i = 0; i < object_tihao.size(); i++)
  349. temp.tihao.push_back(object_tihao[i].asInt());
  350. }
  351. Json::Value object_points = obj_area["default_points"];
  352. if (!object_points.isNull() && object_points.isArray())
  353. {
  354. for (int i = 0; i < object_points.size(); i++)
  355. temp.default_points.push_back(object_points[i].asDouble());
  356. }
  357. temp.isSplit = obj_area["span"].asBool();
  358. temp.unitID = obj_area["span_id"].asInt();
  359. rcVec.push_back(temp);
  360. }
  361. else if (strType == "optional_choice") //??×?ìaí?μ?
  362. {
  363. AI_RET_RECT2 temp;
  364. temp.rect_type = AI_XUANZUOTUDIAN;
  365. //temp.tihao.push_back(obj_area["number"].asInt());
  366. Json::Value object_location = obj_area["bounding_box"];
  367. temp.x = object_location["xmin"].asInt();
  368. temp.y = object_location["ymin"].asInt();
  369. temp.width = object_location["xmax"].asInt() - temp.x;
  370. temp.height = object_location["ymax"].asInt() - temp.y;
  371. temp.widthH = obj_area["single_width"].asInt();
  372. temp.widthV = obj_area["single_height"].asInt();
  373. //temp.default_points = row["default_points"].asInt();
  374. //temp.outputChar = obj_area["option"].asString();
  375. temp.nRows = obj_area["rows"].asInt();
  376. temp.nCols = obj_area["cols"].asInt();
  377. temp.directoin = obj_area["direction"].asInt();
  378. Json::Value object_tihao = obj_area["number"];
  379. if (!object_tihao.isNull() && object_tihao.isArray())
  380. {
  381. for (int i = 0; i < object_tihao.size(); i++)
  382. temp.tihao.push_back(object_tihao[i].asInt());
  383. }
  384. rcVec.push_back(temp);
  385. }
  386. else if (strType == "lack") //缺考标记
  387. {
  388. AI_RET_RECT2 temp;
  389. temp.rect_type = AI_QUEKAO;
  390. //temp.tihao.push_back(obj_area["number"].asInt());
  391. Json::Value object_location = obj_area["bounding_box"];
  392. temp.x = object_location["xmin"].asInt();
  393. temp.y = object_location["ymin"].asInt();
  394. temp.width = object_location["xmax"].asInt() - temp.x;
  395. temp.height = object_location["ymax"].asInt() - temp.y;
  396. temp.widthH = temp.width;
  397. temp.widthV = temp.height;
  398. temp.nCols = temp.nRows = 1;
  399. rcVec.push_back(temp);
  400. }
  401. else if (strType == "anchor_point") //定位点json解析
  402. {
  403. AI_RET_RECT2 temp;
  404. temp.rect_type = AI_DINGWEIDIAN;
  405. Json::Value object_location = obj_area["bounding_box"];
  406. temp.x = object_location["xmin"].asInt();
  407. temp.y = object_location["ymin"].asInt();
  408. temp.width = object_location["xmax"].asInt() - temp.x;
  409. temp.height = object_location["ymax"].asInt() - temp.y;
  410. rcVec.push_back(temp);
  411. }
  412. else if (strType == "position_area") //定位区json解析
  413. {
  414. AI_RET_RECT2 temp;
  415. temp.rect_type = AI_DINGWEIQU;
  416. Json::Value object_location = obj_area["bounding_box"];
  417. temp.x = object_location["xmin"].asInt();
  418. temp.y = object_location["ymin"].asInt();
  419. temp.width = object_location["xmax"].asInt() - temp.x;
  420. temp.height = object_location["ymax"].asInt() - temp.y;
  421. rcVec.push_back(temp);
  422. }
  423. else if (strType == "cross_points") //交叉点json解析
  424. {
  425. AI_RET_RECT2 temp;
  426. temp.rect_type = AI_JIAOCHADIAN;
  427. Json::Value object_location = obj_area["bounding_box"];
  428. temp.x = object_location["xmin"].asInt();
  429. temp.y = object_location["ymin"].asInt();
  430. Json::Value diretion = obj_area["direction"];
  431. if (!diretion.isNull() && diretion.isString())
  432. {
  433. string strDirectoin = obj_area["direction"].asString();//方向
  434. GetDirection(temp, strDirectoin);
  435. }
  436. rcVec.push_back(temp);
  437. }
  438. }
  439. }
  440. //retList.push_back(rcVec);
  441. retList[order] = rcVec;
  442. //retList.insert(retList.begin() + order, rcVec);
  443. }
  444. }
  445. }
  446. else
  447. {
  448. if (!object_imgs_info.isNull() && object_imgs_info.isArray())
  449. {
  450. std::vector<AI_RET_RECT2> rcVec;
  451. int order = 0;
  452. for (int i = 0; i < object_imgs_info.size(); i++)
  453. {
  454. rcVec.clear();
  455. Json::Value object_imgs = object_imgs_info[i];
  456. string strImgName = object_imgs["img_name"].asString();
  457. for (int k = 0; k < imgPath.size(); k++)
  458. {
  459. int nPos = imgPath[k].ReverseFind('/');
  460. CString fileName = imgPath[k].Right(imgPath[k].GetLength() - nPos - 1);
  461. if (strImgName.compare(CT2A(fileName.GetString())) == 0)
  462. {
  463. order = k;
  464. break;
  465. }
  466. }
  467. Json::Value object_regions = object_imgs["regions"];
  468. if (!object_regions.isNull() && object_regions.isArray())
  469. {
  470. for (int j = 0; j < object_regions.size(); j++)
  471. {
  472. Json::Value obj_area = object_regions[j];
  473. AI_RET_RECT2 temp;
  474. temp.rect_type = AI_ZHUGUANTI2;
  475. if (obj_area["type"].asInt() == 1) //选择题有选项
  476. {
  477. temp.postMarkTypeID = 1;
  478. }
  479. else
  480. {
  481. temp.postMarkTypeID = 0;
  482. }
  483. //temp.tihao.push_back(obj_area["number"].asInt());
  484. temp.tihao_aiExamper = obj_area["number"].asString();
  485. if (obj_area["issplit"].asInt() == 1)
  486. temp.isSplit = true;
  487. else
  488. temp.isSplit = false;
  489. temp.unitID = obj_area["splitId"].asInt();
  490. Json::Value object_location = obj_area["bounding_box"];
  491. temp.x = object_location["xmin"].asInt();
  492. temp.y = object_location["ymin"].asInt();
  493. temp.width = object_location["xmax"].asInt() - temp.x;
  494. temp.height = object_location["ymax"].asInt() - temp.y;
  495. rcVec.push_back(temp);
  496. }
  497. }
  498. retList[order] = rcVec;
  499. }
  500. }
  501. }
  502. }
  503. else
  504. {
  505. return -1;
  506. }
  507. }
  508. return 0;
  509. }
  510. ThreadPool *CImgUploadManager::getThreadPool()
  511. {
  512. return &m_threadPool;
  513. }
  514. #include <direct.h>
  515. void ThreadLog14(char* ThreadName, char* fileName)
  516. {
  517. TCHAR szCommandLine[MAX_PATH];
  518. memset(szCommandLine, 0, sizeof(szCommandLine));
  519. GetModuleFileName(NULL, szCommandLine, MAX_PATH);
  520. (_tcsrchr(szCommandLine, '\\'))[1] = 0;
  521. TCHAR pathFile[MAX_PATH];
  522. lstrcpy(pathFile, szCommandLine);
  523. int nInputStrLen = wcslen(szCommandLine);
  524. int nOutputStrLen = WideCharToMultiByte(CP_ACP, 0, szCommandLine, nInputStrLen, NULL, 0, 0, 0) + 2;
  525. char* pszOut = new char[nOutputStrLen];
  526. memset(pszOut, 0x00, nOutputStrLen);
  527. WideCharToMultiByte(CP_ACP, 0, szCommandLine, nInputStrLen, pszOut, nOutputStrLen, 0, 0);
  528. char buf[200] = {0};
  529. //WideCharToMultiByte(CP_UTF8, 0, szCommandLine, -1, buf, 200, NULL, NULL);
  530. //_getcwd(buf, sizeof(buf));
  531. //strcat_s(buf, "\\");
  532. //strcat_s(pszOut, fileName);
  533. sprintf(buf, "%s%s", pszOut, fileName);
  534. FILE *file = NULL;
  535. printf(buf);
  536. fopen_s(&file, buf, "at+");
  537. if (file == NULL)
  538. {
  539. printf("路径错误\n");
  540. //system("pause");
  541. return;
  542. }
  543. fseek(file, 0, SEEK_END);
  544. //char bufThread[10240];
  545. //strcpy_s(bufThread, sizeof(bufThread), ThreadName);
  546. //fwrite(&bufThread, strlen(bufThread), 1, file);
  547. fwrite(ThreadName, strlen(ThreadName), 1, file);
  548. fclose(file);
  549. delete[] ThreadName;
  550. }
  551. void CImgUploadManager::logForDbg(string strLog)
  552. {
  553. //char logContent[300];
  554. char *logContent;
  555. char logName[300];
  556. char sYear[10], sMonth[5], sDay[25];
  557. SYSTEMTIME st;
  558. GetLocalTime(&st);
  559. int j0 = 0;
  560. int m_nYear = st.wYear; ///年
  561. int m_nMonth = st.wMonth; ///月
  562. int m_nDay = st.wDay; ///日
  563. int m_nHour = st.wHour; ///小时
  564. int m_nMinute = st.wMinute; ///分钟
  565. int m_nSecond = st.wSecond; ///秒
  566. int m_nMillSecond = st.wMilliseconds; ///毫秒
  567. char strTime[300];
  568. sprintf(strTime, "----------------------------------%d_%02d_%02d_%d_%02d_%02d", m_nYear, m_nMonth, m_nDay, m_nHour, m_nMinute, m_nSecond);
  569. strLog += strTime;
  570. sprintf_s(sYear, sizeof(sYear), "%d", m_nYear);
  571. sprintf_s(sMonth, sizeof(sMonth), "_%02d", m_nMonth);
  572. sprintf_s(sDay, sizeof(sDay), "_%02d_log.txt", m_nDay);
  573. strcpy(logName, sYear);
  574. strcat(logName, sMonth);
  575. strcat(logName, sDay);
  576. //char strScore[MAX_PATH] = { 0 };
  577. char *strScore = new char[strLog.size()+1];
  578. memset(strScore, 0, strLog.size() + 1);
  579. //logContent = new char[strLog.size()+1];
  580. int i = 0;
  581. for (; i < strLog.size(); i++)
  582. strScore[i] = strLog.at(i);
  583. strScore[strLog.size()] = '\n';
  584. //sprintf_s(logContent, sizeof(char), "%s\n", strScore);
  585. //delete[] strScore;
  586. ThreadLog14(strScore, logName);
  587. }