feat: Logging when we intentionally restart the program or processor

This commit is contained in:
Chris Cameron
2021-05-17 15:30:53 -04:00
parent 28335ad99c
commit 1390af967f
2 changed files with 18 additions and 0 deletions

View File

@@ -213,6 +213,10 @@ namespace ICD.Common.Utils
[PublicAPI]
public static void RestartProgram()
{
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger != null)
logger.AddEntry(eSeverity.Informational, "Intentional Restart of Program");
string consoleResult = string.Empty;
string command = string.Format("progreset -p:{0:D2}", ProgramUtils.ProgramNumber);
IcdConsole.SendControlSystemCommand(command, ref consoleResult);
@@ -224,6 +228,10 @@ namespace ICD.Common.Utils
[PublicAPI]
public static void Reboot()
{
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger != null)
logger.AddEntry(eSeverity.Informational, "Intentional Reboot of Processor");
string consoleResult = string.Empty;
IcdConsole.SendControlSystemCommand("reboot", ref consoleResult);
}

View File

@@ -5,6 +5,8 @@ using System.Linq;
using System.Management;
using ICD.Common.Properties;
using ICD.Common.Utils.IO;
using ICD.Common.Utils.Services;
using ICD.Common.Utils.Services.Logging;
using Microsoft.Win32;
namespace ICD.Common.Utils
@@ -163,6 +165,10 @@ namespace ICD.Common.Utils
if (string.IsNullOrEmpty(filename) || !IcdFile.Exists(filename))
throw new InvalidOperationException("Failed to find program filename");
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger != null)
logger.AddEntry(eSeverity.Informational, "Intentional Restart of Program");
Process.Start(filename);
Environment.Exit(0);
}
@@ -173,6 +179,10 @@ namespace ICD.Common.Utils
[PublicAPI]
public static void Reboot()
{
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
if (logger != null)
logger.AddEntry(eSeverity.Informational, "Intentional Reboot of Processor");
// TODO - Linux
ProcessStartInfo psi =
new ProcessStartInfo("shutdown", "/r /t 0")