recordinfo.cpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "recordinfo.h"
  2. #include "strutil.h"
  3. #include "Event.h"
  4. #include "CommEntityUtil.hpp"
  5. void HttpsLogCallBack(const char* logtxt) {
  6. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("HttpsLogCallBack")("HttpsLogCallBack: %s.", logtxt);
  7. }
  8. int post_video_recordinfo_list(unsigned int& uposttime, CSimpleStringA& errormsg, video_record_info_t* pinfo, int itimeout, bool bprintdbg)
  9. {
  10. int iret = -1;
  11. IHttpFunc* client = create_http(HttpsLogCallBack);
  12. RecordInfoHTTPReq req;
  13. req.m_timeOut = itimeout;
  14. if (bprintdbg) {
  15. req.m_printDbg = true;
  16. }
  17. const char* pData = pinfo->strServerURL.GetData();
  18. if (pData) {
  19. req.m_url = pData;
  20. }
  21. pData = pinfo->strAPI.GetData();
  22. if (pData) {
  23. req.m_url.append(pData);
  24. }
  25. Json::Value rootReq;
  26. pData = pinfo->strTerminalNo.GetData();
  27. if (pData) {
  28. rootReq["terminal_no"] = pData;
  29. }
  30. pData = pinfo->strAppVersion.GetData();
  31. if (pData) {
  32. rootReq["app_version"] = pData;
  33. }
  34. pData = pinfo->strRecordEndTime.GetData();
  35. if (pData) {
  36. rootReq["upload_time"] = pData;
  37. }
  38. pData = pinfo->strRecordID.GetData();
  39. if (pData) {
  40. rootReq["video_serial_id"] = pData;
  41. }
  42. rootReq["business_status"] = pinfo->iBusinessStatus;
  43. for (vector<record_item_t>::iterator it = pinfo->vRecordList.begin(); it < pinfo->vRecordList.end(); ++it) {
  44. Json::Value item;
  45. item["file_name"] = it->file_name;
  46. item["file_path"] = it->file_path;
  47. item["file_length"] = it->file_length;
  48. rootReq["file_list"].append(item);
  49. }
  50. Json::StyledWriter sw;
  51. req.m_reqContent = sw.write(rootReq);
  52. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("m_reqContent is %s.", req.m_reqContent.c_str());
  53. DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin http get request, timeout is %d, printdbg flag is %s.", req.m_timeOut, req.m_printDbg ? "true" : "false");
  54. unsigned int ustarttime = SP::Module::Comm::RVCGetTickCount();
  55. RecordInfoHTTPRet ret;
  56. if (client->Post(req, ret)) {
  57. DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("post result is %s, returnCode:%s, code:%s, errorMsg:%s, message:%s.",
  58. ret.m_success ? "success" : "failed", ret.m_returnCode.c_str(), ret.m_code.c_str(), ret.m_errorMsg.c_str(), ret.m_message.c_str());
  59. uposttime = SP::Module::Comm::RVCGetTickCount() - ustarttime;
  60. iret = 0;
  61. }
  62. else {
  63. errormsg = CSimpleStringA::Format("post video record infos fail, url=%s, syscode=%d, usercode=%s, errmsg=%s", req.m_url.c_str(), ret.m_sysCode, ret.m_userCode.c_str(), ret.m_errMsg.c_str());
  64. }
  65. return iret;
  66. }