From 4d5b8932a5b954e8ba76d9e55f5c134e0632824a Mon Sep 17 00:00:00 2001 From: eugeniy_ivanov Date: Fri, 14 Apr 2023 00:46:31 +0500 Subject: [PATCH] delete comment --- .../Repository/GtrWitsRepository.cs | 1 - .../Controllers/GTR/GtrWitsController.cs | 30 +++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs index 15128a49..b96448f2 100644 --- a/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs +++ b/AsbCloudInfrastructure/Repository/GtrWitsRepository.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; diff --git a/AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs b/AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs index 01af471e..2b9dd79c 100644 --- a/AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs +++ b/AsbCloudWebApi/Controllers/GTR/GtrWitsController.cs @@ -23,7 +23,7 @@ namespace AsbCloudWebApi.Controllers.GTR private readonly IGtrRepository gtrRepository; private readonly IHubContext telemetryHubContext; - //public string SirnalRMethodGetDataName { get; protected set; } = "ReceiveData"; + public string SirnalRMethodGetDataName { get; protected set; } = "ReceiveData"; public GtrWitsController( ITelemetryService telemetryService, @@ -47,20 +47,20 @@ namespace AsbCloudWebApi.Controllers.GTR /// Токен завершения задачи /// [HttpGet("{idWell}")] - //[Permission] + [Permission] public async Task>> GetDataAsync(int idWell, DateTime begin = default, int intervalSec = 600, int approxPointsCount = 1024, CancellationToken token = default) { - //int? idCompany = User.GetCompanyId(); + int? idCompany = User.GetCompanyId(); - //if (idCompany is null) - // return Forbid(); + if (idCompany is null) + return Forbid(); - //bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, - // idWell, token).ConfigureAwait(false); + bool isCompanyOwnsWell = await wellService.IsCompanyInvolvedInWellAsync((int)idCompany, + idWell, token).ConfigureAwait(false); - //if (!isCompanyOwnsWell) - // return Forbid(); + if (!isCompanyOwnsWell) + return Forbid(); var content = await gtrRepository.GetAsync(idWell, begin, intervalSec, approxPointsCount, token).ConfigureAwait(false); @@ -71,17 +71,15 @@ namespace AsbCloudWebApi.Controllers.GTR [HttpPost("{uid}")] public async Task PostDataAsync( string uid, - [FromBody] WitsRecordDto dto, - [FromServices] IGtrRepository gtrRepository, + [FromBody] WitsRecordDto dto, CancellationToken token = default) { var idTelemetry = telemetryService.GetOrCreateTelemetryIdByUid(uid); await gtrRepository.SaveDataAsync(idTelemetry, dto, token).ConfigureAwait(false); - //var idWell = telemetryService.GetIdWellByTelemetryUid(uid); - //if (idWell != null && dtos.Any()) - // _ = Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}_wits") - // .SendAsync(SirnalRMethodGetDataName, dtos), CancellationToken.None); - + var idWell = telemetryService.GetIdWellByTelemetryUid(uid); + if (idWell is not null && dto is not null) + _ = Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}_wits") + .SendAsync(SirnalRMethodGetDataName, dto), CancellationToken.None); return Ok(); } }