NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Render.Host.DefaultHostPageRender Class Reference
Inheritance diagram for Ntp.Analyzer.Render.Host.DefaultHostPageRender:
Collaboration diagram for Ntp.Analyzer.Render.Host.DefaultHostPageRender:

Public Member Functions

 DefaultHostPageRender (HostPageConfiguration config, string ip, int refresh)
 
override string Render ()
 
override string RenderFooter ()
 
override string RenderHead ()
 
- Public Member Functions inherited from Ntp.Analyzer.Render.HtmlObjectRender
void Add (IHtmlObject child)
 

Private Attributes

readonly HostPageConfiguration config
 
readonly string ip
 
readonly int refresh
 

Additional Inherited Members

- Public Attributes inherited from Ntp.Analyzer.Render.HtmlObjectRender
IEnumerable< IHtmlObjectChildren => children.ToArray()
 
- Protected Member Functions inherited from Ntp.Analyzer.Render.HtmlObjectRender
 HtmlObjectRender (Uri webPath)
 
- Properties inherited from Ntp.Analyzer.Render.HtmlObjectRender
Uri WebPath [get]
 
- Properties inherited from Ntp.Analyzer.Render.IHtmlObject
IEnumerable< IHtmlObjectChildren [get]
 
Uri WebPath [get]
 

Detailed Description

Definition at line 30 of file DefaultHostPageRender.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Render.Host.DefaultHostPageRender.DefaultHostPageRender ( HostPageConfiguration  config,
string  ip,
int  refresh 
)
inline

Definition at line 32 of file DefaultHostPageRender.cs.

33  : base(config.WebPath)
34  {
35  this.config = config;
36  this.ip = ip;
37  this.refresh = refresh;
38  }
Uri WebPath
Gets the web path in the HostSubConfiguration.

Member Function Documentation

override string Ntp.Analyzer.Render.Host.DefaultHostPageRender.Render ( )
inline

Implements Ntp.Analyzer.Render.IHtmlObject.

Definition at line 44 of file DefaultHostPageRender.cs.

45  {
46  return "<body>";
47  }
override string Ntp.Analyzer.Render.Host.DefaultHostPageRender.RenderFooter ( )
inlinevirtual

Implements Ntp.Analyzer.Render.HtmlObjectRender.

Definition at line 49 of file DefaultHostPageRender.cs.

50  {
51  var builder = new StringBuilder();
52  builder.AppendLine(string.Empty);
53 
54  DateTime now = DateTime.Now;
55 
56  builder.AppendLine("<br>");
57 
58  if (config.ShowUtc == DateTimeKind.Utc)
59  {
60  builder.Append("Time is ");
61  builder.Append(now.ToLongDateString() + " ");
62  builder.Append(TimeZoneInfo.Utc.StandardName);
63  }
64  else
65  {
66  builder.Append("Local time is ");
67  builder.Append(now.ToLongDateString() + " ");
68  builder.Append(TimeZoneInfo.Local.IsDaylightSavingTime(now)
69  ? TimeZoneInfo.Local.DaylightName
70  : TimeZoneInfo.Local.StandardName);
71  }
72  builder.Append(" " + now.ToShortTimeString() + ". ");
73 
74  builder.AppendLine("<br><br>");
75  if (config.PoolMember)
76  {
77  string poolLink = "http://www.pool.ntp.org/scores/" + ip;
78  string poolText = $@"<a href=""{poolLink}"">pool.ntp.org</a>";
79  builder.Append("Server is pool member on ");
80  builder.Append(poolText);
81  }
82 
83  if (config.PeerSummaries.Pages.Count() != 0)
84  {
85  builder.AppendLine("<br><br>");
86  builder.Append("Peer graphs are available with ");
87  builder.Append(@"<a href=""");
88  builder.Append(config.PeerSummaries.Pages.First().Link.ToHtmlString());
89  builder.Append(@""">");
90  builder.Append(config.PeerSummaries.Pages.First().Title);
91  builder.Append(@"</a> and ");
92  builder.Append(@"<a href=""");
93  builder.Append(config.PeerSummaries.Pages.ToList()[1].Link.ToHtmlString());
94  builder.Append(@""">");
95  builder.Append(config.PeerSummaries.Pages.ToList()[1].Title);
96  builder.Append(@"</a>.");
97  }
98 
99  builder.AppendLine("<br><br>");
100  builder.AppendLine("Page refreshes every 5 minutes.");
101 
102  builder.AppendLine("</body>");
103  builder.AppendLine("</html>");
104 
105  return builder.ToString();
106  }
SummaryCollection PeerSummaries
Gets the peer summeries to be linked from this page.
override string Ntp.Analyzer.Render.Host.DefaultHostPageRender.RenderHead ( )
inlinevirtual

Implements Ntp.Analyzer.Render.HtmlObjectRender.

Definition at line 108 of file DefaultHostPageRender.cs.

109  {
110  var builder = new StringBuilder();
111 
112  builder.AppendLine("<!DOCTYPE html>");
113  builder.AppendLine("<html><head>");
114  builder.AppendLine(@"<meta charset=""UTF-8"">");
115  builder.AppendLine(@"<style type=""text/css"" media=""screen"">");
116  builder.AppendLine("body {font-family: monospace; line-height:100%; }");
117  builder.AppendLine("table { border-collapse:collapse; border-spacing: 0; width: 940px; }");
118  builder.AppendLine(
119  "th { text-align: left; font-weight: bold; border-bottom: 2px solid; padding: 0px; padding-top: 5px; padding-bottom: 3px;}");
120  builder.AppendLine(
121  "td { padding: 0px; padding-right: 7px; padding-left: 2px; padding-top: 2px; padding-bottom: 2px; }");
122  builder.AppendLine("td.aright { text-align: right; padding-right: 17px;}");
123  builder.AppendLine("td.spc { padding: 0px; line-height: 5px; }");
124  builder.AppendLine("td.but { border-top: 2px solid; padding: 0px; padding-top: 2px; line-height: 7px; }");
125  builder.AppendLine("a:link { color:#33348e; text-decoration: none; }");
126  builder.AppendLine("a:visited { color:#33348e; text-decoration: none; }");
127  builder.AppendLine("a:hover { color:#33348e; text-decoration: underline;; }");
128  builder.AppendLine("a:active { color:#7476b4; text-decoration: underline; }");
129  builder.AppendLine("</style>");
130  builder.AppendLine("<title>");
131  builder.AppendLine(config.ServerName);
132  builder.AppendLine("</title>");
133  builder.AppendLine($@"<meta http-equiv=""refresh"" content=""{refresh}"">");
134  builder.AppendLine("</head>");
135  return builder.ToString();
136  }
string ServerName
Gets the name of the server in the HostSubConfiguration.

Member Data Documentation

readonly HostPageConfiguration Ntp.Analyzer.Render.Host.DefaultHostPageRender.config
private

Definition at line 40 of file DefaultHostPageRender.cs.

readonly string Ntp.Analyzer.Render.Host.DefaultHostPageRender.ip
private

Definition at line 41 of file DefaultHostPageRender.cs.

readonly int Ntp.Analyzer.Render.Host.DefaultHostPageRender.refresh
private

Definition at line 42 of file DefaultHostPageRender.cs.


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