diff options
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs | 44 | ||||
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.Shared/Insights/InsightsRequest.cs | 9 |
2 files changed, 39 insertions, 14 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 c51485f29..fbe606af9 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Insights/DefaultInsightsService.cs @@ -68,23 +68,39 @@ namespace Tango.PPC.Common.Insights [ExternalBridgeRequestHandlerMethod(typeof(InsightsRequest), RequestHandlerLoggingMode.LogRequestName)] public async Task OnInsightsRequest(InsightsRequest request, String token, ExternalBridgeReceiver receiver) { - InsightsFile insightsFile = new InsightsFile(); - var filePath = TemporaryManager.CreateImaginaryFile(); - - await Task.Factory.StartNew(() => + try { - var frames = InsightsManager.Default.GetFrames(request.StartDateUTC, request.EndDateUTC); - insightsFile.Frames = frames; - insightsFile.Events = InsightsManager.Default.GetEvents(request.StartDateUTC, request.EndDateUTC); - insightsFile.Statuses = InsightsManager.Default.GetStatuses(request.StartDateUTC, request.EndDateUTC); - insightsFile.ToFile(filePath); - }); + InsightsFile insightsFile = new InsightsFile(); + var filePath = TemporaryManager.CreateImaginaryFile(); + + await Task.Factory.StartNew(() => + { + var frames = InsightsManager.Default.GetFrames(request.StartDateUTC, request.EndDateUTC); + insightsFile.Frames = frames; + + if (request.IncludeEvents) + { + insightsFile.Events = InsightsManager.Default.GetEvents(request.StartDateUTC, request.EndDateUTC); + } + + if (request.IncludeStatuses) + { + insightsFile.Statuses = InsightsManager.Default.GetStatuses(request.StartDateUTC, request.EndDateUTC); + } + + insightsFile.ToFile(filePath); + }); - await receiver.SendGenericResponse(new InsightsResponse() + await receiver.SendGenericResponse(new InsightsResponse() + { + InisightsFilePath = filePath, + InsightsFileLength = new FileInfo(filePath).Length + }, token); + } + catch (Exception ex) { - InisightsFilePath = filePath, - InsightsFileLength = new FileInfo(filePath).Length - }, token); + LogManager.Log(ex, "Error processing insights request."); + } } public void OnReceiverDisconnected(ExternalBridgeReceiver receiver) 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 23d19f4c9..6603a05b5 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Shared/Insights/InsightsRequest.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Shared/Insights/InsightsRequest.cs @@ -10,5 +10,14 @@ namespace Tango.PPC.Shared.Insights { public DateTime StartDateUTC { get; set; } public DateTime EndDateUTC { get; set; } + + public bool IncludeEvents { get; set; } + public bool IncludeStatuses { get; set; } + + public InsightsRequest() + { + IncludeEvents = true; + IncludeStatuses = true; + } } } |
