aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2019-04-24 19:30:23 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2019-04-24 19:30:23 +0300
commit4b95b6c19bdf18e50068285b3b0a8a8ab0a7b4ce (patch)
tree327f7c345e6364ee961916b628a1f8029459d7ee /Software/Visual_Studio/PPC/Tango.PPC.UI
parent7ebc478b390e52ea5332bf7c443ca6a8ac79154c (diff)
downloadTango-4b95b6c19bdf18e50068285b3b0a8a8ab0a7b4ce.tar.gz
Tango-4b95b6c19bdf18e50068285b3b0a8a8ab0a7b4ce.zip
Machine Studio v4.0.13.0
PPC v1.0.11.0
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs70
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs2
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest2
3 files changed, 72 insertions, 2 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
index 0eb982d08..0bd9f9d1d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
@@ -9,9 +9,12 @@ using System.Threading.Tasks;
using System.Windows;
using Tango.BL;
using Tango.Core;
+using Tango.Core.DI;
using Tango.Core.Helpers;
using Tango.Logging;
using Tango.PPC.Common;
+using Tango.PPC.Common.EventLogging;
+using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.WatchDog;
using Tango.Settings;
@@ -22,6 +25,8 @@ namespace Tango.PPC.UI
/// </summary>
public partial class App : Application
{
+ private WpfGlobalExceptionTrapper exceptionTrapper;
+
public static String[] StartupArgs { get; private set; }
private LogManager LogManager = LogManager.Default;
@@ -47,6 +52,10 @@ namespace Tango.PPC.UI
base.OnStartup(e);
+ exceptionTrapper = new WpfGlobalExceptionTrapper();
+ exceptionTrapper.Initialize(this);
+ exceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed;
+
LogManager.Categories.Clear();
CoreSettings.DefaultDataSource = new DataSource()
@@ -72,5 +81,66 @@ namespace Tango.PPC.UI
LogManager.Categories.AddRange(settings.LoggingCategories);
}
+
+ #region Global Exception Trapping
+
+ /// <summary>
+ /// Handles the ApplicationCrashed event of the ExceptionTrapper.
+ /// </summary>
+ /// <param name="sender">The source of the event.</param>
+ /// <param name="e">The <see cref="ApplicationCrashedEventArgs"/> instance containing the event data.</param>
+ private void ExceptionTrapper_ApplicationCrashed(object sender, ApplicationCrashedEventArgs e)
+ {
+ e.TryRecover = true;
+
+ try
+ {
+ LogManager.Log(e.Exception, "Application Crashed!");
+ LogManager.Log("Trying to recover from application crash...");
+
+ try
+ {
+ if (Application.Current == null)
+ {
+ new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown };
+ }
+ }
+ catch { }
+
+ try
+ {
+ var eventLogger = TangoIOC.Default.GetInstance<IEventLogger>();
+ if (eventLogger != null)
+ {
+ eventLogger.Log(e.Exception, "Application Crashed!");
+ }
+ }
+ catch { }
+
+ Application.Current.Dispatcher.Invoke(async () =>
+ {
+ try
+ {
+ LogManager.Log("Trying to notify the user about the crash...");
+ INotificationProvider notificationProvider = TangoIOC.Default.GetInstance<INotificationProvider>();
+
+ if (notificationProvider != null)
+ {
+ await notificationProvider.ShowError("An unexpected error has occurred. Use the application logs to diagnose and report the problem.");
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error using the notification provider.");
+ }
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error in global exception trapper!");
+ }
+ }
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs
index 1f4f36e0b..6244f13fb 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs
@@ -8,4 +8,4 @@ using System.Windows;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Tango PPC Application")]
-[assembly: AssemblyVersion("1.0.10.0")]
+[assembly: AssemblyVersion("1.0.11.0")]
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
index efc5f8179..d72e75011 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest
@@ -16,7 +16,7 @@
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
- <!--<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />-->
+ <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>