using AsbCloudApp.Services; using AsbCloudWebApi.SignalR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; namespace AsbCloudWebApi.Controllers { [Route("api/telemetry/{uid}/wits")] [ApiController] public class WitsController : ControllerBase { private readonly IWitsRepository witsService; private readonly ITelemetryService telemetryService; private readonly IHubContext telemetryHubContext; public WitsController( IWitsRepository witsService, ITelemetryService telemetryService, IHubContext telemetryHubContext) { this.witsService = witsService; this.telemetryService = telemetryService; this.telemetryHubContext = telemetryHubContext; } //[HttpPost("record1")] //[AllowAnonymous] //public virtual async Task PostDataAsync(string uid, [FromBody] IEnumerable dtos, // CancellationToken token = default) //{ // await telemetryDataService.UpdateDataAsync(uid, dtos, token).ConfigureAwait(false); // var idWell = telemetryService.GetIdWellByTelemetryUid(uid); // if (idWell != null && dtos.Any()) // _ = Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}") // .SendAsync(SirnalRMethodGetDataName, dtos), CancellationToken.None); // return Ok(); //} //private async Task PostDataAsync( // string uid, // IEnumerable dtos, // CancellationToken token = default) //{ // //await witsService.SaveDataAsync(uid, dtos, token).ConfigureAwait(false); // var idWell = telemetryService.GetIdWellByTelemetryUid(uid); // if (idWell != null && dtos.Any()) // _ = Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}") // .SendAsync(SirnalRMethodGetDataName, dtos), CancellationToken.None); // return Ok(); //} } }