瀏覽代碼

注意:task屋的taskid是无效的,要使用job层级里的taskid才有效;

scbc.sat2 5 年之前
父節點
當前提交
c653ca3b97
共有 2 個文件被更改,包括 61 次插入10 次删除
  1. 58 10
      SATHTTP/SATHTTP/SATHTTP.cpp
  2. 3 0
      SATHTTP/SATHTTP/SATHTTP.h

+ 58 - 10
SATHTTP/SATHTTP/SATHTTP.cpp

@@ -161,6 +161,9 @@ SATHTTP_API int Login(std::string url, const SATParameters::STLoginReq &stLoginR
 	char *pText = cJSON_Print(pRoot);
 	std::string post_data = "requestMsg=";
 	post_data.append(CharEncoding::EnCode_UTF8URL(pText));
+#ifdef _DEBUG
+	OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -183,7 +186,9 @@ SATHTTP_API int Login(std::string url, const SATParameters::STLoginReq &stLoginR
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -283,6 +288,9 @@ SATHTTP_API int UpdateDeviceMessage(std::string url, const SATParameters::STUpda
 	char *pText = cJSON_Print(pRoot);
 	std::string post_data = "requestMsg=";
 	post_data.append(CharEncoding::EnCode_UTF8URL(pText));
+#ifdef _DEBUG
+	OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -305,7 +313,9 @@ SATHTTP_API int UpdateDeviceMessage(std::string url, const SATParameters::STUpda
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -380,6 +390,9 @@ SATHTTP_API int Heartbeat(std::string url, const SATParameters::STHeartbeatReq &
 	char *pText = cJSON_Print(pRoot);
 	std::string post_data = "requestMsg=";
 	post_data.append(CharEncoding::EnCode_UTF8URL(pText));
+#ifdef _DEBUG
+	//OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -402,7 +415,9 @@ SATHTTP_API int Heartbeat(std::string url, const SATParameters::STHeartbeatReq &
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			//OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -442,6 +457,7 @@ SATHTTP_API int Heartbeat(std::string url, const SATParameters::STHeartbeatReq &
 									stTask.Id = cJSON_GetObjectItem(pTask, "id") ? cJSON_GetObjectItem(pTask, "id")->valueint : -1;
 									stTask.fd = cJSON_GetObjectItem(pTask, "fd") ? cJSON_GetObjectItem(pTask, "fd")->valueint : -1;
 									stTask.nTaskId = cJSON_GetObjectItem(pTask, "taskId") ? cJSON_GetObjectItem(pTask, "taskId")->valueint : -1;
+									//stTask.strTaskId = cJSON_GetObjectItem(pTask, "taskId") ? cJSON_GetObjectItem(pTask, "taskId")->valuestring : "0";
 									// email其实可忽略;
 									cJSON *pEmals = cJSON_GetObjectItem(pTask, "emails");
 									if ( pEmals )
@@ -577,6 +593,9 @@ SATHTTP_API int SetResult(std::string url, const SATParameters::STNotifyJobStart
 	std::string post_data = "requestMsg=";
 	post_data.append(pText);
 	//post_data.append(CharEncoding::EnCode_UTF8URL(pText));
+#ifdef _DEBUG
+	OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -599,7 +618,9 @@ SATHTTP_API int SetResult(std::string url, const SATParameters::STNotifyJobStart
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -694,6 +715,9 @@ SATHTTP_API int SetResultList(std::string url, const SATParameters::STJobProcess
 	std::string post_data = "requestMsg=";
 	post_data.append(CharEncoding::EnCode_GB2312URL(pText));
 	//post_data.append(pText);
+#ifdef _DEBUG
+	OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -716,7 +740,9 @@ SATHTTP_API int SetResultList(std::string url, const SATParameters::STJobProcess
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -774,6 +800,9 @@ SATHTTP_API int GetCaseFileListUrl(std::string url, std::string strCaseId, SATPa
 	char *pText = cJSON_Print(pRoot);
 	std::string post_data = "requestMsg=";
 	post_data.append(CharEncoding::EnCode_UTF8URL(pText));
+#ifdef _DEBUG
+	OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -796,7 +825,9 @@ SATHTTP_API int GetCaseFileListUrl(std::string url, std::string strCaseId, SATPa
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -1001,7 +1032,9 @@ SATHTTP_API int StopTaskFromRunner(std::string url, std::string strInstnaceId, S
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -1057,6 +1090,9 @@ SATHTTP_API int SaveCaseOrTaskLog(std::string url, const SATParameters::STSaveLo
 	//std::string post_data = CharEncoding::EnCode_UTF8URL(pText);
 	// POST表单提交,此处不需要转url格式,注意避坑!
 	std::string post_data = pText;
+#ifdef _DEBUG
+	OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -1079,7 +1115,9 @@ SATHTTP_API int SaveCaseOrTaskLog(std::string url, const SATParameters::STSaveLo
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -1154,6 +1192,9 @@ SATHTTP_API int SaveResultFile(std::string url, const SATParameters::STSaveFileR
 	//std::string post_data = CharEncoding::EnCode_UTF8URL(pText);
 	// POST表单提交,此处不需要转url格式,注意避坑!
 	std::string post_data = pText;
+#ifdef _DEBUG
+	OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -1176,7 +1217,9 @@ SATHTTP_API int SaveResultFile(std::string url, const SATParameters::STSaveFileR
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)
@@ -1237,6 +1280,9 @@ SATHTTP_API int SaveResultImg(std::string url, const SATParameters::STSaveImgReq
 	//std::string post_data = CharEncoding::EnCode_UTF8URL(pText);
 	// POST表单提交,此处不需要转url格式,注意避坑!
 	std::string post_data = pText;
+#ifdef _DEBUG
+	//OutputDebugString(CString(pText)+"\n");
+#endif
 
 	// 释放堆内存;
 	if (pText)
@@ -1259,7 +1305,9 @@ SATHTTP_API int SaveResultImg(std::string url, const SATParameters::STSaveImgReq
 		if ( curlCode == CURLE_OK )
 		{
 			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
-
+#ifdef _DEBUG
+			//OutputDebugString(CString(reponse.c_str())+"\n");
+#endif
 			// 解析返回值;
 			pRoot = cJSON_Parse(reponse.c_str());
 			if (pRoot != NULL)

+ 3 - 0
SATHTTP/SATHTTP/SATHTTP.h

@@ -106,6 +106,7 @@ namespace SATParameters{
 
 	typedef struct __ST_CASE__
 	{		
+		int _nCaseStep;
 		std::string strIndex;
 		std::string strCaseName;
 		std::string strMainFilePath;
@@ -127,6 +128,7 @@ namespace SATParameters{
 		std::string _strCaseLog;
 		__ST_CASE__()
 		{
+			_nCaseStep = 1;
 			_pExcutor = NULL;
 			// 0表示未执行;1表示执行中;2表示执行完毕;3表示超时中断;
 			_nExecutionState = 0;
@@ -200,6 +202,7 @@ namespace SATParameters{
 		int Id;			// 注意:对应__ST_NOTIFY_JOB_START_REQ__的strInstanceId,而非__ST_TASK__.nInstanceId;
 		int fd;
 		int nTaskId;
+		//std::string strTaskId;
 		STJob Job;
 		// 任务日志;
 		std::string _strTaskLog;