private void button7_Click(object sender, EventArgs e) { DataAcquisitionResult result = new DataAcquisitionResult(); List <DataAcquisitionJiadongRateDTO> dtos = new List <DataAcquisitionJiadongRateDTO>(); DataAcquisitionJiadongRateDTO dto = new DataAcquisitionJiadongRateDTO(); dto.devicename = "CNC1发那科"; dto.todayoutput = 21; dto.todayjiadong = 0.68; dtos.Add(dto); dto = new DataAcquisitionJiadongRateDTO(); dto.devicename = "CNC2发那科"; dto.todayoutput = 3; dto.todayjiadong = 0.34; dtos.Add(dto); string server = "http://localhost:15988/api/AutomationLine/SaveDataAcquisitionJiadongRate"; DataAcquisitionJiadongRateAPIParameter param = new DataAcquisitionJiadongRateAPIParameter(); 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 UpdateDataAcquisitionJiadongRate(DataAcquisitionJiadongRateDTO dto) { bool fla = false; try { int re = 0; DbService ds = new DbService(dbnfin, "MySQL"); string srt = string.Format(@"UPDATE Sys_DataAcquisition set TodayOutput={0},TodayJiadong={1} where DeviceName='{2}'", dto.todayoutput, dto.todayjiadong, dto.devicename); int sult = ds.InsertSql(srt, out re); if (sult > 0) { fla = true; } } catch (Exception ex) { LogHelper.Error(ex.Message); } return(fla); }