From e9379697a1c476d34fa42b6abfcb2347b57dfd59 Mon Sep 17 00:00:00 2001 From: Dylan Bickerstaff Date: Fri, 10 Sep 2021 09:43:09 -0400 Subject: [PATCH] 1.2.5.0 --- SuperCAL/Classes/Config.cs | 11 ++++++++- SuperCAL/Classes/McrsCalSrvc.cs | 38 ++++++++++++++++++++++------- SuperCAL/Properties/AssemblyInfo.cs | 4 +-- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/SuperCAL/Classes/Config.cs b/SuperCAL/Classes/Config.cs index cfd2dd7..4a0706c 100644 --- a/SuperCAL/Classes/Config.cs +++ b/SuperCAL/Classes/Config.cs @@ -60,7 +60,16 @@ public static class Config2 {"FoldersToDelete", @"C:\Micros\Simphony"}, {"XComment11", @"Pipe delimited list of files to delete on re-cal / re-download. (Example: C:\File1.txt|C:\File2.txt )"}, - {"FilesToDelete", @""} + {"FilesToDelete", @""}, + + {"XComment13", @"Pipe delimited list of processes to stop on re-cal / re-download. (Example: Process1|Process2 )"}, + {"ProcessesToStop", @"WIN7CALStart|SarOpsWin32|KDSDisplay"}, + + {"XComment14", @"Pipe delimited list of services to stop on re-cal / re-download excluding 'Micros Cal Client'. (Example: Service1|Service2 )"}, + {"ServicesToStop", @"World Wide Web Publishing Service|MICROS KDS Controller"}, + + {"XComment15", @"Pipe delimited list of services to start after re-cal / re-download excluding 'Micros Cal Client'. (Example: Service1|Service2 )"}, + {"ServicesToStart", @"World Wide Web Publishing Service|MICROS KDS Controller"} }; public static Dictionary DefaultSettings = Settings; public static void SaveConfig() diff --git a/SuperCAL/Classes/McrsCalSrvc.cs b/SuperCAL/Classes/McrsCalSrvc.cs index 6ce95e3..1001480 100644 --- a/SuperCAL/Classes/McrsCalSrvc.cs +++ b/SuperCAL/Classes/McrsCalSrvc.cs @@ -10,6 +10,8 @@ class McrsCalSrvc { public static Button StopStartCAL; public static ServiceController Service = new ServiceController("MICROS CAL Client"); + private static int StopTries = 3; + private static int StartTries = 3; public static bool IsRunning() { Service.Refresh(); @@ -30,11 +32,8 @@ public static Task Stop() try { if (Service.Status != ServiceControllerStatus.Stopped) Service.Stop(); - TryStopService("World Wide Web Publishing Service"); - TryStopService("MICROS KDS Controller"); - TryStopProcesses(Process.GetProcessesByName("WIN7CALStart")); - TryStopProcesses(Process.GetProcessesByName("SarOpsWin32")); - TryStopProcesses(Process.GetProcessesByName("KDSDisplay")); + foreach (string srvs in Config2.Settings["ServicesToStop"].Split('|')) TryStopService(srvs); + foreach (string proc in Config2.Settings["ProcessesToStop"].Split('|')) TryStopProcesses(Process.GetProcessesByName(proc)); Logger.Good("CAL Stopped."); StopStartCAL.Invoke(new Action(() => { StopStartCAL.Text = "Start CAL"; @@ -44,7 +43,18 @@ public static Task Stop() { Logger.Warning("Failed to stop Micros CAL: " + e.Message); await Task.Delay(1000); - await Stop(); + if (--StopTries == 0) + { + StopTries = 3; + Logger.Error("Failed to stop Micros CAL! Tried 3 times."); + StopStartCAL.Invoke(new Action(() => { + StopStartCAL.Text = "Stop CAL"; + })); + } + else + { + await Stop(); + } } }); } @@ -55,8 +65,7 @@ public static Task Start() return Task.Run(async () => { try { - TryStartService("World Wide Web Publishing Service"); - TryStartService("MICROS KDS Controller"); + foreach (string srvs in Config2.Settings["ServicesToStart"].Split('|')) TryStartService(srvs); Service.Start(); Logger.Good("CAL Started."); StopStartCAL.Invoke(new Action(() => { @@ -67,7 +76,18 @@ public static Task Start() { Logger.Warning("Failed to start Micros CAL: " + e.Message); await Task.Delay(1000); - await Start(); + if (--StartTries == 0) + { + StartTries = 3; + Logger.Error("Failed to start Micros CAL! Tried 3 times."); + StopStartCAL.Invoke(new Action(() => { + StopStartCAL.Text = "Start CAL"; + })); + } + else + { + await Start(); + } } }); } diff --git a/SuperCAL/Properties/AssemblyInfo.cs b/SuperCAL/Properties/AssemblyInfo.cs index 544278d..d1da35f 100644 --- a/SuperCAL/Properties/AssemblyInfo.cs +++ b/SuperCAL/Properties/AssemblyInfo.cs @@ -12,6 +12,6 @@ [assembly: AssemblyCulture("")] [assembly: ComVisible(true)] [assembly: Guid("12ea0caa-7402-4b6b-b75d-466f788900e2")] -[assembly: AssemblyVersion("1.2.4.0")] -[assembly: AssemblyFileVersion("1.2.4.0")] +[assembly: AssemblyVersion("1.2.5.0")] +[assembly: AssemblyFileVersion("1.2.5.0")] [assembly: NeutralResourcesLanguage("en")] \ No newline at end of file