private async void ReadAlarmHistory() { try { if (Device == null) { return; } this.listView.Items.Clear(); IO_DEVICE copyDevice = this.Device.Copy(); //获取读取历史数据 InfluxDBHistoryData resultData = await IOCenterManager.QueryFormManager.ReadHistoryAlarmDevice(this.Server, this.Communication, copyDevice, this.search.StartDate, this.search.EndDate, this.search.AlarmType, this.search.AlarmLevel, this.ucPagerControl.PageSize, this.ucPagerControl.PageIndex); if (resultData == null || !resultData.ReturnResult) { if (resultData != null) { FrmDialog.ShowDialog(this, resultData.Msg); } else { FrmDialog.ShowDialog(this, "查询失败"); } return; } //设置页眉控件参数 this.ucPagerControl.PageCount = resultData.PageCount; this.ucPagerControl.RecordCount = resultData.RecordCount; //删除曲线 //循环读取每个历史数据 //首先构造ListColumn if (resultData.Seres.Count() > 0) { //field_io_alarm_date //field_io_alarm_disposalidea //field_io_alarm_disposaluser //field_io_alarm_level //field_io_alarm_type //field_io_alarm_value //field_io_label //field_io_name Serie s = resultData.Seres.ElementAt(0); //获取首个时间 for (int i = 0; i < s.Values.Count; i++) { int timeindex = s.Columns.IndexOf("time"); string time = UnixDateTimeConvert.ConvertDateTimeInt(Convert.ToDateTime(InfluxDbManager.GetInfluxdbValue(s.Values[i][timeindex]))).ToString(); int dateindex = s.Columns.IndexOf("field_io_alarm_date"); string date = InfluxDbManager.GetInfluxdbValue(s.Values[i][dateindex]); ListViewItem lvi = new ListViewItem(time); int io_name_index = s.Columns.IndexOf("field_io_name"); if (io_name_index >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][io_name_index])); } else { lvi.SubItems.Add(""); } /// int io_name_label = s.Columns.IndexOf("field_io_label"); if (io_name_label >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][io_name_label])); } else { lvi.SubItems.Add(""); } /// int io_alarm_value = s.Columns.IndexOf("field_io_alarm_value"); if (io_alarm_value >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][io_alarm_value])); } else { lvi.SubItems.Add(""); } int io_alarm_date = s.Columns.IndexOf("field_io_alarm_date"); if (io_alarm_date >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][io_alarm_date])); } else { lvi.SubItems.Add(""); } int io_alarm_level = s.Columns.IndexOf("field_io_alarm_level"); if (io_alarm_level >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][io_alarm_level])); } else { lvi.SubItems.Add(""); } int io_alarm_type = s.Columns.IndexOf("field_io_alarm_type"); if (io_alarm_type >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][io_alarm_type])); } else { lvi.SubItems.Add(""); } int io_alarm_disposalidea = s.Columns.IndexOf("field_io_alarm_disposalidea"); if (io_alarm_disposalidea >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][io_alarm_disposalidea])); } else { lvi.SubItems.Add(""); } int io_alarm_disposaluser = s.Columns.IndexOf("field_io_alarm_disposaluser"); if (io_alarm_disposaluser >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][io_alarm_disposaluser])); } else { lvi.SubItems.Add(""); } listView.Items.Add(lvi); } } } catch (Exception ex) { IOCenterManager.QueryFormManager.DisplyException(ex); } }
private async void ReadAlarmConfigHistory() { try { if (Device == null) { return; } this.listViewSendCommand.Clear(); IO_DEVICE copyDevice = this.Device.Copy(); //获取读取历史数据 InfluxDBHistoryData resultData = await IOCenterManager.QueryFormManager.ReadHistoryAlarmConfigsDevice(this.Server, this.Communication, copyDevice, this.search.StartDate, this.search.EndDate, this.ucPagerControl.PageSize, this.ucPagerControl.PageIndex); if (resultData == null || !resultData.ReturnResult) { if (resultData != null) { FrmDialog.ShowDialog(this, resultData.Msg); } else { FrmDialog.ShowDialog(this, "查询失败"); } return; } //设置页眉控件参数 this.ucPagerControl.PageCount = resultData.PageCount; this.ucPagerControl.RecordCount = resultData.RecordCount; //删除曲线 if (resultData.Seres.Count() > 0) { Serie s = resultData.Seres.ElementAt(0); //获取首个时间 for (int i = 0; i < s.Values.Count; i++) { int timeindex = s.Columns.IndexOf("time"); string time = UnixDateTimeConvert.ConvertDateTimeInt(Convert.ToDateTime(InfluxDbManager.GetInfluxdbValue(s.Values[i][timeindex]))).ToString(); int field_update_date = s.Columns.IndexOf("field_update_date"); string date = InfluxDbManager.GetInfluxdbValue(s.Values[i][field_update_date]); ListViewItem lvi = new ListViewItem(date); int field_update_result = s.Columns.IndexOf("field_update_result"); if (field_update_result >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_update_result])); } else { lvi.SubItems.Add(""); } int field_update_uid = s.Columns.IndexOf("field_update_uid"); if (field_update_uid >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_update_uid])); } else { lvi.SubItems.Add(""); } int field_io_name = s.Columns.IndexOf("field_io_name"); if (field_io_name >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_name])); } else { lvi.SubItems.Add(""); } /// int field_io_label = s.Columns.IndexOf("field_io_label"); if (field_io_label >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_label])); } else { lvi.SubItems.Add(""); } int field_io_condition = s.Columns.IndexOf("field_io_condition"); if (field_io_condition >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_condition])); } else { lvi.SubItems.Add(""); } int field_io_enable_maxmax = s.Columns.IndexOf("field_io_enable_maxmax"); if (field_io_enable_maxmax >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_enable_maxmax])); } else { lvi.SubItems.Add(""); } int field_io_maxmax_type = s.Columns.IndexOf("field_io_maxmax_type"); if (field_io_maxmax_type >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_maxmax_type])); } else { lvi.SubItems.Add(""); } int field_io_maxmax_value = s.Columns.IndexOf("field_io_maxmax_value"); if (field_io_maxmax_value >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_maxmax_value])); } else { lvi.SubItems.Add(""); } int field_io_enable_max = s.Columns.IndexOf("field_io_enable_max"); if (field_io_enable_max >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_enable_max])); } else { lvi.SubItems.Add(""); } int field_io_max_type = s.Columns.IndexOf("field_io_max_type"); if (field_io_max_type >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_max_type])); } else { lvi.SubItems.Add(""); } int field_io_max_value = s.Columns.IndexOf("field_io_max_value"); if (field_io_max_value >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_max_value])); } else { lvi.SubItems.Add(""); } int field_io_enable_min = s.Columns.IndexOf("field_io_enable_min"); if (field_io_enable_min >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_enable_min])); } else { lvi.SubItems.Add(""); } int field_io_min_type = s.Columns.IndexOf("field_io_min_type"); if (field_io_min_type >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_min_type])); } else { lvi.SubItems.Add(""); } int field_io_min_value = s.Columns.IndexOf("field_io_min_value"); if (field_io_min_value >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_min_value])); } else { lvi.SubItems.Add(""); } int field_io_enable_minmin = s.Columns.IndexOf("field_io_enable_minmin"); if (field_io_enable_minmin >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_enable_minmin])); } else { lvi.SubItems.Add(""); } int field_io_minmin_type = s.Columns.IndexOf("field_io_minmin_type"); if (field_io_minmin_type >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_minmin_type])); } else { lvi.SubItems.Add(""); } int field_io_minmin_value = s.Columns.IndexOf("field_io_minmin_value"); if (field_io_minmin_value >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_io_minmin_value])); } else { lvi.SubItems.Add(""); } this.listViewSendCommand.Items.Add(lvi); } } } catch (Exception ex) { IOCenterManager.QueryFormManager.DisplyException(ex); } }
/// <summary> /// 获取要上传的实时数据字符串组合 /// </summary> /// <param name="device"></param> /// <returns></returns> public static string GetRealDataCacheString(IO_DEVICE device) { List <IO_PARA> paras = new List <IO_PARA>(); string str = "IO_COMM_ID:" + device.IO_COMM_ID + "#IO_DEVICE_ID:" + device.IO_DEVICE_ID + "#IO_SERVER_ID:" + device.IO_SERVER_ID + "#IO_DEVICE_NAME:" + device.IO_DEVICE_NAME + "#DATE:" + (device.GetedValueDate == null ? "" : UnixDateTimeConvert.ConvertDateTimeInt(device.GetedValueDate.Value).ToString()) + ""; for (int i = 0; i < device.IOParas.Count; i++) { if (device.IOParas[i].IORealData == null) { continue; } string QualityStampStr = "BAD"; if (device.IOParas[i].RealQualityStamp == Scada.IOStructure.QualityStamp.NONE) { device.IOParas[i].IORealData.QualityStamp = Scada.IOStructure.QualityStamp.NONE; QualityStampStr = "NONE"; } else if (device.IOParas[i].RealQualityStamp == Scada.IOStructure.QualityStamp.GOOD) { device.IOParas[i].IORealData.QualityStamp = Scada.IOStructure.QualityStamp.GOOD; QualityStampStr = "GOOD"; } else { device.IOParas[i].IORealData.QualityStamp = Scada.IOStructure.QualityStamp.BAD; QualityStampStr = "BAD"; } if (device.IOParas[i].RealValue == "") { device.IOParas[i].IORealData.ParaValue = "-9999"; device.IOParas[i].IORealData.QualityStamp = Scada.IOStructure.QualityStamp.BAD; QualityStampStr = "BAD"; } str += "#" + device.IOParas[i].IO_NAME + ":" + device.IOParas[i].IO_ID + "|" + device.IOParas[i].RealValue + "|" + QualityStampStr; } return(str); }
private async void ReadBackupHistory() { this.listView.Items.Clear(); try { //获取读取历史数据 InfluxDBHistoryData resultData = await IOCenterManager.QueryFormManager.ReadBackupHistory(this.ucPagerControl.PageSize, this.ucPagerControl.PageIndex); if (resultData == null || !resultData.ReturnResult) { if (resultData != null) { FrmDialog.ShowDialog(this, resultData.Msg); } else { FrmDialog.ShowDialog(this, "查询失败"); } return; } //设置页眉控件参数 this.ucPagerControl.PageCount = resultData.PageCount; this.ucPagerControl.RecordCount = resultData.RecordCount; if (resultData.Seres.Count() > 0) { Serie s = resultData.Seres.ElementAt(0); //获取首个时间 for (int i = 0; i < s.Values.Count; i++) { int timeindex = s.Columns.IndexOf("time"); string time = UnixDateTimeConvert.ConvertDateTimeInt(Convert.ToDateTime(InfluxDbManager.GetInfluxdbValue(s.Values[i][timeindex]))).ToString(); int dateindex = s.Columns.IndexOf("field_backup_date"); string date = InfluxDbManager.GetInfluxdbValue(s.Values[i][dateindex]); ListViewItem lvi = new ListViewItem(time); int field_backup_date = s.Columns.IndexOf("field_backup_date"); if (field_backup_date >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_backup_date])); } else { lvi.SubItems.Add(""); } int field_backup_path = s.Columns.IndexOf("field_backup_path"); if (field_backup_path >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_backup_path])); } else { lvi.SubItems.Add(""); } /// int field_backup_file = s.Columns.IndexOf("field_backup_file"); if (field_backup_file >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_backup_file])); } else { lvi.SubItems.Add(""); } /// int field_backup_result = s.Columns.IndexOf("field_backup_result"); if (field_backup_result >= 0) { lvi.SubItems.Add(InfluxDbManager.GetInfluxdbValue(s.Values[i][field_backup_result])); } else { lvi.SubItems.Add(""); } listView.Items.Add(lvi); } } } catch (Exception ex) { IOCenterManager.QueryFormManager.DisplyException(ex); } }