NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Data.Import.TimeServerImporter Class Reference
Collaboration diagram for Ntp.Analyzer.Data.Import.TimeServerImporter:

Package Functions

 TimeServerImporter (LogBase log)
 
TimeServer ParseTable (string table, int orgId)
 

Private Member Functions

bool GetBool (string boolString)
 

Private Attributes

readonly LogBase log
 

Detailed Description

Definition at line 31 of file TimeServerImporter.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Data.Import.TimeServerImporter.TimeServerImporter ( LogBase  log)
inlinepackage

Definition at line 33 of file TimeServerImporter.cs.

34  {
35  this.log = log;
36  }

Member Function Documentation

bool Ntp.Analyzer.Data.Import.TimeServerImporter.GetBool ( string  boolString)
inlineprivate

Definition at line 150 of file TimeServerImporter.cs.

151  {
152  string test = boolString.Trim().ToLower();
153 
154  if (test == "yes")
155  return true;
156  if (test == "no")
157  return false;
158  if (test == string.Empty)
159  return null;
160 
161  throw new ApplicationException("Unknown boolean type.");
162  }
TimeServer Ntp.Analyzer.Data.Import.TimeServerImporter.ParseTable ( string  table,
int  orgId 
)
inlinepackage

Definition at line 40 of file TimeServerImporter.cs.

References e.

41  {
42  if (table == null)
43  {
44  log.WriteLine("Not parsing empty HTML.", Severity.Debug);
45  return null;
46  }
47 
48  try
49  {
50  var doc = new XmlDocument();
51  doc.LoadXml(table);
52 
53  XmlNodeList rows = doc.ChildNodes[0].ChildNodes;
54 
55  bool firstRow = true;
56 
57  var entries = new Dictionary<string, string>();
58 
59  foreach (XmlNode node in rows)
60  {
61  if (firstRow)
62  {
63  firstRow = false;
64  continue;
65  }
66 
67  entries.Add(
68  node.ChildNodes[0].InnerText.Trim(),
69  node.ChildNodes[1].InnerText.Trim()
70  );
71  }
72 
73  if (!entries.ContainsKey("IPv6 Address"))
74  {
75  entries.Add("IPv6 Address", string.Empty);
76  }
77  if (!entries.ContainsKey("HostOrganization"))
78  {
79  entries.Add("HostOrganization", string.Empty);
80  }
81  if (!entries.ContainsKey("AutoKeyURL"))
82  {
83  entries.Add("AutoKeyURL", string.Empty);
84  }
85  if (!entries.ContainsKey("SymmetricKeyType"))
86  {
87  entries.Add("SymmetricKeyType", string.Empty);
88  }
89  if (!entries.ContainsKey("SymmetricKeyURL"))
90  {
91  entries.Add("SymmetricKeyURL", string.Empty);
92  }
93 
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"];
114 
115  int stratus;
116 
117  if (stratusStr == "StratumOne")
118  {
119  stratus = 1;
120  }
121  else if (stratusStr == "StratumTwo")
122  {
123  stratus = 2;
124  }
125  else
126  {
127  stratus = 19;
128  }
129 
130  IPAddress address;
131  IPAddress.TryParse(ip, out address);
132 
133  bool? useDns = GetBool(useDnsStr);
134  bool? poolMember = GetBool(poolMemberStr);
135  bool? notification = GetBool(notificationStr);
136 
137  return new CalgaryTimeServer(
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);
141  }
142  catch (Exception e)
143  {
144  log.WriteLine("Could not parse TimeServer HTML.", Severity.Error);
145  log.WriteLine(e);
146  return null;
147  }
148  }
abstract void WriteLine(string text, Severity severity)
var e
Definition: bootstrap.min.js:6

Member Data Documentation

readonly LogBase Ntp.Analyzer.Data.Import.TimeServerImporter.log
private

Definition at line 38 of file TimeServerImporter.cs.


The documentation for this class was generated from the following file: