forked from ddrilling/AsbCloudServer
CS2-6: Логика регистрации передачи данных вынесена из конструктора контроллера в методы
This commit is contained in:
parent
0be4847f58
commit
f21c75d450
@ -3,7 +3,6 @@ using AsbCloudApp.Services;
|
||||
using AsbCloudWebApi.SignalR;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -41,19 +40,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
this.telemetryUserService = telemetryUserService;
|
||||
this.telemetryHubContext = telemetryHubContext;
|
||||
this.telemetryTracker = telemetryTracker;
|
||||
|
||||
RegisterRequest();
|
||||
}
|
||||
|
||||
private void RegisterRequest()
|
||||
{
|
||||
if (Request.Query.TryGetValue("uid", out Microsoft.Extensions.Primitives.StringValues pId) && pId.Count > 0)
|
||||
{
|
||||
string panelId = pId.First();
|
||||
telemetryTracker.SaveRequest(panelId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Принимает общую информацию по скважине
|
||||
/// </summary>
|
||||
@ -65,6 +53,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
public IActionResult PostInfo(string uid, [FromBody] TelemetryInfoDto info)
|
||||
{
|
||||
telemetryService.UpdateInfo(uid, info);
|
||||
telemetryTracker.SaveRequest(uid);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -84,6 +73,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (wellId != null && dtos.Any())
|
||||
Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos));
|
||||
|
||||
telemetryTracker.SaveRequest(uid);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -103,6 +93,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
if (dtos.Any())
|
||||
Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos));
|
||||
|
||||
telemetryTracker.SaveRequest(uid);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -117,6 +108,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
public IActionResult PostEvents(string uid, [FromBody] List<EventDto> events)
|
||||
{
|
||||
eventService.Upsert(uid, events);
|
||||
telemetryTracker.SaveRequest(uid);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -131,6 +123,7 @@ namespace AsbCloudWebApi.Controllers
|
||||
public IActionResult PostUsers(string uid, [FromBody] List<TelemetryUserDto> users)
|
||||
{
|
||||
telemetryUserService.Upsert(uid, users);
|
||||
telemetryTracker.SaveRequest(uid);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user