Пример #1
0
        private object backupcfgPro(object param)
        {
            string str_folder = (string)param;

            this.syncThreshold();
            DeviceOperation.RefreshDBCache(false);
            EcoGlobalVar.setDashBoardFlg(2uL, "", 0);
            int num = Backuptask.BackupConfig4UI(str_folder);

            return(num);
        }
Пример #2
0
        private object delDevicePro(object param)
        {
            int num = 1;

            System.Collections.ArrayList arrayList = param as System.Collections.ArrayList;
            DBConn connection = DBConnPool.getConnection();

            for (int i = 0; i < arrayList.Count; i++)
            {
                string     value      = (string)arrayList[i];
                DeviceInfo deviceByID = DeviceOperation.getDeviceByID(System.Convert.ToInt32(value));
                int        num2       = DeviceOperation.DeleteDeviceByID(connection, System.Convert.ToInt32(value));
                if (num2 < 0)
                {
                    num = num2;
                }
                else
                {
                    string valuePair = ValuePairs.getValuePair("Username");
                    if (!string.IsNullOrEmpty(valuePair))
                    {
                        LogAPI.writeEventLog("0430001", new string[]
                        {
                            deviceByID.ModelNm,
                            deviceByID.Mac,
                            deviceByID.DeviceIP,
                            deviceByID.DeviceName,
                            valuePair
                        });
                    }
                    else
                    {
                        LogAPI.writeEventLog("0430001", new string[]
                        {
                            deviceByID.ModelNm,
                            deviceByID.Mac,
                            deviceByID.DeviceIP,
                            deviceByID.DeviceName
                        });
                    }
                }
            }
            connection.Close();
            DeviceOperation.RefreshDBCache(false);
            DeviceOperation.StartDBCleanupThread();
            return(num);
        }
Пример #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);
                }
            }
        }
Пример #4
0
        private object SetDeviceThresholdProc(object param)
        {
            DBConn dBConn = null;
            bool   flag   = false;
            string text   = "";

            try
            {
                System.Collections.Generic.List <object> list = (System.Collections.Generic.List <object>)param;
                DeviceThreshold deviceThreshold = (DeviceThreshold)list[0];
                DeviceInfo      tmp_di          = (DeviceInfo)list[1];
                System.Collections.Generic.List <DevSnmpConfig> configs = (System.Collections.Generic.List <DevSnmpConfig>)list[2];
                System.Collections.Generic.List <DeviceInfo>    list2   = (System.Collections.Generic.List <DeviceInfo>)list[3];
                DeviceInfo     deviceInfo        = list2[0];
                DevModelConfig deviceModelConfig = DevAccessCfg.GetInstance().getDeviceModelConfig(deviceInfo.ModelNm, deviceInfo.FWVersion);
                System.Collections.Generic.Dictionary <string, bool> dictionary = null;
                if (deviceModelConfig.commonThresholdFlag != Constant.EatonPDUThreshold)
                {
                    AppDevAccess appDevAccess = new AppDevAccess();
                    dictionary = appDevAccess.SetDeviceThresholds(configs, deviceThreshold);
                }
                dBConn = DBConnPool.getConnection();
                foreach (DeviceInfo current in list2)
                {
                    string key = CultureTransfer.ToString(current.DeviceID);
                    bool   flag2;
                    if (dictionary == null)
                    {
                        flag2 = true;
                    }
                    else
                    {
                        if (!dictionary.ContainsKey(key))
                        {
                            continue;
                        }
                        flag2 = dictionary[key];
                    }
                    if (flag2)
                    {
                        current.CopyThreshold(tmp_di);
                        current.UpdateDeviceThreshold(dBConn);
                        flag = true;
                    }
                    else
                    {
                        text = text + current.DeviceIP + ",";
                    }
                }
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine("Devive Porperties -- butAssign_Click Error:" + ex.Message);
                text = "HAVE EXCEPTION!";
            }
            if (dBConn != null)
            {
                dBConn.close();
            }
            DeviceOperation.RefreshDBCache(false);
            return(new System.Collections.Generic.List <object>
            {
                flag,
                text
            });
        }