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])); } }