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 IReportService reportService;
|
||||||
private readonly FileService fileService;
|
private readonly FileService fileService;
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
private readonly IHubContext<ReportsHub> reportsHubContext;
|
private readonly IHubContext<ReportsHub, IReportHubClient> reportsHubContext;
|
||||||
|
|
||||||
public ReportController(IReportService reportService, IWellService wellService,
|
public ReportController(IReportService reportService, IWellService wellService,
|
||||||
FileService fileService, IHubContext<ReportsHub> reportsHubContext)
|
FileService fileService, IHubContext<ReportsHub, IReportHubClient> reportsHubContext)
|
||||||
{
|
{
|
||||||
this.reportService = reportService;
|
this.reportService = reportService;
|
||||||
this.fileService = fileService;
|
this.fileService = fileService;
|
||||||
@ -60,18 +60,8 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
void HandleReportProgressAsync(object progress, string id) =>
|
void HandleReportProgressAsync(object progress, string id) =>
|
||||||
Task.Run(async() =>
|
Task.Run(async() =>
|
||||||
{
|
{
|
||||||
//reportsHubContext.Clients.Group($"Report_{id}")
|
await reportsHubContext.Clients.Group($"Report_{id}")
|
||||||
// .GetReportProgressTest(progress, token);
|
.GetReportProgress(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);
|
|
||||||
}, token);
|
}, token);
|
||||||
|
|
||||||
var id = reportService.EnqueueCreateReportWork(idWell, (int)idUser,
|
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) =>
|
public virtual Task RemoveFromGroup(string groupName) =>
|
||||||
Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
|
Groups.RemoveFromGroupAsync(Context.ConnectionId, groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class BaseHub2 : Hub
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
@ -2,7 +2,6 @@
|
|||||||
using AsbCloudInfrastructure.Background;
|
using AsbCloudInfrastructure.Background;
|
||||||
using AsbCloudWebApi.SignalR.Clients;
|
using AsbCloudWebApi.SignalR.Clients;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.SignalR;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -16,8 +15,7 @@ namespace AsbCloudWebApi.SignalR
|
|||||||
/// ReportsHub
|
/// ReportsHub
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class ReportsHub : BaseHub2
|
public class ReportsHub : BaseHub<IReportHubClient>
|
||||||
//BaseHub<IReportHubClient> //Hub<IReportHubClient> //BaseHub<>
|
|
||||||
{
|
{
|
||||||
private readonly BackgroundWorker backgroundWorker;
|
private readonly BackgroundWorker backgroundWorker;
|
||||||
|
|
||||||
@ -31,10 +29,9 @@ namespace AsbCloudWebApi.SignalR
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="groupName"></param>
|
/// <param name="groupName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task AddToGroup(string groupName)
|
public override async Task AddToGroup(string groupName)
|
||||||
{
|
{
|
||||||
//await this.AddToGroup(groupName);
|
await base.AddToGroup(groupName);
|
||||||
//await this.Groups.AddToGroupAsync(Context.ConnectionId, groupName);
|
|
||||||
|
|
||||||
var workId = groupName.Replace("Report_", "");
|
var workId = groupName.Replace("Report_", "");
|
||||||
var work = backgroundWorker.WorkStore.RunOnceQueue.FirstOrDefault(work => work.Id == workId);
|
var work = backgroundWorker.WorkStore.RunOnceQueue.FirstOrDefault(work => work.Id == workId);
|
||||||
@ -51,19 +48,8 @@ namespace AsbCloudWebApi.SignalR
|
|||||||
progress.Operation = state.State;
|
progress.Operation = state.State;
|
||||||
progress.Progress = (float)state.Progress;
|
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