diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-19 05:18:18 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-19 05:18:18 +0300 |
| commit | ee5797d5754ff5b15f5d5224a8d797806701bb00 (patch) | |
| tree | 030b7244b7e66bb59344bf0beb798922a6275abd /Software | |
| parent | ba766608b41016546bc5be1a7246d8b60e180317 (diff) | |
| download | Tango-ee5797d5754ff5b15f5d5224a8d797806701bb00.tar.gz Tango-ee5797d5754ff5b15f5d5224a8d797806701bb00.zip | |
Added insights selection to request message.
Diffstat (limited to 'Software')
| -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; + } } } |
