Esempio n. 1
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);
                }
            }));
        }
Esempio n. 2
0
        public static ValueMessage GetValueMessageApcPDU(DevModelConfig modelCfg, System.Collections.Generic.Dictionary <string, string> result)
        {
            ValueMessage valueMessage = new ValueMessage();

            System.Collections.Generic.Dictionary <string, string> dictionary  = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary2 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary3 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.IEnumerator <string>        enumerator  = result.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if (current.StartsWith(ApcDeviceStatusMib.Entry) || current.StartsWith(ApcPhaseStatusMib.Entry))
                {
                    dictionary.Add(current, text);
                }
                else
                {
                    if (current.StartsWith(ApcBankStatusMib.Entry))
                    {
                        dictionary2.Add(current, text);
                    }
                    else
                    {
                        if (current.StartsWith(ApcPDUBaseMib.Mac))
                        {
                            valueMessage.DeviceReplyMac = text.Replace(" ", ":").Replace("-", ":");
                        }
                        else
                        {
                            if (current.StartsWith(ApcSensorStatusMib.Entry))
                            {
                                dictionary3.Add(current, text);
                            }
                        }
                    }
                }
            }
            if (dictionary != null && dictionary.Count > 0)
            {
                valueMessage.DeviceValue = ApcMibParser.GetDeviceValue(dictionary);
            }
            if (dictionary2 != null && dictionary2.Count > 0)
            {
                valueMessage.BankValue = ApcMibParser.GetBankValue(dictionary2);
            }
            if (dictionary3 != null && dictionary3.Count > 0)
            {
                valueMessage.SensorValue = ApcMibParser.GetSensorValue(dictionary3);
            }
            else
            {
                valueMessage.SensorValue = ApcMibParser.GetSensorValue_Empty(dictionary3);
            }
            return(valueMessage);
        }
Esempio n. 3
0
        public static ValueMessage GetValueMessageEatonPDU_M2(DevModelConfig modelCfg, System.Collections.Generic.Dictionary <string, string> result)
        {
            ValueMessage valueMessage = new ValueMessage();

            System.Collections.Generic.Dictionary <string, string> dictionary  = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary2 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary3 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.Dictionary <string, string> dictionary4 = new System.Collections.Generic.Dictionary <string, string>();
            System.Collections.Generic.IEnumerator <string>        enumerator  = result.Keys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string current = enumerator.Current;
                string text    = result[current];
                if (current.StartsWith(EatonInputCurrentMib_M2.Entry) || current.StartsWith(EatonInputVoltageMib_M2.Entry) || current.StartsWith(EatonInputPowerMib_M2.Entry))
                {
                    dictionary.Add(current, text);
                }
                else
                {
                    if (current.StartsWith(EatonSensorTemperatureMib_M2.Entry) || current.StartsWith(EatonSensorHumidityMib_M2.Entry))
                    {
                        dictionary2.Add(current, text);
                    }
                    else
                    {
                        if (current.StartsWith(EatonOutletCurrentMib_M2.Entry) || current.StartsWith(EatonOutletVoltageMib_M2.Entry) || current.StartsWith(EatonOutletPowerMib_M2.Entry))
                        {
                            dictionary3.Add(current, text);
                        }
                        else
                        {
                            if (current.StartsWith(EatonGroupCurrentMib_M2.Entry) || current.StartsWith(EatonGroupVoltageMib_M2.Entry) || current.StartsWith(EatonGroupPowerMib_M2.Entry))
                            {
                                dictionary4.Add(current, text);
                            }
                            else
                            {
                                if (current.StartsWith(EatonPDUBaseMib_M2.Mac))
                                {
                                    valueMessage.DeviceReplyMac = text.Replace(" ", ":").Replace("-", ":");
                                }
                            }
                        }
                    }
                }
            }
            if (dictionary != null && dictionary.Count > 0)
            {
                valueMessage.DeviceValue = EatonMibParser.GetDeviceValue(dictionary);
            }
            if (dictionary3 != null && dictionary3.Count > 0)
            {
                valueMessage.OutletValue = EatonMibParser.GetOutletValue(dictionary3);
            }
            if (dictionary2 != null && dictionary2.Count > 0)
            {
                valueMessage.SensorValue = EatonMibParser.GetSensorValue(dictionary2);
            }
            if (dictionary4 != null && dictionary4.Count > 0)
            {
                valueMessage.BankValue = EatonMibParser.GetBankValue(dictionary4);
            }
            if (modelCfg.doorReading == Constant.DoorSensorNo)
            {
                valueMessage.DeviceValue.DoorSensorStatus = -500;
            }
            if (modelCfg.commonThresholdFlag == Constant.EatonPDU_M2)
            {
                valueMessage.DeviceValue.PowerDissipation = "N/A";
                if (valueMessage.BankValue != null && valueMessage.BankValue.Count > 0)
                {
                    foreach (System.Collections.Generic.KeyValuePair <int, BankValueEntry> current2 in valueMessage.BankValue)
                    {
                        BankValueEntry value = current2.Value;
                        value.PowerDissipation = "N/A";
                        value.Voltage          = valueMessage.DeviceValue.Voltage;
                    }
                }
                if (valueMessage.OutletValue != null && valueMessage.OutletValue.Count > 0)
                {
                    foreach (System.Collections.Generic.KeyValuePair <int, OutletValueEntry> current3 in valueMessage.OutletValue)
                    {
                        OutletValueEntry value2 = current3.Value;
                        value2.PowerDissipation = "N/A";
                    }
                }
            }
            return(valueMessage);
        }