Example #1
0
        override public string ToString()
        {
            var keyXML  = XmlNode.SelectSingleNode("ComponentKey");
            var itemKey = new CCMModelItemKey(keyXML);

            return(itemKey.ToStringOneLine());
        }
Example #2
0
        public NodeItem(XmlNode node)
        {
            var keyXML = node.SelectSingleNode("ComponentKey");

            if (keyXML == null)
            {
                return;
            }

            var attrXML = node.SelectSingleNode("Attributes");

            if (attrXML == null)
            {
                return;
            }

            var element = keyXML.SelectSingleNode("Type");

            if (element != null)
            {
                var type = element.InnerText.Trim();
                if (CCMModelItemKey.ShouldTypeIgnoreHostInKey(type))
                {
                    keyXML = keyXML.CloneNode(true); // to make sure host is still part of the original node. We only want to remove it from the key
                    var host = keyXML.SelectSingleNode("Host");
                    if (host != null)
                    {
                        keyXML.RemoveChild(host);
                    }
                }
            }

            Key = keyXML.InnerText;

            // CMS updates the LastUpdate field every tike it gets data from CTM, even if no chagne was done.
            // Since we compare old and new Attr to check if the component were changed, we ignore the LastUpdate field
            // so we only identify real updates.
            var    lastUpdateField = attrXML.SelectSingleNode("LastUpdate");
            string lastUpdate      = null;

            if (lastUpdateField != null)
            {
                lastUpdate = lastUpdateField.InnerText;
                lastUpdateField.InnerText = string.Empty;
            }

            Attr = attrXML.InnerText;

            if (lastUpdateField != null)
            {
                lastUpdateField.InnerText = lastUpdate;
            }

            XmlNode = node;

            IsFiltered = false; // by default
        }
Example #3
0
        public void UpdateParentComponentKey(XmlNode xmlNode)
        {
            Debug.Assert(xmlNode != null, "_xmlNode is not initialized");

            var parentComponentKey = xmlNode.SelectSingleNode("../../" + "ComponentKey");

            if (parentComponentKey != null)
            {
                ParentComponentKey = new CCMModelItemKey(parentComponentKey);
            }
        }
Example #4
0
        public CCMModelItem(XmlNode xmlNode)
        {
            UpdateParentComponentKey(xmlNode);

            var nodeList = xmlNode.ChildNodes;

            foreach (XmlNode node in nodeList)
            {
                switch (node.Name)
                {
                case "ComponentKey":
                    ComponentKey = new CCMModelItemKey(node);
                    break;

                case "Attributes":
                    string xml = null;
                    try
                    {
                        xml        = string.Format("<{0}>{1}</{0}>", typeof(components_attributes_type).Name, node.InnerXml);
                        Attributes = DeserializeXML <components_attributes_type>(xml);

                        // we need to trim values, as they might not be trimmed in the XML
                        Attributes.CurrentState = TrimIfNeeded(Attributes.CurrentState);
                        Attributes.DesiredState = TrimIfNeeded(Attributes.DesiredState);
                        Attributes.Status       = TrimIfNeeded(Attributes.Status);
                        //Attributes.StatusMessage = TrimIfNeeded(Attributes.StatusMessage);
                        Attributes.OSType           = TrimIfNeeded(Attributes.OSType);
                        Attributes.Version          = TrimIfNeeded(Attributes.Version);
                        Attributes.AdminAgentStatus = TrimIfNeeded(Attributes.AdminAgentStatus);
                    }
                    catch (Exception ex)
                    {
                        Attributes = new components_attributes_type
                        {
                            Status = "3",
                            //  StatusMessage = GetXMLNodeErrorMessage(ex, xml),
                        };
                    }
                    break;
                    //case CCMSchemaTags.TAG_Sub_components:
                    // do nothing - we only keep reference to its parent
                    break;

                default:
                    break;
                }
            }

            if (ComponentKey == null)
            {
                ComponentKey = new CCMModelItemKey();
            }
        }