Beispiel #1
0
        public DataAcquisitionResult SaveRunningState([FromBody] RunningStateAPIParameterA param)
        {
            DataAcquisitionResult result = new DataAcquisitionResult();

            result.code = "1000";
            result.msg  = "success";
            if (param == null)
            {
                param = new RunningStateAPIParameterA();
                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"];
                param.strdata       = request.Form["strdata"];

                LogHelper.Info("WebApi-SaveRunningState param from forms");
            }
            //else LogHelper.Info(string.Format("WebApi-SaveDataAcquisition param from body{0}", Serialize(param)));
            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);
            }
            RunningStateDTOA dto = new RunningStateDTOA();

            try
            {
                dto = Deserialize <RunningStateDTOA>(param.strdata);
                bool fla = InsertRunningState(dto);
                if (!fla)
                {
                    LogHelper.Error(string.Format("新增失败-SaveRunningState:{0}", Serialize(dto)));
                    //result.msg = "数据插入失败";
                    //result.code = "1050";
                    //return result;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message);
                result.msg  = ex.Message;
                result.code = "1060";
                return(result);
            }
            return(result);
        }
Beispiel #2
0
        private void button6_Click(object sender, EventArgs e)
        {
            DataAcquisitionResult result = new DataAcquisitionResult();
            RunningStateDTOA      dto    = new RunningStateDTOA();

            dto.Describe1      = "CNC1发那科<br>运行中";
            dto.DescribeColor1 = "#23ab33";
            dto.Describe2      = "CNC2发那科<br>运行中";
            dto.DescribeColor2 = "#23ab33";
            dto.Describe3      = "CNC3发那科<br>待机";
            dto.DescribeColor3 = "yellow";
            dto.Describe4      = "CMM2海克斯康<br>离线";
            dto.DescribeColor4 = "#c8c8c8";
            dto.Describe5      = "Robot<br>未就绪";
            dto.DescribeColor5 = "#0fcdfd";
            dto.Describe6      = "清洗机<br>待机";
            dto.DescribeColor6 = "#0865e3";

            string server = "http://localhost:15988/api/AutomationLine/SaveRunningState";
            RunningStateAPIParameterA param = new RunningStateAPIParameterA();

            param.operator_name = "WebApi";
            param.operator_time = GenerateTimeStamp(DateTime.Now);
            param.sign          = GenSign(param.operator_name, param.operator_time);
            param.data          = dto;
            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);
            dic.Add("strdata", Serialize(param.data));

            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();

                DataAcquisitionResult rtn = Deserialize <DataAcquisitionResult>(responseContent);
                if (rtn.code != "1000")
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                return;
            }
        }
Beispiel #3
0
        public bool InsertRunningState(RunningStateDTOA dto)
        {
            bool fla = false;

            try
            {
                int       re    = 0;
                DbService ds    = new DbService(dbnfin, "MySQL");
                string    str1  = string.Format(@"SELECT  *  from Sys_RunningState WHERE IsEffective=1;");
                bool      sult1 = ds.IsExistRecord(str1);
                if (sult1)
                {
                    string srt = string.Format(@"UPDATE Sys_RunningState SET Describe1='{0}',DescribeColor1='{1}',Describe2='{2}',DescribeColor2='{3}',Describe3='{4}',DescribeColor3='{5}',Describe4='{6}',DescribeColor4='{7}',Describe5='{8}',DescribeColor5='{9}',Describe6='{10}',DescribeColor6='{11}' WHERE IsEffective=1",
                                               dto.Describe1, dto.DescribeColor1, dto.Describe2, dto.DescribeColor2, dto.Describe3, dto.DescribeColor3, dto.Describe4, dto.DescribeColor4, dto.Describe5, dto.DescribeColor5, dto.Describe6, dto.DescribeColor6);
                    int sult = ds.InsertSql(srt, out re);
                    if (sult > 0)
                    {
                        fla = true;
                    }
                }
                else
                {
                    string srt  = string.Format(@"INSERT INTO Sys_RunningState(Picture_Tip,Picture_Url,Describe1,DescribeColor1,Describe2,DescribeColor2,Describe3,DescribeColor3,Describe4,DescribeColor4,Describe5,DescribeColor5,Describe6,DescribeColor6,CreationTime)
                    VALUES  ( '测试显示','/Content/img/product/runningstate/01.png','{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',NOW())", dto.Describe1, dto.DescribeColor1, dto.Describe2, dto.DescribeColor2, dto.Describe3, dto.DescribeColor3, dto.Describe4, dto.DescribeColor4, dto.Describe5, dto.DescribeColor5, dto.Describe6, dto.DescribeColor6);
                    int    sult = ds.InsertSql(srt, out re);
                    if (sult > 0)
                    {
                        fla = true;
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message);
            }
            return(fla);
        }