From 05de113e9e801f61590fcb650b4c1c48ac3cdd62 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Wed, 1 Nov 2023 17:45:25 +0500 Subject: [PATCH] =?UTF-8?q?TelemetryDataBaseService.GetRangeAsync=20=D0=B2?= =?UTF-8?q?=D0=BE=D1=81=D1=81=D1=82=D0=B0=D0=BD=D0=BE=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=B4=D0=BB=D1=8F=20Witsml.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudApp/Services/ITelemetryDataService.cs | 2 +- .../Services/SAUB/TelemetryDataBaseService.cs | 6 ++++-- .../Controllers/SAUB/TelemetryDataBaseController.cs | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/AsbCloudApp/Services/ITelemetryDataService.cs b/AsbCloudApp/Services/ITelemetryDataService.cs index 583da43e..bb40771b 100644 --- a/AsbCloudApp/Services/ITelemetryDataService.cs +++ b/AsbCloudApp/Services/ITelemetryDataService.cs @@ -44,7 +44,7 @@ namespace AsbCloudApp.Services /// /// /// - Task GetRangeAsync(int idWell, DateTimeOffset geDate, DateTimeOffset? leDate, CancellationToken token); + Task GetRangeAsync(int idWell, DateTimeOffset geDate, DateTimeOffset? leDate, CancellationToken token); /// /// Период за который есть данные по скважине diff --git a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataBaseService.cs b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataBaseService.cs index a837ae04..44f730d3 100644 --- a/AsbCloudInfrastructure/Services/SAUB/TelemetryDataBaseService.cs +++ b/AsbCloudInfrastructure/Services/SAUB/TelemetryDataBaseService.cs @@ -205,7 +205,7 @@ namespace AsbCloudInfrastructure.Services.SAUB } /// - public async Task GetRangeAsync(int idWell, DateTimeOffset geDate, DateTimeOffset? leDate, CancellationToken token) + public async Task GetRangeAsync(int idWell, DateTimeOffset geDate, DateTimeOffset? leDate, CancellationToken token) { var telemetry = telemetryService.GetOrDefaultTelemetryByIdWell(idWell) ?? throw new ArgumentInvalidException(nameof(idWell), $"По скважине id:{idWell} нет телеметрии"); @@ -242,7 +242,9 @@ namespace AsbCloudInfrastructure.Services.SAUB MaxDate = group.Max(entity => entity.DateTime), }); - var result = await gquery.FirstAsync(token); + var result = await gquery.FirstOrDefaultAsync(token); + if (result is null) + return null; var range = new DatesRangeDto { diff --git a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs index 21efdcde..a09fd6bf 100644 --- a/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs +++ b/AsbCloudWebApi/Controllers/SAUB/TelemetryDataBaseController.cs @@ -136,6 +136,8 @@ namespace AsbCloudWebApi.Controllers.SAUB /// /// [HttpGet("{idWell}/dateRange")] + [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] + [ProducesResponseType((int)System.Net.HttpStatusCode.NotFound)] public virtual async Task> GetRangeAsync( [FromRoute] int idWell, [Required] DateTimeOffset geDate, @@ -167,7 +169,8 @@ namespace AsbCloudWebApi.Controllers.SAUB [HttpGet("{idWell}/datesRange")] [Permission] [ProducesResponseType(typeof(DatesRangeDto), (int)System.Net.HttpStatusCode.OK)] - public virtual async Task> GetDataDatesRangeAsync(int idWell, + [ProducesResponseType((int)System.Net.HttpStatusCode.NotFound)] + public virtual async Task> GetDataDatesRangeAsync(int idWell, CancellationToken token) { int? idCompany = User.GetCompanyId();