소스 검색

1、char* -> const char*
2、脚本下载地址;

scbc.sat2 5 년 전
부모
커밋
af4cdeb69e
4개의 변경된 파일101개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      SATHTTP/SATHTTP/CharEncoding.cpp
  2. 1 1
      SATHTTP/SATHTTP/CharEncoding.h
  3. 87 0
      SATHTTP/SATHTTP/SATHTTP.cpp
  4. 12 2
      SATHTTP/SATHTTP/SATHTTP.h

+ 1 - 1
SATHTTP/SATHTTP/CharEncoding.cpp

@@ -436,7 +436,7 @@ void CharEncoding::GB2312ToUTF_8(string& pOut, const char *pText, int pLen)
 /*  ÈÕÆÚ£º;
 /*  ÄÚÈÝ£º;
 /************************************************************************/
-string CharEncoding::EnCode_GB2312URL(IN CHAR* pText)
+string CharEncoding::EnCode_GB2312URL(IN const CHAR* pText)
 {
 	string dd;
 	size_t len = strlen(pText);

+ 1 - 1
SATHTTP/SATHTTP/CharEncoding.h

@@ -75,7 +75,7 @@ public:
 	static string GB2312IntoUTF8(IN CHAR* pGB2312Text, IN const INT& nGB2312TextLen);
 
 	// 将字符串编码成为GB2312编码格式的URL;
-	static string EnCode_GB2312URL(IN CHAR* pText);
+	static string EnCode_GB2312URL(IN const CHAR* pText);
 	static void EnCode_GB2312URL(IN CHAR* pText, OUT string& strResult);
 	// 将字符串编码成为UTF-8编码格式的URL;
 	static string EnCode_UTF8URL(IN const CHAR* pText);

+ 87 - 0
SATHTTP/SATHTTP/SATHTTP.cpp

@@ -785,5 +785,92 @@ SATHTTP_API int SetResultList(std::string url, const SATParameters::STJobProcess
 		}
 	}
 
+	return FALSE;
+}
+
+
+SATHTTP_API int GetCaseFileListUrl(std::string url, std::string strCaseId, SATParameters::STScriptUrlResp &stScriptUrlResp)
+{
+	// 转化为Json;
+	cJSON *pRoot = cJSON_CreateObject();
+	if ( pRoot == NULL )
+	{
+		return -1;
+	}
+
+	ASSERT(cJSON_AddStringToObject(pRoot, "sysCode", "Execute"));
+	ASSERT(cJSON_AddStringToObject(pRoot, "function", "getCaseFileListUrl"));
+	cJSON *pData = cJSON_CreateObject();
+	if ( pData )
+	{
+		ASSERT(cJSON_AddStringToObject(pData, "testCaseId", strCaseId.c_str()));
+		// 添加到根结点中;
+		cJSON_AddItemToObject(pRoot, "data", pData);
+	}
+
+	char *pText = cJSON_Print(pRoot);
+	std::string post_data = "requestMsg=";
+	post_data.append(CharEncoding::EnCode_UTF8URL(pText));
+
+	// 释放堆内存;
+	if (pText)
+		delete pText;
+	pText = NULL;
+
+	if ( pRoot )
+		cJSON_Delete(pRoot);
+	pRoot = NULL;		
+
+	CCurlClient curl;
+	std::string reponse;	
+	CURLcode curlCode = CURLE_OK;
+	if ( CURLE_OK == curl.Initialize() )
+	{
+		if (_tcsstr(url.c_str(), "https://") || _tcsstr(url.c_str(), "HTTPS://") )
+			curlCode = curl.Posts(url, post_data, reponse);
+		else
+			curlCode = curl.Post(url, post_data, reponse);
+
+		if ( curlCode == CURLE_OK )
+		{
+			reponse = CharEncoding::DeCode_URLUTF8(reponse.c_str());
+
+			// 解析返回值;
+			pRoot = cJSON_Parse(reponse.c_str());
+			if (pRoot != NULL)
+			{
+				cJSON *pMsg = cJSON_GetObjectItem(pRoot, "responseMsg");
+				if ( pMsg )
+				{
+					stScriptUrlResp.strCode = cJSON_GetObjectItem(pMsg, "code") ? cJSON_GetObjectItem(pMsg, "code")->valuestring : "";
+					stScriptUrlResp.strMessage = cJSON_GetObjectItem(pMsg, "message") ? cJSON_GetObjectItem(pMsg, "message")->valuestring : "";
+					stScriptUrlResp.strProjectId = cJSON_GetObjectItem(pMsg, "strProjectId") ? (cJSON_GetObjectItem(pMsg, "strProjectId")->valuestring ? cJSON_GetObjectItem(pMsg, "strProjectId")->valuestring : "") : "";
+					stScriptUrlResp.strCaseType = cJSON_GetObjectItem(pMsg, "caseType") ? (cJSON_GetObjectItem(pMsg, "caseType")->valuestring ? cJSON_GetObjectItem(pMsg, "caseType")->valuestring : "") : "";
+					if ( stScriptUrlResp.strCode == "00" )
+					{				
+						cJSON *pObj = cJSON_GetObjectItem(pMsg, "data");
+						if (pObj != NULL)
+						{
+							if ( cJSON_GetArraySize(pObj) >= 1 )
+							{
+								cJSON *pScripURL = cJSON_GetArrayItem(pObj, 0);
+								if ( pScripURL )
+									stScriptUrlResp.strURL = cJSON_GetObjectItem(pScripURL, "url") ? (cJSON_GetObjectItem(pScripURL, "url")->valuestring ? cJSON_GetObjectItem(pScripURL, "url")->valuestring : "") : "";
+							}
+						}
+
+						// 释放内存;
+						cJSON_Delete(pRoot);
+						// 返回结果;
+						return TRUE;
+					}
+				}
+
+				// 错误产生,可输出msg方便查询;
+				cJSON_Delete(pRoot);	
+			}
+		}
+	}
+
 	return FALSE;
 }

+ 12 - 2
SATHTTP/SATHTTP/SATHTTP.h

@@ -245,6 +245,17 @@ namespace SATParameters{
 	{
 		std::string strIsDelete;
 	}STJobProcessResp, *pSTJobProcessResp;
+
+	//////////////////////////////////////////////////////////////////////////
+	// 6¡¢»ñÈ¡½Å±¾ÏÂÔØµØÖ·;
+	typedef struct __ST_SCRIPURL_RESP__
+	{
+		std::string strCaseType;
+		std::string strCode;
+		std::string strURL;
+		std::string strMessage;
+		std::string strProjectId;		
+	}STScriptUrlResp,*pSTScriptUrlResp;
 }
 
 extern SATHTTP_API int nSATHTTP;
@@ -270,12 +281,11 @@ __if_not_exists(NotifyJobStart)
 }
 
 SATHTTP_API int SetResultList(std::string url, const SATParameters::STJobProcessReq &stJobProcessReq, SATParameters::STJobProcessResp &stJobProcessResp) throw();
+SATHTTP_API int GetCaseFileListUrl(std::string url, std::string strCaseId, SATParameters::STScriptUrlResp &stScriptUrlResp) throw();
 
 SATHTTP_API int GetIdNumber();
-
 SATHTTP_API int StopTaskFromRunner();
 SATHTTP_API int GetPyCaseInfo();
-SATHTTP_API int GetCaseFileListUrl();
 SATHTTP_API int GetCaseInfo();
 SATHTTP_API int SaveCaseOrTaskLog();
 SATHTTP_API int SaveResultFile();