delete comment

This commit is contained in:
eugeniy_ivanov 2023-04-14 00:46:31 +05:00
parent 9b1b1f9736
commit 4d5b8932a5
2 changed files with 14 additions and 17 deletions

View File

@ -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;

View File

@ -23,7 +23,7 @@ namespace AsbCloudWebApi.Controllers.GTR
private readonly IGtrRepository gtrRepository;
private readonly IHubContext<TelemetryHub> 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
/// <param name = "token" > Токен завершения задачи</param>
/// <returns></returns>
[HttpGet("{idWell}")]
//[Permission]
[Permission]
public async Task<ActionResult<IEnumerable<WitsRecordDto>>> 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<IActionResult> 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();
}
}