mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-01-11 19:44:55 +00:00
feat: Logging when we intentionally restart the program or processor
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user