diff --git a/AsbCloudWebApi/Controllers/ReportController.cs b/AsbCloudWebApi/Controllers/ReportController.cs index 5e7a8fc2..c9f0c8d9 100644 --- a/AsbCloudWebApi/Controllers/ReportController.cs +++ b/AsbCloudWebApi/Controllers/ReportController.cs @@ -22,10 +22,10 @@ namespace AsbCloudWebApi.Controllers private readonly IReportService reportService; private readonly FileService fileService; private readonly IWellService wellService; - private readonly IHubContext reportsHubContext; + private readonly IHubContext reportsHubContext; public ReportController(IReportService reportService, IWellService wellService, - FileService fileService, IHubContext reportsHubContext) + FileService fileService, IHubContext 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, diff --git a/AsbCloudWebApi/SignalR/BaseHub.cs b/AsbCloudWebApi/SignalR/BaseHub.cs index 1bb151c1..28de8ab5 100644 --- a/AsbCloudWebApi/SignalR/BaseHub.cs +++ b/AsbCloudWebApi/SignalR/BaseHub.cs @@ -12,8 +12,3 @@ public abstract class BaseHub : Hub where T : class public virtual Task RemoveFromGroup(string groupName) => Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName); } - -public abstract class BaseHub2 : Hub -{ - -} \ No newline at end of file diff --git a/AsbCloudWebApi/SignalR/ReportsHub.cs b/AsbCloudWebApi/SignalR/ReportsHub.cs index c4335396..f0608eac 100644 --- a/AsbCloudWebApi/SignalR/ReportsHub.cs +++ b/AsbCloudWebApi/SignalR/ReportsHub.cs @@ -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 /// [Authorize] - public class ReportsHub : BaseHub2 - //BaseHub //Hub //BaseHub<> + public class ReportsHub : BaseHub { private readonly BackgroundWorker backgroundWorker; @@ -31,10 +29,9 @@ namespace AsbCloudWebApi.SignalR /// /// /// - 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); - //} } }