NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Monitor.Server.TextCommand.UptimeCommand Class Reference
Inheritance diagram for Ntp.Analyzer.Monitor.Server.TextCommand.UptimeCommand:
Collaboration diagram for Ntp.Analyzer.Monitor.Server.TextCommand.UptimeCommand:

Public Member Functions

 UptimeCommand (string[] args)
 
- Public Member Functions inherited from Ntp.Analyzer.Monitor.Server.TextCommand.MonitorTextCommand
override object Execute ()
 

Protected Member Functions

override string ExecuteTextCommand ()
 
- Protected Member Functions inherited from Ntp.Analyzer.Monitor.Server.TextCommand.MonitorTextCommand
 MonitorTextCommand (string[] args)
 
 MonitorTextCommand ()
 

Private Member Functions

string FormatTimespan (TimeSpan time)
 

Additional Inherited Members

- Public Attributes inherited from Ntp.Analyzer.Monitor.Server.TextCommand.MonitorTextCommand
override CommandType CommandType => CommandType.Text
 
- Properties inherited from Ntp.Analyzer.Monitor.Server.TextCommand.MonitorTextCommand
string[] Args [get]
 
- Properties inherited from Ntp.Analyzer.Monitor.Server.Command
abstract CommandType CommandType [get]
 

Detailed Description

Definition at line 28 of file UptimeCommand.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Monitor.Server.TextCommand.UptimeCommand.UptimeCommand ( string[]  args)
inline

Definition at line 30 of file UptimeCommand.cs.

31  : base(args)
32  {
33  }

Member Function Documentation

override string Ntp.Analyzer.Monitor.Server.TextCommand.UptimeCommand.ExecuteTextCommand ( )
inlineprotectedvirtual

Implements Ntp.Analyzer.Monitor.Server.TextCommand.MonitorTextCommand.

Definition at line 35 of file UptimeCommand.cs.

References Ntp.Analyzer.Monitor.Server.ApplicationState.StartupTime.

36  {
37  TimeSpan runtime = DateTime.Now.Subtract(ApplicationState.StartupTime);
38 
39  var builder = new StringBuilder();
40 
41  builder.Append("Daemon was started ");
42  builder.Append(ApplicationState.StartupTime.ToShortDateString());
43  builder.Append(" ");
44  builder.Append(TimeZone.CurrentTimeZone.StandardName);
45  builder.Append(" ");
46  builder.Append(ApplicationState.StartupTime.ToLongTimeString());
47  builder.AppendLine();
48 
49  builder.Append("Uptime ");
50  builder.Append(FormatTimespan(runtime));
51  builder.AppendLine();
52 
53  return builder.ToString();
54  }
string Ntp.Analyzer.Monitor.Server.TextCommand.UptimeCommand.FormatTimespan ( TimeSpan  time)
inlineprivate

Definition at line 56 of file UptimeCommand.cs.

57  {
58  string days;
59 
60  if (time.TotalDays >= 1 && time.TotalDays < 2)
61  {
62  days = "1 day ";
63  }
64  else if (time.TotalDays >= 2)
65  {
66  days = time.TotalDays.ToString(CultureInfo.InvariantCulture) + " days ";
67  }
68  else
69  {
70  days = string.Empty;
71  }
72 
73  string hours;
74 
75  if (time.Hours >= 1 && time.Hours < 2)
76  {
77  hours = "1 hour ";
78  }
79  else if (time.Hours >= 2)
80  {
81  hours = time.Hours.ToString(CultureInfo.InvariantCulture) + " hours ";
82  }
83  else
84  {
85  hours = string.Empty;
86  }
87 
88  string minutes;
89 
90  if (time.Minutes >= 1 && time.Minutes < 2)
91  {
92  minutes = "1 minute ";
93  }
94  else if (time.Minutes >= 2)
95  {
96  minutes = time.Minutes.ToString(CultureInfo.InvariantCulture) + " minutes ";
97  }
98  else
99  {
100  minutes = string.Empty;
101  }
102 
103  string seconds;
104 
105  if (time.Seconds >= 1 && time.Seconds < 2)
106  {
107  seconds = "1 second";
108  }
109  else if (time.Seconds >= 2)
110  {
111  seconds = time.Seconds.ToString(CultureInfo.InvariantCulture) + " seconds";
112  }
113  else
114  {
115  seconds = string.Empty;
116  }
117 
118  return string.Concat(days, hours, minutes, seconds);
119  }

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