forked from ddrilling/AsbCloudServer
Правки в ReportsHub, удаление ненужного кода
This commit is contained in:
parent
f043253cf2
commit
11163bf977
@ -22,10 +22,10 @@ namespace AsbCloudWebApi.Controllers
|
||||
private readonly IReportService reportService;
|
||||
private readonly FileService fileService;
|
||||
private readonly IWellService wellService;
|
||||
private readonly IHubContext<ReportsHub> reportsHubContext;
|
||||
private readonly IHubContext<ReportsHub, IReportHubClient> reportsHubContext;
|
||||
|
||||
public ReportController(IReportService reportService, IWellService wellService,
|
||||
FileService fileService, IHubContext<ReportsHub> reportsHubContext)
|
||||
FileService fileService, IHubContext<ReportsHub, IReportHubClient> reportsHubContext)
|
||||
{
|
||||
this.reportService = reportService;
|
||||
this.fileService = fileService;
|
||||
@ -60,18 +60,8 @@ namespace AsbCloudWebApi.Controllers
|
||||
void HandleReportProgressAsync(object progress, string id) =>
|
||||
Task.Run(async() =>
|
||||
{
|
||||
//reportsHubContext.Clients.Group($"Report_{id}")
|
||||
// .GetReportProgressTest(progress, token);
|
||||
//.ConfigureAwait(false);
|
||||
|
||||
//await reportsHubContext.Clients.Group($"Report_{id}")
|
||||
// .GetReportProgress(progress, token);
|
||||
|
||||
await reportsHubContext.Clients.Group($"Report_{id}").SendAsync(
|
||||
nameof(IReportHubClient.GetReportProgress),
|
||||
progress,
|
||||
token
|
||||
).ConfigureAwait(false);
|
||||
await reportsHubContext.Clients.Group($"Report_{id}")
|
||||
.GetReportProgress(progress, token);
|
||||
}, token);
|
||||
|
||||
var id = reportService.EnqueueCreateReportWork(idWell, (int)idUser,
|
||||
|
@ -12,8 +12,3 @@ public abstract class BaseHub<T> : Hub<T> where T : class
|
||||
public virtual Task RemoveFromGroup(string groupName) =>
|
||||
Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
|
||||
}
|
||||
|
||||
public abstract class BaseHub2 : Hub
|
||||
{
|
||||
|
||||
}
|
@ -2,7 +2,6 @@
|
||||
using AsbCloudInfrastructure.Background;
|
||||
using AsbCloudWebApi.SignalR.Clients;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -16,8 +15,7 @@ namespace AsbCloudWebApi.SignalR
|
||||
/// ReportsHub
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
public class ReportsHub : BaseHub2
|
||||
//BaseHub<IReportHubClient> //Hub<IReportHubClient> //BaseHub<>
|
||||
public class ReportsHub : BaseHub<IReportHubClient>
|
||||
{
|
||||
private readonly BackgroundWorker backgroundWorker;
|
||||
|
||||
@ -31,10 +29,9 @@ namespace AsbCloudWebApi.SignalR
|
||||
/// </summary>
|
||||
/// <param name="groupName"></param>
|
||||
/// <returns></returns>
|
||||
public async Task AddToGroup(string groupName)
|
||||
public override async Task AddToGroup(string groupName)
|
||||
{
|
||||
//await this.AddToGroup(groupName);
|
||||
//await this.Groups.AddToGroupAsync(Context.ConnectionId, groupName);
|
||||
await base.AddToGroup(groupName);
|
||||
|
||||
var workId = groupName.Replace("Report_", "");
|
||||
var work = backgroundWorker.WorkStore.RunOnceQueue.FirstOrDefault(work => work.Id == workId);
|
||||
@ -51,19 +48,8 @@ namespace AsbCloudWebApi.SignalR
|
||||
progress.Operation = state.State;
|
||||
progress.Progress = (float)state.Progress;
|
||||
}
|
||||
await Clients.Group(groupName).SendAsync(
|
||||
nameof(IReportHubClient.GetReportProgress),
|
||||
progress,
|
||||
CancellationToken.None
|
||||
);
|
||||
|
||||
//await Clients.Group(groupName).GetReportProgress(progress, CancellationToken.None);
|
||||
|
||||
await Clients.Group(groupName).GetReportProgress(progress, CancellationToken.None);
|
||||
}
|
||||
|
||||
//public async Task GetReportProgressTest(object obj, CancellationToken token)
|
||||
//{
|
||||
// await Clients.All.GetReportProgressTest(obj, token);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user