Пример #1
0
        public void FromXml(string content)
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(content);
            XmlElement root = xdoc.DocumentElement;

            State = CollectorStateConverter.GetCollectorStateFromText(root.ReadXmlElementAttr("state", "NotAvailable"));
            try
            {
                StateChangedTime = DateTime.Parse(root.ReadXmlElementAttr("stateChangedTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            }
            catch { }
            try
            {
                Timestamp = DateTime.Parse(root.ReadXmlElementAttr("timeStamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            }
            catch { }
            try
            {
                CallDurationMS = root.ReadXmlElementAttr("callDurationMS", 0);
            }
            catch { }
            CurrentValue           = root.ReadXmlElementAttr("currentValue", "");
            ExecutedOnHostComputer = root.ReadXmlElementAttr("executedOnHostComputer", "");
            RawDetails             = root.SelectSingleNode("rawDetails").InnerText;
            HtmlDetails            = root.SelectSingleNode("htmlDetails").InnerText;
            XmlNodeList alertNodes = root.SelectNodes("alerts");

            AlertsRaised = new List <string>();
            foreach (XmlNode alertNode in alertNodes)
            {
                AlertsRaised.Add(alertNode.InnerText);
            }
        }
Пример #2
0
        public void FromXml(string content)
        {
            XmlDocument xdoc = new XmlDocument();

            xdoc.LoadXml(content);
            XmlElement root = xdoc.DocumentElement;

            UniqueId = root.ReadXmlElementAttr("uniqueId", Guid.NewGuid().ToString());
            State    = CollectorStateConverter.GetCollectorStateFromText(root.ReadXmlElementAttr("state", "NotAvailable"));
            try
            {
                StateChangedTime = DateTime.Parse(root.ReadXmlElementAttr("stateChangedTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            }
            catch { }
            try
            {
                Timestamp = DateTime.Parse(root.ReadXmlElementAttr("timeStamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
            }
            catch { }
            try
            {
                CallDurationMS = root.ReadXmlElementAttr("callDurationMS", 0);
            }
            catch { }
            ForAgent               = root.ReadXmlElementAttr("forAgent", "");
            ForAgentType           = root.ReadXmlElementAttr("forAgentType", "");
            ForAgentId             = root.ReadXmlElementAttr("forAgentId", -1);
            CurrentValue           = root.ReadXmlElementAttr("currentValue", "");
            PrimaryUIValue         = root.ReadXmlElementAttr("primaryUIValue", false);
            ExecutedOnHostComputer = root.ReadXmlElementAttr("executedOnHostComputer", "");
            RanAs       = root.ReadXmlElementAttr("ranAs", "");
            RepeatCount = root.ReadXmlElementAttr("repeatCount", 0);
            try
            {
                AlertHeader = root.SelectSingleNode("alertHeader").InnerText;
            }
            catch { }
            try
            {
                AlertFooter = root.SelectSingleNode("alertFooter").InnerText;
            }
            catch { }
            try
            {
                AdditionalAlertText = root.SelectSingleNode("additionalAlertText").InnerText;
            }
            catch { }

            RawDetails  = root.SelectSingleNode("rawDetails").InnerText;
            HtmlDetails = root.SelectSingleNode("htmlDetails").InnerText;
            XmlNodeList alertNodes = root.SelectNodes("alerts");

            AlertsRaised = new List <string>();
            foreach (XmlNode alertNode in alertNodes)
            {
                if (alertNode.InnerText.Trim().Length > 0)
                {
                    AlertsRaised.Add(alertNode.InnerText);
                }
            }

            XmlNodeList scriptsRanNodes = root.SelectNodes("scriptsRan");

            ScriptsRan = new List <string>();
            foreach (XmlNode scriptNode in scriptsRanNodes)
            {
                if (scriptNode.InnerText.Trim().Length > 0)
                {
                    ScriptsRan.Add(scriptNode.InnerText);
                }
            }

            ChildStates = new List <MonitorState>();
            XmlNodeList childStates = root.SelectNodes("childStates/monitorState");

            foreach (XmlNode childStateNode in childStates)
            {
                MonitorState childState = new MonitorState();
                childState.FromXml(childStateNode.OuterXml);
                ChildStates.Add(childState);
            }
        }