示例#1
0
        private void button3_Click(object sender, EventArgs e)
        {
            DataAcquisitionResult      result = new DataAcquisitionResult();
            List <EquipmentListOneDTO> dtos   = new List <EquipmentListOneDTO>();
            EquipmentListOneDTO        dto    = new EquipmentListOneDTO();

            dto.equipmentname  = "CNC01";
            dto.moldno         = "JD1";
            dto.workpiecesname = "JDM-007";
            dto.colour         = "red";
            dtos.Add(dto);
            dto = new EquipmentListOneDTO();
            dto.equipmentname  = "CNC02";
            dto.moldno         = "JD2";
            dto.workpiecesname = "JDM-008";
            dto.colour         = "yellow";
            dtos.Add(dto);
            string server = "http://localhost:15988/api/TeamTask/SaveEquipmentMachining";
            EquipmentListAPIParameterA param = new EquipmentListAPIParameterA();

            param.operator_name = "WebApi";
            param.operator_time = GenerateTimeStamp(DateTime.Now);
            param.sign          = GenSign(param.operator_name, param.operator_time);
            param.data          = dtos;
            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;
            }
        }
        public bool UpdateEquipmentListOne(EquipmentListOneDTO dto)
        {
            bool fla = false;

            try
            {
                int       re   = 0;
                DbService ds   = new DbService(dbnfin, "MySQL");
                string    srt  = string.Format(@"UPDATE  Sys_EquipmentList set  Mold_No='{0}',Workpieces_Name='{1}',Colour='{2}' where Equipment_Name='{3}'", dto.moldno, dto.workpiecesname, Colour(dto.colour), dto.equipmentname);
                int       sult = ds.InsertSql(srt, out re);
                if (sult > 0)
                {
                    fla = true;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message);
            }
            return(fla);
        }