修改hub

Uat_Study
hang 2022-08-05 17:22:43 +08:00
parent e6239aef8b
commit ef81a4c27e
3 changed files with 17 additions and 16 deletions

View File

@ -281,7 +281,12 @@ namespace IRaCIS.Core.API.Controllers
} }
} }
await _uploadHub.Clients.All.ReceivProgressAsync(archiveStudyCommand.StudyInstanceUid, receivedCount); //await _uploadHub.Clients.All.ReceivProgressAsync(archiveStudyCommand.StudyInstanceUid, receivedCount);
await _uploadHub.Clients.User(_userInfo.Id.ToString()).ReceivProgressAsync(archiveStudyCommand.StudyInstanceUid, receivedCount);
} }
catch (Exception e) catch (Exception e)

View File

@ -14,6 +14,14 @@ namespace IRaCIS.Core.API
} }
public class IRaCISUserIdProvider : IUserIdProvider
{
public virtual string GetUserId(HubConnectionContext connection)
{
return connection.User?.FindFirst(JwtIRaCISClaimType.Id)?.Value!;
}
}
//[Authorize] //[Authorize]
[AllowAnonymous] [AllowAnonymous]
[DisableCors] [DisableCors]

View File

@ -21,6 +21,7 @@ using Magicodes.ExporterAndImporter.Core.Filters;
using IRaCIS.Core.Application.MediatR.CommandAndQueries; using IRaCIS.Core.Application.MediatR.CommandAndQueries;
using IRaCIS.Core.Infra.EFCore.Common; using IRaCIS.Core.Infra.EFCore.Common;
using Invio.Extensions.Authentication.JwtBearer; using Invio.Extensions.Authentication.JwtBearer;
using Microsoft.AspNetCore.SignalR;
namespace IRaCIS.Core.API namespace IRaCIS.Core.API
{ {
@ -149,21 +150,8 @@ namespace IRaCIS.Core.API
// 实时应用 // 实时应用
services.AddSignalR(); services.AddSignalR();
////设置跨域访问
//services.AddCors(options => services.AddSingleton<IUserIdProvider, IRaCISUserIdProvider>();
//{
// //hub使用
// options.AddPolicy("any", builder =>
// {
// builder
// .AllowAnyMethod()
// .AllowAnyHeader()
// .AllowAnyOrigin()
// .DisallowCredentials();
// });
// //公开使用
//});
//services.AddSingleton<IImportResultFilter, ImportResultFilteTest>(); //services.AddSingleton<IImportResultFilter, ImportResultFilteTest>();