forked from ddrilling/AsbCloudServer
Правка по результатам ревью
This commit is contained in:
parent
11163bf977
commit
107a81f24d
@ -2,6 +2,7 @@
|
||||
using AsbCloudApp.Requests;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudWebApi.SignalR;
|
||||
using AsbCloudWebApi.SignalR.Clients;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
@ -23,20 +24,22 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
protected readonly IWellService wellService;
|
||||
private readonly ITelemetryService telemetryService;
|
||||
private readonly ITelemetryDataService<TDto> telemetryDataService;
|
||||
private readonly IHubContext<TelemetryHub> telemetryHubContext;
|
||||
|
||||
public string SignalRMethodGetDataName { get; protected set; } = "ReceiveData";
|
||||
protected readonly IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext;
|
||||
public Action<int?, IEnumerable<TDto>> SignalrReceiveDataOperation { get; set; }
|
||||
|
||||
public TelemetryDataBaseController(
|
||||
ITelemetryService telemetryService,
|
||||
ITelemetryDataService<TDto> telemetryDataService,
|
||||
IWellService wellService,
|
||||
IHubContext<TelemetryHub> telemetryHubContext)
|
||||
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext)
|
||||
{
|
||||
this.telemetryService = telemetryService;
|
||||
this.telemetryDataService = telemetryDataService;
|
||||
this.wellService = wellService;
|
||||
this.telemetryHubContext = telemetryHubContext;
|
||||
this.SignalrReceiveDataOperation = (int? idWell, IEnumerable<TDto> dtos) => {
|
||||
telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveData<TDto>(dtos, CancellationToken.None);
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -55,8 +58,7 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
|
||||
var idWell = telemetryService.GetIdWellByTelemetryUid(uid);
|
||||
if (idWell is not null && dtos.Any())
|
||||
_ = Task.Run(() => telemetryHubContext.Clients.Group($"well_{idWell}")
|
||||
.SendAsync(SignalRMethodGetDataName, dtos), CancellationToken.None);
|
||||
_ = Task.Run(() => SignalrReceiveDataOperation.Invoke(idWell, dtos));
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
using AsbCloudApp.Data.SAUB;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudWebApi.SignalR;
|
||||
using AsbCloudWebApi.SignalR.Clients;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers.SAUB
|
||||
{
|
||||
@ -23,14 +25,16 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
ITelemetryService telemetryService,
|
||||
ITelemetryDataSaubService telemetryDataService,
|
||||
IWellService wellService,
|
||||
IHubContext<TelemetryHub> telemetryHubContext)
|
||||
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext)
|
||||
: base(
|
||||
telemetryService,
|
||||
telemetryDataService,
|
||||
wellService,
|
||||
telemetryHubContext)
|
||||
{
|
||||
SignalRMethodGetDataName = "ReceiveDataSaub";
|
||||
SignalrReceiveDataOperation = (int? idWell, IEnumerable<TelemetryDataSaubDto> dtos) => {
|
||||
telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveDataSaub<TelemetryDataSaubDto>(dtos, CancellationToken.None);
|
||||
};
|
||||
telemetryDataSaubService = telemetryDataService;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
using AsbCloudApp.Data.SAUB;
|
||||
using AsbCloudApp.Services;
|
||||
using AsbCloudWebApi.SignalR;
|
||||
using AsbCloudWebApi.SignalR.Clients;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace AsbCloudWebApi.Controllers.SAUB
|
||||
{
|
||||
@ -17,14 +20,16 @@ namespace AsbCloudWebApi.Controllers.SAUB
|
||||
ITelemetryService telemetryService,
|
||||
ITelemetryDataService<TelemetryDataSpinDto> telemetryDataService,
|
||||
IWellService wellService,
|
||||
IHubContext<TelemetryHub> telemetryHubContext)
|
||||
IHubContext<TelemetryHub, ITelemetryHubClient> telemetryHubContext)
|
||||
: base(
|
||||
telemetryService,
|
||||
telemetryDataService,
|
||||
wellService,
|
||||
telemetryHubContext)
|
||||
{
|
||||
SignalRMethodGetDataName = "ReceiveDataSpin";
|
||||
SignalrReceiveDataOperation = (int? idWell, IEnumerable<TelemetryDataSpinDto> dtos) => {
|
||||
telemetryHubContext.Clients.Group($"well_{idWell}").ReceiveDataSpin<TelemetryDataSpinDto>(dtos, CancellationToken.None);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,12 @@ namespace AsbCloudWebApi.SignalR.Clients
|
||||
public interface INotificationHubClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Отправка клиенту сообщения с уведомлением
|
||||
/// Отправка клиенту сообщения с уведомлением.
|
||||
/// Для подписки на метод необходимо отправить connectionId
|
||||
/// </summary>
|
||||
/// <param name="message">сообщение с уведомлением</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task ReceiveNotifications(NotificationMessage message, CancellationToken token = default);
|
||||
Task ReceiveNotifications(NotificationMessage message, CancellationToken token);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,8 @@ namespace AsbCloudWebApi.SignalR.Clients
|
||||
public interface IReportHubClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Отправка клиенту сообщения о статусе формирования отчета
|
||||
/// Отправка клиенту сообщения о статусе формирования отчета.
|
||||
/// Для подписки на метод необходимо отправить сообщение в формате $"Report_{id}"
|
||||
/// </summary>
|
||||
/// <param name="progress">статус формирования отчета</param>
|
||||
/// <param name="token"></param>
|
||||
|
@ -1,8 +1,6 @@
|
||||
using AsbCloudApp.Data;
|
||||
using AsbCloudApp.Data.SAUB;
|
||||
using AsbCloudApp.Data.SAUB;
|
||||
using SignalRSwaggerGen.Attributes;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -15,12 +13,13 @@ namespace AsbCloudWebApi.SignalR.Clients
|
||||
public interface ITelemetryHubClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Отправка клиенту уведомления о доставке с панели drill test данных
|
||||
/// Отправка клиенту уведомления о доставке с панели drill test данных.
|
||||
/// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}"
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task ReceiveDrilltestData(DrillTestDto dto, CancellationToken token = default);
|
||||
Task ReceiveDrilltestData(DrillTestDto dto, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@ -29,6 +28,37 @@ namespace AsbCloudWebApi.SignalR.Clients
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateProcessMap<T>(IEnumerable dtos, CancellationToken token = default);
|
||||
Task UpdateProcessMap<T>(IEnumerable dtos, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Отправка данных клиенту.
|
||||
/// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}"
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task ReceiveData<T>(IEnumerable dtos, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Отправка сауб-данных клиенту.
|
||||
/// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}"
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task ReceiveDataSaub<T>(IEnumerable dtos, CancellationToken token);
|
||||
|
||||
/// <summary>
|
||||
/// Отправка спин-данных клиенту.
|
||||
/// Для подписки на метод необходимо отправить сообщение в формате $"well_{idWell}"
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="dtos"></param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task ReceiveDataSpin<T>(IEnumerable dtos, CancellationToken token);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -13,10 +13,11 @@ namespace AsbCloudWebApi.SignalR.Clients
|
||||
{
|
||||
/// <summary>
|
||||
/// Отправка клиенту сообщения об обновлении информации о скважине
|
||||
/// Для подписки на метод необходимо отправить сообщение в формате $"well_info_{idWell}"
|
||||
/// </summary>
|
||||
/// <param name="wellInfo">информация о скважине</param>
|
||||
/// <param name="token"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateWellInfo(object wellInfo, CancellationToken token = default);
|
||||
Task UpdateWellInfo(object wellInfo, CancellationToken token);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user