internal static EventLogData GetEventLogData(Ipmi.EventLogMsgType eventType, int number, int offset) { EventLogData logDataQuery = (from eventLog in EventStrings where eventLog.Number == number && eventLog.OffSet == offset && eventLog.MessageClass == eventType select eventLog).FirstOrDefault(); if (logDataQuery != null) { // Create new instance of EventLogData to avoid overwriting EventMessage and Description EventLogData tempData = new EventLogData(logDataQuery.Number, logDataQuery.OffSet, logDataQuery.MessageClass, string.Copy(logDataQuery.EventMessage), string.Copy(logDataQuery.Description)); return(tempData); } else { return(new EventLogData()); } }
private static List<EventLogData> XmlToObject(string xmlTag, XmlDocument xmlEventLogDoc) { List<EventLogData> response = new List<EventLogData>(); try { XmlNodeList rootNodeList = xmlEventLogDoc.GetElementsByTagName(xmlTag); if (rootNodeList.Count > 0) { // root level node: EventLogTypeCode foreach (XmlNode root in rootNodeList) { // GenericEvent/SensorSpecificEvent foreach (XmlNode node in root.ChildNodes) { EventLogMsgType clasification = GetEventLogClass(node.Name.ToString()); XmlNodeList firstTierNodes = node.ChildNodes; // enumerate first level child nodes foreach (XmlNode firstNode in firstTierNodes) { int number = Convert.ToInt32(firstNode.Attributes["Number"].Value.ToString()); string description = firstNode.Attributes["ReadingClass"].Value.ToString(); XmlNodeList secondTierNodes = firstNode.ChildNodes; // enumerate second level xml nodes foreach (XmlNode secondNode in secondTierNodes) { int offset = Convert.ToInt32(secondNode.Attributes["Number"].Value.ToString()); string message = secondNode.Attributes["Description"].Value.ToString(); EventLogData respObj = new EventLogData(number, offset, clasification, message, description); XmlNodeList thirdTierNodes = secondNode.ChildNodes; if (thirdTierNodes.Count > 0) { // enumerate third level xml nodes foreach (XmlNode extension in thirdTierNodes) { int id = Convert.ToInt32(extension.Attributes["Number"].Value.ToString()); string detail = extension.Attributes["Description"].Value.ToString(); respObj.AddExtension(id, detail); } // enumerate third level xml nodes } response.Add(respObj); } // enumerate second level xml nodes } // enumerate first level child nodes } // GenericEvent/SensorSpecificEvent } } else { Tracer.WriteWarning("ERROR: Could not load Event Log Strings, could not find xml root node in file"); } } catch (Exception ex) { Tracer.WriteError(string.Format("ERROR: Could not load Event Log Strings. Error: {0}", ex.ToString())); } return response; }
private static List <EventLogData> XmlToObject(string xmlTag, XmlDocument xmlEventLogDoc) { List <EventLogData> response = new List <EventLogData>(); try { XmlNodeList rootNodeList = xmlEventLogDoc.GetElementsByTagName(xmlTag); if (rootNodeList.Count > 0) { // root level node: EventLogTypeCode foreach (XmlNode root in rootNodeList) { // GenericEvent/SensorSpecificEvent foreach (XmlNode node in root.ChildNodes) { EventLogMsgType clasification = GetEventLogClass(node.Name.ToString()); XmlNodeList firstTierNodes = node.ChildNodes; // enumerate first level child nodes foreach (XmlNode firstNode in firstTierNodes) { int number = Convert.ToInt32(firstNode.Attributes["Number"].Value.ToString()); string description = firstNode.Attributes["ReadingClass"].Value.ToString(); XmlNodeList secondTierNodes = firstNode.ChildNodes; // enumerate second level xml nodes foreach (XmlNode secondNode in secondTierNodes) { int offset = Convert.ToInt32(secondNode.Attributes["Number"].Value.ToString()); string message = secondNode.Attributes["Description"].Value.ToString(); EventLogData respObj = new EventLogData(number, offset, clasification, message, description); XmlNodeList thirdTierNodes = secondNode.ChildNodes; if (thirdTierNodes.Count > 0) { // enumerate third level xml nodes foreach (XmlNode extension in thirdTierNodes) { int id = Convert.ToInt32(extension.Attributes["Number"].Value.ToString()); string detail = extension.Attributes["Description"].Value.ToString(); respObj.AddExtension(id, detail); } // enumerate third level xml nodes } response.Add(respObj); } // enumerate second level xml nodes } // enumerate first level child nodes } // GenericEvent/SensorSpecificEvent } } else { Tracer.WriteWarning("ERROR: Could not load Event Log Strings, could not find xml root node in file"); } } catch (Exception ex) { Tracer.WriteError(string.Format("ERROR: Could not load Event Log Strings. Error: {0}", ex.ToString())); } return(response); }
internal static EventLogData GetEventLogData(Ipmi.EventLogMsgType eventType, int number, int offset) { EventLogData logDataQuery = (from eventLog in EventStrings where eventLog.Number == number && eventLog.OffSet == offset && eventLog.MessageClass == eventType select eventLog).FirstOrDefault(); if (logDataQuery != null) { // Create new instance of EventLogData to avoid overwriting EventMessage and Description EventLogData tempData = new EventLogData(logDataQuery.Number, logDataQuery.OffSet, logDataQuery.MessageClass, string.Copy(logDataQuery.EventMessage), string.Copy(logDataQuery.Description)); return tempData; } else { return new EventLogData(); } }