//Select DXC in ComboBox1 void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string selItem = comboBox1.SelectedItem.ToString(); if (string.IsNullOrWhiteSpace(selItem)) { return; } _selectedDxc = ListDxc.FirstOrDefault(x => x.Ip == selItem); bindingSource1.DataSource = _selectedDxc.Ports; dataGridView1.DataSource = bindingSource1; //Порты //dataGridView1.Rows.Clear(); //foreach (Port port in SelectedDXC.Ports) { // dataGridView1.Rows.Add(port.BordNumber,port.PortNumber,port.Name,port.Alarmed); // //} //Other textboxes tbName.Text = _selectedDxc.CustomName; tbSysName.Text = _selectedDxc.Info.SysName; tbIP.Text = _selectedDxc.Ip; tbSYNC.Text = _selectedDxc.Info.Nodalclock; tbBackup.Text = _selectedDxc.BackupPath; }
public EditDxc(List <ClassDxc> list) { InitializeComponent(); _selectedDxc = new ClassDxc("1.1.1.1"); this.Load += new EventHandler(EditDXC_Load); comboBox1.SelectedIndexChanged += new EventHandler(comboBox1_SelectedIndexChanged); ListDxc = list; if (!list.Any()) { return; } string[] ips = new string[list.Count]; for (int i = 0; i < list.Count; i++) { ips[i] = ListDxc[i].Ip; } comboBox1.Items.AddRange(ips); if (ips.Count() > 0) { comboBox1.SelectedIndex = 0; } }
void BtAddDxcClick(object sender, EventArgs e) { DialogResult dr = _addForm.ShowDialog(); if (dr != DialogResult.OK) { return; } ClassDxc newDxc = new ClassDxc(_addForm.Ip); newDxc.CustomName = _addForm.DxcName; if (ListDxc.Any(x => x.CustomName == newDxc.CustomName)) { MessageBox.Show(" Имя " + newDxc.CustomName + " уже существует у IP: " + ListDxc.Find(x => x.CustomName == newDxc.CustomName).Ip); return; } //check Existing if (ListDxc.All(x => x.Ip != newDxc.Ip)) { ListDxc.Add(newDxc); } else { MessageBox.Show(" IP адресс " + newDxc.Ip + " уже существует."); return; } ViewIPinCombo(); }
public void ViewDXCAlarmsDGV(ClassDxc dxc, DateTime from, DateTime to) { try { if (dxc == null || from == null || to == null) { return; } var FROM = dxc.CorrectTimeToDXC(from);//приводим к локальному времени на dxc var TO = dxc.CorrectTimeToDXC(to); IEnumerable <Alarm> Filteredalarms; if (!dxc.Alarms.Any(x => x.Start <= FROM)) //try read from arhiv { dxc.ReadAlarmsFromInterval(FROM, TO); } if (!checkBox1.Checked) { Filteredalarms = dxc.Alarms.Where(a => a.Start >= FROM && a.Start <= TO); } else { Filteredalarms = dxc.GetCorrectedAlarms().Where(a => a.Start >= from && a.Start <= to); } DisplayAlarmsDgv(Filteredalarms.ToList()); } catch (Exception ex) { Log.WriteLog("ViewAlarms.main.", ex.Message); } }
//Select DXC in listbox void LbAllSelectedIndexChanged(object sender, EventArgs e) { string methodName = new StackTrace(false).GetFrame(0).GetMethod().Name; try { if (lbAll.SelectedItems.Count != 1) { return; } CurrentDxc = DxcList.Find(x => x.CustomName == lbAll.SelectedItem.ToString()); ClearLog(); CurrentDxc.ReadInfoFromIp(); Help.BeepClick(); InvokeLog("", CurrentDxc.ToString()); #region test //CurrentDXC.alarms=ReadAlarmsFromFile("test_ALARMS.txt"); #endregion dataGridView1.Rows.Clear(); ViewDXCAlarmsDGV(CurrentDxc, FromFilter, ToFilter); } catch (Exception exception) { Log.WriteLog(methodName, exception.Message); } }
public bool Equals(ClassDxc other) { //if(other==null) return false; // add comparisions for all members here return(this.Ip == other.Ip && this.Info == other.Info); }
public void ReadSettings() { string methodName = new StackTrace(false).GetFrame(0).GetMethod().Name; try { #region Чтение имен DXC DxcList.Clear(); var dxcKeys = Cfg.GetAllKeys("LIST_DXC"); if (dxcKeys.Count() > 0) //read all DXC NAME--IP { //KEY - IP //VALUE - NAME foreach (var dxcKey in dxcKeys) { if (String.IsNullOrWhiteSpace(dxcKey)) { continue; } ClassDxc newDxc = new ClassDxc(dxcKey); newDxc.CustomName = Cfg.ReadIni("LIST_DXC", dxcKey); if (DxcList.All(x => x.Ip != dxcKey)) { DxcList.Add(newDxc); } } } #endregion #region Чтение Информации о DXC if (DxcList.Any()) { for (int i = 0; i < DxcList.Count; i++) { ClassDxc d = DxcList[i]; d.LoadFromFile(Cfg); //D.backupPath = Cfg.ReadINI(D.ip, "BackupPath"); //D.info.sys_name = Cfg.ReadINI(D.ip, "Sys_Name"); //string file = Cfg.ReadIni(d.Ip, "Alarms_file"); //if(Cfg.KeyExists("TimeCorrection",D.ip)) D.info.dt=new TimeSpan(long.Parse(Cfg.ReadINI(D.ip,"TimeCorrection"))); d.ReadArhivAlarmsForDays(10); DxcList[i] = d; } } #endregion if (Cfg.KeyExists("backupDir", "Global")) { BackupPath = Cfg.ReadIni("Global", "backupDir"); } else { BackupPath = ""; } } catch (Exception exception) { Log.WriteLog(methodName, exception.Message); } }
public DataStorage(ClassDxc Dxc) { dxc = Dxc; }