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

Public Member Functions

abstract TimeServer Import (int orgId)
 

Static Public Member Functions

static TimeServerWebAdapter Create (LogBase log)
 
static void Initialize (bool enable)
 

Protected Member Functions

 TimeServerWebAdapter (LogBase log)
 
string FetchHtml (string url, int orgId)
 

Protected Attributes

readonly LogBase Log
 

Properties

abstract string Provider [get]
 

Private Member Functions

string Download (string url, int orgId)
 

Static Private Attributes

static bool enabled
 

Detailed Description

Definition at line 31 of file TimeServerWebAdapter.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Data.Import.TimeServerWebAdapter.TimeServerWebAdapter ( LogBase  log)
inlineprotected

Definition at line 33 of file TimeServerWebAdapter.cs.

34  {
35  Log = log;
36  }

Member Function Documentation

static TimeServerWebAdapter Ntp.Analyzer.Data.Import.TimeServerWebAdapter.Create ( LogBase  log)
inlinestatic

Definition at line 44 of file TimeServerWebAdapter.cs.

Referenced by Ntp.Analyzer.Data.Sql.TimeServerDatabaseMapper.FetchExternal().

45  {
46  // Use the ExactlyAdapter for now
47  return enabled ? new ExactlyAdapter(log) : null;
48  }

Here is the caller graph for this function:

string Ntp.Analyzer.Data.Import.TimeServerWebAdapter.Download ( string  url,
int  orgId 
)
inlineprivate

Definition at line 73 of file TimeServerWebAdapter.cs.

References e.

74  {
75  try
76  {
77  var client = new WebClient();
78  // TODO: Set timeout
79  client.Headers.Add(
80  "user-agent",
81  "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;)"
82  );
83 
84  var stream = client.OpenRead(url);
85  Log.TimeServerDownload(Provider, url, orgId);
86 
87  if (stream != null)
88  {
89  var reader = new StreamReader(stream);
90  string html = reader.ReadToEnd();
91  reader.Close();
92  return html;
93  }
94  }
95  catch (WebException e)
96  {
97  var response = e.Response as HttpWebResponse;
98  if (response != null && response.StatusCode == HttpStatusCode.NotFound)
99  {
100  Log.TimeServerNotFound(Provider, orgId);
101  }
102  else
103  {
104  Log.TimeServerError(Provider, orgId);
105  }
106 
107  Log.WriteLine(e);
108  }
109  catch (Exception e)
110  {
111  Log.TimeServerError(Provider, orgId);
112  Log.WriteLine(e);
113  }
114 
115  return null;
116  }
abstract void WriteLine(string text, Severity severity)
var e
Definition: bootstrap.min.js:6
string Ntp.Analyzer.Data.Import.TimeServerWebAdapter.FetchHtml ( string  url,
int  orgId 
)
inlineprotected

Definition at line 57 of file TimeServerWebAdapter.cs.

58  {
59  if (orgId >= 5000)
60  {
61  Log.TimeServerMaxId(Provider);
62  return null;
63  }
64 
65  string html = Download(url, orgId);
66  if (html != null)
67  return html;
68 
69  Log.TimeServerNotReceived(orgId);
70  return null;
71  }
abstract TimeServer Ntp.Analyzer.Data.Import.TimeServerWebAdapter.Import ( int  orgId)
pure virtual
static void Ntp.Analyzer.Data.Import.TimeServerWebAdapter.Initialize ( bool  enable)
inlinestatic

Definition at line 52 of file TimeServerWebAdapter.cs.

Referenced by Ntp.Analyzer.Process.Initializer.InitializeData().

53  {
54  enabled = enable;
55  }

Here is the caller graph for this function:

Member Data Documentation

bool Ntp.Analyzer.Data.Import.TimeServerWebAdapter.enabled
staticprivate

Definition at line 38 of file TimeServerWebAdapter.cs.

readonly LogBase Ntp.Analyzer.Data.Import.TimeServerWebAdapter.Log
protected

Definition at line 40 of file TimeServerWebAdapter.cs.

Property Documentation

abstract string Ntp.Analyzer.Data.Import.TimeServerWebAdapter.Provider
getprotected

Definition at line 42 of file TimeServerWebAdapter.cs.


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