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

Public Member Functions

override TimeServer Import (int orgId)
 

Protected Attributes

override string Provider => "support.ntp.org"
 
- Protected Attributes inherited from Ntp.Analyzer.Data.Import.TimeServerWebAdapter
readonly LogBase Log
 

Package Functions

 TimeServerLoader (LogBase log)
 

Private Member Functions

string ImportServer (int orgId)
 

Private Attributes

const string ServerTagEnd = @"</div><!-- /twikiForm --></div><!-- /patternContent-->"
 
const string ServerTagStart = @"<div class=""twikiAfterText""></div><div class=""twikiForm"">"
 

Additional Inherited Members

- Static Public Member Functions inherited from Ntp.Analyzer.Data.Import.TimeServerWebAdapter
static TimeServerWebAdapter Create (LogBase log)
 
static void Initialize (bool enable)
 
- Protected Member Functions inherited from Ntp.Analyzer.Data.Import.TimeServerWebAdapter
 TimeServerWebAdapter (LogBase log)
 
string FetchHtml (string url, int orgId)
 
- Properties inherited from Ntp.Analyzer.Data.Import.TimeServerWebAdapter
abstract string Provider [get]
 

Detailed Description

Definition at line 30 of file TimeServerLoader.cs.

Constructor & Destructor Documentation

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

Definition at line 32 of file TimeServerLoader.cs.

33  : base(log)
34  {
35  }

Member Function Documentation

override TimeServer Ntp.Analyzer.Data.Import.TimeServerLoader.Import ( int  orgId)
inlinevirtual

Implements Ntp.Analyzer.Data.Import.TimeServerWebAdapter.

Definition at line 42 of file TimeServerLoader.cs.

43  {
44  string table = ImportServer(orgId);
45  if (table == null)
46  return null;
47 
48  var importer = new TimeServerImporter(Log);
49  var server = importer.ParseTable(table, orgId);
50  return server;
51  }
string Ntp.Analyzer.Data.Import.TimeServerLoader.ImportServer ( int  orgId)
inlineprivate

Definition at line 53 of file TimeServerLoader.cs.

References e.

54  {
55  string orgString = orgId.ToString(CultureInfo.InvariantCulture).PadLeft(6, '0');
56  string url = $"http://support.ntp.org/bin/view/Servers/PublicTimeServer{orgString}";
57  string html = FetchHtml(url, orgId);
58 
59  if (html == null)
60  return null;
61 
62  html = html.Replace("<nos>", string.Empty);
63 
64  try
65  {
66  int serverTagPos = html.IndexOf(ServerTagStart, StringComparison.Ordinal);
67  int tableStartPos = html.IndexOf("<table", serverTagPos, StringComparison.Ordinal);
68  int tableEndPos = html.IndexOf(ServerTagEnd, serverTagPos, StringComparison.Ordinal);
69  string table = html.Substring(tableStartPos, tableEndPos - tableStartPos);
70  return table;
71  }
72  catch (Exception e)
73  {
74  Log.TimeServerParseError("HTML", e);
75  return null;
76  }
77  }
var e
Definition: bootstrap.min.js:6

Member Data Documentation

override string Ntp.Analyzer.Data.Import.TimeServerLoader.Provider => "support.ntp.org"
protected

Definition at line 40 of file TimeServerLoader.cs.

const string Ntp.Analyzer.Data.Import.TimeServerLoader.ServerTagEnd = @"</div><!-- /twikiForm --></div><!-- /patternContent-->"
private

Definition at line 38 of file TimeServerLoader.cs.

const string Ntp.Analyzer.Data.Import.TimeServerLoader.ServerTagStart = @"<div class=""twikiAfterText""></div><div class=""twikiForm"">"
private

Definition at line 37 of file TimeServerLoader.cs.


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