Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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]));
     }
 }
Exemplo n.º 3
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);
                }
            }
        }
Exemplo n.º 4
0
 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]));
     }
 }
Exemplo n.º 5
0
 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]));
     }
 }
Exemplo n.º 6
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.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]));
     }
 }