Bladeren bron

1、新增日志内容InsertReportInfo函数重载,可上传异常日志内容;

Jeff 5 jaren geleden
bovenliggende
commit
4fdf1f9cad
3 gewijzigde bestanden met toevoegingen van 78 en 0 verwijderingen
  1. 9 0
      TCL Copy Tool/TCL Copy Tool/OTA.cpp
  2. 67 0
      TCL Copy Tool/TCL Copy Tool/db.cpp
  3. 2 0
      TCL Copy Tool/TCL Copy Tool/db.h

+ 9 - 0
TCL Copy Tool/TCL Copy Tool/OTA.cpp

@@ -1636,6 +1636,15 @@ end:
 	if ( mid.factoryname.size() )
 		UpgradeCheck(mid.factoryNum);
 
+	if (!bRet)
+	{
+		std::map<std::string, std::string> report_data;
+		report_data.insert(std::pair<std::string, std::string>("host", host));
+		report_data.insert(std::pair<std::string, std::string>("context", context));
+		report_data.insert(std::pair<std::string, std::string>("result", result));
+		g_db.InsertReportInfo("GetMIDInfo", report_data);
+	}
+
 	return bRet;
 }
 

+ 67 - 0
TCL Copy Tool/TCL Copy Tool/db.cpp

@@ -234,6 +234,73 @@ INT CDataImpl::InsertReportInfo(std::string url, std::string content, bool repor
 	return sqlite_error;
 }
 
+INT CDataImpl::InsertReportInfo(std::string content)
+{
+	if (m_psqlite3 == NULL)
+		return -1;
+
+	std::string strInsert = "INSERT INTO report(url, content)VALUES ('";
+	strInsert.append("'https://cn.ota.qhmoka.com/ota-services/upmp/reportToolsLog.do'");
+	strInsert.append("','");
+	strInsert.append(content);
+	strInsert.append("');");
+	char* psqlite_error = NULL;
+	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
+	if (SQLITE_OK != sqlite_error)
+	{
+		//Global::WriteTextLog(_T("InsertContactsType:%s"), psqlite_error);
+		FREE_MSG;
+	}
+
+	return sqlite_error;
+}
+
+INT CDataImpl::InsertReportInfo(std::string report_type, std::map<std::string, std::string> report_data)
+{
+	if (m_psqlite3 == NULL)
+		return -1;
+
+	// JsonÊý¾Ý;
+	std::string content;
+	cJSON* pJson = cJSON_CreateObject();
+	if (!pJson)
+		return -1;
+	cJSON_AddStringToObject(pJson, "reportType", report_type.c_str());
+
+	cJSON* pObj = cJSON_AddObjectToObject(pJson, _T("reportData"));
+	for (auto it : report_data)
+	{
+		cJSON_AddStringToObject(pObj, it.first.c_str(), it.second.c_str());
+	}
+
+	char* pJsonText = cJSON_Print(pJson);
+	if (!pJsonText)
+	{
+		cJSON_Delete(pJson);
+		return -1;
+	}
+
+	content = pJsonText;
+	if (pJsonText)
+		free(pJsonText);
+	cJSON_Delete(pJson);
+
+	std::string strInsert = "INSERT INTO report(url, content)VALUES ('";
+	strInsert.append("'https://cn.ota.qhmoka.com/ota-services/upmp/reportToolsLog.do'");
+	strInsert.append("','");
+	strInsert.append(content);
+	strInsert.append("');");
+	char* psqlite_error = NULL;
+	int sqlite_error = sqlite3_exec(m_psqlite3, strInsert.c_str(), NULL, 0, &psqlite_error);
+	if (SQLITE_OK != sqlite_error)
+	{
+		//Global::WriteTextLog(_T("InsertContactsType:%s"), psqlite_error);
+		FREE_MSG;
+	}
+
+	return sqlite_error;
+}
+
 INT CDataImpl::RemoveReportInfo()
 {
 	if (m_psqlite3 == NULL)

+ 2 - 0
TCL Copy Tool/TCL Copy Tool/db.h

@@ -101,6 +101,8 @@ public:
 	// 插入mid信息;
 	INT InsertReportInfo(STReport& data);
 	INT InsertReportInfo(std::string url, std::string content, bool report_status =  false);
+	INT InsertReportInfo(std::string content);
+	INT InsertReportInfo(std::string report_type, std::map<std::string, std::string> report_data);
 	// 删除已上报成功的记录(1个月前的);
 	INT RemoveReportInfo();