12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #include "recordinfo.h"
- #include "strutil.h"
- #include "Event.h"
- #include "CommEntityUtil.hpp"
- void HttpsLogCallBack(const char* logtxt) {
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM).setAPI("HttpsLogCallBack")("HttpsLogCallBack: %s.", logtxt);
- }
- int post_video_recordinfo_list(unsigned int& uposttime, CSimpleStringA& errormsg, video_record_info_t* pinfo, int itimeout, bool bprintdbg)
- {
- int iret = -1;
- IHttpFunc* client = create_http(HttpsLogCallBack);
- RecordInfoHTTPReq req;
- req.m_timeOut = itimeout;
- if (bprintdbg) {
- req.m_printDbg = true;
- }
- const char* pData = pinfo->strServerURL.GetData();
- if (pData) {
- req.m_url = pData;
- }
- pData = pinfo->strAPI.GetData();
- if (pData) {
- req.m_url.append(pData);
- }
- Json::Value rootReq;
- pData = pinfo->strTerminalNo.GetData();
- if (pData) {
- rootReq["terminal_no"] = pData;
- }
- pData = pinfo->strAppVersion.GetData();
- if (pData) {
- rootReq["app_version"] = pData;
- }
- pData = pinfo->strRecordEndTime.GetData();
- if (pData) {
- rootReq["upload_time"] = pData;
- }
- pData = pinfo->strRecordID.GetData();
- if (pData) {
- rootReq["video_serial_id"] = pData;
- }
- rootReq["business_status"] = pinfo->iBusinessStatus;
- for (vector<record_item_t>::iterator it = pinfo->vRecordList.begin(); it < pinfo->vRecordList.end(); ++it) {
- Json::Value item;
- item["file_name"] = it->file_name;
- item["file_path"] = it->file_path;
- item["file_length"] = it->file_length;
- rootReq["file_list"].append(item);
- }
- Json::StyledWriter sw;
- req.m_reqContent = sw.write(rootReq);
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("m_reqContent is %s.", req.m_reqContent.c_str());
- 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");
- unsigned int ustarttime = SP::Module::Comm::RVCGetTickCount();
- RecordInfoHTTPRet ret;
- if (client->Post(req, ret)) {
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("post result is %s, returnCode:%s, code:%s, errorMsg:%s, message:%s.",
- 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());
- uposttime = SP::Module::Comm::RVCGetTickCount() - ustarttime;
- iret = 0;
- }
- else {
- 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());
- }
- return iret;
- }
|