aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs72
1 files changed, 24 insertions, 48 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
index 7eab5066a..8309500b7 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs
@@ -23,37 +23,21 @@ using Tango.MachineStudio.UI.Views;
using Tango.MachineStudio.Common;
using Tango.Core;
using Tango.BL;
-using Tango.Integration.Operation;
-using System.Net;
-using System.Globalization;
-using System.Windows.Markup;
namespace Tango.MachineStudio.UI
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
- public partial class App : Application
+ public partial class App : Application
{
private WpfGlobalExceptionTrapper exceptionTrapper;
private LogManager LogManager = LogManager.Default;
- public static String[] StartupArgs { get; set; } = Environment.GetCommandLineArgs().Skip(1).ToArray();
+ public static String[] StartupArgs { get; set; }
protected override void OnStartup(StartupEventArgs e)
{
- //Set culture info.
- var enUSCulture = new CultureInfo("en-US");
-
- Thread.CurrentThread.CurrentCulture = enUSCulture;
- Thread.CurrentThread.CurrentUICulture = enUSCulture;
- CultureInfo.DefaultThreadCurrentCulture = enUSCulture;
- CultureInfo.DefaultThreadCurrentUICulture = enUSCulture;
-
- FrameworkElement.LanguageProperty.OverrideMetadata(
- typeof(FrameworkElement),
- new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
-
StartupArgs = e.Args;
#if DEBUG
@@ -77,14 +61,7 @@ namespace Tango.MachineStudio.UI
#if DEBUG
LogManager.RegisterLogger(new VSOutputLogger());
#endif
- LogManager.RegisterLogger(new FileLogger() { EnableAutoLogRemoval = true, EnableMaxFileSizeLimit = true });
-
- var operatorLogger = MachineOperator.EmbeddedLogManager.RegisteredLoggers.SingleOrDefault(x => x is FileLogger) as FileLogger;
- if (operatorLogger != null)
- {
- operatorLogger.EnableAutoLogRemoval = true;
- operatorLogger.EnableMaxFileSizeLimit = true;
- }
+ LogManager.RegisterLogger(new FileLogger());
LogManager.Log("Application Started...");
@@ -95,30 +72,24 @@ namespace Tango.MachineStudio.UI
base.OnStartup(e);
- exceptionTrapper = new WpfGlobalExceptionTrapper();
- exceptionTrapper.Initialize(this);
- exceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed;
-
- ApplyEFCacheSettings();
+ LogManager.Categories.Clear();
- WebRequest.DefaultWebProxy = null;
- GetLastApplicationCrashFromWindows();
- }
-
- private async void GetLastApplicationCrashFromWindows()
- {
- var logItem = await exceptionTrapper.GetLastApplicationCrashEventLog();
- if (logItem != null)
+ if (settings.LoggingCategories.Count == 0)
{
- LogManager.Log(logItem);
+ settings.LoggingCategories.Add(LogCategory.Critical);
+ settings.LoggingCategories.Add(LogCategory.Error);
+ settings.LoggingCategories.Add(LogCategory.Info);
+ settings.LoggingCategories.Add(LogCategory.Warning);
}
- }
- private void ApplyEFCacheSettings()
- {
- var settings = SettingsManager.Default.GetOrCreate<MachineStudioSettings>();
+ LogManager.Categories.AddRange(settings.LoggingCategories);
+
+ exceptionTrapper = new WpfGlobalExceptionTrapper();
+ exceptionTrapper.Initialize(this);
+ exceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed;
+ //Apply Caching
if (settings.CachingMode != ObservablesContextInMemoryCachingMode.None)
{
LogManager.Log("EF Caching is enabled.");
@@ -137,7 +108,9 @@ namespace Tango.MachineStudio.UI
{
LogManager.Log("EF Caching is disabled");
}
+
}
+
#region Global Exception Trapping
@@ -159,12 +132,15 @@ namespace Tango.MachineStudio.UI
}
catch { }
- if (e.Exception.ToString().Contains("A Task's exception(s) were not observed"))
+ try
{
- e.TryRecover = true;
- LogManager.Log("Task not observed exception. Ignoring...");
- return;
+ var eventLogger = TangoIOC.Default.GetInstance<IEventLogger>();
+ if (eventLogger != null)
+ {
+ eventLogger.Log(e.Exception, "Application Crashed!");
+ }
}
+ catch { }
Application.Current.Dispatcher.Invoke(() =>
{