public void pageInit(int devID, bool onlinest) { this.butSave.Enabled = onlinest; DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID); this.labDevNm.Text = deviceByID.DeviceName; this.labDevModel.Text = deviceByID.ModelNm; this.labDevModel.Tag = devID.ToString(); string text = deviceByID.ModelNm; if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion)) { text = text + " (F/W: " + deviceByID.FWVersion + ")"; } this.toolTip1.SetToolTip(this.labDevModel, text); this.labDevIp.Text = deviceByID.DeviceIP; this.labDevIp.Tag = deviceByID.FWVersion; this.labDevNm.Text = deviceByID.DeviceName; RackInfo rackByID = RackInfo.getRackByID(deviceByID.RackID); this.labDevRackNm.Text = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion); if (deviceModelConfig.popReading != 2) { this.gbPop.Hide(); this.gbPop2.Hide(); this.gbPOPBankPriority.Hide(); return; } if (deviceModelConfig.popNewRule == Constant.YES) { this.gbPop.Hide(); this.gbPop2.Show(); if (deviceModelConfig.perportreading == Constant.NO) { this.pop2_cbOutlet.Hide(); this.pop2_cbBankLIFO.Hide(); } else { this.pop2_cbOutlet.Show(); this.pop2_cbBankLIFO.Show(); } if (deviceByID.OutletPOPMode == 1) { this.pop2_cbOutlet.Checked = false; } else { this.pop2_cbOutlet.Checked = true; } if (deviceByID.BankPOPLIFOMode == 1) { this.pop2_cbBankLIFO.Checked = false; } else { this.pop2_cbBankLIFO.Checked = true; } if (deviceByID.BankPOPPriorityMode == 1) { this.pop2_cbBankPriority.Checked = false; } else { this.pop2_cbBankPriority.Checked = true; } if (deviceModelConfig.popPrioritySupport == Constant.NO) { this.gbPOPBankPriority.Hide(); return; } this.gbPOPBankPriority.Show(); string[] array = deviceByID.Bank_Priority.Split(new char[] { '#' }); string[] array2 = array[0].Split(new char[] { ',' }); string[] array3 = null; if (array.Length >= 2) { array3 = array[1].Split(new char[] { ',' }); } this.dgvBank1_PList.Rows.Clear(); DataGridViewComboBoxColumn dataGridViewComboBoxColumn = (DataGridViewComboBoxColumn)this.dgvBank1_PList.Columns[1]; this.m_Bank1_Priority_ComboStrings = new System.Collections.Generic.List <string>(); dataGridViewComboBoxColumn.Items.Clear(); dataGridViewComboBoxColumn.Items.Add("N/A"); this.m_Bank1_Priority_ComboStrings.Add("N/A"); int num; int num2; if (deviceModelConfig.bankNum == 0) { num = 1; num2 = deviceModelConfig.portNum; } else { num = deviceModelConfig.bankOutlets[0].fromPort; num2 = deviceModelConfig.bankOutlets[0].toPort; } for (int i = num; i <= num2; i++) { if (deviceModelConfig.isOutletSwitchable(i - 1)) { dataGridViewComboBoxColumn.Items.Add("Outlet " + i.ToString()); this.m_Bank1_Priority_ComboStrings.Add("Outlet " + i.ToString()); } } int num3 = 0; for (int j = num; j <= num2; j++) { if (deviceModelConfig.isOutletSwitchable(j - 1)) { if (array2[num3].Equals("0")) { this.dgvBank1_PList.Rows.Add(new object[] { "Priority" + (num3 + 1).ToString(), "N/A" }); } else { string text2 = "Outlet " + System.Convert.ToInt16(array2[num3]).ToString(); if (this.m_Bank1_Priority_ComboStrings.Contains(text2)) { this.dgvBank1_PList.Rows.Add(new object[] { "Priority" + (num3 + 1).ToString(), text2 }); } else { this.dgvBank1_PList.Rows.Add(new object[] { "Priority" + (num3 + 1).ToString(), "N/A" }); } } num3++; } } if (deviceModelConfig.bankNum >= 2) { this.lbbank2.Visible = true; this.dgvBank2_PList.Visible = true; this.dgvBank2_PList.Rows.Clear(); dataGridViewComboBoxColumn = (DataGridViewComboBoxColumn)this.dgvBank2_PList.Columns[1]; this.m_Bank2_Priority_ComboStrings = new System.Collections.Generic.List <string>(); dataGridViewComboBoxColumn.Items.Clear(); dataGridViewComboBoxColumn.Items.Add("N/A"); this.m_Bank2_Priority_ComboStrings.Add("N/A"); for (int k = deviceModelConfig.bankOutlets[1].fromPort; k <= deviceModelConfig.bankOutlets[1].toPort; k++) { if (deviceModelConfig.isOutletSwitchable(k - 1)) { dataGridViewComboBoxColumn.Items.Add("Outlet " + k.ToString()); this.m_Bank2_Priority_ComboStrings.Add("Outlet " + k.ToString()); } } num3 = 0; for (int l = deviceModelConfig.bankOutlets[1].fromPort; l <= deviceModelConfig.bankOutlets[1].toPort; l++) { if (deviceModelConfig.isOutletSwitchable(l - 1)) { if (array3[num3].Equals("0")) { this.dgvBank2_PList.Rows.Add(new object[] { "Priority" + (num3 + 1).ToString(), "N/A" }); } else { string text2 = "Outlet " + System.Convert.ToInt16(array3[num3]).ToString(); if (this.m_Bank2_Priority_ComboStrings.Contains(text2)) { this.dgvBank2_PList.Rows.Add(new object[] { "Priority" + (num3 + 1).ToString(), text2 }); } else { this.dgvBank2_PList.Rows.Add(new object[] { "Priority" + (num3 + 1).ToString(), "N/A" }); } } num3++; } } return; } this.lbbank2.Visible = false; this.dgvBank2_PList.Visible = false; return; } else { if (deviceByID.POPThreshold == -500f) { this.gbPop.Hide(); this.gbPop2.Hide(); this.gbPOPBankPriority.Hide(); return; } this.gbPop.Show(); this.gbPop2.Hide(); this.gbPOPBankPriority.Hide(); this.rbPopMaxBankC.Text = this.PopMaxBank_txt + " " + deviceModelConfig.popDefault.ToString("F1") + "A"; if (deviceByID.POPEnableMode == 1) { this.cbPopEnable.Checked = false; this.rbPopMaxBankC.Checked = true; this.tbPopThreshold.Text = ""; this.cbPopEnable_CheckedChanged(this.cbPopEnable, null); return; } if (deviceByID.POPThreshold < 0f) { this.cbPopEnable.Checked = true; this.rbPopMaxBankC.Checked = true; this.tbPopThreshold.Text = ""; return; } this.cbPopEnable.Checked = true; this.rbPopUsrdef.Checked = true; this.tbPopThreshold.Text = deviceByID.POPThreshold.ToString("F1"); return; } }
private void showOutletInfo(long gpID) { DataTable dataTable = new DataTable(); dataTable.Columns.Add("devID", typeof(string)); dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.OPDataGp_InfoC1No, new string[0]), typeof(int)); dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Comm_name, new string[0]), typeof(string)); dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_TPOutlet, new string[0]), typeof(int)); dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.OPDataGp_Status, new string[0]), typeof(string)); dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMDev, new string[0]), typeof(string)); dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMRack, new string[0]), typeof(string)); dataTable.Columns.Add(EcoLanguage.getMsg(LangRes.Group_NMZone, new string[0]), typeof(string)); DataSet dataSet = ClientAPI.getDataSet(0); if (dataSet == null) { return; } DataTable onlineOutlets = dataSet.Tables[2]; GroupInfo groupInfo = null; System.Collections.Generic.List <GroupInfo> groupCopy = ClientAPI.getGroupCopy(); foreach (GroupInfo current in groupCopy) { if (current.ID == gpID) { groupInfo = current; break; } } if (groupInfo == null) { return; } string groupType = groupInfo.GroupType; string text = groupInfo.Members; if (text == null || text.Length == 0) { text = "-1"; } System.DateTime now = System.DateTime.Now; commUtil.ShowInfo_DEBUG("Start GetDevicRackZoneRelation ----------------" + now.ToString("yyyy/MM/dd HH:mm:ss:fff")); System.Collections.Generic.Dictionary <int, ClientAPI.DeviceWithZoneRackInfo> devicRackZoneRelation = ClientAPI.GetDevicRackZoneRelation(); System.DateTime now2 = System.DateTime.Now; System.TimeSpan timeSpan = now2 - now; commUtil.ShowInfo_DEBUG(string.Concat(new object[] { "End GetDevicRackZoneRelation ----------------", now2.ToString("yyyy/MM/dd HH:mm:ss:fff"), " spend=", timeSpan.TotalMilliseconds })); string ssss = "device_id"; string key; switch (key = groupType) { case "zone": { string text2 = ClientAPI.getRacklistByZonelist(text); text2 = commUtil.uniqueIDs(text2); text = ""; if (text2.Length > 0) { text2 = text2.Substring(0, text2.Length - 1); DataRow[] dataRows = ClientAPI.getDataRows(0, "rack_id in (" + text2 + ")", ""); DataRow[] array = dataRows; for (int i = 0; i < array.Length; i++) { DataRow dataRow = array[i]; text = text + dataRow["device_id"] + ","; } text = commUtil.uniqueIDs(text); } if (text.Length > 0) { text = text.Substring(0, text.Length - 1); } ssss = "device_id"; break; } case "rack": case "allrack": { DataRow[] dataRows = ClientAPI.getDataRows(0, "rack_id in (" + text + ")", ""); text = ""; DataRow[] array2 = dataRows; for (int j = 0; j < array2.Length; j++) { DataRow dataRow2 = array2[j]; text = text + dataRow2["device_id"] + ","; } text = commUtil.uniqueIDs(text); if (text.Length > 0) { text = text.Substring(0, text.Length - 1); } ssss = "device_id"; break; } case "dev": case "alldev": ssss = "device_id"; break; case "outlet": case "alloutlet": ssss = "port_id"; break; } DataTable oPOutlets = this.getOPOutlets(onlineOutlets, ssss, text); string text3 = ""; string text4 = ""; DataGridViewCell currentCell = this.dgvInfo.CurrentCell; if (currentCell != null) { int rowIndex = currentCell.RowIndex; text3 = this.dgvInfo.Rows[rowIndex].Cells[0].Value.ToString(); text4 = this.dgvInfo.Rows[rowIndex].Cells[3].Value.ToString(); } foreach (DataRow dataRow3 in oPOutlets.Rows) { string text5 = dataRow3["device_id"].ToString(); if (devicRackZoneRelation.ContainsKey(System.Convert.ToInt32(text5))) { ClientAPI.DeviceWithZoneRackInfo deviceWithZoneRackInfo = devicRackZoneRelation[System.Convert.ToInt32(text5)]; string device_model = deviceWithZoneRackInfo.device_model; string fw_version = deviceWithZoneRackInfo.fw_version; DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(device_model, fw_version); if (deviceModelConfig.switchableOutlets != 0uL) { int num2 = System.Convert.ToInt32(dataRow3["port_number"].ToString()); if (deviceModelConfig.isOutletSwitchable(num2 - 1)) { if (dataRow3["port_nm"].ToString().Equals(System.Convert.ToString(-500)) || dataRow3["port_nm"].ToString().Equals(System.Convert.ToString(-1000))) { dataRow3["port_nm"] = ""; } string text6 = dataRow3["port_state"].ToString(); if (text6.Equals(OutletStatus.OFF.ToString())) { dataRow3["port_state"] = EcoLanguage.getMsg(LangRes.OPST_OFF, new string[0]); } else { if (text6.Equals(OutletStatus.ON.ToString())) { dataRow3["port_state"] = EcoLanguage.getMsg(LangRes.OPST_ON, new string[0]); } else { if (text6.Equals(OutletStatus.Pending.ToString())) { dataRow3["port_state"] = EcoLanguage.getMsg(LangRes.OPST_PENDING, new string[0]); } else { if (text6.Equals(OutletStatus.Fault.ToString())) { dataRow3["port_state"] = EcoLanguage.getMsg(LangRes.OPST_FAULT, new string[0]); } } } } string text7 = dataRow3["port_nm"].ToString(); if (text7.Equals("\0")) { dataRow3["port_nm"] = string.Empty; } dataTable.Rows.Add(new object[] { text5, 0, dataRow3["port_nm"], dataRow3["port_number"], dataRow3["port_state"], deviceWithZoneRackInfo.device_nm, deviceWithZoneRackInfo.rack_nm, deviceWithZoneRackInfo.zone_list }); } } } } dataTable = new DataView(dataTable) { Sort = EcoLanguage.getMsg(LangRes.Group_NMDev, new string[0]) + " ASC, " + EcoLanguage.getMsg(LangRes.Group_TPOutlet, new string[0]) + " ASC" }.ToTable(); int num3 = -1; int num4 = 0; foreach (DataRow dataRow4 in dataTable.Rows) { num4++; dataRow4[1] = num4; string text5 = (string)dataRow4[0]; if (text3.Equals(text5) && text4.Equals(dataRow4[3].ToString())) { num3 = num4 - 1; } } this.dgvInfo.DataSource = null; this.dgvInfo.DataSource = dataTable; this.dgvInfo.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; this.dgvInfo.Columns[0].Visible = false; this.dgvInfo.Columns[1].Width = 60; this.dgvInfo.Columns[2].Width = 150; this.dgvInfo.Columns[3].Width = 40; this.dgvInfo.Columns[4].Width = 45; this.dgvInfo.Columns[5].Width = 150; this.dgvInfo.Columns[6].Width = 130; this.dgvInfo.Columns[7].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; int count = oPOutlets.Rows.Count; this.nonOPoutletNum.Text = System.Convert.ToString(count - num4); this.canOPoutletNum.Text = System.Convert.ToString(num4); if (num4 > 0) { this.groupBoxPowerControl.Visible = true; this.butOn.Enabled = EcoGlobalVar.flgEnablePower; this.butOff.Enabled = EcoGlobalVar.flgEnablePower; this.cbDReboot.Enabled = EcoGlobalVar.flgEnablePower; } else { this.groupBoxPowerControl.Visible = false; } if (num3 >= 0) { this.dgvInfo.CurrentCell = this.dgvInfo.Rows[num3].Cells[2]; } }