コード例 #1
0
        public System.Collections.Generic.List <ThresholdMessage> GetChainThresholds()
        {
            System.DateTime arg_05_0 = System.DateTime.Now;
            System.Collections.Generic.List <ThresholdMessage> list             = new System.Collections.Generic.List <ThresholdMessage>();
            SystemThreadPool <SnmpConfiger, ThresholdMessage>  systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, ThresholdMessage>(this.snmpConfigs);

            return(systemThreadPool.GetResults(delegate(System.Collections.ICollection col, object obj)
            {
                SnmpConfiger snmpConfig = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfig);
                System.Collections.Generic.List <ThresholdMessage> list2 = new System.Collections.Generic.List <ThresholdMessage>();
                try
                {
                    list2 = snmpExecutor.GetChainThresholds();
                }
                catch (System.Exception)
                {
                }
                if (list2 != null && list2.Count > 0)
                {
                    lock (col)
                    {
                        foreach (ThresholdMessage current in list2)
                        {
                            ((System.Collections.Generic.List <ThresholdMessage>)col).Add(current);
                        }
                    }
                }
            }));
        }
コード例 #2
0
        public System.Collections.Generic.List <PropertiesMessage> GetProperties_ALL()
        {
            System.DateTime createTime = System.DateTime.Now;
            SystemThreadPool <SnmpConfiger, PropertiesMessage> systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, PropertiesMessage>(this.snmpConfigs);

            return(systemThreadPool.GetResults(delegate(System.Collections.ICollection col, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                PropertiesMessage propertiesMessage = null;
                try
                {
                    propertiesMessage = snmpExecutor.GetProperties_ALL();
                    propertiesMessage.CreateTime = createTime;
                    propertiesMessage.IpAddress = snmpConfiger.SnmpConfig.AgentIp;
                    propertiesMessage.PortNums = snmpConfiger.PortNumbers;
                    propertiesMessage.PerPortReading = snmpConfiger.PerPortReading;
                    propertiesMessage.Switchable = snmpConfiger.Switchable;
                    propertiesMessage.SensorNums = snmpConfiger.SensorNumber;
                }
                catch (System.Exception)
                {
                }
                if (propertiesMessage != null)
                {
                    lock (col)
                    {
                        ((System.Collections.Generic.List <PropertiesMessage>)col).Add(propertiesMessage);
                    }
                }
            }));
        }
コード例 #3
0
        public System.Collections.Generic.List <ValueMessage> GetChainVaules()
        {
            System.Threading.ThreadPool.SetMaxThreads(ThreadUtil.WorkThreadNum * 2, ThreadUtil.CompletionPortNum * 2);
            int num;
            int num2;

            System.Threading.ThreadPool.GetMaxThreads(out num, out num2);
            System.DateTime arg_22_0 = System.DateTime.Now;
            System.Collections.Generic.List <ValueMessage> list             = new System.Collections.Generic.List <ValueMessage>();
            SystemThreadPool <SnmpConfiger, ValueMessage>  systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, ValueMessage>(this.snmpConfigs);

            return(systemThreadPool.GetResults(delegate(System.Collections.ICollection col, object obj)
            {
                SnmpConfiger snmpConfig = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfig);
                System.Collections.Generic.List <ValueMessage> list2 = new System.Collections.Generic.List <ValueMessage>();
                try
                {
                    list2 = snmpExecutor.GetChainValues();
                }
                catch (System.Exception)
                {
                }
                if (list2 != null && list2.Count > 0)
                {
                    lock (col)
                    {
                        foreach (ValueMessage current in list2)
                        {
                            ((System.Collections.Generic.List <ValueMessage>)col).Add(current);
                        }
                    }
                }
            }));
        }
コード例 #4
0
        public System.Collections.Generic.List <SnmpConfiger> UpdateDeviceVoltages(float voltage)
        {
            System.Collections.Generic.List <SnmpConfiger> failConfigs      = new System.Collections.Generic.List <SnmpConfiger>();
            SystemThreadPool <SnmpConfiger, bool>          systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, bool>(this.snmpConfigs);

            systemThreadPool.GetResults(delegate(System.Collections.ICollection coll, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                try
                {
                    if (!snmpExecutor.UpdateDeviceVoltage(voltage))
                    {
                        lock (DefaultSnmpExecutors.lockRestore)
                        {
                            failConfigs.Add(snmpConfiger);
                        }
                    }
                }
                catch (System.Exception)
                {
                    lock (DefaultSnmpExecutors.lockRestore)
                    {
                        failConfigs.Add(snmpConfiger);
                    }
                }
            });
            return(failConfigs);
        }
コード例 #5
0
        public System.Collections.Generic.List <ValueMessage> GetVaules()
        {
            System.Threading.ThreadPool.SetMaxThreads(ThreadUtil.WorkThreadNum * 2, ThreadUtil.CompletionPortNum * 2);
            int num;
            int num2;

            System.Threading.ThreadPool.GetMaxThreads(out num, out num2);
            System.DateTime createTime = System.DateTime.Now;
            System.Collections.Generic.List <ValueMessage> list             = new System.Collections.Generic.List <ValueMessage>();
            SystemThreadPool <SnmpConfiger, ValueMessage>  systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, ValueMessage>(this.snmpConfigs);

            return(systemThreadPool.GetResults(delegate(System.Collections.ICollection col, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                ValueMessage valueMessage = null;
                try
                {
                    if (snmpConfiger.DevModelConfig.commonThresholdFlag == Constant.EatonPDU_M2)
                    {
                        valueMessage = snmpExecutor.GetValuesEatonPDU_M2();
                    }
                    else
                    {
                        if (snmpConfiger.DevModelConfig.commonThresholdFlag == Constant.APC_PDU)
                        {
                            valueMessage = snmpExecutor.GetValuesApcPDU();
                        }
                        else
                        {
                            valueMessage = snmpExecutor.GetValues();
                        }
                    }
                }
                catch (System.Exception)
                {
                }
                if (valueMessage == null)
                {
                    valueMessage = new ValueMessage();
                }
                valueMessage.CreateTime = createTime;
                valueMessage.ModelName = snmpConfiger.DevModel;
                valueMessage.IpAddress = snmpConfiger.SnmpConfig.AgentIp;
                valueMessage.PortNums = snmpConfiger.PortNumbers;
                valueMessage.PerPortReading = snmpConfiger.PerPortReading;
                valueMessage.Switchable = snmpConfiger.Switchable;
                valueMessage.SensorNums = snmpConfiger.SensorNumber;
                valueMessage.BankNums = snmpConfiger.BankNumber;
                valueMessage.DeviceID = snmpConfiger.DeviceID;
                valueMessage.DeviceMac = snmpConfiger.DeviceMac;
                lock (col)
                {
                    ((System.Collections.Generic.List <ValueMessage>)col).Add(valueMessage);
                }
            }));
        }
コード例 #6
0
        public System.Collections.Generic.List <ThresholdMessage> GetThresholds()
        {
            this.retryconfigs.Clear();
            System.DateTime createTime = System.DateTime.Now;
            System.Collections.Generic.List <ThresholdMessage> list             = new System.Collections.Generic.List <ThresholdMessage>();
            SystemThreadPool <SnmpConfiger, ThresholdMessage>  systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, ThresholdMessage>(this.snmpConfigs);

            return(systemThreadPool.GetResults(delegate(System.Collections.ICollection col, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                ThresholdMessage thresholdMessage = null;
                try
                {
                    if (snmpConfiger.DevModelConfig.commonThresholdFlag == Constant.EatonPDU_M2)
                    {
                        thresholdMessage = snmpExecutor.GetThresholdsEatonPDU_M2();
                    }
                    else
                    {
                        if (snmpConfiger.DevModelConfig.commonThresholdFlag == Constant.APC_PDU)
                        {
                            thresholdMessage = snmpExecutor.GetThresholdsApcPDU();
                        }
                        else
                        {
                            thresholdMessage = snmpExecutor.GetThresholds();
                        }
                    }
                    thresholdMessage.CreateTime = createTime;
                    thresholdMessage.IpAddress = snmpConfiger.SnmpConfig.AgentIp;
                    thresholdMessage.PortNums = snmpConfiger.PortNumbers;
                    thresholdMessage.PerPortReading = snmpConfiger.PerPortReading;
                    thresholdMessage.Switchable = snmpConfiger.Switchable;
                    thresholdMessage.SensorNums = snmpConfiger.SensorNumber;
                    thresholdMessage.BankNums = snmpConfiger.BankNumber;
                    thresholdMessage.DeviceID = snmpConfiger.DeviceID;
                    thresholdMessage.DeviceMac = snmpConfiger.DeviceMac;
                }
                catch (System.Exception)
                {
                }
                if (thresholdMessage != null)
                {
                    lock (col)
                    {
                        ((System.Collections.Generic.List <ThresholdMessage>)col).Add(thresholdMessage);
                        return;
                    }
                }
                this.retryconfigs.Add(snmpConfiger);
            }));
        }
コード例 #7
0
        public string[] GetStatusGroupOutlets()
        {
            string failDID    = "";
            string successDID = "";
            SystemThreadPool <SnmpConfiger, bool> systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, bool>(this.snmpConfigs);

            systemThreadPool.GetResults(delegate(System.Collections.ICollection coll, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                try
                {
                    System.Collections.Generic.List <int> list = new System.Collections.Generic.List <int>();
                    for (int i = 1; i <= snmpConfiger.DevModelConfig.portNum; i++)
                    {
                        if (snmpConfiger.DevModelConfig.isOutletSwitchable(i - 1))
                        {
                            list.Add(i);
                        }
                    }
                    if (snmpExecutor.GetDeviceOutletsStatus(list) == null)
                    {
                        lock (DefaultSnmpExecutors.lockGroup)
                        {
                            failDID = failDID + snmpConfiger.DeviceID + ",";
                            goto IL_DA;
                        }
                    }
                    lock (DefaultSnmpExecutors.lockGroup)
                    {
                        successDID = successDID + snmpConfiger.DeviceID + ",";
                    }
                    IL_DA:;
                }
                catch (System.Exception)
                {
                    lock (DefaultSnmpExecutors.lockGroup)
                    {
                        failDID = failDID + snmpConfiger.DeviceID + ",";
                    }
                }
            });
            return(new string[]
            {
                failDID,
                successDID
            });
        }
コード例 #8
0
        public string[] RestoreThresholds2Device()
        {
            string failMAC    = "";
            string successDID = "";
            string misMAC     = "";
            SystemThreadPool <SnmpConfiger, bool> systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, bool>(this.snmpConfigs);

            systemThreadPool.GetResults(delegate(System.Collections.ICollection coll, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                try
                {
                    bool flag = false;
                    int num   = snmpExecutor.CheckDeviceMac(snmpConfiger.DeviceMac);
                    if (num >= 0)
                    {
                        flag = snmpExecutor.UpdateDeviceName(snmpConfiger.RestoreThresholds.DeviceName);
                    }
                    else
                    {
                        if (num == -1)
                        {
                            lock (DefaultSnmpExecutors.lockRestore)
                            {
                                misMAC = misMAC + snmpConfiger.DeviceMac + ",";
                            }
                        }
                    }
                    if (flag)
                    {
                        DevicePOPSettings devicePOPSettings = new DevicePOPSettings();
                        devicePOPSettings.copyPOPSetings(snmpConfiger.RestoreThresholds.DeviceThreshold);
                        snmpExecutor.SetDevicePOPSettings(devicePOPSettings);
                        snmpExecutor.SetDeviceThreshold(snmpConfiger.RestoreThresholds.DeviceThreshold);
                        for (int i = 0; i < snmpConfiger.RestoreThresholds.SensorThreshold.Count; i++)
                        {
                            snmpExecutor.SetSensorThreshold(snmpConfiger.RestoreThresholds.SensorThreshold[i + 1]);
                        }
                        for (int j = 0; j < snmpConfiger.RestoreThresholds.BankThreshold.Count; j++)
                        {
                            snmpExecutor.SetBankThreshold(snmpConfiger.RestoreThresholds.BankThreshold[j + 1]);
                        }
                        for (int k = 0; k < snmpConfiger.RestoreThresholds.OutletThreshold.Count; k++)
                        {
                            snmpExecutor.SetOutletThreshold(snmpConfiger.RestoreThresholds.OutletThreshold[k + 1]);
                        }
                        for (int l = 0; l < snmpConfiger.RestoreThresholds.LineThreshold.Count; l++)
                        {
                            snmpExecutor.SetLineThreshold(snmpConfiger.RestoreThresholds.LineThreshold[l + 1]);
                        }
                    }
                    if (!flag)
                    {
                        lock (DefaultSnmpExecutors.lockRestore)
                        {
                            failMAC = failMAC + snmpConfiger.DeviceMac + ",";
                            goto IL_217;
                        }
                    }
                    lock (DefaultSnmpExecutors.lockRestore)
                    {
                        successDID = successDID + snmpConfiger.DeviceID + ",";
                    }
                    IL_217:;
                }
                catch (System.Exception ex)
                {
                    lock (DefaultSnmpExecutors.lockRestore)
                    {
                        failMAC = failMAC + snmpConfiger.DeviceMac + ",";
                    }
                    DebugCenter instance = DebugCenter.GetInstance();
                    instance.appendToFile("Failed to restore config to device: " + snmpConfiger.RestoreThresholds.DeviceName + ", " + ex.Message);
                }
            });
            return(new string[]
            {
                failMAC,
                successDID,
                misMAC
            });
        }
コード例 #9
0
        public string[] RebootGroupOutlets()
        {
            string failDID    = "";
            string successDID = "";
            SystemThreadPool <SnmpConfiger, bool> systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, bool>(this.snmpConfigs);

            systemThreadPool.GetResults(delegate(System.Collections.ICollection coll, object obj)
            {
                SnmpConfiger snmpConfiger = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor = new DefaultSnmpExecutor(snmpConfiger);
                string text = "";
                bool flag   = false;
                try
                {
                    foreach (int current in snmpConfiger.GroupOutlets)
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            text += ",";
                        }
                        text += current;
                    }
                    flag = snmpExecutor.RebootGroupOutlets(snmpConfiger.GroupOutlets);
                }
                catch (System.Exception)
                {
                }
                lock (DefaultSnmpExecutors.lockGroup)
                {
                    if (flag)
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            object successDID;
                            if (!string.IsNullOrEmpty(successDID))
                            {
                                successDID += ";";
                            }
                            successDID = successDID;
                            successDID = string.Concat(new object[]
                            {
                                successDID,
                                snmpConfiger.DeviceID,
                                ":",
                                text
                            });
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(text))
                        {
                            object failDID;
                            if (!string.IsNullOrEmpty(failDID))
                            {
                                failDID += ";";
                            }
                            failDID = failDID;
                            failDID = string.Concat(new object[]
                            {
                                failDID,
                                snmpConfiger.DeviceID,
                                ":",
                                text
                            });
                        }
                    }
                }
            });
            return(new string[]
            {
                failDID,
                successDID
            });
        }
コード例 #10
0
        public void UpdateTrapReceiver(Sys_Para pSys, TrapEnabled open)
        {
            if (pSys.TrapPort <= 0 || pSys.TrapPort > 65535)
            {
                return;
            }
            DebugCenter debug = DebugCenter.GetInstance();

            debug.appendToFile("*****=====***** Begin to send trap receiver config to device *****=====*****");
            SystemThreadPool <SnmpConfiger, bool> systemThreadPool = new SystemLargeThreadPool <SnmpConfiger, bool>(this.snmpConfigs);

            systemThreadPool.GetResults(delegate(System.Collections.ICollection coll, object obj)
            {
                System.Collections.Generic.List <System.Net.IPAddress> managerLocalIpAddress = this.getManagerLocalIpAddress();
                System.Net.IPAddress iPAddress = managerLocalIpAddress[0];
                SnmpConfiger snmpConfiger      = (SnmpConfiger)obj;
                SnmpExecutor snmpExecutor      = new DefaultSnmpExecutor(snmpConfiger);
                if (snmpConfiger.DevModelConfig.commonThresholdFlag != Constant.EatonPDU_M2 && snmpConfiger.DevModelConfig.commonThresholdFlag != Constant.APC_PDU && !snmpConfiger.SnmpConfig.AgentIp.Equals("127.0.0.1"))
                {
                    try
                    {
                        if (managerLocalIpAddress.Count > 1)
                        {
                            iPAddress = this.getLocalSameNetworkIP(snmpConfiger.SnmpConfig.AgentIp);
                            if (iPAddress.ToString().Equals("127.0.0.1"))
                            {
                                int deviceHttpPort = snmpExecutor.DeviceHttpPort;
                                if (deviceHttpPort > 0)
                                {
                                    iPAddress = this.getLocalConnectibleIP(snmpConfiger.SnmpConfig.AgentIp, deviceHttpPort);
                                    if (iPAddress.ToString().Equals("127.0.0.1"))
                                    {
                                        debug.appendToFile("Failed to get connectiable IP, Device IP: " + snmpConfiger.SnmpConfig.AgentIp);
                                        if (iPAddress.ToString().Equals("127.0.0.1"))
                                        {
                                            iPAddress = managerLocalIpAddress[0];
                                        }
                                    }
                                }
                                else
                                {
                                    debug.appendToFile(string.Concat(new object[]
                                    {
                                        "Failed to get device http port: ",
                                        deviceHttpPort,
                                        ", Device IP: ",
                                        snmpConfiger.SnmpConfig.AgentIp
                                    }));
                                    iPAddress = managerLocalIpAddress[0];
                                }
                            }
                        }
                        TrapReceiverConfiguration trapReceiverConfig = snmpExecutor.GetTrapReceiverConfig(1);
                        if (trapReceiverConfig != null && (trapReceiverConfig.Enabled != open || trapReceiverConfig.TrapVersion != pSys.TrapSnmpVersion || trapReceiverConfig.TrapPort != pSys.TrapPort || trapReceiverConfig.ReceiverIp.ToString() != iPAddress.ToString()))
                        {
                            snmpExecutor.ConfigTrapReceiver(new TrapReceiverConfiguration(1)
                            {
                                AgentVersion = (int)snmpConfiger.SnmpConfig.Version,
                                Enabled      = open,
                                ReceiverIp   = iPAddress,
                                TrapPort     = pSys.TrapPort,
                                TrapVersion  = pSys.TrapSnmpVersion,
                                Community    = pSys.TrapUserName,
                                Username     = pSys.TrapUserName,
                                AuthPassword = pSys.TrapAuthenPwd,
                                PrivPassword = pSys.TrapPrivacyPwd
                            });
                        }
                    }
                    catch (System.Exception)
                    {
                    }
                }
            });
        }