From afd34c7c9b677b5864d4e78aa7521596118cc67e Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Mon, 21 Apr 2025 14:15:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Document/SystemDocumentService.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs index 5a1c520e4..dbd815f8a 100644 --- a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; using UserRole = IRaCIS.Core.Domain.Models.UserRole; using IRaCIS.Core.Application.MassTransit.Consumer; using MassTransit.Mediator; +using Microsoft.Extensions.DependencyInjection; namespace IRaCIS.Core.Application.Services { @@ -23,6 +24,7 @@ namespace IRaCIS.Core.Application.Services IScopedMediator _mediatorScoped, IRepository _systemDocumentAttachmentRepository, IRepository _identityUserRepository, + IServiceScopeFactory serviceScopeFactory, IRepository _systemDocConfirmedUserRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ISystemDocumentService { @@ -175,10 +177,18 @@ namespace IRaCIS.Core.Application.Services }); + Task.Run(async () => + { + // 创建独立作用域 + using (var scope = serviceScopeFactory.CreateScope()) + { + // 从新作用域解析服务 + var mediator = scope.ServiceProvider.GetRequiredService(); + await mediator.Publish(new SystemDocumentPublishEvent { Ids = inDto.Ids }); + } + }); - _mediatorScoped.Publish(new SystemDocumentPublishEvent() { Ids = inDto.Ids }); - return ResponseOutput.Result(true); }