mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 21:24:58 +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]
|
[PublicAPI]
|
||||||
public static void RestartProgram()
|
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 consoleResult = string.Empty;
|
||||||
string command = string.Format("progreset -p:{0:D2}", ProgramUtils.ProgramNumber);
|
string command = string.Format("progreset -p:{0:D2}", ProgramUtils.ProgramNumber);
|
||||||
IcdConsole.SendControlSystemCommand(command, ref consoleResult);
|
IcdConsole.SendControlSystemCommand(command, ref consoleResult);
|
||||||
@@ -224,6 +228,10 @@ namespace ICD.Common.Utils
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static void Reboot()
|
public static void Reboot()
|
||||||
{
|
{
|
||||||
|
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
|
||||||
|
if (logger != null)
|
||||||
|
logger.AddEntry(eSeverity.Informational, "Intentional Reboot of Processor");
|
||||||
|
|
||||||
string consoleResult = string.Empty;
|
string consoleResult = string.Empty;
|
||||||
IcdConsole.SendControlSystemCommand("reboot", ref consoleResult);
|
IcdConsole.SendControlSystemCommand("reboot", ref consoleResult);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ using System.Linq;
|
|||||||
using System.Management;
|
using System.Management;
|
||||||
using ICD.Common.Properties;
|
using ICD.Common.Properties;
|
||||||
using ICD.Common.Utils.IO;
|
using ICD.Common.Utils.IO;
|
||||||
|
using ICD.Common.Utils.Services;
|
||||||
|
using ICD.Common.Utils.Services.Logging;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace ICD.Common.Utils
|
namespace ICD.Common.Utils
|
||||||
@@ -163,6 +165,10 @@ namespace ICD.Common.Utils
|
|||||||
if (string.IsNullOrEmpty(filename) || !IcdFile.Exists(filename))
|
if (string.IsNullOrEmpty(filename) || !IcdFile.Exists(filename))
|
||||||
throw new InvalidOperationException("Failed to find program 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);
|
Process.Start(filename);
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
@@ -173,6 +179,10 @@ namespace ICD.Common.Utils
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static void Reboot()
|
public static void Reboot()
|
||||||
{
|
{
|
||||||
|
ILoggerService logger = ServiceProvider.TryGetService<ILoggerService>();
|
||||||
|
if (logger != null)
|
||||||
|
logger.AddEntry(eSeverity.Informational, "Intentional Reboot of Processor");
|
||||||
|
|
||||||
// TODO - Linux
|
// TODO - Linux
|
||||||
ProcessStartInfo psi =
|
ProcessStartInfo psi =
|
||||||
new ProcessStartInfo("shutdown", "/r /t 0")
|
new ProcessStartInfo("shutdown", "/r /t 0")
|
||||||
|
|||||||
Reference in New Issue
Block a user