Exemplo n.º 1
0
        public System.Collections.Generic.List <string> SetDevPOPs(DevicePOPSettings pop2dev)
        {
            System.Collections.Generic.List <string> list             = new System.Collections.Generic.List <string>();
            SystemThreadPool <SnmpConfiger, string>  systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, string>(this.snmpConfigs);

            return(systemThreadPool.GetResults(delegate(System.Collections.ICollection col, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                string arg = CultureTransfer.ToString(snmpConfiger.DeviceID);
                bool flag = false;
                try
                {
                    flag = snmpExecutor.SetDevicePOPSettings(pop2dev);
                }
                catch (System.Exception)
                {
                }
                lock (col)
                {
                    ((System.Collections.Generic.List <string>)col).Add(arg + ":" + flag);
                }
            }));
        }
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
        public System.Collections.Generic.Dictionary <string, bool> SetDevicePOPs(System.Collections.Generic.List <DevSnmpConfig> configs, DevicePOPSettings pop2dev)
        {
            DevAccessCfg instance = DevAccessCfg.GetInstance();

            System.Collections.Generic.List <SnmpConfiger> list = new System.Collections.Generic.List <SnmpConfiger>();
            foreach (DevSnmpConfig current in configs)
            {
                DevModelConfig deviceModelConfig = instance.getDeviceModelConfig(current.modelName, current.fmwareVer);
                SnmpConfiger   item = new SnmpConfiger(instance.getSnmpConfig(current), deviceModelConfig, current.devMac, current.devID);
                list.Add(item);
            }
            System.Collections.Generic.List <string>             list2      = new AppSnmpExecutors(list).SetDevPOPs(pop2dev);
            System.Collections.Generic.Dictionary <string, bool> dictionary = new System.Collections.Generic.Dictionary <string, bool>();
            foreach (string current2 in list2)
            {
                string[] array = current2.Split(new char[]
                {
                    ':'
                });
                dictionary.Add(array[0], System.Convert.ToBoolean(array[1]));
            }
            return(dictionary);
        }