Example #1
0
        public DevSnmpConfig getSNMPpara()
        {
            DevSnmpConfig devSnmpConfig = new DevSnmpConfig();

            switch (this.m_pSyspara.SnmpVersion)
            {
            case 1:
                devSnmpConfig.snmpVer = 0;
                break;

            case 2:
                devSnmpConfig.snmpVer = 1;
                break;

            case 3:
                devSnmpConfig.snmpVer = 3;
                break;
            }
            devSnmpConfig.devPort  = this.m_pSyspara.port;
            devSnmpConfig.userName = this.m_pSyspara.username;
            devSnmpConfig.retry    = this.m_pSyspara.retry;
            devSnmpConfig.timeout  = this.m_pSyspara.timeout;
            devSnmpConfig.authPSW  = this.m_pSyspara.authenpwd;
            devSnmpConfig.authType = this.m_pSyspara.authen;
            devSnmpConfig.privPSW  = this.m_pSyspara.privacypwd;
            devSnmpConfig.privType = this.m_pSyspara.privacy;
            return(devSnmpConfig);
        }
Example #2
0
        public static DevSnmpConfig getSNMPpara(DeviceInfo pDevInfo)
        {
            DevSnmpConfig devSnmpConfig = new DevSnmpConfig();

            devSnmpConfig.devID     = pDevInfo.DeviceID;
            devSnmpConfig.devMac    = pDevInfo.Mac;
            devSnmpConfig.modelName = pDevInfo.ModelNm;
            devSnmpConfig.devIP     = pDevInfo.DeviceIP;
            devSnmpConfig.devPort   = pDevInfo.Port;
            devSnmpConfig.fmwareVer = pDevInfo.FWVersion;
            switch (pDevInfo.SnmpVersion)
            {
            case 1:
                devSnmpConfig.snmpVer = 0;
                break;

            case 2:
                devSnmpConfig.snmpVer = 1;
                break;

            case 3:
                devSnmpConfig.snmpVer = 3;
                break;
            }
            devSnmpConfig.userName = pDevInfo.Username;
            devSnmpConfig.retry    = pDevInfo.Retry;
            devSnmpConfig.timeout  = pDevInfo.Timeout;
            devSnmpConfig.authPSW  = pDevInfo.AuthenPassword;
            devSnmpConfig.authType = pDevInfo.Authentication;
            devSnmpConfig.privPSW  = pDevInfo.PrivacyPassword;
            devSnmpConfig.privType = pDevInfo.Privacy;
            return(devSnmpConfig);
        }
Example #3
0
        private int syncThreshold()
        {
            int result;

            try
            {
                System.Collections.Generic.List <DeviceInfo>    allDevice = DeviceOperation.GetAllDevice();
                System.Collections.Generic.List <DevSnmpConfig> list      = new System.Collections.Generic.List <DevSnmpConfig>();
                new System.Collections.Generic.List <System.Collections.Hashtable>();
                foreach (DeviceInfo current in allDevice)
                {
                    if (ClientAPI.IsDeviceOnline(current.DeviceID))
                    {
                        DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current);
                        list.Add(sNMPpara);
                    }
                }
                DevMonitorAPI devMonitorAPI = new DevMonitorAPI();
                System.Collections.Generic.List <ThresholdMessage> monitorThresholds = devMonitorAPI.GetMonitorThresholds(list);
                this.UpdateAllThresholds(monitorThresholds);
                result = 1;
            }
            catch (System.Exception)
            {
                result = -1;
            }
            return(result);
        }
Example #4
0
        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);
        }
Example #5
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);
        }
Example #6
0
 public DiscoverThread(int scanCompany, string strIPs, DevSnmpConfig SNMPPara)
 {
     this.m_scanCompany = scanCompany;
     this.m_strip       = strIPs;
     this.m_SNMPPara    = SNMPPara;
 }
Example #7
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]));
     }
 }
Example #8
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);
                }
            }
        }
Example #9
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]));
     }
 }
Example #10
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]));
     }
 }
Example #11
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]));
     }
 }
Example #12
0
        private void butOff_Click(object sender, System.EventArgs e)
        {
            DataTable dataTable = (DataTable)this.dgvInfo.DataSource;

            System.Collections.Generic.List <DevSnmpConfig> list = new System.Collections.Generic.List <DevSnmpConfig>();
            System.Collections.Generic.Dictionary <string, System.Collections.Generic.List <int> > dictionary = new System.Collections.Generic.Dictionary <string, System.Collections.Generic.List <int> >();
            this.m_parent.endTimer();
            DialogResult dialogResult;

            if (this.cbDReboot.Checked)
            {
                dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.OPCrm_reboot, new string[0]), MessageBoxButtons.OKCancel);
            }
            else
            {
                dialogResult = EcoMessageBox.ShowWarning(EcoLanguage.getMsg(LangRes.OPCrm_off, new string[0]), MessageBoxButtons.OKCancel);
            }
            if (dialogResult == DialogResult.Cancel)
            {
                this.m_parent.starTimer();
                return;
            }
            foreach (DataRow dataRow in dataTable.Rows)
            {
                string text  = dataRow[0].ToString();
                string value = dataRow[3].ToString();
                if (dictionary.ContainsKey(text))
                {
                    System.Collections.Generic.List <int> list2 = dictionary[text];
                    list2.Add(System.Convert.ToInt32(value));
                }
                else
                {
                    dictionary.Add(text, new System.Collections.Generic.List <int>
                    {
                        System.Convert.ToInt32(value)
                    });
                }
            }
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
            foreach (System.Collections.Generic.KeyValuePair <string, System.Collections.Generic.List <int> > current in dictionary)
            {
                string text = current.Key;
                stringBuilder.Append(text + ",");
            }
            string text2 = stringBuilder.ToString();

            if (text2.Length > 1)
            {
                text2 = text2.Substring(0, text2.Length - 1);
            }
            System.Collections.Generic.List <DeviceInfo> list3 = (System.Collections.Generic.List <DeviceInfo>)ClientAPI.RemoteCall(7, 1, text2, 10000);
            if (list3 == null)
            {
                list3 = new System.Collections.Generic.List <DeviceInfo>();
            }
            foreach (DeviceInfo current2 in list3)
            {
                string        text     = current2.DeviceID.ToString();
                DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current2);
                sNMPpara.groupOutlets = dictionary[text];
                list.Add(sNMPpara);
            }
            DevPortGroupAPI devPortGroupAPI = new DevPortGroupAPI(list);
            bool            flag;

            if (this.cbDReboot.Checked)
            {
                flag = devPortGroupAPI.RebootGroupOutlets();
            }
            else
            {
                flag = devPortGroupAPI.TurnOffGroupOutlets();
            }
            if (flag)
            {
                EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0]));
            }
            else
            {
                EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.OPfail, new string[0]));
            }
            this.m_parent.starTimer();
        }
Example #13
0
        private void butSysparaSave_Click(object sender, System.EventArgs e)
        {
            if (!this.sysparaCheck())
            {
                return;
            }
            int num = System.Convert.ToInt32(this.tbSysTrapPort.Text);

            if (num != this.m_pSyspara.TrapPort)
            {
                bool flag = NetworkShareAccesser.UDPPortInUse(num);
                if (flag)
                {
                    this.tbSysTrapPort.Focus();
                    EcoMessageBox.ShowError(EcoLanguage.getMsg(LangRes.Portconflict, new string[]
                    {
                        this.tbSysTrapPort.Text
                    }));
                    return;
                }
            }
            this.m_pSyspara.username = this.tbSysUserNm.Text;
            this.m_pSyspara.timeout  = System.Convert.ToInt32(this.tbSysTimeOut.Text);
            this.m_pSyspara.port     = System.Convert.ToInt32(this.tbSysPort.Text);
            this.m_pSyspara.retry    = System.Convert.ToInt32(this.tbSysRetry.Text);
            int num2 = System.Convert.ToInt32(((Combobox_item)this.cbSnmpV.SelectedItem).getKey());

            this.m_pSyspara.SnmpVersion = num2;
            this.m_pSyspara.authen      = "None";
            this.m_pSyspara.authenpwd   = string.Empty;
            this.m_pSyspara.privacy     = "None";
            this.m_pSyspara.privacypwd  = string.Empty;
            if (num2 == 3)
            {
                this.m_pSyspara.authen = this.cbSysAuthen.SelectedItem.ToString();
                if (!this.m_pSyspara.authen.Equals("None"))
                {
                    this.m_pSyspara.authenpwd  = this.tbSysAuthenPw.Text;
                    this.m_pSyspara.privacy    = this.cbSysPrivacy.SelectedItem.ToString();
                    this.m_pSyspara.privacypwd = this.tbSysPrivacyPw.Text;
                }
            }
            Sys_Para sys_Para = new Sys_Para();
            bool     flag2    = false;

            sys_Para.TrapUserName = this.tbSysTrapUserNm.Text;
            sys_Para.TrapPort     = System.Convert.ToInt32(this.tbSysTrapPort.Text);
            num2 = System.Convert.ToInt32(((Combobox_item)this.cbTrapSnmpV.SelectedItem).getKey());
            sys_Para.TrapSnmpVersion = num2;
            sys_Para.TrapAuthen      = "None";
            sys_Para.TrapAuthenPwd   = string.Empty;
            sys_Para.TrapPrivacy     = "None";
            sys_Para.TrapPrivacyPwd  = string.Empty;
            if (num2 == 2)
            {
                sys_Para.TrapAuthen = this.cbSysTrapAuthen.SelectedItem.ToString();
                if (!sys_Para.TrapAuthen.Equals("None"))
                {
                    sys_Para.TrapAuthenPwd  = this.tbSysTrapAuthenPw.Text;
                    sys_Para.TrapPrivacy    = this.cbSysTrapPrivacy.SelectedItem.ToString();
                    sys_Para.TrapPrivacyPwd = this.tbSysTrapPrivacyPw.Text;
                }
            }
            if (!this.m_pSyspara.TrapUserName.Equals(sys_Para.TrapUserName) || this.m_pSyspara.TrapPort != sys_Para.TrapPort || this.m_pSyspara.TrapSnmpVersion != sys_Para.TrapSnmpVersion || !this.m_pSyspara.TrapAuthen.Equals(sys_Para.TrapAuthen) || !this.m_pSyspara.TrapAuthenPwd.Equals(sys_Para.TrapAuthenPwd) || !this.m_pSyspara.TrapPrivacy.Equals(sys_Para.TrapPrivacy) || !this.m_pSyspara.TrapPrivacyPwd.Equals(sys_Para.TrapPrivacyPwd))
            {
                this.m_pSyspara.TrapUserName    = sys_Para.TrapUserName;
                this.m_pSyspara.TrapPort        = sys_Para.TrapPort;
                this.m_pSyspara.TrapSnmpVersion = sys_Para.TrapSnmpVersion;
                this.m_pSyspara.TrapAuthen      = sys_Para.TrapAuthen;
                this.m_pSyspara.TrapAuthenPwd   = sys_Para.TrapAuthenPwd;
                this.m_pSyspara.TrapPrivacy     = sys_Para.TrapPrivacy;
                this.m_pSyspara.TrapPrivacyPwd  = sys_Para.TrapPrivacyPwd;
                flag2 = true;
            }
            this.m_pSyspara.update();
            string valuePair = ValuePairs.getValuePair("Username");

            if (!string.IsNullOrEmpty(valuePair))
            {
                LogAPI.writeEventLog("0130022", new string[]
                {
                    valuePair
                });
            }
            else
            {
                LogAPI.writeEventLog("0130022", new string[0]);
            }
            if (flag2)
            {
                System.Collections.Generic.List <DeviceInfo>    allDevice = DeviceOperation.GetAllDevice();
                System.Collections.Generic.List <DevSnmpConfig> list      = new System.Collections.Generic.List <DevSnmpConfig>();
                foreach (DeviceInfo current in allDevice)
                {
                    if (ClientAPI.IsDeviceOnline(current.DeviceID))
                    {
                        DevSnmpConfig sNMPpara = commUtil.getSNMPpara(current);
                        list.Add(sNMPpara);
                    }
                }
                try
                {
                    DevMonitorAPI devMonitorAPI = new DevMonitorAPI();
                    devMonitorAPI.SetTrapReceiver(list, this.m_pSyspara);
                }
                catch (System.Exception)
                {
                }
            }
            EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0]));
        }