23 using System.Collections.Generic;
29 namespace Ntp.Analyzer.Data.Import
44 log.WriteLine(
"Not parsing empty HTML.",
Severity.Debug);
50 var doc =
new XmlDocument();
53 XmlNodeList rows = doc.ChildNodes[0].ChildNodes;
57 var entries =
new Dictionary<string, string>();
59 foreach (XmlNode node
in rows)
68 node.ChildNodes[0].InnerText.Trim(),
69 node.ChildNodes[1].InnerText.Trim()
73 if (!entries.ContainsKey(
"IPv6 Address"))
75 entries.Add(
"IPv6 Address",
string.Empty);
77 if (!entries.ContainsKey(
"HostOrganization"))
79 entries.Add(
"HostOrganization",
string.Empty);
81 if (!entries.ContainsKey(
"AutoKeyURL"))
83 entries.Add(
"AutoKeyURL",
string.Empty);
85 if (!entries.ContainsKey(
"SymmetricKeyType"))
87 entries.Add(
"SymmetricKeyType",
string.Empty);
89 if (!entries.ContainsKey(
"SymmetricKeyURL"))
91 entries.Add(
"SymmetricKeyURL",
string.Empty);
94 string stratusStr = entries[
"ServerStratum"];
95 string country = entries[
"CountryCode"];
96 string name = entries[
"Hostname"];
97 string ip = entries[
"IP Address"];
98 string ip6 = entries[
"IPv6 Address"];
99 string useDnsStr = entries[
"UseDNS"];
100 string poolMemberStr = entries[
"PoolMember"];
101 string location = entries[
"ServerLocation"];
102 string display = entries[
"ServerLocation"];
103 string org = entries[
"HostOrganization"];
104 string geo = entries[
"GeographicCoordinates"];
105 string server = entries[
"ServerSynchronization"];
106 string serviceArea = entries[
"ServiceArea"];
107 string accessPolicy = entries[
"AccessPolicy"];
108 string accessDetails = entries[
"AccessDetails"];
109 string notificationStr = entries[
"NotificationMessage"];
110 string autoKey = entries[
"AutoKeyURL"];
111 string symKey = entries[
"SymmetricKeyType"];
112 string symUrl = entries[
"SymmetricKeyURL"];
113 string contact = entries[
"ServerContact"];
117 if (stratusStr ==
"StratumOne")
121 else if (stratusStr ==
"StratumTwo")
131 IPAddress.TryParse(ip, out address);
133 bool? useDns = GetBool(useDnsStr);
134 bool? poolMember = GetBool(poolMemberStr);
135 bool? notification = GetBool(notificationStr);
138 orgId, stratus, country, name, address, ip6, useDns, poolMember, location,
139 display, org, geo, server, serviceArea, accessDetails, accessPolicy,
140 notification, autoKey, symKey, symUrl, contact, null, null, DateTime.Now);
144 log.WriteLine(
"Could not parse TimeServer HTML.",
Severity.Error);
152 string test = boolString.Trim().ToLower();
158 if (test ==
string.Empty)
161 throw new ApplicationException(
"Unknown boolean type.");
TimeServerImporter(LogBase log)
TimeServer ParseTable(string table, int orgId)
bool GetBool(string boolString)