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); })); }
public static ThresholdMessage GetThresholdMessageEatonPDU_M2(DevModelConfig modelcfg, System.Collections.Generic.Dictionary <string, string> result) { ThresholdMessage thresholdMessage = new ThresholdMessage(); System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator(); 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>(); while (enumerator.MoveNext()) { string current = enumerator.Current; string text = result[current]; if (current.StartsWith(EatonInputCurrentMib_M2.Entry) || current.StartsWith(EatonInputVoltageMib_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(EatonOutletEntryMib_M2.Entry) || current.StartsWith(EatonOutletControlMib_M2.Entry)) { dictionary3.Add(current, text); } else { if (current.StartsWith(EatonGroupCurrentMib_M2.Entry) || current.StartsWith(EatonGroupVoltageMib_M2.Entry) || current.StartsWith(EatonGroupEntryMib_M2.Entry)) { dictionary4.Add(current, text); } else { if (current.StartsWith(EatonPDUBaseMib_M2.Mac)) { thresholdMessage.DeviceReplyMac = text.Replace(" ", ":").Replace("-", ":"); } else { if (current.StartsWith(EatonPDUBaseMib_M2.FWversion)) { thresholdMessage.DeviceFWVer = text; } else { if (current.StartsWith(EatonPDUBaseMib_M2.DeviceName)) { if ("\0".Equals(text) || string.IsNullOrEmpty(text)) { text = string.Empty; } thresholdMessage.DeviceName = text; } } } } } } } } if (dictionary != null && dictionary.Count > 0) { thresholdMessage.DeviceThreshold = EatonMibParser.GetDeviceThreshold(dictionary); } if (dictionary3 != null && dictionary3.Count > 0) { thresholdMessage.OutletThreshold = EatonMibParser.GetOutletThreshold(dictionary3); } if (dictionary2 != null && dictionary2.Count > 0) { thresholdMessage.SensorThreshold = EatonMibParser.GetSensorThreshold(dictionary2); } if (dictionary4 != null && dictionary4.Count > 0) { thresholdMessage.BankThreshold = EatonMibParser.GetBankThreshold(dictionary4); } return(thresholdMessage); }
public static ThresholdMessage GetThresholdMessageApcPDU(DevModelConfig modelcfg, System.Collections.Generic.Dictionary <string, string> result) { ThresholdMessage thresholdMessage = new ThresholdMessage(); System.Collections.Generic.IEnumerator <string> enumerator = result.Keys.GetEnumerator(); 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>(); new System.Collections.Generic.Dictionary <string, string>(); System.Collections.Generic.Dictionary <string, string> dictionary3 = new System.Collections.Generic.Dictionary <string, string>(); while (enumerator.MoveNext()) { string current = enumerator.Current; string text = result[current]; if (current.StartsWith(ApcPDUBaseMib.Mac)) { thresholdMessage.DeviceReplyMac = text.Replace(" ", ":").Replace("-", ":"); } else { if (current.StartsWith(ApcPDUBaseMib.FWversion)) { text = text.Replace("v", ""); text = text.Replace("V", ""); thresholdMessage.DeviceFWVer = text; } else { if (current.StartsWith(ApcPDUBaseMib.DeviceName)) { if ("\0".Equals(text) || string.IsNullOrEmpty(text)) { text = string.Empty; } thresholdMessage.DeviceName = text; } else { if (current.StartsWith(ApcDeviceConfigMib.Entry) || current.StartsWith(ApcPhaseConfigMib.Entry)) { dictionary.Add(current, text); } else { if (current.StartsWith(ApcBankConfigMib.Entry)) { dictionary3.Add(current, text); } else { if (current.StartsWith(ApcSensorConfigMib.Entry)) { dictionary2.Add(current, text); } } } } } } } if (dictionary != null && dictionary.Count > 0) { thresholdMessage.DeviceThreshold = ApcMibParser.GetDeviceThreshold(dictionary); } if (dictionary3 != null && dictionary3.Count > 0) { thresholdMessage.BankThreshold = ApcMibParser.GetBankThreshold(dictionary3); } if (dictionary2 != null && dictionary2.Count > 0) { thresholdMessage.SensorThreshold = ApcMibParser.GetSensorThreshold(dictionary2); } else { thresholdMessage.SensorThreshold = ApcMibParser.GetSensorThreshold_Empty(dictionary2); } return(thresholdMessage); }