diff --git a/OpenRPA.Interfaces/Config.cs b/OpenRPA.Interfaces/Config.cs index 9d3f8519..d4d209e1 100644 --- a/OpenRPA.Interfaces/Config.cs +++ b/OpenRPA.Interfaces/Config.cs @@ -86,6 +86,7 @@ public class Config public bool disable_instance_store { get { return GetProperty(null, false); } set { SetProperty(null, value); } } public bool skip_online_state { get { return GetProperty(null, false); } set { SetProperty(null, value); } } public int thread_lock_timeout_seconds { get { return GetProperty(null, 10); } set { SetProperty(null, value); } } + public bool thread_exit_on_lock_timeout { get { return GetProperty(null, false); } set { SetProperty(null, value); } } public bool skip_child_session_check { get { return GetProperty(null, false); } set { SetProperty(null, value); } } private void loadEntropy() { @@ -258,6 +259,7 @@ public void Save(string filename) _ = skip_online_state; _ = thread_lock_timeout_seconds; _ = skip_child_session_check; + _ = thread_exit_on_lock_timeout; _ = max_trace_lines; _ = max_output_lines; diff --git a/OpenRPA/App.xaml.cs b/OpenRPA/App.xaml.cs index fc59f904..fb7fbf25 100644 --- a/OpenRPA/App.xaml.cs +++ b/OpenRPA/App.xaml.cs @@ -235,7 +235,7 @@ private async void Application_Startup(object sender, StartupEventArgs e) } } - if (Config.local.restoreDependenciesOnStartup) + if (Config.local.restore_dependencies_on_startup) { Log.Debug("Package restore on startup enabled -> cleaning existing extensions."); var extensionsPath = Path.Combine(Interfaces.Extensions.ProjectsDirectory, "extensions"); diff --git a/OpenRPA/Detector.cs b/OpenRPA/Detector.cs index 0acb9274..bf660def 100644 --- a/OpenRPA/Detector.cs +++ b/OpenRPA/Detector.cs @@ -56,11 +56,19 @@ public async Task Save(bool skipOnline = false) System.Threading.Monitor.Exit(RobotInstance.instance.Detectors); } } - else { throw new LockNotReceivedException("Saving detector"); } + else + { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Saving detector"); + } } public async Task Delete(bool skipOnline = false) { - if(!skipOnline) await Delete(); + if (!skipOnline) await Delete(); if (System.Threading.Monitor.TryEnter(RobotInstance.instance.Detectors, Config.local.thread_lock_timeout_seconds * 1000)) { try @@ -72,7 +80,15 @@ public async Task Delete(bool skipOnline = false) System.Threading.Monitor.Exit(RobotInstance.instance.Detectors); } } - else { throw new LockNotReceivedException("Deleting detector"); } + else + { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Deleting detector"); + } } public void ExportFile(string filepath) { @@ -91,12 +107,13 @@ public void Start(bool doRegisterExchange) return; } } - if(doRegisterExchange) _ = RegisterExchange(); - if(RobotInstance.instance != null && RobotInstance.instance.Window != null) + if (doRegisterExchange) _ = RegisterExchange(); + if (RobotInstance.instance != null && RobotInstance.instance.Window != null) { dp.OnDetector -= RobotInstance.instance.Window.OnDetector; dp.OnDetector += RobotInstance.instance.Window.OnDetector; - } else + } + else { Log.Error("Failed registering detector event sink for " + name + " main window not loaded yet !!!!!"); } @@ -113,7 +130,7 @@ async public Task RegisterExchange() var reqver = Version.Parse("1.3.103"); // exchange support for detectors was not added until 1.3.103 if (ver < reqver) return; if (dp.Entity != null && dp.Entity.detectortype == "exchange" && !string.IsNullOrEmpty(dp.Entity._id)) - { + { await global.webSocketClient.RegisterExchange(dp.Entity._id, "fanout", false, "", ""); } } diff --git a/OpenRPA/LocallyCached.cs b/OpenRPA/LocallyCached.cs index fa694a32..a6a9aba0 100644 --- a/OpenRPA/LocallyCached.cs +++ b/OpenRPA/LocallyCached.cs @@ -134,7 +134,14 @@ public async Task Save(bool skipOnline = false) where T : apibase System.Threading.Monitor.Exit(savelock); } } - else { throw new LockNotReceivedException("Locally Cached savelock"); } + else { + if(Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Locally Cached savelock"); + } } catch (Exception) { @@ -173,7 +180,14 @@ public async Task Delete() where T : apibase System.Threading.Monitor.Exit(savelock); } } - else { throw new LockNotReceivedException("Locally Cached savelock"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Locally Cached savelock"); + } } catch (Exception ex) { @@ -199,7 +213,14 @@ public async Task Delete() where T : apibase System.Threading.Monitor.Exit(savelock); } } - else { throw new LockNotReceivedException("Locally Cached savelock"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Locally Cached savelock"); + } } } } diff --git a/OpenRPA/OpenRPA.csproj b/OpenRPA/OpenRPA.csproj index b88e2190..a4f61a9c 100644 --- a/OpenRPA/OpenRPA.csproj +++ b/OpenRPA/OpenRPA.csproj @@ -11,7 +11,7 @@ Base UI of OpenRPA, used as part of OpenRPA robot MPL-2.0 https://github.com/open-rpa/openrpa - 1.4.57.7 + 1.4.57.8 openrpa.png Debug;Release;ReleaseNuget;PrepInstaller diff --git a/OpenRPA/Project.cs b/OpenRPA/Project.cs index 376dc278..add13bf4 100644 --- a/OpenRPA/Project.cs +++ b/OpenRPA/Project.cs @@ -396,7 +396,14 @@ public async Task Save(bool skipOnline = false) System.Threading.Monitor.Exit(RobotInstance.instance.Projects); } } - else { throw new LockNotReceivedException("Saving Project"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Saving Project"); + } }); } public async Task Update(IProject item, bool skipOnline = false) @@ -483,7 +490,14 @@ public async Task Delete(bool skipOnline = false) System.Threading.Monitor.Exit(RobotInstance.instance.Projects); } } - else { throw new LockNotReceivedException("Delete Project"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Delete Project"); + } }); } public override string ToString() diff --git a/OpenRPA/RobotInstance.cs b/OpenRPA/RobotInstance.cs index 754cdf54..a012dfb3 100644 --- a/OpenRPA/RobotInstance.cs +++ b/OpenRPA/RobotInstance.cs @@ -143,7 +143,6 @@ public bool isRunningInChildSession } } } - private static readonly object statelock = new object(); public IMainWindow Window { get; set; } public List WorkflowInstances { @@ -161,7 +160,14 @@ public List WorkflowInstances System.Threading.Monitor.Exit(WorkflowInstance.Instances); } } - else { throw new LockNotReceivedException("Failed returning list of workflow instances"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Failed returning list of workflow instances"); + } return result; } } @@ -770,7 +776,7 @@ await GenericTools.RunUIAsync(async () => { // just started a new instance, load all project dependencies first_serverDataLoad = false; - if (Config.local.restoreDependenciesOnStartup) + if (Config.local.restore_dependencies_on_startup) { try { diff --git a/OpenRPA/Store/AsyncResult.cs b/OpenRPA/Store/AsyncResult.cs index 251abea1..af8d3fd7 100644 --- a/OpenRPA/Store/AsyncResult.cs +++ b/OpenRPA/Store/AsyncResult.cs @@ -55,7 +55,14 @@ public WaitHandle AsyncWaitHandle System.Threading.Monitor.Exit(ThisLock); } } - else { throw new LockNotReceivedException("Async ThisLock"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Interfaces.Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Async ThisLock"); + } return manualResetEvent; } } @@ -125,7 +132,14 @@ protected void Complete(bool completedSynchronously) System.Threading.Monitor.Exit(ThisLock); } } - else { throw new LockNotReceivedException("Async ThisLock"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Interfaces.Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Async ThisLock"); + } } if (callback != null) { diff --git a/OpenRPA/Workflow.cs b/OpenRPA/Workflow.cs index 923d3beb..b5e28877 100644 --- a/OpenRPA/Workflow.cs +++ b/OpenRPA/Workflow.cs @@ -410,7 +410,14 @@ public async Task Save(bool skipOnline = false) System.Threading.Monitor.Exit(RobotInstance.instance.Workflows); } } - else { throw new LockNotReceivedException("Failed saving workflow"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Failed saving workflow"); + } } public async Task Update(IWorkflow item, bool skipOnline = false) { @@ -468,7 +475,14 @@ public async Task Delete(bool skipOnline = false) System.Threading.Monitor.Exit(RobotInstance.instance.Workflows); } } - else { throw new LockNotReceivedException("Failed deleting workflow"); } + else { + if (Config.local.thread_exit_on_lock_timeout) + { + Log.Error("Locally Cached savelock"); + System.Environment.Exit(1); + } + throw new LockNotReceivedException("Failed deleting workflow"); + } } catch (Exception ex) { diff --git a/OpenRPA/WorkflowInstance.cs b/OpenRPA/WorkflowInstance.cs index 2a28ff4b..8f1d9148 100644 --- a/OpenRPA/WorkflowInstance.cs +++ b/OpenRPA/WorkflowInstance.cs @@ -202,7 +202,14 @@ public static WorkflowInstance Create(Workflow Workflow, Dictionary