private void handleTheResult(FirmwareUpgrade.Upgrading upgrading, int status) { switch (status) { case 0: upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, ""); return; case 2: upgrading(UpgradeStatus.Upgrading, this.m_devID, ""); return; case 3: upgrading(UpgradeStatus.NoNeedToUpgrade, this.m_devID, ""); return; case 4: upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, ""); return; case 5: upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, ""); return; } string text = string.Empty; DefaultSnmpExecutor defaultSnmpExecutor = null; try { DeviceInfo deviceByID = DeviceOperation.getDeviceByID(this.m_devID); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); SnmpConfig snmpConfig = DevAccessCfg.GetInstance().getSnmpConfig(sNMPpara); defaultSnmpExecutor = new DefaultSnmpExecutor(new SnmpConfiger(snmpConfig, 1)); } catch (System.Exception) { } int num = 0; while (num++ < 20) { try { PropertiesMessage properties_ATEN = defaultSnmpExecutor.GetProperties_ATEN(); text = properties_ATEN.FirwWareVersion; break; } catch (System.Exception) { System.Threading.Thread.Sleep(1000); } } if (text.Equals(string.Empty)) { upgrading(UpgradeStatus.UpgradeFailed, this.m_devID, ""); return; } upgrading(UpgradeStatus.UpgradeSucceed, this.m_devID, text); }
private bool devConfigCheck() { string value = this.labDevModel.Tag.ToString(); string fmwareVer = this.labDevIp.Tag.ToString(); System.Convert.ToInt32(value); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(this.labDevModel.Text, fmwareVer); bool flag = false; if (this.tbRefVoltage.Visible) { Ecovalidate.checkTextIsNull(this.tbRefVoltage, ref flag); if (flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.lbRefVoltage.Text })); return(false); } if (!Ecovalidate.RangeDouble(this.tbRefVoltage, 90.0, 260.0)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[] { this.lbRefVoltage.Text, "90", "260" })); return(false); } } flag = true; int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "dev"); Ecovalidate.checkThresholdValue(this.tbMinCurrent, this.labMaxCurrentBound, (num & 256) == 0, ref flag); Ecovalidate.checkThresholdValue(this.tbMaxCurrent, this.labMaxCurrentBound, (num & 512) == 0, ref flag); Ecovalidate.checkThresholdValue(this.tbMinVoltage, this.labMaxVoltageBound, (num & 1024) == 0, ref flag); Ecovalidate.checkThresholdValue(this.tbMaxVoltage, this.labMaxVoltageBound, (num & 2048) == 0, ref flag); Ecovalidate.checkThresholdValue(this.tbMinPower, this.labMaxPowerBound, (num & 4096) == 0, ref flag); Ecovalidate.checkThresholdValue(this.tbMaxPower, this.labMaxPowerBound, (num & 8192) == 0, ref flag); Ecovalidate.checkThresholdValue(this.tbMinPowerDiss, this.labMaxPowerDisBound, (num & 16384) == 0, ref flag); Ecovalidate.checkThresholdValue(this.tbMaxPowerDiss, this.labMaxPowerDisBound, (num & 32768) == 0, ref flag); if (!flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_Thresholdinvalid, new string[0])); return(false); } Ecovalidate.checkThresholdMaxMixValue(this.tbMaxCurrent, this.tbMinCurrent, ref flag); Ecovalidate.checkThresholdMaxMixValue(this.tbMaxVoltage, this.tbMinVoltage, ref flag); Ecovalidate.checkThresholdMaxMixValue(this.tbMaxPower, this.tbMinPower, ref flag); Ecovalidate.checkThresholdMaxMixValue(this.tbMaxPowerDiss, this.tbMinPowerDiss, ref flag); if (!flag) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdMinMax, new string[0])); return(false); } return(true); }
public ScanDevDlg() { this.InitializeComponent(); this.tbIp1.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbIp2.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbIp3.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbIp.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbSysUserNm.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbSysPort.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbSysTimeOut.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbSysRetry.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.cbSnmpV.Items.Clear(); this.cbSnmpV.Items.Add(this.m_snmpV1Comb); this.cbSnmpV.Items.Add(this.m_snmpV2Comb); this.cbSnmpV.Items.Add(this.m_snmpV3Comb); this.cbSysAuthen.Items.Clear(); this.cbSysAuthen.Items.Add("MD5"); this.cbSysAuthen.Items.Add("SHA"); this.cbSysAuthen.Items.Add("None"); this.cbSysPrivacy.Items.Clear(); this.cbSysPrivacy.Items.Add("AES"); this.cbSysPrivacy.Items.Add("DES"); this.cbSysPrivacy.Items.Add("None"); this.cbScanCompany.Items.Clear(); this.cbScanCompany.Items.Add(this.m_ScanComanyCombo_aten); int num = DevAccessCfg.GetInstance().supportOEMdev(); if (num == 0) { this.lbScanCompany.Visible = false; this.cbScanCompany.Visible = false; } if ((num & 1) != 0) { this.cbScanCompany.Items.Add(this.m_ScanComanyCombo_eaton); Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ATEN\\ecoSensors"); if (registryKey == null) { registryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\ATEN\\ecoSensors"); } if (registryKey != null) { try { string text = registryKey.GetValue("SerialNo").ToString(); if (text.Contains("HONDA-")) { this.cbScanCompany.Items.Add(this.m_ScanComanyCombo_APC); } } catch (System.Exception) { } } } this.cbScanCompany.SelectedItem = this.m_ScanComanyCombo_aten; }
private void setBankConfigData(DeviceInfo pCurDev, int bankID) { string text = this.labDevModel.Text; string value = bankID.ToString(); BankInfo bankInfoByID = DeviceOperation.GetBankInfoByID(bankID); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, pCurDev.FWVersion); int selNo = System.Convert.ToInt32(bankInfoByID.PortLists); this.labBankNo.Text = selNo.ToString(); System.Collections.Generic.List <BankInfo> bankInfo = pCurDev.GetBankInfo(); for (int i = 1; i <= bankInfo.Count; i++) { Control[] array = this.gbBankConfig.Controls.Find("butBank" + i, false); if (array.Length > 0) { string text2 = ((Button)array[0]).Tag.ToString(); if (!text2.Equals(value)) { ((Button)array[0]).BackColor = Color.PaleTurquoise; } else { ((Button)array[0]).BackColor = Color.DarkCyan; } } } this.tbBankNm.Text = bankInfoByID.BankName; int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "bank"); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU) { this.labMaxPortCurrentBound.Text = ((!this.tbOMinCurrent.ReadOnly || !this.tbOMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "bank", selNo, "F0") : ""); ThresholdUtil.SetUIEdit(this.tbOMinCurrent, (num & 1) == 0, bankInfoByID.Min_current, 0, "F0"); ThresholdUtil.SetUIEdit(this.tbOMaxCurrent, (num & 2) == 0, bankInfoByID.Max_current, 0, "F0"); } else { this.labMaxPortCurrentBound.Text = ((!this.tbOMinCurrent.ReadOnly || !this.tbOMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "bank", selNo, "F1") : ""); ThresholdUtil.SetUIEdit(this.tbOMinCurrent, (num & 1) == 0, bankInfoByID.Min_current, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbOMaxCurrent, (num & 2) == 0, bankInfoByID.Max_current, 0, "F1"); } ThresholdUtil.SetUIEdit(this.tbOMinVoltage, (num & 4) == 0, bankInfoByID.Min_voltage, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbOMaxVoltage, (num & 8) == 0, bankInfoByID.Max_voltage, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbOMinPower, (num & 16) == 0, bankInfoByID.Min_power, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbOMaxPower, (num & 32) == 0, bankInfoByID.Max_power, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbOMinPowerDiss, (num & 64) == 0, bankInfoByID.Min_power_diss, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbOMaxPowerDiss, (num & 128) == 0, bankInfoByID.Max_power_diss, 0, "F1"); this.labMaxVoltageBound.Text = ((!this.tbOMinVoltage.ReadOnly || !this.tbOMaxVoltage.ReadOnly) ? devcfgUtil.RangeVoltage(deviceModelConfig, "bank", selNo) : ""); this.labMaxPowerBound.Text = ((!this.tbOMinPower.ReadOnly || !this.tbOMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "bank", selNo, 1.0) : ""); this.labMaxPowerDisBound.Text = ((!this.tbOMinPowerDiss.ReadOnly || !this.tbOMaxPowerDiss.ReadOnly) ? devcfgUtil.RangePowerDiss(deviceModelConfig, "bank", selNo) : ""); this.tbBankNm.BackColor = Color.White; }
public void pageInit(DevManDevice pParent, int devID, string devName, bool onlinest) { this.m_ininit = true; this.m_cleartab = true; this.tcDev.Controls.Clear(); this.m_cleartab = false; DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID); if (deviceByID == null) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.DevInfo_nofind, new string[] { devName })); return; } this.m_onlinest = onlinest; this.m_curdevID = devID.ToString(); this.tcDev.Controls.Add(this.tbDevice); this.propDev1.pageInit(pParent, devID, onlinest); if (deviceByID.GetPortInfo().Count > 0) { this.tcDev.Controls.Add(this.tbOutlet); this.propOutlet1.pageInit(devID, 0, onlinest); } if (deviceByID.GetBankInfo().Count > 0) { this.tcDev.Controls.Add(this.tbBank); this.propBank1.pageInit(devID, 0, onlinest); } if (deviceByID.GetLineInfo().Count > 0) { this.tcDev.Controls.Add(this.tbLine); this.propLine1.pageInit(devID, 0, onlinest); } if (deviceByID.GetSensorInfo().Count > 0) { this.tcDev.Controls.Add(this.tbSensor); this.propSensor1.pageInit(devID, onlinest); } if (DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion).popReading == 2) { this.tcDev.Controls.Add(this.tbPop); this.propPOP1.pageInit(devID, onlinest); } if (this.m_selectedTab == null || !this.tcDev.Contains(this.m_selectedTab)) { this.m_selectedTab = this.tbDevice; } this.tcDev.SelectTab(this.m_selectedTab); this.m_ininit = false; }
private void butBank_Click(object sender, System.EventArgs e) { string text = this.labDevModel.Text; string value = this.labDevModel.Tag.ToString(); int l_id = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(l_id); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion); this.bankConfigPageControlInit(deviceModelConfig); string value2 = ((Button)sender).Tag.ToString(); ((Button)sender).BackColor = Color.DarkCyan; this.setBankConfigData(deviceByID, System.Convert.ToInt32(value2)); }
private bool devConfigCheck() { string value = this.labDevModel.Tag.ToString(); string fmwareVer = this.labDevIp.Tag.ToString(); System.Convert.ToInt32(value); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(this.labDevModel.Text, fmwareVer); bool flag = true; if (this.gbPop.Visible && this.cbPopEnable.Checked && this.rbPopUsrdef.Checked) { flag = false; Ecovalidate.checkTextIsNull(this.tbPopThreshold, ref flag); if (flag) { this.tbPopThreshold.Focus(); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Required, new string[] { this.rbPopUsrdef.Text })); return(false); } float num = 0f; try { num = System.Convert.ToSingle(this.tbPopThreshold.Text); } catch (System.Exception) { this.tbPopThreshold.Focus(); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Comm_invalidNumber, new string[0])); bool result = false; return(result); } if (num > (float)deviceModelConfig.popUdefmax) { this.tbPopThreshold.Focus(); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Range, new string[] { this.rbPopUsrdef.Text, "0", deviceModelConfig.popUdefmax.ToString() })); return(false); } return(true); } return(true); }
public Login() { this.InitializeComponent(); this.tbuserId.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.tbpassword.ContextMenuStrip = EcoGlobalVar.nullcontextMenuStrip; this.cbolanguage.Items.Clear(); this.rmtcbLang.Items.Clear(); for (int i = 0; i < EcoLanguage.strLang.Length; i++) { this.cbolanguage.Items.Add(EcoLanguage.strLang[i]); this.rmtcbLang.Items.Add(EcoLanguage.strLang[i]); } this.cbolanguage.SelectedIndex = 0; this.rmtcbLang.SelectedIndex = 0; string text = DevAccessCfg.GetInstance().getVersion(); if (text.Length > 0) { text = " (" + text + ")"; } else { System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; text = string.Concat(new string[] { " (V", version.Major.ToString(), ".", version.Minor.ToString(), ".", version.Build.ToString("000"), ".", version.Revision.ToString("000"), ")" }); } this.Text += text; if (EcoGlobalVar.ECOAppRunMode == 1) { this.panelRemote.Visible = false; ValuePairs.setValuePair("MasterIP", "127.0.0.1"); return; } this.panelLocal.Visible = false; this.lbSetting.Visible = false; this.rmttbSrvIP.Text = ValuePairs.getValuePair("MasterIP"); this.rmttbSrvPort.Text = ValuePairs.getValuePair("ServicePort"); }
private void threshold_KeyPress(object sender, KeyPressEventArgs e) { TextBox textBox = (TextBox)sender; bool flag = Ecovalidate.inputCheck_float(textBox, e.KeyChar, 1); if (flag) { char keyChar = e.KeyChar; if ((keyChar == '.' || keyChar == ',') && (textBox.Name.Equals(this.tbOMinCurrent.Name) || textBox.Name.Equals(this.tbOMaxCurrent.Name))) { string text = this.labDevModel.Text; string fmwareVer = this.labDevIp.Tag.ToString(); if (DevAccessCfg.GetInstance().getDeviceModelConfig(text, fmwareVer).commonThresholdFlag == Constant.APC_PDU) { e.Handled = true; } } return; } e.Handled = true; }
private void setLineConfigData(DeviceInfo pCurDev, int lineID) { string text = this.labDevModel.Text; string value = lineID.ToString(); LineInfo lineInfoByID = DeviceOperation.GetLineInfoByID(lineID); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, pCurDev.FWVersion); int selNo = System.Convert.ToInt32(lineInfoByID.LineNumber); this.labLineNo.Text = selNo.ToString(); System.Collections.Generic.List <LineInfo> lineInfo = pCurDev.GetLineInfo(); for (int i = 1; i <= lineInfo.Count; i++) { Control[] array = this.gbLineConfig.Controls.Find("butLine" + i, false); if (array.Length > 0) { string text2 = ((Button)array[0]).Tag.ToString(); if (!text2.Equals(value)) { ((Button)array[0]).BackColor = Color.PaleTurquoise; } else { ((Button)array[0]).BackColor = Color.DarkCyan; } } } int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "line"); this.labMaxCurrentBound.Text = ((!this.tbLMinCurrent.ReadOnly || !this.tbLMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "line", selNo, "F1") : ""); ThresholdUtil.SetUIEdit(this.tbLMinCurrent, (num & 1) == 0, lineInfoByID.Min_current, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbLMaxCurrent, (num & 2) == 0, lineInfoByID.Max_current, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbLMinVoltage, (num & 4) == 0, lineInfoByID.Min_voltage, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbLMaxVoltage, (num & 8) == 0, lineInfoByID.Max_voltage, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbLMinPower, (num & 16) == 0, lineInfoByID.Min_power, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbLMaxPower, (num & 32) == 0, lineInfoByID.Max_power, 0, "F1"); this.labMaxVoltageBound.Text = ((!this.tbLMinVoltage.ReadOnly || !this.tbLMaxVoltage.ReadOnly) ? devcfgUtil.RangeVoltage(deviceModelConfig, "line", selNo) : ""); this.labMaxPowerBound.Text = ((!this.tbLMinPower.ReadOnly || !this.tbLMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "line", selNo, 1.0) : ""); this.labMaxPowerDisBound.Text = ((!this.tbLMinPowerDiss.ReadOnly || !this.tbLMaxPowerDiss.ReadOnly) ? devcfgUtil.RangePowerDiss(deviceModelConfig, "line", selNo) : ""); }
public System.Collections.Generic.Dictionary <string, bool> SetDeviceThresholds(System.Collections.Generic.List <DevSnmpConfig> configs, DeviceThreshold deviceThreshold) { DevAccessCfg instance = DevAccessCfg.GetInstance(); System.Collections.Generic.List <SnmpConfiger> list = new System.Collections.Generic.List <SnmpConfiger>(); foreach (DevSnmpConfig current in configs) { DevModelConfig deviceModelConfig = instance.getDeviceModelConfig(current.modelName, current.fmwareVer); SnmpConfiger item = new SnmpConfiger(instance.getSnmpConfig(current), deviceModelConfig, current.devMac, current.devID); list.Add(item); } System.Collections.Generic.List <string> list2 = new AppSnmpExecutors(list).SetDevThresholds(deviceThreshold); System.Collections.Generic.Dictionary <string, bool> dictionary = new System.Collections.Generic.Dictionary <string, bool>(); foreach (string current2 in list2) { string[] array = current2.Split(new char[] { ':' }); dictionary.Add(array[0], System.Convert.ToBoolean(array[1])); } return(dictionary); }
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 (deviceByID.ModelNm.Equals("EC1000")) { this.lbRefVoltage.Visible = true; this.tbRefVoltage.Visible = true; this.lbRefVoltageUnit.Visible = true; if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion)) { this.tbRefVoltage.Enabled = true; if (deviceByID.ReferenceVoltage == -500f || deviceByID.ReferenceVoltage == -300f) { this.tbRefVoltage.Text = ""; } else { this.tbRefVoltage.Text = System.Convert.ToString(deviceByID.ReferenceVoltage); } } else { this.tbRefVoltage.Enabled = false; this.tbRefVoltage.Text = System.Convert.ToString(Sys_Para.GetEnergyValue()); } } else { this.lbRefVoltage.Visible = false; this.tbRefVoltage.Visible = false; this.lbRefVoltageUnit.Visible = false; } int num = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "dev"); ThresholdUtil.SetUIEdit(this.tbMinVoltage, (num & 4) == 0, deviceByID.Min_voltage, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbMaxVoltage, (num & 8) == 0, deviceByID.Max_voltage, 0, "F1"); this.labMaxVoltageBound.Text = ((!this.tbMinVoltage.ReadOnly || !this.tbMaxVoltage.ReadOnly) ? devcfgUtil.RangeVoltage(deviceModelConfig, "dev", 0) : ""); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU) { ThresholdUtil.SetUIEdit(this.tbMinCurrent, (num & 1) == 0, deviceByID.Min_current, 0, "F0"); ThresholdUtil.SetUIEdit(this.tbMaxCurrent, (num & 2) == 0, deviceByID.Max_current, 0, "F0"); this.labMaxCurrentBound.Text = ((!this.tbMinCurrent.ReadOnly || !this.tbMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "dev", 0, "F0") : ""); this.lbunitPower.Text = "kW"; ThresholdUtil.SetUIEdit(this.tbMinPower, (num & 16) == 0, deviceByID.Min_power / 1000f, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbMaxPower, (num & 32) == 0, deviceByID.Max_power / 1000f, 0, "F1"); this.labMaxPowerBound.Text = ((!this.tbMinPower.ReadOnly || !this.tbMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "dev", 0, 1000.0) : ""); } else { ThresholdUtil.SetUIEdit(this.tbMinCurrent, (num & 1) == 0, deviceByID.Min_current, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbMaxCurrent, (num & 2) == 0, deviceByID.Max_current, 0, "F1"); this.labMaxCurrentBound.Text = ((!this.tbMinCurrent.ReadOnly || !this.tbMaxCurrent.ReadOnly) ? devcfgUtil.RangeCurrent(deviceModelConfig, "dev", 0, "F1") : ""); this.lbunitPower.Text = "W"; ThresholdUtil.SetUIEdit(this.tbMinPower, (num & 16) == 0, deviceByID.Min_power, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbMaxPower, (num & 32) == 0, deviceByID.Max_power, 0, "F1"); this.labMaxPowerBound.Text = ((!this.tbMinPower.ReadOnly || !this.tbMaxPower.ReadOnly) ? devcfgUtil.RangePower(deviceModelConfig, "dev", 0, 1.0) : ""); } ThresholdUtil.SetUIEdit(this.tbMinPowerDiss, (num & 64) == 0, deviceByID.Min_power_diss, 0, "F1"); ThresholdUtil.SetUIEdit(this.tbMaxPowerDiss, (num & 128) == 0, deviceByID.Max_power_diss, 0, "F1"); this.labMaxPowerDisBound.Text = ((!this.tbMinPowerDiss.ReadOnly || !this.tbMaxPowerDiss.ReadOnly) ? devcfgUtil.RangePowerDiss(deviceModelConfig, "dev", 0) : ""); if (deviceModelConfig.doorReading != 2) { this.gbDoorSS.Hide(); return; } this.gbDoorSS.Show(); switch (deviceByID.DoorSensor) { case 0: this.rbNoInstall_0.Checked = true; return; case 1: this.rbPhoto_1.Checked = true; return; case 2: this.rbInductive_2.Checked = true; return; case 3: this.rbReed_3.Checked = true; return; default: return; } }
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 FillData() { string[] array = this.m_devidsinRack.Split(new char[] { ',' }); System.Collections.Generic.Dictionary <int, ClientAPI.DeviceWithZoneRackInfo> devicRackZoneRelation = ClientAPI.GetDevicRackZoneRelation(); this.treeView1.Nodes.Clear(); string text = ""; TreeNode treeNode = new TreeNode(); treeNode.Name = "Root"; treeNode.ImageIndex = 1; this.treeView1.Nodes.Add(treeNode); this.treeView1.Indent = 15; DataSet dataSet = new DataSet(); try { dataSet = this.allData; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i]; int num = System.Convert.ToInt32(text2); if (devicRackZoneRelation.ContainsKey(num)) { ClientAPI.DeviceWithZoneRackInfo deviceWithZoneRackInfo = devicRackZoneRelation[num]; DataTable dataTable = dataSet.Tables[0].Clone(); DataRow[] array3 = dataSet.Tables[0].Select("device_id=" + text2); for (int j = 0; j < array3.Length; j++) { dataTable.ImportRow(array3[j]); } if (dataTable.Rows.Count > 0 && this.m_UACDevPort.ContainsKey((long)num)) { TreeNode treeNode2 = new TreeNode(); treeNode2.Name = "Device"; if (System.Convert.ToString(dataTable.Rows[0]["device_nm"]) != System.Convert.ToString(-1000)) { if (System.Convert.ToString(dataTable.Rows[0]["device_nm"]) != "") { treeNode2.Text = System.Convert.ToString(dataTable.Rows[0]["device_nm"]); } else { treeNode2.Text = System.Convert.ToString(dataTable.Rows[0]["device_ip"]); } } else { treeNode2.Text = ""; } text = deviceWithZoneRackInfo.rack_nm; if (System.Convert.ToString(dataTable.Rows[0]["device_state"]) != "1") { treeNode2.ImageIndex = 6; treeNode2.SelectedImageIndex = 6; treeNode.Nodes.Add(treeNode2); } else { treeNode2.ImageIndex = 7; treeNode2.SelectedImageIndex = 7; string device_model = deviceWithZoneRackInfo.device_model; string fw_version = deviceWithZoneRackInfo.fw_version; DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(device_model, fw_version); bool flag = true; if (this.m_UACDevPort.ContainsKey((long)num) && (this.m_UACDevPort[(long)num] == null || this.m_UACDevPort[(long)num].Count == 0)) { double maxV = ecoConvert.f2d(dataTable.Rows[0]["max_power"]); double minV = ecoConvert.f2d(dataTable.Rows[0]["min_power"]); double maxV2 = ecoConvert.f2d(dataTable.Rows[0]["max_current"]); double minV2 = ecoConvert.f2d(dataTable.Rows[0]["min_current"]); double maxV3 = ecoConvert.f2d(dataTable.Rows[0]["max_voltage"]); double minV3 = ecoConvert.f2d(dataTable.Rows[0]["min_voltage"]); double maxV4 = ecoConvert.f2d(dataTable.Rows[0]["max_power_diss"]); double minV4 = ecoConvert.f2d(dataTable.Rows[0]["min_power_diss"]); int uIthEdidflg = devcfgUtil.UIThresholdEditFlg(deviceModelConfig, "dev"); TreeNode treeNode3 = this.genTreeNode(uIthEdidflg, 4, EcoLanguage.getMsg(LangRes.Title_PowerDiss, new string[0]), ecoConvert.f2d(dataTable.Rows[0]["power_consumption"]), minV4, maxV4, "F4", "kWh", 13, 15, 14, 12, ref flag); if (treeNode3 != null) { treeNode2.Nodes.Add(treeNode3); } TreeNode treeNode4 = this.genTreeNode(uIthEdidflg, 3, EcoLanguage.getMsg(LangRes.Title_Power, new string[0]), ecoConvert.f2d(dataTable.Rows[0]["power_value"]), minV, maxV, "F4", "W", 13, 15, 14, 12, ref flag); if (treeNode4 != null) { treeNode2.Nodes.Add(treeNode4); } TreeNode treeNode5 = this.genTreeNode(uIthEdidflg, 2, EcoLanguage.getMsg(LangRes.Title_Voltage, new string[0]), ecoConvert.f2d(dataTable.Rows[0]["voltage_value"]), minV3, maxV3, "F2", "V", 25, 27, 26, 24, ref flag); if (treeNode5 != null) { treeNode2.Nodes.Add(treeNode5); } TreeNode treeNode6 = this.genTreeNode(uIthEdidflg, 1, EcoLanguage.getMsg(LangRes.Title_Current, new string[0]), ecoConvert.f2d(dataTable.Rows[0]["current_value"]), minV2, maxV2, "F2", "A", 3, 5, 4, 2, ref flag); if (treeNode6 != null) { treeNode2.Nodes.Add(treeNode6); } if (deviceModelConfig.leakCurrent == Constant.YES) { int num2 = (int)dataTable.Rows[0]["leakcurrent_status"]; if (num2 == Constant.YES) { TreeNode treeNode7 = new TreeNode(); treeNode7.Name = "Neutral leakage current"; treeNode7.ToolTipText = treeNode7.Name; treeNode7.ImageIndex = 35; treeNode7.SelectedImageIndex = 35; treeNode7.Text = "Neutral leakage current"; treeNode2.Nodes.Add(treeNode7); flag = false; } } } if (!flag) { treeNode2.Expand(); } if (this.m_UACDevPort.ContainsKey((long)num)) { this.FillData_Outlet(treeNode2, dataSet, text2, deviceModelConfig); } if (this.m_UACDevPort.ContainsKey((long)num) && (this.m_UACDevPort[(long)num] == null || this.m_UACDevPort[(long)num].Count == 0)) { this.FillData_Bank(treeNode2, dataSet, text2, deviceModelConfig); } if (this.m_UACDevPort.ContainsKey((long)num) && (this.m_UACDevPort[(long)num] == null || this.m_UACDevPort[(long)num].Count == 0)) { this.FillData_Line(treeNode2, dataSet, text2, deviceModelConfig); } treeNode.Nodes.Add(treeNode2); } } } } } catch (System.Exception ex) { System.Console.WriteLine(ex.Message); } treeNode.Text = text; treeNode.Expand(); }
private bool UpdateAllThresholds(System.Collections.Generic.List <ThresholdMessage> thresholdMessageList) { bool result = false; DBConn dBConn = null; System.Collections.Hashtable deviceCache = DBCache.GetDeviceCache(); System.Collections.Hashtable portCache = DBCache.GetPortCache(); System.Collections.Hashtable bankCache = DBCache.GetBankCache(); System.Collections.Hashtable sensorCache = DBCache.GetSensorCache(); System.Collections.Hashtable deviceBankMap = DBCache.GetDeviceBankMap(); System.Collections.Hashtable devicePortMap = DBCache.GetDevicePortMap(); System.Collections.Hashtable deviceSensorMap = DBCache.GetDeviceSensorMap(); if (dBConn == null) { dBConn = DBConnPool.getConnection(); } foreach (ThresholdMessage current in thresholdMessageList) { if (current != null && current.DeviceReplyMac.Equals(current.DeviceMac)) { if (!string.IsNullOrEmpty(current.AutoBasicInfo) && !string.IsNullOrEmpty(current.AutoRatingInfo)) { try { DevAccessCfg.GetInstance().updateAutoModelList2Database(dBConn, current.ModelName, current.DeviceFWVer, current.AutoBasicInfo, current.AutoRatingInfo); } catch (System.Exception) { } } if (deviceCache != null && deviceCache.Count >= 1 && deviceCache.ContainsKey(current.DeviceID)) { DeviceInfo deviceInfo = (DeviceInfo)deviceCache[current.DeviceID]; if (deviceInfo != null) { deviceInfo.FWVersion = current.DeviceFWVer; deviceInfo.DeviceName = current.DeviceName; if (current.DeviceThreshold.MaxCurrentMT != -500f) { deviceInfo.Max_current = current.DeviceThreshold.MaxCurrentMT; } if (current.DeviceThreshold.MaxPowerMT != -500f) { deviceInfo.Max_power = current.DeviceThreshold.MaxPowerMT; } if (current.DeviceThreshold.MaxPowerDissMT != -500f) { deviceInfo.Max_power_diss = current.DeviceThreshold.MaxPowerDissMT; } if (current.DeviceThreshold.MaxVoltageMT != -500f) { deviceInfo.Max_voltage = current.DeviceThreshold.MaxVoltageMT; } if (current.DeviceThreshold.MinCurrentMT != -500f) { deviceInfo.Min_current = current.DeviceThreshold.MinCurrentMT; } if (current.DeviceThreshold.MinPowerMT != -500f) { deviceInfo.Min_power = current.DeviceThreshold.MinPowerMT; } if (current.DeviceThreshold.MinVoltageMT != -500f) { deviceInfo.Min_voltage = current.DeviceThreshold.MinVoltageMT; } deviceInfo.POPThreshold = current.DeviceThreshold.PopThreshold; deviceInfo.POPEnableMode = current.DeviceThreshold.PopEnableMode; deviceInfo.OutletPOPMode = current.DeviceThreshold.PopModeOutlet; deviceInfo.BankPOPLIFOMode = current.DeviceThreshold.PopModeLIFO; deviceInfo.BankPOPPriorityMode = current.DeviceThreshold.PopModePriority; if (current.DeviceThreshold.DoorSensorType != -500) { deviceInfo.DoorSensor = current.DeviceThreshold.DoorSensorType; } deviceInfo.UpdateDeviceThreshold(dBConn); if (current.SensorThreshold != null && current.SensorThreshold.Count > 0) { if (sensorCache == null || sensorCache.Count < 1 || deviceSensorMap == null || deviceSensorMap.Count < 1 || !deviceSensorMap.ContainsKey(current.DeviceID)) { continue; } System.Collections.Generic.IEnumerator <int> enumerator2 = current.SensorThreshold.Keys.GetEnumerator(); while (enumerator2.MoveNext()) { SensorThreshold sensorThreshold = current.SensorThreshold[enumerator2.Current]; SensorInfo sensor = this.getSensor(sensorCache, (System.Collections.Generic.List <int>)deviceSensorMap[current.DeviceID], enumerator2.Current); if (sensor != null) { if (sensorThreshold.MaxHumidityMT != -500f) { sensor.Max_humidity = sensorThreshold.MaxHumidityMT; } if (sensorThreshold.MaxPressMT != -500f) { sensor.Max_press = sensorThreshold.MaxPressMT; } if (sensorThreshold.MaxTemperatureMT != -500f) { sensor.Max_temperature = sensorThreshold.MaxTemperatureMT; } if (sensorThreshold.MinHumidityMT != -500f) { sensor.Min_humidity = sensorThreshold.MinHumidityMT; } if (sensorThreshold.MinPressMT != -500f) { sensor.Min_press = sensorThreshold.MinPressMT; } if (sensorThreshold.MinTemperatureMT != -500f) { sensor.Min_temperature = sensorThreshold.MinTemperatureMT; } sensor.UpdateSensorThreshold(dBConn); } } } if (current.OutletThreshold != null && current.OutletThreshold.Count > 0) { if (portCache == null || portCache.Count < 1 || devicePortMap == null || devicePortMap.Count < 1 || !devicePortMap.ContainsKey(current.DeviceID)) { continue; } System.Collections.Generic.IEnumerator <int> enumerator3 = current.OutletThreshold.Keys.GetEnumerator(); while (enumerator3.MoveNext()) { OutletThreshold outletThreshold = current.OutletThreshold[enumerator3.Current]; PortInfo port = this.getPort(portCache, (System.Collections.Generic.List <int>)devicePortMap[current.DeviceID], enumerator3.Current); if (port != null) { port.PortName = outletThreshold.OutletName; if (outletThreshold.MaxCurrentMT != -500f) { port.Max_current = outletThreshold.MaxCurrentMT; } if (outletThreshold.MaxPowerMT != -500f) { port.Max_power = outletThreshold.MaxPowerMT; } if (outletThreshold.MaxPowerDissMT != -500f) { port.Max_power_diss = outletThreshold.MaxPowerDissMT; } if (outletThreshold.MaxVoltageMT != -500f) { port.Max_voltage = outletThreshold.MaxVoltageMT; } if (outletThreshold.MinCurrentMt != -500f) { port.Min_current = outletThreshold.MinCurrentMt; } if (outletThreshold.MinPowerMT != -500f) { port.Min_power = outletThreshold.MinPowerMT; } if (outletThreshold.MinVoltageMT != -500f) { port.Min_voltage = outletThreshold.MinVoltageMT; } port.OutletConfirmation = (int)outletThreshold.Confirmation; port.OutletOffDelayTime = outletThreshold.OffDelayTime; port.OutletOnDelayTime = outletThreshold.OnDelayTime; port.OutletShutdownMethod = (int)outletThreshold.ShutdownMethod; port.OutletMAC = outletThreshold.MacAddress; port.UpdatePortThreshold(dBConn); } } } if (current.BankThreshold != null && current.BankThreshold.Count > 0 && bankCache != null && bankCache.Count >= 1 && deviceBankMap != null && deviceBankMap.Count >= 1 && deviceBankMap.ContainsKey(current.DeviceID)) { System.Collections.Generic.IEnumerator <int> enumerator4 = current.BankThreshold.Keys.GetEnumerator(); while (enumerator4.MoveNext()) { BankThreshold bankThreshold = current.BankThreshold[enumerator4.Current]; BankInfo bank = this.getBank(bankCache, (System.Collections.Generic.List <int>)deviceBankMap[current.DeviceID], enumerator4.Current); if (bank != null) { bank.BankName = bankThreshold.BankName; if (bankThreshold.MaxCurrentMT != -500f) { bank.Max_current = bankThreshold.MaxCurrentMT; } if (bankThreshold.MinCurrentMt != -500f) { bank.Min_current = bankThreshold.MinCurrentMt; } if (bankThreshold.MaxVoltageMT != -500f) { bank.Max_voltage = bankThreshold.MaxVoltageMT; } if (bankThreshold.MinVoltageMT != -500f) { bank.Min_voltage = bankThreshold.MinVoltageMT; } if (bankThreshold.MaxPowerMT != -500f) { bank.Max_power = bankThreshold.MaxPowerMT; } if (bankThreshold.MinPowerMT != -500f) { bank.Min_power = bankThreshold.MinPowerMT; } if (bankThreshold.MaxPowerDissMT != -500f) { bank.Max_power_diss = bankThreshold.MaxPowerDissMT; } bank.UpdateBankThreshold(dBConn); } } } } } } } if (dBConn != null) { dBConn.close(); } return(result); }
public void pageInit(int devID, int bankID, bool onlinest) { this.butBankAssign.Enabled = onlinest; this.butBankSave.Enabled = onlinest; DeviceInfo deviceByID = DeviceOperation.getDeviceByID(devID); this.labDevIp.Text = deviceByID.DeviceIP; this.labDevIp.Tag = deviceByID.FWVersion; this.labDevModel.Text = deviceByID.ModelNm; this.labDevModel.Tag = devID.ToString(); this.labDevNm.Text = deviceByID.DeviceName; string text = deviceByID.ModelNm; if (DevAccessCfg.GetInstance().isAutodectDev(deviceByID.ModelNm, deviceByID.FWVersion)) { text = text + " (F/W: " + deviceByID.FWVersion + ")"; } this.toolTip1.SetToolTip(this.labDevModel, text); RackInfo rackByID = RackInfo.getRackByID(deviceByID.RackID); this.labDevRackNm.Text = rackByID.GetDisplayRackName(EcoGlobalVar.RackFullNameFlag); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion); this.butBank1.Visible = false; this.butBank2.Visible = false; this.butBank3.Visible = false; this.butBank4.Visible = false; this.butBank5.Visible = false; this.butBank6.Visible = false; this.butBank7.Visible = false; this.butBank8.Visible = false; System.Collections.Generic.List <BankInfo> bankInfo = deviceByID.GetBankInfo(); foreach (BankInfo current in bankInfo) { string portLists = current.PortLists; switch (System.Convert.ToInt32(portLists)) { case 1: this.butBank1.Visible = true; this.butBank1.Tag = current.ID.ToString(); break; case 2: this.butBank2.Visible = true; this.butBank2.Tag = current.ID.ToString(); break; case 3: this.butBank3.Visible = true; this.butBank3.Tag = current.ID.ToString(); break; case 4: this.butBank4.Visible = true; this.butBank4.Tag = current.ID.ToString(); break; case 5: this.butBank5.Visible = true; this.butBank5.Tag = current.ID.ToString(); break; case 6: this.butBank6.Visible = true; this.butBank6.Tag = current.ID.ToString(); break; case 7: this.butBank7.Visible = true; this.butBank7.Tag = current.ID.ToString(); break; case 8: this.butBank8.Visible = true; this.butBank8.Tag = current.ID.ToString(); break; } } this.bankConfigPageControlInit(deviceModelConfig); if (bankID == 0) { this.setBankConfigData(deviceByID, System.Convert.ToInt32(this.butBank1.Tag)); return; } this.setBankConfigData(deviceByID, bankID); }
private System.Collections.ArrayList getAnalysisGroup(EGenRptPara m_pParaWindow) { System.Collections.ArrayList arrayList = new System.Collections.ArrayList(); foreach (ListViewItem listViewItem in m_pParaWindow.Grouplist) { string text = System.Convert.ToString(listViewItem.Tag).Split(new char[] { '|' })[0]; string text2 = System.Convert.ToString(listViewItem.Tag).Split(new char[] { '|' })[1]; if (text2.Length == 0) { text2 = "0"; } string text3 = System.Convert.ToString(listViewItem.Tag).Split(new char[] { '|' })[2]; string text4 = System.Convert.ToString(listViewItem.Tag).Split(new char[] { '|' })[3]; string text5 = listViewItem.SubItems[1].Text; string text6 = "0,"; string text7 = "0,"; string text8 = "0,"; string text9 = "0,"; string text10 = "0,"; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); System.Text.StringBuilder stringBuilder2 = new System.Text.StringBuilder(); System.Text.StringBuilder stringBuilder3 = new System.Text.StringBuilder(); string key; switch (key = text3) { case "zone": { string str_sql = "select racks from zone_info where id in (" + text2 + ") and racks <>''"; DataTable dataTable = DBTools.CreateDataTable4SysDB(str_sql); text9 = "0,"; for (int i = 0; i < dataTable.Rows.Count; i++) { string str_sql2 = "select id,model_nm,fw_version from device_base_info where rack_id in (" + System.Convert.ToString(dataTable.Rows[i]["racks"]) + ") "; DataTable dataTable2 = DBTools.CreateDataTable4SysDB(str_sql2); string text11 = ""; text10 = "0,"; stringBuilder2 = new System.Text.StringBuilder(); stringBuilder3 = new System.Text.StringBuilder(); stringBuilder = new System.Text.StringBuilder(); for (int j = 0; j < dataTable2.Rows.Count; j++) { System.Convert.ToString(dataTable2.Rows[j]["id"]); string modelname = System.Convert.ToString(dataTable2.Rows[j]["model_nm"]); string fmwareVer = System.Convert.ToString(dataTable2.Rows[j]["fw_version"]); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(modelname, fmwareVer); if (!deviceModelConfig.devcapacity.Equals("N/A")) { if (deviceModelConfig.perportreading == 2) { stringBuilder2.Append(System.Convert.ToString(dataTable2.Rows[j]["id"]) + ","); } else { stringBuilder3.Append(System.Convert.ToString(dataTable2.Rows[j]["id"]) + ","); } stringBuilder.Append(System.Convert.ToString(dataTable2.Rows[j]["id"]) + ","); } } text11 += stringBuilder.ToString(); text10 += stringBuilder2.ToString(); text8 += stringBuilder3.ToString(); if (text11.Length > 0) { text11 = text11.Substring(0, text11.Length - 1); } if (text10.Length > 0) { text10 = text10.Substring(0, text10.Length - 1); } string str_sql3 = "select id from port_info where device_id in (" + text10 + ")"; DataTable dataTable3 = DBTools.CreateDataTable4SysDB(str_sql3); stringBuilder = new System.Text.StringBuilder(); for (int k = 0; k < dataTable3.Rows.Count; k++) { stringBuilder.Append(System.Convert.ToString(dataTable3.Rows[k]["id"]) + ","); } text7 += stringBuilder.ToString(); text9 = text9 + text11 + ","; } text9 = commUtil.uniqueIDs(text9); if (text9.Length > 0) { text6 = text9.Substring(0, text9.Length - 1); } text8 = commUtil.uniqueIDs(text8); if (text8.Length > 0) { text8 = text8.Substring(0, text8.Length - 1); } text7 = commUtil.uniqueIDs(text7); if (text7.Length > 0) { text7 = text7.Substring(0, text7.Length - 1); } break; } case "rack": case "allrack": { string str_sql2 = "select id,model_nm,fw_version from device_base_info where rack_id in (" + text2 + ")"; DataTable dataTable2 = DBTools.CreateDataTable4SysDB(str_sql2); stringBuilder2 = new System.Text.StringBuilder(); stringBuilder3 = new System.Text.StringBuilder(); stringBuilder = new System.Text.StringBuilder(); for (int l = 0; l < dataTable2.Rows.Count; l++) { System.Convert.ToString(dataTable2.Rows[l]["id"]); string modelname2 = System.Convert.ToString(dataTable2.Rows[l]["model_nm"]); string fmwareVer2 = System.Convert.ToString(dataTable2.Rows[l]["fw_version"]); DevModelConfig deviceModelConfig2 = DevAccessCfg.GetInstance().getDeviceModelConfig(modelname2, fmwareVer2); if (!deviceModelConfig2.devcapacity.Equals("N/A")) { if (deviceModelConfig2.perportreading == 2) { stringBuilder2.Append(System.Convert.ToString(dataTable2.Rows[l]["id"]) + ","); } else { stringBuilder3.Append(System.Convert.ToString(dataTable2.Rows[l]["id"]) + ","); } stringBuilder.Append(System.Convert.ToString(dataTable2.Rows[l]["id"]) + ","); } } text9 += stringBuilder.ToString(); text10 += stringBuilder2.ToString(); text8 += stringBuilder3.ToString(); if (text9.Length > 0) { text6 = text9.Substring(0, text9.Length - 1); } if (text10.Length > 0) { text10 = text10.Substring(0, text10.Length - 1); } if (text8.Length > 0) { text8 = text8.Substring(0, text8.Length - 1); } string str_sql3 = "select id from port_info where device_id in (" + text10 + ")"; DataTable dataTable3 = DBTools.CreateDataTable4SysDB(str_sql3); stringBuilder = new System.Text.StringBuilder(); for (int m = 0; m < dataTable3.Rows.Count; m++) { stringBuilder.Append(System.Convert.ToString(dataTable3.Rows[m]["id"]) + ","); } text7 += stringBuilder.ToString(); if (text7.Length > 0) { text7 = text7.Substring(0, text7.Length - 1); } break; } case "dev": case "alldev": { string str_sql2 = "select id,model_nm,fw_version from device_base_info where id in (" + text2 + ")"; DataTable dataTable2 = DBTools.CreateDataTable4SysDB(str_sql2); text10 = "0,"; stringBuilder2 = new System.Text.StringBuilder(); stringBuilder3 = new System.Text.StringBuilder(); stringBuilder = new System.Text.StringBuilder(); for (int n = 0; n < dataTable2.Rows.Count; n++) { System.Convert.ToString(dataTable2.Rows[n]["id"]); string modelname3 = System.Convert.ToString(dataTable2.Rows[n]["model_nm"]); string fmwareVer3 = System.Convert.ToString(dataTable2.Rows[n]["fw_version"]); DevModelConfig deviceModelConfig3 = DevAccessCfg.GetInstance().getDeviceModelConfig(modelname3, fmwareVer3); if (!deviceModelConfig3.devcapacity.Equals("N/A")) { if (deviceModelConfig3.perportreading == 2) { stringBuilder2.Append(System.Convert.ToString(dataTable2.Rows[n]["id"]) + ","); } else { stringBuilder3.Append(System.Convert.ToString(dataTable2.Rows[n]["id"]) + ","); } stringBuilder.Append(System.Convert.ToString(dataTable2.Rows[n]["id"]) + ","); } } text10 += stringBuilder2.ToString(); text8 += stringBuilder3.ToString(); text6 += stringBuilder.ToString(); if (text6.Length > 0) { text6 = text6.Substring(0, text6.Length - 1); } if (text10.Length > 0) { text10 = text10.Substring(0, text10.Length - 1); } if (text8.Length > 0) { text8 = text8.Substring(0, text8.Length - 1); } string str_sql3 = "select id from port_info where device_id in (" + text10 + ")"; DataTable dataTable3 = DBTools.CreateDataTable4SysDB(str_sql3); stringBuilder = new System.Text.StringBuilder(); for (int num2 = 0; num2 < dataTable3.Rows.Count; num2++) { stringBuilder.Append(System.Convert.ToString(dataTable3.Rows[num2]["id"]) + ","); } text7 += stringBuilder.ToString(); if (text7.Length > 0) { text7 = text7.Substring(0, text7.Length - 1); } break; } case "alloutlet": { text6 = "0"; text8 = "0"; string str_sql3 = "select a.id,b.model_nm,b.fw_version from port_info a left join device_base_info b on a.device_id=b.id where a.id in (select id from port_info)"; DataTable dataTable3 = DBTools.CreateDataTable4SysDB(str_sql3); stringBuilder = new System.Text.StringBuilder(); for (int num3 = 0; num3 < dataTable3.Rows.Count; num3++) { string modelname4 = System.Convert.ToString(dataTable3.Rows[num3]["model_nm"]); string fmwareVer4 = System.Convert.ToString(dataTable3.Rows[num3]["fw_version"]); DevModelConfig deviceModelConfig4 = DevAccessCfg.GetInstance().getDeviceModelConfig(modelname4, fmwareVer4); if (!deviceModelConfig4.devcapacity.Equals("N/A") && deviceModelConfig4.perportreading == 2) { stringBuilder.Append(System.Convert.ToString(dataTable3.Rows[num3]["id"]) + ","); } } text7 += stringBuilder.ToString(); if (text7.Length > 0) { text7 = text7.Substring(0, text7.Length - 1); } break; } case "outlet": { text6 = "0"; text8 = "0"; string str_sql3 = "select a.id,b.model_nm,b.fw_version from port_info a left join device_base_info b on a.device_id=b.id where a.id in (select dest_id from group_detail where grouptype='outlet' and group_id=" + text + ")"; DataTable dataTable3 = DBTools.CreateDataTable4SysDB(str_sql3); stringBuilder = new System.Text.StringBuilder(); for (int num4 = 0; num4 < dataTable3.Rows.Count; num4++) { string modelname5 = System.Convert.ToString(dataTable3.Rows[num4]["model_nm"]); string fmwareVer5 = System.Convert.ToString(dataTable3.Rows[num4]["fw_version"]); DevModelConfig deviceModelConfig5 = DevAccessCfg.GetInstance().getDeviceModelConfig(modelname5, fmwareVer5); if (!deviceModelConfig5.devcapacity.Equals("N/A") && deviceModelConfig5.perportreading == 2) { stringBuilder.Append(System.Convert.ToString(dataTable3.Rows[num4]["id"]) + ","); } } text7 += stringBuilder.ToString(); if (text7.Length > 0) { text7 = text7.Substring(0, text7.Length - 1); } break; } } arrayList.Add(string.Concat(new string[] { text6, "|", text, "|", text5, "|", text3.ToString(), "|", text7, "|", text8, "|", text4 })); } return(arrayList); }
private void butSave_Click(object sender, System.EventArgs e) { try { if (this.devConfigCheck()) { string text = this.labDevModel.Text; string value = this.labDevModel.Tag.ToString(); int l_id = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(l_id); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion); if (this.tbRefVoltage.Visible) { deviceByID.ReferenceVoltage = System.Convert.ToSingle(this.tbRefVoltage.Text); } deviceByID.Min_current = ThresholdUtil.UI2DB(this.tbMinCurrent, deviceByID.Min_current, 0); deviceByID.Max_current = ThresholdUtil.UI2DB(this.tbMaxCurrent, deviceByID.Max_current, 0); deviceByID.Min_voltage = ThresholdUtil.UI2DB(this.tbMinVoltage, deviceByID.Min_voltage, 0); deviceByID.Max_voltage = ThresholdUtil.UI2DB(this.tbMaxVoltage, deviceByID.Max_voltage, 0); deviceByID.Min_power = ThresholdUtil.UI2DB(this.tbMinPower, deviceByID.Min_power, 0); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Min_power != -300f) { deviceByID.Min_power *= 1000f; } deviceByID.Max_power = ThresholdUtil.UI2DB(this.tbMaxPower, deviceByID.Max_power, 0); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Max_power != -300f) { deviceByID.Max_power *= 1000f; } deviceByID.Min_power_diss = ThresholdUtil.UI2DB(this.tbMinPowerDiss, deviceByID.Min_power_diss, 0); deviceByID.Max_power_diss = ThresholdUtil.UI2DB(this.tbMaxPowerDiss, deviceByID.Max_power_diss, 0); if (deviceModelConfig.doorReading == 2) { deviceByID.DoorSensor = 0; if (this.rbPhoto_1.Checked) { deviceByID.DoorSensor = 1; } else { if (this.rbInductive_2.Checked) { deviceByID.DoorSensor = 2; } else { if (this.rbReed_3.Checked) { deviceByID.DoorSensor = 3; } } } } string mac = deviceByID.Mac; DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); DeviceThreshold deviceThreshold = new DeviceThreshold(); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "dev"); deviceThreshold.MinCurrentMT = deviceByID.Min_current; deviceThreshold.MaxCurrentMT = deviceByID.Max_current; deviceThreshold.MinVoltageMT = deviceByID.Min_voltage; deviceThreshold.MaxVoltageMT = deviceByID.Max_voltage; deviceThreshold.MinPowerMT = deviceByID.Min_power; deviceThreshold.MaxPowerMT = deviceByID.Max_power; deviceThreshold.MaxPowerDissMT = deviceByID.Max_power_diss; ThresholdUtil.UI2Dev(thflg, deviceThreshold); deviceThreshold.DevReferenceVoltage = deviceByID.ReferenceVoltage; deviceThreshold.PopEnableMode = -500; deviceThreshold.PopThreshold = -500f; deviceThreshold.PopModeOutlet = -500; deviceThreshold.PopModeLIFO = -500; deviceThreshold.PopModePriority = -500; deviceThreshold.DoorSensorType = deviceByID.DoorSensor; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && !devAccessAPI.SetDeviceThreshold(deviceThreshold, mac)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } else { deviceByID.Update(); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630000", new string[] { deviceByID.DeviceName, deviceByID.Mac, deviceByID.DeviceIP, valuePair }); } else { LogAPI.writeEventLog("0630000", new string[] { deviceByID.DeviceName, deviceByID.Mac, deviceByID.DeviceIP }); } EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + deviceByID.DeviceID + ":;", 2); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("PropDev Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }
private void DiscoveMethod() { try { string[] array = this.m_strip.Split(new char[] { '.' }); System.Collections.Generic.List <PropertiesMessage> list = null; if (array.Length == 4) { if (this.m_scanCompany == 1) { list = new DevDiscoverAPI(this.m_SNMPPara).Scan_ATEN(this.m_strip, this.m_strip); } else { if (this.m_scanCompany == 2) { list = new DevDiscoverAPI(this.m_SNMPPara).Scan_EATON(this.m_strip, this.m_strip); } else { if (this.m_scanCompany == 4) { list = new DevDiscoverAPI(this.m_SNMPPara).Scan_APC(this.m_strip, this.m_strip); } } } } else { if (array.Length == 3) { if (this.m_scanCompany == 1) { list = new DevDiscoverAPI(this.m_SNMPPara).Scan_ATEN(this.m_strip + ".1", this.m_strip + ".255"); } else { if (this.m_scanCompany == 2) { list = new DevDiscoverAPI(this.m_SNMPPara).Scan_EATON(this.m_strip + ".1", this.m_strip + ".255"); } else { if (this.m_scanCompany == 4) { list = new DevDiscoverAPI(this.m_SNMPPara).Scan_APC(this.m_strip + ".1", this.m_strip + ".255"); } } } } } if (list != null && list.Count > 0) { using (System.Collections.Generic.List <PropertiesMessage> .Enumerator enumerator = list.GetEnumerator()) { while (enumerator.MoveNext()) { PropertiesMessage current = enumerator.Current; string deviceName = current.DeviceName; string ipAddress = current.IpAddress; string macAddress = current.MacAddress; string firwWareVersion = current.FirwWareVersion; string modelName = current.ModelName; if (DeviceOperation.getDeviceByMac(macAddress) == null) { string text = current.DashboardRackname.Equals("\0") ? "" : current.DashboardRackname; if (!DevAccessCfg.GetInstance().getDeviceModelConfig(modelName, firwWareVersion).modelName.Equals(string.Empty)) { string[] item = new string[] { deviceName, macAddress, ipAddress, modelName, text, firwWareVersion }; this.deviceList.Add(item); } } } goto IL_268; } } this.deviceList.Count <string[]>(); IL_268 :; } catch (System.Exception) { } }
private System.Collections.ArrayList getAnalysisGroup(BillingRptPara pPara) { System.Collections.ArrayList arrayList = new System.Collections.ArrayList(); foreach (ListViewItem listViewItem in pPara.Grouplist) { string text = System.Convert.ToString(listViewItem.Tag).Split(new char[] { '|' })[0]; string text2 = System.Convert.ToString(listViewItem.Tag).Split(new char[] { '|' })[1]; if (text2.Length == 0) { text2 = "0"; } string text3 = System.Convert.ToString(listViewItem.Tag).Split(new char[] { '|' })[2]; string text4 = listViewItem.SubItems[1].Text; string text5 = "0,"; string text6 = "0,"; string text7 = "0,"; System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); string key; switch (key = text3) { case "zone": { string str_sql = "select racks from zone_info where id in (" + text2 + ") and racks <>''"; DataTable dataTable = DBTools.CreateDataTable4SysDB(str_sql); text7 = "0,"; for (int i = 0; i < dataTable.Rows.Count; i++) { string str_sql2 = "select id as device_ids from device_base_info where rack_id in (" + System.Convert.ToString(dataTable.Rows[i]["racks"]) + ") "; DataTable dataTable2 = DBTools.CreateDataTable4SysDB(str_sql2); string text8 = ""; stringBuilder = new System.Text.StringBuilder(); for (int j = 0; j < dataTable2.Rows.Count; j++) { stringBuilder.Append(System.Convert.ToString(dataTable2.Rows[j]["device_ids"]) + ","); } text8 += stringBuilder.ToString(); if (text8.Length > 0) { text8 = text8.Substring(0, text8.Length - 1); } text7 = text7 + text8 + ","; } text7 = commUtil.uniqueIDs(text7); if (text7.Length > 0) { text5 = text7.Substring(0, text7.Length - 1); } if (text6.Length > 0) { text6 = text6.Substring(0, text6.Length - 1); } break; } case "rack": case "allrack": { string str_sql2 = "select id as device_ids from device_base_info where rack_id in (" + text2 + ")"; DataTable dataTable2 = DBTools.CreateDataTable4SysDB(str_sql2); stringBuilder = new System.Text.StringBuilder(); for (int k = 0; k < dataTable2.Rows.Count; k++) { stringBuilder.Append(System.Convert.ToString(dataTable2.Rows[k]["device_ids"]) + ","); } text7 += stringBuilder.ToString(); if (text7.Length > 0) { text5 = text7.Substring(0, text7.Length - 1); } if (text6.Length > 0) { text6 = text6.Substring(0, text6.Length - 1); } break; } case "dev": case "alldev": { string str_sql2 = "select id,model_nm from device_base_info where id in (" + text2 + ")"; DataTable dataTable2 = DBTools.CreateDataTable4SysDB(str_sql2); stringBuilder = new System.Text.StringBuilder(); for (int l = 0; l < dataTable2.Rows.Count; l++) { stringBuilder.Append(System.Convert.ToString(dataTable2.Rows[l]["id"]) + ","); } text5 += stringBuilder.ToString(); if (text5.Length > 0) { text5 = text5.Substring(0, text5.Length - 1); } if (text6.Length > 0) { text6 = text6.Substring(0, text6.Length - 1); } break; } case "alloutlet": { text5 = "0"; string str_sql3 = "select a.id,b.model_nm,b.fw_version from port_info a left join device_base_info b on a.device_id=b.id where a.id in (select id from port_info)"; DataTable dataTable3 = DBTools.CreateDataTable4SysDB(str_sql3); stringBuilder = new System.Text.StringBuilder(); for (int m = 0; m < dataTable3.Rows.Count; m++) { string modelname = System.Convert.ToString(dataTable3.Rows[m]["model_nm"]); string fmwareVer = System.Convert.ToString(dataTable3.Rows[m]["fw_version"]); if (DevAccessCfg.GetInstance().getDeviceModelConfig(modelname, fmwareVer).perportreading == 2) { stringBuilder.Append(System.Convert.ToString(dataTable3.Rows[m]["id"]) + ","); } } text6 += stringBuilder.ToString(); if (text6.Length > 0) { text6 = text6.Substring(0, text6.Length - 1); } break; } case "outlet": { text5 = "0"; string str_sql3 = "select a.id,b.model_nm,b.fw_version from port_info a left join device_base_info b on a.device_id=b.id where a.id in (select dest_id from group_detail where grouptype='outlet' and group_id=" + text + ")"; DataTable dataTable3 = DBTools.CreateDataTable4SysDB(str_sql3); stringBuilder = new System.Text.StringBuilder(); for (int n = 0; n < dataTable3.Rows.Count; n++) { string modelname2 = System.Convert.ToString(dataTable3.Rows[n]["model_nm"]); string fmwareVer2 = System.Convert.ToString(dataTable3.Rows[n]["fw_version"]); if (DevAccessCfg.GetInstance().getDeviceModelConfig(modelname2, fmwareVer2).perportreading == 2) { stringBuilder.Append(System.Convert.ToString(dataTable3.Rows[n]["id"]) + ","); } } text6 += stringBuilder.ToString(); if (text6.Length > 0) { text6 = text6.Substring(0, text6.Length - 1); } break; } } arrayList.Add(string.Concat(new string[] { text5, "|", text, "|", text4, "|", text3.ToString(), "|", text6 })); } return(arrayList); }
private object SetDeviceThresholdProc(object param) { DBConn dBConn = null; bool flag = false; string text = ""; try { System.Collections.Generic.List <object> list = (System.Collections.Generic.List <object>)param; DeviceThreshold deviceThreshold = (DeviceThreshold)list[0]; DeviceInfo tmp_di = (DeviceInfo)list[1]; System.Collections.Generic.List <DevSnmpConfig> configs = (System.Collections.Generic.List <DevSnmpConfig>)list[2]; System.Collections.Generic.List <DeviceInfo> list2 = (System.Collections.Generic.List <DeviceInfo>)list[3]; DeviceInfo deviceInfo = list2[0]; DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceInfo.ModelNm, deviceInfo.FWVersion); System.Collections.Generic.Dictionary <string, bool> dictionary = null; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { AppDevAccess appDevAccess = new AppDevAccess(); dictionary = appDevAccess.SetDeviceThresholds(configs, deviceThreshold); } dBConn = DBConnPool.getConnection(); foreach (DeviceInfo current in list2) { string key = CultureTransfer.ToString(current.DeviceID); bool flag2; if (dictionary == null) { flag2 = true; } else { if (!dictionary.ContainsKey(key)) { continue; } flag2 = dictionary[key]; } if (flag2) { current.CopyThreshold(tmp_di); current.UpdateDeviceThreshold(dBConn); flag = true; } else { text = text + current.DeviceIP + ","; } } } catch (System.Exception ex) { System.Console.WriteLine("Devive Porperties -- butAssign_Click Error:" + ex.Message); text = "HAVE EXCEPTION!"; } if (dBConn != null) { dBConn.close(); } DeviceOperation.RefreshDBCache(false); return(new System.Collections.Generic.List <object> { flag, text }); }
private void butAssign_Click(object sender, System.EventArgs e) { try { if (this.devConfigCheck()) { DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyAll, new string[0]), MessageBoxButtons.OKCancel); if (dialogResult != DialogResult.Cancel) { string text = this.labDevModel.Text; string value = this.labDevModel.Tag.ToString(); int l_id = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(l_id); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion); System.Collections.Generic.List <DeviceInfo> allDeviceByModel = DeviceOperation.GetAllDeviceByModel(text); string fWVersion = deviceByID.FWVersion; System.Collections.Generic.List <DeviceInfo> list = new System.Collections.Generic.List <DeviceInfo>(); foreach (DeviceInfo current in allDeviceByModel) { if (current.DeviceID != deviceByID.DeviceID) { if (!DevAccessCfg.GetInstance().isAutodectDev(current.ModelNm, current.FWVersion)) { list.Add(current); } else { if (current.FWVersion.Equals(fWVersion)) { list.Add(current); } } } } if (this.tbRefVoltage.Visible) { deviceByID.ReferenceVoltage = System.Convert.ToSingle(this.tbRefVoltage.Text); } deviceByID.Min_current = ThresholdUtil.UI2DB(this.tbMinCurrent, deviceByID.Min_current, 0); deviceByID.Max_current = ThresholdUtil.UI2DB(this.tbMaxCurrent, deviceByID.Max_current, 0); deviceByID.Min_voltage = ThresholdUtil.UI2DB(this.tbMinVoltage, deviceByID.Min_voltage, 0); deviceByID.Max_voltage = ThresholdUtil.UI2DB(this.tbMaxVoltage, deviceByID.Max_voltage, 0); deviceByID.Min_power = ThresholdUtil.UI2DB(this.tbMinPower, deviceByID.Min_power, 0); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Min_power != -300f) { deviceByID.Min_power *= 1000f; } deviceByID.Max_power = ThresholdUtil.UI2DB(this.tbMaxPower, deviceByID.Max_power, 0); if (deviceModelConfig.commonThresholdFlag == Constant.APC_PDU && deviceByID.Max_power != -300f) { deviceByID.Max_power *= 1000f; } deviceByID.Min_power_diss = ThresholdUtil.UI2DB(this.tbMinPowerDiss, deviceByID.Min_power_diss, 0); deviceByID.Max_power_diss = ThresholdUtil.UI2DB(this.tbMaxPowerDiss, deviceByID.Max_power_diss, 0); if (deviceModelConfig.doorReading == 2) { deviceByID.DoorSensor = 0; if (this.rbPhoto_1.Checked) { deviceByID.DoorSensor = 1; } else { if (this.rbInductive_2.Checked) { deviceByID.DoorSensor = 2; } else { if (this.rbReed_3.Checked) { deviceByID.DoorSensor = 3; } } } } DeviceInfo item = new DeviceInfo(-1, "", "", "", "", "", "", "", 0, 0, "", 161, 1, "", deviceByID.Max_voltage, deviceByID.Min_voltage, deviceByID.Max_power_diss, deviceByID.Min_power_diss, deviceByID.Max_power, deviceByID.Min_power, deviceByID.Max_current, deviceByID.Min_current, -1L, "", -500, -500f, deviceByID.DoorSensor, 0f, -500, -500, -500, "", -500f); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "dev"); DeviceThreshold deviceThreshold = new DeviceThreshold(); deviceThreshold.MinCurrentMT = deviceByID.Min_current; deviceThreshold.MaxCurrentMT = deviceByID.Max_current; deviceThreshold.MinVoltageMT = deviceByID.Min_voltage; deviceThreshold.MaxVoltageMT = deviceByID.Max_voltage; deviceThreshold.MinPowerMT = deviceByID.Min_power; deviceThreshold.MaxPowerMT = deviceByID.Max_power; deviceThreshold.MaxPowerDissMT = deviceByID.Max_power_diss; ThresholdUtil.UI2Dev(thflg, deviceThreshold); deviceThreshold.PopEnableMode = -500; deviceThreshold.PopThreshold = -500f; deviceThreshold.PopModeOutlet = -500; deviceThreshold.PopModeLIFO = -500; deviceThreshold.PopModePriority = -500; deviceThreshold.DoorSensorType = -500; System.Collections.Generic.List <DevSnmpConfig> list2 = new System.Collections.Generic.List <DevSnmpConfig>(); foreach (DeviceInfo current2 in list) { if (ClientAPI.IsDeviceOnline(current2.DeviceID)) { DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current2); list2.Add(sNMPpara); } } bool flag = false; string text2 = ""; if (list.Count > 0) { System.Collections.Generic.List <object> list3 = new System.Collections.Generic.List <object>(); list3.Add(deviceThreshold); list3.Add(item); list3.Add(list2); list3.Add(list); Program.IdleTimer_Pause(1); System.Collections.Generic.List <object> list4; if (list2.Count > 50) { progressPopup progressPopup = new progressPopup("Information", 1, EcoLanguage.getMsg(LangRes.PopProgressMsg_setDevThreshold, new string[0]), null, new progressPopup.ProcessInThread(this.SetDeviceThresholdProc), list3, 0); progressPopup.ShowDialog(); list4 = (progressPopup.Return_V as System.Collections.Generic.List <object>); } else { list4 = (this.SetDeviceThresholdProc(list3) as System.Collections.Generic.List <object>); } flag = (bool)list4[0]; text2 = (string)list4[1]; } if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { DevSnmpConfig sNMPpara2 = commUtil.getSNMPpara(deviceByID); DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara2); deviceThreshold.DevReferenceVoltage = deviceByID.ReferenceVoltage; deviceThreshold.DoorSensorType = deviceByID.DoorSensor; if (devAccessAPI.SetDeviceThreshold(deviceThreshold, deviceByID.Mac)) { flag = true; } else { text2 = "HAVE EXCEPTION!"; } } Program.IdleTimer_Run(1); if (flag) { EcoGlobalVar.setDashBoardFlg(2uL, "", 2); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630001", new string[] { text, valuePair }); } else { LogAPI.writeEventLog("0630001", new string[] { text }); } } if (text2.Length > 0) { if (text2.Equals("HAVE EXCEPTION!")) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } else { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail_1, new string[] { text2 })); } } else { EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } } catch (System.Exception ex) { System.Console.WriteLine("Devive Porperties -- butAssign_Click Error:" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }
private void butSave_Click(object sender, System.EventArgs e) { try { if (this.devConfigCheck()) { string text = this.labDevModel.Text; string value = this.labDevModel.Tag.ToString(); int l_id = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(l_id); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(text, deviceByID.FWVersion); if (this.gbPop2.Visible) { if (this.pop2_cbOutlet.Visible) { deviceByID.OutletPOPMode = (this.pop2_cbOutlet.Checked ? 2 : 1); } if (this.pop2_cbBankLIFO.Visible) { deviceByID.BankPOPLIFOMode = (this.pop2_cbBankLIFO.Checked ? 2 : 1); } deviceByID.BankPOPPriorityMode = (this.pop2_cbBankPriority.Checked ? 2 : 1); } if (this.gbPOPBankPriority.Visible) { string text2 = ""; 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 = 0; i < this.dgvBank1_PList.Rows.Count; i++) { DataGridViewComboBoxCell dataGridViewComboBoxCell = (DataGridViewComboBoxCell)this.dgvBank1_PList.Rows[i].Cells[1]; string text3 = dataGridViewComboBoxCell.Value.ToString(); if (text3.Equals("N/A")) { text2 += "0,"; } else { text3 = text3.Substring("Outlet ".Length); text2 = text2 + ((int)System.Convert.ToInt16(text3)).ToString() + ","; } } for (int j = 0; j < num2 - num + 1 - this.dgvBank1_PList.Rows.Count; j++) { text2 += "0,"; } text2 = text2.Substring(0, text2.Length - 1); if (this.dgvBank2_PList.Visible) { num = deviceModelConfig.bankOutlets[1].fromPort; num2 = deviceModelConfig.bankOutlets[1].toPort; text2 += "#"; for (int k = 0; k < this.dgvBank2_PList.Rows.Count; k++) { DataGridViewComboBoxCell dataGridViewComboBoxCell = (DataGridViewComboBoxCell)this.dgvBank2_PList.Rows[k].Cells[1]; string text3 = dataGridViewComboBoxCell.Value.ToString(); if (text3.Equals("N/A")) { text2 += "0,"; } else { text3 = text3.Substring("Outlet ".Length); text2 = text2 + ((int)System.Convert.ToInt16(text3)).ToString() + ","; } } for (int l = 0; l < num2 - num + 1 - this.dgvBank1_PList.Rows.Count; l++) { text2 += "0,"; } text2 = text2.Substring(0, text2.Length - 1); } deviceByID.Bank_Priority = text2; } if (this.gbPop.Visible) { if (!this.cbPopEnable.Checked) { deviceByID.POPEnableMode = 1; } else { deviceByID.POPEnableMode = 2; if (this.rbPopMaxBankC.Checked) { deviceByID.POPThreshold = -0.1f; } else { deviceByID.POPThreshold = System.Convert.ToSingle(this.tbPopThreshold.Text); } } } string mac = deviceByID.Mac; DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); DevicePOPSettings devicePOPSettings = new DevicePOPSettings(); devicePOPSettings.PopEnableMode = deviceByID.POPEnableMode; devicePOPSettings.PopThreshold = deviceByID.POPThreshold; devicePOPSettings.PopModeOutlet = deviceByID.OutletPOPMode; devicePOPSettings.PopModeLIFO = deviceByID.BankPOPLIFOMode; devicePOPSettings.PopModePriority = deviceByID.BankPOPPriorityMode; devicePOPSettings.PopPriorityList = deviceByID.Bank_Priority; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && !devAccessAPI.SetDevicePOPSettings(devicePOPSettings, mac)) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } else { deviceByID.Update(); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630005", new string[] { deviceByID.DeviceName, deviceByID.Mac, deviceByID.DeviceIP, valuePair }); } else { LogAPI.writeEventLog("0630005", new string[] { deviceByID.DeviceName, deviceByID.Mac, deviceByID.DeviceIP }); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("PropDev Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }
private void filteronlinedev() { this.dgvFwDevice.Rows.Clear(); this.cbsel.Checked = true; string text = null; string strB = null; string text2 = null; string text3 = ""; string text4 = ""; if (this.tbFileNm.Text.Length > 0) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(this.tbFileNm.Text); text = fileInfo.Name.ToUpper(); text2 = fileInfo.Extension; if (text2 != null) { text2 = text2.ToUpper(); } strB = this.getDevFWflg(this.tbFileNm.Text, ref text3, ref text4); } DevAccessCfg instance = DevAccessCfg.GetInstance(); if (text4.Length == 0) { using (System.Collections.Generic.List <string[]> .Enumerator enumerator = this.m_allRows.GetEnumerator()) { while (enumerator.MoveNext()) { string[] current = enumerator.Current; string text5 = current[6]; string text6 = current[7]; string text7 = current[4]; if (text != null) { DevModelConfig deviceModelConfig = instance.getDeviceModelConfig(current[3], text7); if (deviceModelConfig.FWvalidate != 0) { if ((deviceModelConfig.FWnms.Length > 0 && !text.StartsWith(deviceModelConfig.FWnms)) || (deviceModelConfig.FWext.Length > 0 && (text2 == null || !text2.Equals(deviceModelConfig.FWext)))) { continue; } switch (deviceModelConfig.FWvalidate) { case 1: if (!text3.Equals("ATEN") || (this.cbMainFw.Checked && text7.CompareTo(strB) >= 0)) { continue; } break; } } } string[] obj = new string[] { "1", current[1], current[2], current[3], text7, current[5], text5, text6 }; ControlAccess.ConfigControl config = delegate(Control control, object param) { DataGridView dataGridView = control as DataGridView; string[] array2 = param as string[]; dataGridView.Rows.Add(new object[] { true, array2[1], array2[2], array2[3], array2[4], array2[5], array2[6], array2[7] }); }; ControlAccess controlAccess = new ControlAccess(this, config); controlAccess.Access(this.dgvFwDevice, obj); } goto IL_37E; } } string[] array = text4.Split(new char[] { '/' }); foreach (string[] current2 in this.m_allRows) { string text5 = current2[6]; string text6 = current2[7]; string text7 = current2[4]; if (text != null) { bool flag = false; for (int i = 0; i < array.Length; i++) { string text8 = array[i]; int num = text8.IndexOf("*"); if (num >= 0) { text8 = text8.Substring(0, num); if (current2[3].IndexOf(text8) >= 0) { flag = true; break; } } else { if (current2[3].Equals(array[i])) { flag = true; break; } } } if (!flag || (this.cbMainFw.Checked && text7.CompareTo(strB) >= 0)) { continue; } } string[] obj2 = new string[] { "1", current2[1], current2[2], current2[3], text7, current2[5], text5, text6 }; ControlAccess.ConfigControl config2 = delegate(Control control, object param) { DataGridView dataGridView = control as DataGridView; string[] array2 = param as string[]; dataGridView.Rows.Add(new object[] { true, array2[1], array2[2], array2[3], array2[4], array2[5], array2[6], array2[7] }); }; ControlAccess controlAccess2 = new ControlAccess(this, config2); controlAccess2.Access(this.dgvFwDevice, obj2); } IL_37E : ControlAccess.ConfigControl config3 = delegate(Control control, object param) { this.cbMainFw.Enabled = true; this.butBrowse.Enabled = true; this.butUpdate.Enabled = true; this.cbsel.Enabled = true; }; ControlAccess controlAccess3 = new ControlAccess(this, config3); controlAccess3.Access(this.dgvFwDevice, null); }
private void butBankSave_Click(object sender, System.EventArgs e) { try { string value = this.labDevModel.Tag.ToString(); int num = System.Convert.ToInt32(value); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(num); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion); if (this.bankCheck(deviceModelConfig)) { string text = this.tbBankNm.Text; string text2 = this.labBankNo.Text; int num2 = System.Convert.ToInt32(text2); BankInfo bankInfo = new BankInfo(num, num2); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); BankThreshold bankThreshold = new BankThreshold(num2); bankThreshold.BankName = text; if (this.gbThreshold.Visible) { bankInfo.Min_current = ThresholdUtil.UI2DB(this.tbOMinCurrent, bankInfo.Min_current, 0); bankInfo.Max_current = ThresholdUtil.UI2DB(this.tbOMaxCurrent, bankInfo.Max_current, 0); bankInfo.Min_voltage = ThresholdUtil.UI2DB(this.tbOMinVoltage, bankInfo.Min_voltage, 0); bankInfo.Max_voltage = ThresholdUtil.UI2DB(this.tbOMaxVoltage, bankInfo.Max_voltage, 0); bankInfo.Min_power = ThresholdUtil.UI2DB(this.tbOMinPower, bankInfo.Min_power, 0); bankInfo.Max_power = ThresholdUtil.UI2DB(this.tbOMaxPower, bankInfo.Max_power, 0); bankInfo.Min_power_diss = ThresholdUtil.UI2DB(this.tbOMinPowerDiss, bankInfo.Min_power_diss, 0); bankInfo.Max_power_diss = ThresholdUtil.UI2DB(this.tbOMaxPowerDiss, bankInfo.Max_power_diss, 0); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "bank"); bankThreshold.MinCurrentMt = bankInfo.Min_current; bankThreshold.MaxCurrentMT = bankInfo.Max_current; bankThreshold.MinVoltageMT = bankInfo.Min_voltage; bankThreshold.MaxVoltageMT = bankInfo.Max_voltage; bankThreshold.MinPowerMT = bankInfo.Min_power; bankThreshold.MaxPowerMT = bankInfo.Max_power; bankThreshold.MaxPowerDissMT = bankInfo.Max_power_diss; ThresholdUtil.UI2Dev(thflg, bankThreshold); } bool flag = true; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); flag = devAccessAPI.SetBankThreshold(bankThreshold, deviceByID.Mac); } if (flag) { if (bankInfo != null) { bankInfo.BankName = text; bankInfo.Update(); EcoGlobalVar.setDashBoardFlg(128uL, string.Concat(new object[] { "#UPDATE#D", bankInfo.DeviceID, ":B", bankInfo.ID, ";" }), 2); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630010", new string[] { bankInfo.BankName, bankInfo.PortLists, deviceByID.DeviceIP, deviceByID.DeviceName, valuePair }); } else { LogAPI.writeEventLog("0630010", new string[] { bankInfo.BankName, bankInfo.PortLists, deviceByID.DeviceIP, deviceByID.DeviceName }); } } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } else { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("PropBank Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }
public MainForm(UserInfo pUser) { this.InitializeComponent(); MainForm.RawInput_Install(base.Handle); string text = DevAccessCfg.GetInstance().getVersion(); if (text.Length > 0) { text = " (" + text + ")"; } else { System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version; text = string.Concat(new string[] { " (V", version.Major.ToString(), ".", version.Minor.ToString(), ".", version.Build.ToString("000"), ")" }); } this.Text += text; EcoGlobalVar.gl_DevManPage = this.devManPage1; int num = 1; this.butUser.Hide(); this.butDevice.Hide(); this.butSysManagement.Hide(); this.butLog.Hide(); if (EcoGlobalVar.ECOAppRunMode == 1) { int userRight = pUser.UserRight; if ((userRight & 1) != 0) { this.tlpMainMenu.SetCellPosition(this.butUser, new TableLayoutPanelCellPosition(num, 0)); this.butUser.Show(); num++; } if ((userRight & 2) != 0) { this.tlpMainMenu.SetCellPosition(this.butDevice, new TableLayoutPanelCellPosition(num, 0)); this.butDevice.Show(); num++; } if ((userRight & 4) != 0) { this.tlpMainMenu.SetCellPosition(this.butSysManagement, new TableLayoutPanelCellPosition(num, 0)); this.butSysManagement.Show(); num++; } if ((userRight & 8) != 0) { this.tlpMainMenu.SetCellPosition(this.butLog, new TableLayoutPanelCellPosition(num, 0)); this.butLog.Show(); num++; } } if (pUser.UserType != 0) { this.enegManPage1.hiddenPowerAnalysisButton(); this.logPage1.hidden_LogOptionEvent(); } this.pageInit(); }
private object initFWDevProc(object aaa) { System.Collections.Generic.List <DeviceInfo> allDevice = DeviceOperation.GetAllDevice(); DevAccessCfg.GetInstance(); foreach (DeviceInfo current in allDevice) { if (ClientAPI.IsDeviceOnline(current.DeviceID)) { string text = current.DeviceID.ToString(); string modelNm = current.ModelNm; DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(modelNm, current.FWVersion); if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDU_M2 && deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold && deviceModelConfig.commonThresholdFlag != Constant.APC_PDU) { DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current); string mac = current.Mac; DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); DevServiceInfo devServiceInfo = devAccessAPI.GetDevServiceInfo(mac); int httpPort = devServiceInfo.httpPort; if (httpPort != 0) { string[] obj = new string[] { "1", current.DeviceName, current.DeviceIP, current.ModelNm, devServiceInfo.fwVersion, "", text, httpPort.ToString() }; ControlAccess.ConfigControl config = delegate(Control control, object param) { DataGridView dataGridView = control as DataGridView; string[] array = param as string[]; dataGridView.Rows.Add(new object[] { true, array[1], array[2], array[3], array[4], array[5], array[6], array[7] }); this.m_allRows.Add(array); }; ControlAccess controlAccess = new ControlAccess(this, config); controlAccess.Access(this.dgvFwDevice, obj); } } } } ControlAccess.ConfigControl config2 = delegate(Control control, object param) { this.cbMainFw.Enabled = true; this.butBrowse.Enabled = true; this.butUpdate.Enabled = true; this.cbsel.Enabled = true; }; ControlAccess controlAccess2 = new ControlAccess(this, config2); controlAccess2.Access(this.dgvFwDevice, null); return(0); }
private void butBankAssign_Click(object sender, System.EventArgs e) { bool flag = false; DBConn dBConn = null; string text = this.labDevModel.Tag.ToString(); try { int num = System.Convert.ToInt32(text); DeviceInfo deviceByID = DeviceOperation.getDeviceByID(num); DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceByID.ModelNm, deviceByID.FWVersion); if (this.bankCheck(deviceModelConfig)) { DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyBank, new string[0]), MessageBoxButtons.OKCancel); if (dialogResult != DialogResult.Cancel) { string text2 = this.tbBankNm.Text; string text3 = this.labBankNo.Text; int num2 = System.Convert.ToInt32(text3); BankInfo bankInfo = new BankInfo(num, num2); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); BankThreshold bankThreshold = new BankThreshold(1); if (this.gbThreshold.Visible) { bankInfo.Min_current = ThresholdUtil.UI2DB(this.tbOMinCurrent, bankInfo.Min_current, 0); bankInfo.Max_current = ThresholdUtil.UI2DB(this.tbOMaxCurrent, bankInfo.Max_current, 0); bankInfo.Min_voltage = ThresholdUtil.UI2DB(this.tbOMinVoltage, bankInfo.Min_voltage, 0); bankInfo.Max_voltage = ThresholdUtil.UI2DB(this.tbOMaxVoltage, bankInfo.Max_voltage, 0); bankInfo.Min_power = ThresholdUtil.UI2DB(this.tbOMinPower, bankInfo.Min_power, 0); bankInfo.Max_power = ThresholdUtil.UI2DB(this.tbOMaxPower, bankInfo.Max_power, 0); bankInfo.Min_power_diss = ThresholdUtil.UI2DB(this.tbOMinPowerDiss, bankInfo.Min_power_diss, 0); bankInfo.Max_power_diss = ThresholdUtil.UI2DB(this.tbOMaxPowerDiss, bankInfo.Max_power_diss, 0); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "bank"); bankThreshold.MinCurrentMt = bankInfo.Min_current; bankThreshold.MaxCurrentMT = bankInfo.Max_current; bankThreshold.MinVoltageMT = bankInfo.Min_voltage; bankThreshold.MaxVoltageMT = bankInfo.Max_voltage; bankThreshold.MinPowerMT = bankInfo.Min_power; bankThreshold.MaxPowerMT = bankInfo.Max_power; bankThreshold.MaxPowerDissMT = bankInfo.Max_power_diss; ThresholdUtil.UI2Dev(thflg, bankThreshold); } DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); string myMac = deviceByID.Mac; System.Collections.Generic.List <BankInfo> bankInfo2 = deviceByID.GetBankInfo(); dBConn = DBConnPool.getConnection(); foreach (BankInfo current in bankInfo2) { BankThreshold bankThreshold2 = new BankThreshold(System.Convert.ToInt32(current.PortLists)); if (num2 == System.Convert.ToInt32(current.PortLists)) { current.BankName = text2; } bankThreshold2.BankName = current.BankName; if (this.gbThreshold.Visible) { bankThreshold2.MaxCurrentMT = bankThreshold.MaxCurrentMT; bankThreshold2.MinCurrentMt = bankThreshold.MinCurrentMt; bankThreshold2.MaxPowerMT = bankThreshold.MaxPowerMT; bankThreshold2.MinPowerMT = bankThreshold.MinPowerMT; bankThreshold2.MaxVoltageMT = bankThreshold.MaxVoltageMT; bankThreshold2.MinVoltageMT = bankThreshold.MinVoltageMT; bankThreshold2.MaxPowerDissMT = bankThreshold.MaxPowerDissMT; } bool flag2 = true; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { flag2 = devAccessAPI.SetBankThreshold(bankThreshold2, myMac); } if (!flag2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); return; } if (this.gbThreshold.Visible) { current.CopyThreshold(bankInfo); } current.UpdateBankThreshold(dBConn); flag = true; myMac = ""; } if (dBConn != null) { dBConn.close(); } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630011", new string[] { deviceByID.ModelNm, deviceByID.DeviceIP, deviceByID.DeviceName, valuePair }); } else { LogAPI.writeEventLog("0630011", new string[] { deviceByID.ModelNm, deviceByID.DeviceIP, deviceByID.DeviceName }); } EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.Dev_ThresholdSucc, new string[0])); } } } catch (System.Exception ex) { System.Console.WriteLine("butBankAssign_Click Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } finally { if (dBConn != null) { dBConn.close(); } DeviceOperation.RefreshDBCache(false); if (flag) { EcoGlobalVar.setDashBoardFlg(128uL, "#UPDATE#D" + text + ":B*;", 2); } } }
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]; } }
private static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); System.Security.Principal.WindowsPrincipal windowsPrincipal = new System.Security.Principal.WindowsPrincipal(System.Security.Principal.WindowsIdentity.GetCurrent()); if (!windowsPrincipal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) { TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.NeedPrivilege, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); System.Environment.Exit(0); return; } EcoGlobalVar.nullcontextMenuStrip = new ContextMenuStrip(); EcoGlobalVar.ECOAppRunMode = 1; AppInterProcess.OpenInterProcessShared(); int processID = AppInterProcess.getProcessID(Program.program_uid, Program.program_serverid, EcoGlobalVar.ECOAppRunMode); if (processID != 0) { AppInterProcess.CloseShared(); string processOwner = Program.GetProcessOwner(processID); string processOwner2 = Program.GetProcessOwner(Process.GetCurrentProcess().Id); if (processOwner.Equals(processOwner2)) { Program.setTopMost(processID); } else { TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.APPRunbyuser, new string[] { processOwner }), "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } System.Environment.Exit(0); return; } AppInterProcess.setMyProcessID(Program.program_uid, Program.program_serverid, EcoGlobalVar.ECOAppRunMode); Program.setTopMost(Process.GetCurrentProcess().Id); int mySQLUseMajorVersionOnly = DevAccessCfg.GetInstance().getMySQLUseMajorVersionOnly(); DBMaintain.SetMySQLVersionRole(mySQLUseMajorVersionOnly); while (Program.LocalConsole_cfg() == -2) { } DBUrl.RUNMODE = 1; ClientAPI.SetBroadcastCallback(new CommonAPI.CommonAPI.DelegateOnBroadcast(EcoGlobalVar.receiveDashBoardFlgProc)); ClientAPI.SetClosedCallback(new CommonAPI.CommonAPI.DelegateOnClosed(EcoGlobalVar.ServerClosedProc)); Login.Login login = new Login.Login(); login.Icon = null; login.ShowDialog(); if (login.UserName == null) { Program.ExitApp(); return; } EcoGlobalVar.gl_StartProcessfThread(true); Application.CurrentCulture = System.Globalization.CultureInfo.CurrentUICulture; if (EcoGlobalVar.ECOAppRunMode == 1) { DBCacheStatus.DBSyncEventInit(false); DBCacheEventProcess.StartRefreshThread(false); DBCache.DBCacheInit(false); } if (ClientAPI.WaitDatasetReady(40000u) < 0) { TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.DB_waitready, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); Program.ExitApp(); return; } EcoGlobalVar.DCLayoutType = ClientAPI.getRackLayout(); EcoGlobalVar.gl_maxZoneNum = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxZoneNum")); EcoGlobalVar.gl_maxRackNum = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxRackNum")); EcoGlobalVar.gl_maxDevNum = CultureTransfer.ToInt32(ClientAPI.getKeyValue("MaxDevNum")); EcoGlobalVar.gl_supportISG = (CultureTransfer.ToInt32(ClientAPI.getKeyValue("SupportISG")) > 0); EcoGlobalVar.gl_supportBP = (CultureTransfer.ToInt32(ClientAPI.getKeyValue("SupportBP")) > 0); EcoGlobalVar.TempUnit = CultureTransfer.ToInt32(ClientAPI.getKeyValue("TempUnit")); EcoGlobalVar.CurCurrency = ClientAPI.getKeyValue("CurCurrency"); EcoGlobalVar.co2kg = CultureTransfer.ToSingle(ClientAPI.getKeyValue("co2kg")); EcoGlobalVar.flgEnablePower = AppData.getDB_flgEnablePower(); EcoGlobalVar.RackFullNameFlag = CultureTransfer.ToInt32(ClientAPI.getKeyValue("RackFullNameFlag")); EcoGlobalVar.gl_PeakPowerMethod = DevAccessCfg.GetInstance().getPowerPeakMethod(); string valuePair = ValuePairs.getValuePair("UserID"); long l_id = System.Convert.ToInt64(valuePair); string valuePair2 = ValuePairs.getValuePair("UserName"); valuePair = ValuePairs.getValuePair("UserType"); int i_type = System.Convert.ToInt32(valuePair); valuePair = ValuePairs.getValuePair("UserRight"); int i_right = System.Convert.ToInt32(valuePair); string valuePair3 = ValuePairs.getValuePair("UserPortNM"); string valuePair4 = ValuePairs.getValuePair("UserDevice"); string valuePair5 = ValuePairs.getValuePair("UserGroup"); valuePair = ValuePairs.getValuePair("UserStatus"); ValuePairs.getValuePair("trial"); ValuePairs.getValuePair("remaining_days"); int i_status = System.Convert.ToInt32(valuePair); UserInfo userInfo = new UserInfo(l_id, valuePair2, "", i_status, i_type, i_right, valuePair3, valuePair4, valuePair5); EcoGlobalVar.gl_LoginUser = userInfo; EcoGlobalVar.gl_LoginUserUACDev2Port = (System.Collections.Generic.Dictionary <long, System.Collections.Generic.List <long> >)ClientAPI.RemoteCall(8, 1, "", 10000); if (EcoGlobalVar.gl_LoginUserUACDev2Port == null) { TopMostMessageBox.Show(EcoLanguage.getMsg(LangRes.DB_waitready, new string[0]), "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); Program.ExitApp(); return; } string para = "0230000\n" + userInfo.UserName; ClientAPI.RemoteCall(100, 1, para, 10000); MainForm.MainForm mainForm = new MainForm.MainForm(userInfo); EcoGlobalVar.gl_mainForm = mainForm; if (!EcoGlobalVar.gl_supportISG) { EcoGlobalVar.gl_monitorCtrl.FreshFlg_ISGPower = 0; EcoGlobalVar.gl_DashBoardCtrl.FreshFlg_ISGPower = 0; } EcoGlobalVar.gl_StopProcessfThread(); Program.IdleTimer_init(); Application.ApplicationExit += new System.EventHandler(Program.Application_ApplicationExit); System.AppDomain.CurrentDomain.ProcessExit += new System.EventHandler(Program.CurrentDomain_ProcessExit); Application.Run(mainForm); }