aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-23 08:44:31 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-08-23 08:44:31 +0300
commit02ae577faa0bd4938507061d603e4f9447e2b64f (patch)
tree7daf0e275338ec92e93bfca39f2d529d93858162 /Software/Visual_Studio/PPC/Tango.PPC.UI
parent67770063ff1a1c5c522e3bc29f442c42eb6dc521 (diff)
downloadTango-02ae577faa0bd4938507061d603e4f9447e2b64f.tar.gz
Tango-02ae577faa0bd4938507061d603e4f9447e2b64f.zip
Fixed issue with insights file datetime utc.
added insights application exception/crash. added remote actions service. fixed issue with LiteDB hang on application start/exit. reduced insights listener empty frames.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs33
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs3
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/RemoteActions/DefaultRemoteActionsService.cs54
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj6
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs4
5 files changed, 94 insertions, 6 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 16eb656a8..e478dba77 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs
@@ -13,6 +13,7 @@ using Tango.BL;
using Tango.Core;
using Tango.Core.DI;
using Tango.Core.Helpers;
+using Tango.Insights;
using Tango.Integration.Operation;
using Tango.Logging;
using Tango.PPC.Common;
@@ -29,7 +30,7 @@ namespace Tango.PPC.UI
/// </summary>
public partial class App : Application
{
- private WpfGlobalExceptionTrapper exceptionTrapper;
+ public static WpfGlobalExceptionTrapper ExceptionTrapper;
public static String[] StartupArgs { get; private set; }
private LogManager LogManager = LogManager.Default;
@@ -80,9 +81,9 @@ namespace Tango.PPC.UI
base.OnStartup(e);
- exceptionTrapper = new WpfGlobalExceptionTrapper();
- exceptionTrapper.Initialize(this);
- exceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed;
+ ExceptionTrapper = new WpfGlobalExceptionTrapper();
+ ExceptionTrapper.Initialize(this);
+ ExceptionTrapper.ApplicationCrashed += ExceptionTrapper_ApplicationCrashed;
CoreSettings.DefaultDataSource = new DataSource()
{
@@ -100,10 +101,21 @@ namespace Tango.PPC.UI
private async void GetLastApplicationCrashFromWindows()
{
- var logItem = await exceptionTrapper.GetLastApplicationCrashEventLog();
+ var logItem = await ExceptionTrapper.GetLastApplicationCrashEventLog(60);
if (logItem != null)
{
LogManager.Log(logItem);
+
+ try
+ {
+ InsightsManager.Default.InsertApplicationException(new InsightsApplicationException()
+ {
+ Time = DateTime.UtcNow,
+ Exception = logItem.Message,
+ IsApplicationCrash = true
+ });
+ }
+ catch { }
}
}
@@ -135,6 +147,17 @@ namespace Tango.PPC.UI
try
{
+ InsightsManager.Default.InsertApplicationException(new InsightsApplicationException()
+ {
+ Time = DateTime.UtcNow,
+ Exception = e.Exception.ToString()
+ });
+ }
+ catch
+ { }
+
+ try
+ {
if (Application.Current == null)
{
new Application { ShutdownMode = ShutdownMode.OnExplicitShutdown };
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
index 54193a793..29f4e65be 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
@@ -476,6 +476,7 @@ namespace Tango.PPC.UI.PPCApplication
{
var frame = InsightsFrame.CreateEmpty(DateTime.UtcNow);
InsightsManager.Default.InsertFrame(frame);
+ InsightsManager.Default.Dispose();
}
catch {}
@@ -528,6 +529,7 @@ namespace Tango.PPC.UI.PPCApplication
{
var frame = InsightsFrame.CreateEmpty(DateTime.UtcNow);
InsightsManager.Default.InsertFrame(frame);
+ InsightsManager.Default.Dispose();
}
catch { }
@@ -566,6 +568,7 @@ namespace Tango.PPC.UI.PPCApplication
{
var frame = InsightsFrame.CreateEmpty(DateTime.UtcNow);
InsightsManager.Default.InsertFrame(frame);
+ InsightsManager.Default.Dispose();
}
catch { }
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/RemoteActions/DefaultRemoteActionsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/RemoteActions/DefaultRemoteActionsService.cs
new file mode 100644
index 000000000..1b8780f91
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/RemoteActions/DefaultRemoteActionsService.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Tango.Core.DI;
+using Tango.Core.Threading;
+using Tango.Integration.ExternalBridge;
+using Tango.PPC.Common.ExternalBridge;
+using Tango.PPC.Common.RemoteActions;
+using Tango.PPC.Common.Threading;
+using Tango.PPC.Shared.RemoteActions;
+
+namespace Tango.PPC.UI.RemoteActions
+{
+ [TangoCreateWhenRegistered]
+ public class DefaultRemoteActionsService : IRemoteActionsService, IExternalBridgeRequestHandler
+ {
+ [TangoInject]
+ private IDispatcherProvider DispatcherProvider { get; set; }
+
+ public DefaultRemoteActionsService(IPPCExternalBridgeService externalBridge)
+ {
+ externalBridge.RegisterRequestHandler(this);
+ }
+
+ public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)
+ {
+ //Do nothing.
+ }
+
+ [ExternalBridgeRequestHandlerMethod(typeof(SimulateApplicationExceptionRequest), RequestHandlerLoggingMode.LogRequestName)]
+ public async Task OnSimulateApplicationExceptionRequest(SimulateApplicationExceptionRequest request, String token, ExternalBridgeReceiver receiver)
+ {
+ await receiver.SendGenericResponse(new SimulateApplicationExceptionResponse(), token);
+
+ Thread.Sleep(500);
+
+ DispatcherProvider.Invoke(() =>
+ {
+ if (request.CrashApplication)
+ {
+ App.ExceptionTrapper.Disable();
+ throw new OutOfMemoryException("This is a simulated exception to cause the application to crash.");
+ }
+ else
+ {
+ throw new ApplicationException("This is a simulated exception to cause an unhandled application error.");
+ }
+ });
+ }
+ }
+}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
index 569621432..bfb16f10d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Tango.PPC.UI.csproj
@@ -181,6 +181,7 @@
<Compile Include="Notifications\PendingNotification.cs" />
<Compile Include="PPCApplication\DefaultPPCApplicationManager.cs" />
<Compile Include="Printing\DefaultPrintingManager.cs" />
+ <Compile Include="RemoteActions\DefaultRemoteActionsService.cs" />
<Compile Include="Threading\DefaultDispatcherProvider.cs" />
<Compile Include="ViewModelLocator.cs" />
<Compile Include="ViewModels\EmergencyViewVM.cs" />
@@ -446,6 +447,9 @@
<Resource Include="Images\firmware.png" />
<Resource Include="Images\power_off_2.gif" />
<Resource Include="Images\loading_anim.gif" />
+ <Content Include="..\..\Build\ColorLib\Debug\Tango.ColorLib_v4.dll">
+ <Link>Tango.ColorLib_v4.dll</Link>
+ </Content>
<Content Include="Manifests\release.xml" />
<Content Include="Manifests\debug.xml" />
<None Include="firmware_package.tfp">
@@ -717,7 +721,7 @@ if $(ConfigurationName) == Debug copy /Y "$(TargetDir)Packages" "$(TargetDir)"</
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
index b5da9f066..7011cd3be 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs
@@ -24,6 +24,7 @@ using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.OS;
using Tango.PPC.Common.Performance;
using Tango.PPC.Common.Printing;
+using Tango.PPC.Common.RemoteActions;
using Tango.PPC.Common.RemoteAssistance;
using Tango.PPC.Common.RemoteDesktop;
using Tango.PPC.Common.RemoteJob;
@@ -42,6 +43,7 @@ using Tango.PPC.UI.Navigation;
using Tango.PPC.UI.Notifications;
using Tango.PPC.UI.PPCApplication;
using Tango.PPC.UI.Printing;
+using Tango.PPC.UI.RemoteActions;
using Tango.PPC.UI.Threading;
using Tango.PPC.UI.ViewModels;
using Tango.PPC.UI.Views;
@@ -94,6 +96,7 @@ namespace Tango.PPC.UI
TangoIOC.Default.Unregister<IRemoteJobService>();
TangoIOC.Default.Unregister<IRemoteSqlService>();
TangoIOC.Default.Unregister<IInsightsService>();
+ TangoIOC.Default.Unregister<IRemoteActionsService>();
if (App.StartupArgs != null && App.StartupArgs.Contains("-webDebug"))
{
@@ -135,6 +138,7 @@ namespace Tango.PPC.UI
TangoIOC.Default.Register<IRemoteJobService, DefaultRemoteJobService>();
TangoIOC.Default.Register<IRemoteSqlService, DefaultRemoteSqlService>();
TangoIOC.Default.Register<IInsightsService, DefaultInsightsService>();
+ TangoIOC.Default.Register<IRemoteActionsService, DefaultRemoteActionsService>();
TangoIOC.Default.Register<LoadingViewVM>();
TangoIOC.Default.Register<MainViewVM>();