Beispiel #1
0
        private void button11_Click(object sender, EventArgs e)
        {
            QualifiedNumberResult result = new QualifiedNumberResult();

            string       server = "http://localhost:15988/api/Applets/MainDetails";
            APIParameter param  = new APIParameter();

            param.operator_name = "WebApi";
            param.operator_time = GenerateTimeStamp(DateTime.Now);
            param.sign          = GenSign(param.operator_name, param.operator_time);

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("operator_name", param.operator_name);
            dic.Add("operator_time", param.operator_time);
            dic.Add("sign", param.sign);

            try
            {
                HttpWebResponse        response = CreatePostHttpResponse(server, dic, null, null, Encoding.UTF8, null);
                System.IO.StreamReader sr       = new System.IO.StreamReader(response.GetResponseStream());
                string responseContent          = sr.ReadToEnd();
                sr.Close();

                QualifiedNumberResult rtn = Deserialize <QualifiedNumberResult>(responseContent);
                if (rtn.code != "1000")
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 执行接口方法
        /// 传入参数列表,比如接口名称,参宿,文件等
        /// 还可以上传文件
        /// </summary>
        /// <param name="path">接口名称</param>
        /// <param name="parameters">参数列表</param>
        /// <param name="file">文件</param>
        /// <returns>服务器响应数据</returns>
        public string RequestWithFile(string path, List <APIParameter> parameters, APIParameter file)
        {
            string        responseData = "";
            APIValidation av           = new APIValidation();

            parameters.Add(new APIParameter("access_token", av.GetAccessToken()));
            string url = APIConfig.RennAPIURL + path;

            responseData = new SyncHttp().HttpRequest("POST", url, parameters, file);
            return(responseData);
        }
Beispiel #3
0
        public QualifiedNumberResult MainDetails([FromBody] APIParameter param)
        {
            QualifiedNumberResult result = new QualifiedNumberResult();

            result.code = "1000";
            result.msg  = "success";
            if (param == null)
            {
                param = new APIParameter();
                this.Request.GetQueryNameValuePairs();

                HttpContextBase context = (HttpContextBase)Request.Properties["MS_HttpContext"]; //获取传统context
                HttpRequestBase request = context.Request;                                       //定义传统request对象
                param.operator_name = request.Form["operator_name"];
                param.operator_time = request.Form["operator_time"];
                param.sign          = request.Form["sign"];

                LogHelper.Info("WXWebApi-MainDetails param from forms");
            }
            if (!VerifyMiddleSign(param.operator_name, param.operator_time, param.sign))
            {
                LogHelper.Info(string.Format("operator_name{0},operation_time{1},sign{2}", param.operator_name, param.operator_time, param.sign));
                result.msg  = "签名错误";
                result.code = "1040";
                return(result);
            }
            try
            {
                DbService ds   = new DbService(dbnfin, "SqlServer");
                string    str  = string.Format(@"SELECT  *  from Bamt_MainDetails WHERE IsEffective=1;");
                DataTable sult = ds.Query(str);
                List <MainDetailsEntity> Qentity = new ModelHandler <MainDetailsEntity>().FillModel(sult);
                string strJson = JsonConvert.SerializeObject(Qentity);
                result.data = strJson;
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message);
                result.msg  = ex.Message;
                result.code = "1060";
                return(result);
            }
            return(result);
        }