private void GetXenServerVersions(XmlDocument xdoc) { if (!_checkForServerVersion && !_checkForPatches) { return; } foreach (XmlNode versions in xdoc.GetElementsByTagName(XenServerVersionsNode)) { foreach (XmlNode version in versions.ChildNodes) { string version_oem = ""; string name = ""; bool is_latest = false; bool is_latest_cr = false; string url = ""; string timestamp = ""; string buildNumber = ""; string patchUuid = ""; bool presentAsUpdate = false; string minXcVersion = ""; foreach (XmlAttribute attrib in version.Attributes) { if (attrib.Name == "value") { version_oem = attrib.Value; } else if (attrib.Name == "name") { name = attrib.Value; } else if (attrib.Name == "latest") { is_latest = attrib.Value.ToUpperInvariant() == bool.TrueString.ToUpperInvariant(); } else if (attrib.Name == "latestcr") { is_latest_cr = attrib.Value.ToUpperInvariant() == bool.TrueString.ToUpperInvariant(); } else if (attrib.Name == "url") { url = attrib.Value; } else if (attrib.Name == "timestamp") { timestamp = attrib.Value; } else if (attrib.Name == "build-number") { buildNumber = attrib.Value; } else if (attrib.Name == "patch-uuid") { patchUuid = attrib.Value; } else if (attrib.Name == "present-as-update") { presentAsUpdate = attrib.Value.ToUpperInvariant() == bool.TrueString.ToUpperInvariant(); } else if (attrib.Name == "minimum-xc-version") { minXcVersion = attrib.Value; } } List <XenServerPatch> patches = new List <XenServerPatch>(); List <XenServerPatch> minimalPatches = null; //keep it null to indicate that there is no a minimalpatches tag foreach (XmlNode childnode in version.ChildNodes) { if (childnode.Name == "minimalpatches") { minimalPatches = new List <XenServerPatch>(); foreach (XmlNode minimalpatch in childnode.ChildNodes) { if (minimalpatch.Name != "patch") { continue; } XenServerPatch mp = XenServerPatches.Find(p => string.Equals(p.Uuid, minimalpatch.Attributes["uuid"].Value, StringComparison.OrdinalIgnoreCase)); if (mp == null) { continue; } minimalPatches.Add(mp); } } if (childnode.Name == "patch") { XenServerPatch patch = XenServerPatches.Find(item => string.Equals(item.Uuid, childnode.Attributes["uuid"].Value, StringComparison.OrdinalIgnoreCase)); if (patch == null) { continue; } patches.Add(patch); } } XenServerVersions.Add(new XenServerVersion(version_oem, name, is_latest, is_latest_cr, url, patches, minimalPatches, timestamp, buildNumber, patchUuid, presentAsUpdate, minXcVersion)); } } }
private void GetXenServerVersions(XmlDocument xdoc) { if (!_checkForServerVersion && !_checkForPatches) { return; } foreach (XmlNode versions in xdoc.GetElementsByTagName(XenServerVersionsNode)) { foreach (XmlNode version in versions.ChildNodes) { string version_oem = ""; string name = ""; bool is_latest = false; string url = ""; string timestamp = ""; string buildNumber = ""; foreach (XmlAttribute attrib in version.Attributes) { if (attrib.Name == "value") { version_oem = attrib.Value; } else if (attrib.Name == "name") { name = attrib.Value; } else if (attrib.Name == "latest") { is_latest = attrib.Value.ToUpperInvariant() == bool.TrueString.ToUpperInvariant(); } else if (attrib.Name == "url") { url = attrib.Value; } else if (attrib.Name == "timestamp") { timestamp = attrib.Value; } else if (attrib.Name == "build-number") { buildNumber = attrib.Value; } } List <XenServerPatch> patches = new List <XenServerPatch>(); foreach (XmlNode childnode in version.ChildNodes) { if (childnode.Name != "patch") { continue; } XenServerPatch patch = XenServerPatches.Find(item => item.Uuid == childnode.Attributes["uuid"].Value); if (patch == null) { continue; } patches.Add(patch); } XenServerVersions.Add(new XenServerVersion(version_oem, name, is_latest, url, patches, timestamp, buildNumber)); } } }