Skip to content

Commit

Permalink
Merge pull request #707 from skadefro/master
Browse files Browse the repository at this point in the history
move plugin loading, add try catch
  • Loading branch information
skadefro authored Oct 10, 2022
2 parents 398874b + 5c7b3d9 commit e85d625
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 28 deletions.
1 change: 1 addition & 0 deletions OpenRPA.MSSpeech/OpenRPA.MSSpeech.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRPA.Interfaces\OpenRPA.Interfaces.csproj" />
<ProjectReference Include="..\OpenRPA.NamedPipeWrapper\OpenRPA.NamedPipeWrapper.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Activities" />
Expand Down
67 changes: 39 additions & 28 deletions OpenRPA/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,55 +199,66 @@ public bool SignalExternalCommandLineArgs(IList<string> args)
}
private async void Application_Startup(object sender, StartupEventArgs e)
{
AutomationHelper.syncContext = System.Threading.SynchronizationContext.Current;
System.Threading.Thread.CurrentThread.Name = "UIThread";
if (!Config.local.isagent)
{
StartupUri = new Uri("/OpenRPA;component/MainWindow.xaml", UriKind.Relative);
notifyIcon.Visible = true;
}
else
{
StartupUri = new Uri("/OpenRPA;component/AgentWindow.xaml", UriKind.Relative);
notifyIcon.Visible = true;
}
if (Config.local.files_pending_deletion.Length > 0)
try
{
bool sucess = true;
foreach (var f in Config.local.files_pending_deletion)
AutomationHelper.syncContext = System.Threading.SynchronizationContext.Current;
System.Threading.Thread.CurrentThread.Name = "UIThread";
if (!Config.local.isagent)
{
try
StartupUri = new Uri("/OpenRPA;component/MainWindow.xaml", UriKind.Relative);
notifyIcon.Visible = true;
}
else
{
StartupUri = new Uri("/OpenRPA;component/AgentWindow.xaml", UriKind.Relative);
notifyIcon.Visible = true;
}
if (Config.local.files_pending_deletion.Length > 0)
{
bool sucess = true;
foreach (var f in Config.local.files_pending_deletion)
{
if (System.IO.File.Exists(f)) System.IO.File.Delete(f);
try
{
if (System.IO.File.Exists(f)) System.IO.File.Delete(f);
}
catch (Exception ex)
{
sucess = false;
Log.Error(ex.ToString());
}
}
catch (Exception ex)
if (sucess)
{
sucess = false;
Log.Error(ex.ToString());
Config.local.files_pending_deletion = new string[] { };
Config.Save();
}
}
if (sucess)
{
Config.local.files_pending_deletion = new string[] { };
Config.Save();
}
RobotInstance.instance.Status += App_Status;
Input.InputDriver.Instance.initCancelKey(Config.local.cancelkey);
Plugins.LoadPlugins(RobotInstance.instance, Interfaces.Extensions.PluginsDirectory, false);
}
RobotInstance.instance.Status += App_Status;
Input.InputDriver.Instance.initCancelKey(Config.local.cancelkey);
catch (Exception ex)
{
Log.Error(ex.ToString());
Console.WriteLine(ex.ToString());
MessageBox.Show(ex.Message);
}

await Task.Run(async () =>
{
try
{
// if (Config.local.showloadingscreen) splash.BusyContent = "loading plugins";
// Plugins.LoadPlugins(RobotInstance.instance, Interfaces.Extensions.ProjectsDirectory);
Plugins.LoadPlugins(RobotInstance.instance, Interfaces.Extensions.PluginsDirectory, false);
// if (Config.local.showloadingscreen) splash.BusyContent = "Initialize main window";
await RobotInstance.instance.init();
}
catch (Exception ex)
{
Log.Error(ex.ToString());
Console.WriteLine(ex.ToString());
MessageBox.Show(ex.Message);
}
});
}
Expand Down

0 comments on commit e85d625

Please sign in to comment.