NTP Analyzer  0.8.2
Analyze the operation of time servers
DefaultPeerSummaryGraphRender.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using System.Collections.Generic;
23 using System.Globalization;
24 using System.Linq;
25 using System.Text;
28 using Ntp.Analyzer.Data;
29 using Ntp.Common.Web;
30 
31 namespace Ntp.Analyzer.Render.Summary
32 {
34  {
36  int hostId,
38  IEnumerable<GraphSetConfiguration> graphs)
39  : base(page.WebPath)
40  {
41  this.hostId = hostId;
42  this.page = page;
43  this.graphs = new List<GraphSetConfiguration>(graphs);
44  }
45 
46  private readonly List<GraphSetConfiguration> graphs;
47  private readonly int hostId;
49 
50  public override string Render()
51  {
52  var builder = new StringBuilder();
53 
54  var peers = DataFace.Instance.PeerActivities.
55  Where(p => p.Host.Id == hostId && p.IsActive);
56 
57  foreach (var entry in peers)
58  {
59  foreach (var graphSet in graphs)
60  {
61  foreach (var graph in graphSet.Graphs)
62  {
63  builder.Append(@"<a href=""");
64  builder.Append(page.GetPeerLink(entry.Id).ToHtmlString());
65  builder.Append(@""">");
66  builder.Append(@"<img src=""");
67  builder.Append(
68  graph.GetLink(graphSet, entry.Id.ToString(CultureInfo.InvariantCulture)).ToHtmlString());
69  builder.Append(@""" alt=""");
70  builder.Append(graph.GetAltName(graphSet, entry.Peer.Name));
71  builder.Append(@""">");
72  builder.AppendLine(@"</a>");
73  }
74  }
75  }
76 
77  return builder.ToString();
78  }
79 
80  public override string RenderFooter()
81  {
82  return string.Empty;
83  }
84 
85  public override string RenderHead()
86  {
87  return string.Empty;
88  }
89  }
90 }
DefaultPeerSummaryGraphRender(int hostId, PeerSummaryPageConfiguration page, IEnumerable< GraphSetConfiguration > graphs)
Singleton facade class used to access memory persistent data.
Definition: DataFace.cs:30
PeerActivityDatabaseMapper PeerActivities
Gets the peer activity mapper.
Definition: DataFace.cs:99
static DataFace Instance
Gets the Singleton instance.
Definition: DataFace.cs:51