public static void UI2Dev(int thflg, BankThreshold threshold) { if ((thflg & 1) != 0) { threshold.MinCurrentMt = -500f; } if ((thflg & 2) != 0) { threshold.MaxCurrentMT = -500f; } if ((thflg & 4) != 0) { threshold.MinVoltageMT = -500f; } if ((thflg & 8) != 0) { threshold.MaxVoltageMT = -500f; } if ((thflg & 16) != 0) { threshold.MinPowerMT = -500f; } if ((thflg & 32) != 0) { threshold.MaxPowerMT = -500f; } if ((thflg & 128) != 0) { threshold.MaxPowerDissMT = -500f; } }
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 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); }
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])); } }