diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-23 08:44:31 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-23 08:44:31 +0300 |
| commit | 02ae577faa0bd4938507061d603e4f9447e2b64f (patch) | |
| tree | 7daf0e275338ec92e93bfca39f2d529d93858162 /Software/Visual_Studio/PPC | |
| parent | 67770063ff1a1c5c522e3bc29f442c42eb6dc521 (diff) | |
| download | Tango-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')
12 files changed, 146 insertions, 7 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs index f015c3bad..75c5ae9cd 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs @@ -89,6 +89,11 @@ namespace Tango.PPC.Common.Insights insightsFile.Statuses = InsightsManager.Default.GetStatuses(request.StartDateUTC, request.EndDateUTC); } + if (request.IncludeApplicationExceptions) + { + insightsFile.ApplicationExceptions = InsightsManager.Default.GetApplicationExceptions(request.StartDateUTC, request.EndDateUTC); + } + insightsFile.ToFile(filePath); }); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteActions/IRemoteActionsService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteActions/IRemoteActionsService.cs new file mode 100644 index 000000000..477663342 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteActions/IRemoteActionsService.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Common.RemoteActions +{ + public interface IRemoteActionsService + { + + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 08e49621c..ed0c30755 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -179,6 +179,7 @@ <Compile Include="RemoteDesktop\RemoteDesktopClient.cs" /> <Compile Include="RemoteJob\DefaultRemoteJobService.cs" /> <Compile Include="RemoteJob\IRemoteJobService.cs" /> + <Compile Include="RemoteActions\IRemoteActionsService.cs" /> <Compile Include="SQL\DefaultRemoteSqlService.cs" /> <Compile Include="SQL\IRemoteSqlService.cs" /> <Compile Include="Synchronization\DefaultMachineDataSynchronizer.cs" /> @@ -483,7 +484,7 @@ </Target> <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.Shared/Insights/InsightsRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Insights/InsightsRequest.cs index 6603a05b5..b34895e78 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Insights/InsightsRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Insights/InsightsRequest.cs @@ -13,11 +13,13 @@ namespace Tango.PPC.Shared.Insights public bool IncludeEvents { get; set; } public bool IncludeStatuses { get; set; } + public bool IncludeApplicationExceptions { get; set; } public InsightsRequest() { IncludeEvents = true; IncludeStatuses = true; + IncludeApplicationExceptions = true; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteActions/SimulateApplicationExceptionRequest.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteActions/SimulateApplicationExceptionRequest.cs new file mode 100644 index 000000000..76216edad --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteActions/SimulateApplicationExceptionRequest.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.RemoteActions +{ + public class SimulateApplicationExceptionRequest + { + public bool CrashApplication { get; set; } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteActions/SimulateApplicationExceptionResponse.cs b/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteActions/SimulateApplicationExceptionResponse.cs new file mode 100644 index 000000000..e0b71ddf4 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/RemoteActions/SimulateApplicationExceptionResponse.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.PPC.Shared.RemoteActions +{ + public class SimulateApplicationExceptionResponse + { + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj index de1eb03b1..bfd4d587b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Tango.PPC.Shared.csproj @@ -95,6 +95,8 @@ <DependentUpon>Settings.settings</DependentUpon> <DesignTimeSharedInput>True</DesignTimeSharedInput> </Compile> + <Compile Include="RemoteActions\SimulateApplicationExceptionRequest.cs" /> + <Compile Include="RemoteActions\SimulateApplicationExceptionResponse.cs" /> <Compile Include="RemoteUpgrade\StartRemoteFirmwareUpgradeRequest.cs" /> <Compile Include="RemoteUpgrade\StartRemoteFirmwareUpgradeResponse.cs" /> <Compile Include="RemoteUpgrade\StartRemoteApplicationUpgradeResponse.cs" /> @@ -137,5 +139,8 @@ <Name>Tango.SystemInfo</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <Folder Include="Simulation\" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file 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>(); |
