Exemple #1
0
        /// <summary>
        /// 根据API 的URL以及传入的参数执行 POST请求
        /// </summary>
        /// <param name="ApiUrl"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public string ExecuteUrl(string ApiUrl, IDictionary <string, string> parameters)
        {
            string result = string.Empty;

            try
            {
                SDKUtils sdk = new SDKUtils();
                result = sdk.DoPost(ApiUrl, parameters);
            }
            catch (Exception e)
            {
                DataResult dataResult = new DataResult()
                {
                    Code = (int)EResponseCode.Exception, Message = e.Message
                };
                result = JsonConvert.SerializeObject(dataResult);
            }
            return(result);
        }
Exemple #2
0
        /// <summary>
        /// 根据API名称以及传入的参数执行 POST 请求
        /// </summary>
        /// <param name="ApiName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public string Execute(string ApiName, IDictionary <string, string> parameters)
        {
            string result = string.Empty;

            try
            {
                SDKUtils sdk    = new SDKUtils();
                string   ApiUrl = string.Format("{0}{1}", ResourceManager.GetSettingEntity("API_URL").Value, ApiName);
                result = sdk.DoPost(ApiUrl, parameters);
            }
            catch (Exception e)
            {
                DataResult dataResult = new DataResult()
                {
                    Code = (int)EResponseCode.Exception, Message = e.Message
                };
                result = JsonConvert.SerializeObject(dataResult);
            }
            return(result);
        }