23 using System.Globalization;
27 namespace Ntp.Analyzer.Render.
Peer 38 private const string Na =
" ";
39 private readonly
string name;
44 var builder =
new StringBuilder();
46 builder.AppendLine(
"<table>");
47 builder.AppendLine(
@"<col class=""fst""><col class=""sec""><col class=""thd""><col class=""frt"">");
48 builder.AppendLine(
"<tbody>");
50 builder.AppendLine(
"<tr>");
51 builder.Append(
@" <td>Server location</td><td colspan=""3"">");
52 builder.Append(server != null ? server.Location : Na);
53 builder.AppendLine(
"</td>");
54 builder.AppendLine(
"</tr>");
56 builder.AppendLine(
"<tr>");
57 builder.Append(
@" <td>Synchronization</td><td colspan=""3"">");
58 builder.Append(server != null ? server.Server : Na);
59 builder.AppendLine(
"</td>");
60 builder.AppendLine(
"</tr>");
62 builder.AppendLine(
"<tr>");
63 builder.Append(
" <td>IP address</td><td>");
64 builder.Append(server?.Address?.ToString() ??
string.Empty);
65 builder.AppendLine(
"</td>");
66 builder.Append(
" <td>Access policy</td><td>");
67 builder.Append(server != null ? GetServerAccess() : Na);
68 builder.AppendLine(
"</td>");
69 builder.AppendLine(
"</tr>");
71 builder.AppendLine(
"<tr>");
72 builder.Append(
" <td>IPv6 address</td><td>");
73 builder.Append(server != null ? server.V6Address ??
"N/A" : Na);
74 builder.AppendLine(
"</td>");
75 builder.Append(
" <td>Service area</td><td>");
76 builder.Append(server != null ? GetServiceArea() : Na);
77 builder.AppendLine(
"</td>");
78 builder.AppendLine(
"</tr>");
80 builder.AppendLine(
"<tr>");
81 builder.Append(
@" <td>Pool member info</td><td>");
82 builder.Append(server != null ? GetPoolMemberLink() : Na);
83 builder.AppendLine(
"</td>");
84 builder.Append(
" <td>Provider page</td><td>");
85 builder.Append(server != null ? GetProviderLink() : Na);
86 builder.AppendLine(
"</td>");
87 builder.AppendLine(
"</tr>");
89 builder.AppendLine(
"<tr>");
90 builder.Append(
"<td>Description updated</td><td>");
91 builder.Append(server?.Updated.ToLongDateString() ?? Na);
92 builder.AppendLine(
"</td>");
93 if (server != null && server.Id <= 10000)
96 @" <td>Additional info</td><td><a href=""http://support.ntp.org/bin/view/Servers/PublicTimeServer");
97 builder.Append(server.Id.ToString(CultureInfo.InvariantCulture).PadLeft(6,
'0'));
98 builder.AppendLine(
@""">support.ntp.org</a></td>");
102 builder.Append($
@" <td>Additional info</td><td>{Na}</td>");
104 builder.AppendLine(
"</tr>");
106 builder.AppendLine(
"</tbody>");
107 builder.AppendLine(
"</table>");
109 return builder.ToString();
119 var builder =
new StringBuilder();
121 builder.Append(
"<h2>");
122 builder.Append(server != null ? server.Name : name);
123 builder.Append(
"</h2> <h4>Stratum ");
124 builder.Append(server != null ? GetStratumText() : Na);
125 builder.AppendLine(
" server</h4>");
127 return builder.ToString();
134 switch (server.Stratum)
157 switch (server.AccessPolicy)
160 return "Open access";
168 string description = server.ServiceArea.Trim();
170 if (description ==
string.Empty)
173 string firstLetter = description.Substring(0, 1);
174 string rest = description.Substring(1);
176 return firstLetter.ToUpper() + rest;
181 if (!server.IsPoolMember)
182 return "Server is not a pool member";
184 var builder =
new StringBuilder();
185 builder.Append(
@"<a href=""http://www.pool.ntp.org/scores/");
186 builder.Append(server.Address);
187 builder.Append(
@""">pool.ntp.org</a>");
188 return builder.ToString();
193 if (server.ProviderPage == null)
196 var builder =
new StringBuilder();
197 builder.Append(
@"<a href=""");
198 builder.Append(server.ProviderUrl);
199 builder.Append(
@""">");
200 builder.Append(server.ProviderPage);
201 builder.Append(
"</a>");
202 return builder.ToString();
string GetPoolMemberLink()
override string RenderHead()
DefaultPeerInfoRender(Uri webPath, TimeServer server, string name)
readonly TimeServer server
override string RenderFooter()