|
@@ -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;
|
|
|
}
|