Exemple #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;
            }
        }
Exemple #2
0
        public QualifiedNumberResult LineChart([FromBody] APIParameterLC param)
        {
            QualifiedNumberResult result = new QualifiedNumberResult();

            result.code = "1000";
            result.msg  = "success";
            if (param == null)
            {
                param = new APIParameterLC();
                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-LineChart 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 = "";
                if (string.IsNullOrEmpty(param.type))
                {
                    param.type = "1";//默认显示第一个的数据。
                }
                if (string.IsNullOrEmpty(param.startdate) && string.IsNullOrEmpty(param.enddate))
                {
                    str = string.Format(@"SELECT  *  from Bamt_LineChart WHERE IsEffective=1 and Name='{0}' and Type='{1}';", param.devicename, param.type);
                }
                else
                {
                    str = string.Format(@"SELECT  *  from Bamt_LineChart WHERE IsEffective=1 and Name='{0}' and Type='{1}' and AcctDate between '{2}' AND '{3}';", param.devicename, param.type, param.startdate, param.enddate);
                }
                DataTable sult = ds.Query(str);
                List <LineChartEntity> Qentity = new ModelHandler <LineChartEntity>().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);
        }
Exemple #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);
        }