DD.WellWorkover.Cloud/AsbCloudWebApi/Controllers/WitsController.cs
2022-04-01 17:55:44 +05:00

64 lines
2.3 KiB
C#

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<TelemetryHub> telemetryHubContext;
public WitsController(
IWitsRepository witsService,
ITelemetryService telemetryService,
IHubContext<TelemetryHub> telemetryHubContext)
{
this.witsService = witsService;
this.telemetryService = telemetryService;
this.telemetryHubContext = telemetryHubContext;
}
//[HttpPost("record1")]
//[AllowAnonymous]
//public virtual async Task<IActionResult> PostDataAsync(string uid, [FromBody] IEnumerable<TDto> 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<IActionResult> PostDataAsync<TDto>(
// string uid,
// IEnumerable<TDto> 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();
//}
}
}