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 AsbCloudWebApi.SignalR;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -41,17 +40,6 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
this.telemetryUserService = telemetryUserService;
|
this.telemetryUserService = telemetryUserService;
|
||||||
this.telemetryHubContext = telemetryHubContext;
|
this.telemetryHubContext = telemetryHubContext;
|
||||||
this.telemetryTracker = telemetryTracker;
|
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)
|
public IActionResult PostInfo(string uid, [FromBody] TelemetryInfoDto info)
|
||||||
{
|
{
|
||||||
telemetryService.UpdateInfo(uid, info);
|
telemetryService.UpdateInfo(uid, info);
|
||||||
|
telemetryTracker.SaveRequest(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +73,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (wellId != null && dtos.Any())
|
if (wellId != null && dtos.Any())
|
||||||
Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos));
|
Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveDataSaub), dtos));
|
||||||
|
|
||||||
|
telemetryTracker.SaveRequest(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +93,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
if (dtos.Any())
|
if (dtos.Any())
|
||||||
Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos));
|
Task.Run(() => telemetryHubContext.Clients.Group($"well_{wellId}").SendAsync(nameof(ITelemetryHubClient.ReceiveMessages), dtos));
|
||||||
|
|
||||||
|
telemetryTracker.SaveRequest(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,6 +108,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public IActionResult PostEvents(string uid, [FromBody] List<EventDto> events)
|
public IActionResult PostEvents(string uid, [FromBody] List<EventDto> events)
|
||||||
{
|
{
|
||||||
eventService.Upsert(uid, events);
|
eventService.Upsert(uid, events);
|
||||||
|
telemetryTracker.SaveRequest(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +123,7 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public IActionResult PostUsers(string uid, [FromBody] List<TelemetryUserDto> users)
|
public IActionResult PostUsers(string uid, [FromBody] List<TelemetryUserDto> users)
|
||||||
{
|
{
|
||||||
telemetryUserService.Upsert(uid, users);
|
telemetryUserService.Upsert(uid, users);
|
||||||
|
telemetryTracker.SaveRequest(uid);
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user