23 using System.Globalization;
29 namespace Ntp.Analyzer.Render.
Peer 49 private readonly
string ip;
50 private readonly
string name;
51 private readonly DateTime
next;
52 private readonly DateTime
now;
55 private string Name =>
string.IsNullOrEmpty(server?.Name) ? name : server.Name;
57 private string StratumText
61 if (server == null || server.Stratum == 0)
64 switch (server.Stratum)
86 public string Time =>
string.Concat(
87 now.ToLongDateString(),
89 TimeZoneInfo.Local.IsDaylightSavingTime(now)
90 ? TimeZoneInfo.Local.DaylightName
91 : TimeZoneInfo.Local.StandardName,
93 now.ToLongTimeString()
96 public string Location =>
string.IsNullOrEmpty(server?.Location) ?
PageText.
HtmlBlank : server.Location;
98 private string ServerSync =>
string.IsNullOrEmpty(server?.Server) ?
PageText.
HtmlBlank : server.Server;
100 private string IpV4Address
104 if (server?.Address == null || Equals(server.Address, IPAddress.None))
107 return server.Address.ToString();
111 private string ServerAccess
115 if (
string.IsNullOrEmpty(server?.AccessPolicy))
118 switch (server.AccessPolicy)
121 return "Open access";
128 private string IpV6Address =>
string.IsNullOrEmpty(server?.V6Address) ?
PageText.
HtmlBlank : server.V6Address;
130 private string ServiceArea
134 if (
string.IsNullOrEmpty(server?.ServiceArea))
137 string description = server.ServiceArea.Trim();
138 string firstLetter = description.Substring(0, 1);
139 string rest = description.Substring(1);
141 return firstLetter.ToUpper() + rest;
145 private string PoolMemberStatus
152 return server.IsPoolMember
153 ?
"Server is pool member" 154 :
"Server is not a pool member";
158 private string PoolMemberLink
162 if (server == null || !server.IsPoolMember)
166 server.Address == null || Equals(server.Address, IPAddress.None)
168 : server.Address.ToString();
170 var builder =
new StringBuilder();
171 builder.Append(
@"<a class=""btn btn-lg btn-primary"" href=""");
172 builder.Append(
"http://www.pool.ntp.org/scores/");
173 builder.Append(address);
174 builder.Append(
@""">View info on pool.ntp.org »</a>");
175 return builder.ToString();
179 private string ProviderLink
183 if (
string.IsNullOrEmpty(server?.ProviderPage))
186 var builder =
new StringBuilder();
187 builder.Append(
@"<a class=""btn btn-lg btn-primary"" href=""");
188 builder.Append(server.ProviderUrl);
189 builder.Append(
@""">View info on ");
190 builder.Append(server.ProviderPage);
191 builder.Append(
" »</a>");
192 return builder.ToString();
198 var builder =
new StringBuilder();
200 builder.AppendLine(
@" <div class=""row"">");
201 builder.AppendLine(
@" <div class=""col-md-2""><b>Server location</b></div>");
202 builder.Append(
@" <div class=""col-md-10"">");
203 builder.Append(Location);
204 builder.AppendLine(
"</div>");
205 builder.AppendLine(
@" </div>");
207 builder.AppendLine(
@" <div class=""row"">");
208 builder.AppendLine(
@" <div class=""col-md-2""><b>Synchronization</b></div>");
209 builder.Append(
@" <div class=""col-md-10"">");
210 builder.Append(ServerSync);
211 builder.AppendLine(
"</div>");
212 builder.AppendLine(
@" </div>");
214 builder.AppendLine(
@" <div class=""row"">");
215 builder.AppendLine(
@" <div class=""col-md-2""><b>IP address</b></div>");
216 builder.Append(
@" <div class=""col-md-4"">");
217 builder.Append(IpV4Address);
218 builder.AppendLine(
"</div>");
220 builder.AppendLine(
@" <div class=""col-md-2""><b>Access policy</b></div>");
221 builder.Append(
@" <div class=""col-md-4"">");
222 builder.Append(ServerAccess);
223 builder.AppendLine(
"</div>");
224 builder.AppendLine(
@" </div>");
226 builder.AppendLine(
@" <div class=""row"">");
227 builder.AppendLine(
@" <div class=""col-md-2""><b>IPv6 address</b></div>");
228 builder.Append(
@" <div class=""col-md-4"">");
229 builder.Append(IpV6Address);
230 builder.AppendLine(
@"</div>");
232 builder.AppendLine(
@" <div class=""col-md-2""><b>Service area</b></div>");
233 builder.Append(
@" <div class=""col-md-4"">");
234 builder.Append(ServiceArea);
235 builder.AppendLine(
@"</div>");
236 builder.AppendLine(
@" </div>");
238 builder.AppendLine(
@" <div class=""row"">");
239 builder.AppendLine(
@" <div class=""col-md-2""><b>Pool member</b></div>");
240 builder.Append(
@" <div class=""col-md-4"">");
241 builder.Append(PoolMemberStatus);
242 builder.AppendLine(
@"</div>");
244 builder.AppendLine(
@" <div class=""col-md-2""><b>Description</b></div>");
245 builder.Append(
@" <div class=""col-md-4"">");
247 builder.AppendLine(
@"</div>");
248 builder.AppendLine(
@" </div>");
250 builder.AppendLine(
@" <p class=""pool"">");
252 if (PoolMemberLink != null)
254 builder.Append(
@" ");
255 builder.Append(PoolMemberLink);
256 builder.AppendLine(
@" ");
259 if (ProviderLink != null)
261 builder.Append(
@" ");
262 builder.Append(ProviderLink);
263 builder.AppendLine(
@" ");
266 if (server != null && server.Id <= 10000)
268 builder.Append(
@" ");
270 @"<a class=""btn btn-lg btn-primary"" href=""http://support.ntp.org/bin/view/Servers/PublicTimeServer");
271 builder.Append(server.Id.ToString(CultureInfo.InvariantCulture).PadLeft(6,
'0'));
272 builder.AppendLine(
@""">View info on support.ntp.org »</a>");
275 builder.AppendLine(
@" </p>");
277 return builder.ToString();
282 var builder =
new StringBuilder();
284 builder.AppendLine(
" </div>");
285 builder.AppendLine(
" </div>");
287 return builder.ToString();
292 var builder =
new StringBuilder();
294 builder.AppendLine(
@" <div class=""container"">");
295 builder.AppendLine(
@" <div class=""jumbotron"">");
297 builder.Append(
" <h1>");
298 builder.Append(Name);
299 builder.Append(
"</h1>");
301 if (StratumText != null)
303 builder.Append(
" <h3>Stratum ");
304 builder.Append(StratumText);
305 builder.AppendLine(
" server</h3>");
308 builder.Append(
" <p>");
309 builder.Append(Time);
310 builder.Append(
". ");
311 builder.Append(
"Next refresh scheduled at ");
312 builder.Append(next.ToShortTimeString());
313 builder.AppendLine(
".</p>");
315 return builder.ToString();
override string RenderHead()
readonly TimeServer server
BootstrapPeerInfoRender(Uri webPath, TimeServer server, DateTime now, DateTime next, string name, string ip)
override string RenderFooter()