public static void UI2Dev(int thflg, LineThreshold 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; } }
private void butLineAssign_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.lineCheck(deviceModelConfig)) { DialogResult dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.Dev_ApplyLine, new string[0]), MessageBoxButtons.OKCancel); if (dialogResult != DialogResult.Cancel) { string text2 = this.labLineNo.Text; int i_linenum = System.Convert.ToInt32(text2); LineInfo lineInfo = new LineInfo(num, i_linenum); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); LineThreshold lineThreshold = new LineThreshold(1); if (this.gbThreshold.Visible) { lineInfo.Min_current = ThresholdUtil.UI2DB(this.tbLMinCurrent, lineInfo.Min_current, 0); lineInfo.Max_current = ThresholdUtil.UI2DB(this.tbLMaxCurrent, lineInfo.Max_current, 0); lineInfo.Min_voltage = ThresholdUtil.UI2DB(this.tbLMinVoltage, lineInfo.Min_voltage, 0); lineInfo.Max_voltage = ThresholdUtil.UI2DB(this.tbLMaxVoltage, lineInfo.Max_voltage, 0); lineInfo.Min_power = ThresholdUtil.UI2DB(this.tbLMinPower, lineInfo.Min_power, 0); lineInfo.Max_power = ThresholdUtil.UI2DB(this.tbLMaxPower, lineInfo.Max_power, 0); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "line"); lineThreshold.MinCurrentMt = lineInfo.Min_current; lineThreshold.MaxCurrentMT = lineInfo.Max_current; lineThreshold.MinVoltageMT = lineInfo.Min_voltage; lineThreshold.MaxVoltageMT = lineInfo.Max_voltage; lineThreshold.MinPowerMT = lineInfo.Min_power; lineThreshold.MaxPowerMT = lineInfo.Max_power; ThresholdUtil.UI2Dev(thflg, lineThreshold); } DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); string myMac = deviceByID.Mac; System.Collections.Generic.List <LineInfo> lineInfo2 = deviceByID.GetLineInfo(); dBConn = DBConnPool.getConnection(); foreach (LineInfo current in lineInfo2) { LineThreshold lineThreshold2 = new LineThreshold(current.LineNumber); if (this.gbThreshold.Visible) { lineThreshold2.MaxCurrentMT = lineThreshold.MaxCurrentMT; lineThreshold2.MinCurrentMt = lineThreshold.MinCurrentMt; lineThreshold2.MaxPowerMT = lineThreshold.MaxPowerMT; lineThreshold2.MinPowerMT = lineThreshold.MinPowerMT; lineThreshold2.MaxVoltageMT = lineThreshold.MaxVoltageMT; lineThreshold2.MinVoltageMT = lineThreshold.MinVoltageMT; } bool flag2 = true; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { flag2 = devAccessAPI.SetLineThreshold(lineThreshold2, myMac); } if (!flag2) { EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); return; } if (this.gbThreshold.Visible) { current.CopyThreshold(lineInfo); } current.UpdateLineThreshold(dBConn); flag = true; myMac = ""; } if (dBConn != null) { dBConn.close(); } string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630016", new string[] { deviceByID.ModelNm, deviceByID.DeviceIP, deviceByID.DeviceName, valuePair }); } else { LogAPI.writeEventLog("0630016", 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("butLineAssign_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 + ":L*;", 2); } } }
private void butLineSave_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.lineCheck(deviceModelConfig)) { string text = this.labLineNo.Text; int num2 = System.Convert.ToInt32(text); LineInfo lineInfo = new LineInfo(num, num2); DevSnmpConfig sNMPpara = commUtil.getSNMPpara(deviceByID); LineThreshold lineThreshold = new LineThreshold(num2); if (this.gbThreshold.Visible) { lineInfo.Min_current = ThresholdUtil.UI2DB(this.tbLMinCurrent, lineInfo.Min_current, 0); lineInfo.Max_current = ThresholdUtil.UI2DB(this.tbLMaxCurrent, lineInfo.Max_current, 0); lineInfo.Min_voltage = ThresholdUtil.UI2DB(this.tbLMinVoltage, lineInfo.Min_voltage, 0); lineInfo.Max_voltage = ThresholdUtil.UI2DB(this.tbLMaxVoltage, lineInfo.Max_voltage, 0); lineInfo.Min_power = ThresholdUtil.UI2DB(this.tbLMinPower, lineInfo.Min_power, 0); lineInfo.Max_power = ThresholdUtil.UI2DB(this.tbLMaxPower, lineInfo.Max_power, 0); int thflg = devcfgUtil.ThresholdFlg(deviceModelConfig, "line"); lineThreshold.MinCurrentMt = lineInfo.Min_current; lineThreshold.MaxCurrentMT = lineInfo.Max_current; lineThreshold.MinVoltageMT = lineInfo.Min_voltage; lineThreshold.MaxVoltageMT = lineInfo.Max_voltage; lineThreshold.MinPowerMT = lineInfo.Min_power; lineThreshold.MaxPowerMT = lineInfo.Max_power; ThresholdUtil.UI2Dev(thflg, lineThreshold); } bool flag = true; if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold) { DevAccessAPI devAccessAPI = new DevAccessAPI(sNMPpara); flag = devAccessAPI.SetLineThreshold(lineThreshold, deviceByID.Mac); } if (flag) { if (lineInfo != null) { lineInfo.Update(); EcoGlobalVar.setDashBoardFlg(128uL, string.Concat(new object[] { "#UPDATE#D", lineInfo.DeviceID, ":L", lineInfo.ID, ";" }), 2); string valuePair = ValuePairs.getValuePair("Username"); if (!string.IsNullOrEmpty(valuePair)) { LogAPI.writeEventLog("0630015", new string[] { lineInfo.LineNumber.ToString(), deviceByID.DeviceIP, deviceByID.DeviceName, valuePair }); } else { LogAPI.writeEventLog("0630015", new string[] { lineInfo.LineNumber.ToString(), 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("PropLine Exception" + ex.Message); EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Dev_ThresholdFail, new string[0])); } }