邮件根据接收人工作语言,动态设置邮件模板

This commit is contained in:
2026-05-13 11:05:22 +08:00
parent 030aa36f94
commit fdb124b12e
7 changed files with 403 additions and 350 deletions
@@ -173,23 +173,16 @@ namespace IRaCIS.Core.Application.Services
if (newUserTypeIds.Any()&& newUserTypeIds.Count()>0)
{
// 发送邮件给新增的角色
Console.WriteLine("开始 发送系统文档更新邮件给新增角色");
Console.WriteLine(string.Join(",", newUserTypeIds));
Log.Logger.Warning("开始 发送系统文档更新邮件给新增角色");
Log.Logger.Warning(string.Join(",", newUserTypeIds));
Task.Run(async () =>
// 只发送给新增的角色
await _mediatorScoped.Publish(new SystemDocumentPublishEvent
{
// 创建独立作用域
using (var scope = serviceScopeFactory.CreateScope())
{
// 从新作用域解析服务
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
// 只发送给新增的角色
await mediator.Publish(new SystemDocumentPublishEvent {
Ids = new List<Guid> { document.Id },
NewUserTypeIds = newUserTypeIds
});
}
Ids = new List<Guid> { document.Id },
NewUserTypeIds = newUserTypeIds
});
}
}
@@ -214,18 +207,10 @@ namespace IRaCIS.Core.Application.Services
IsDeleted = false,
});
Console.WriteLine("开始 发布系统文档");
Log.Logger.Warning("开始 发布系统文档");
await _mediatorScoped.Publish(new SystemDocumentPublishEvent { Ids = inDto.Ids });
Task.Run(async () =>
{
// 创建独立作用域
using (var scope = serviceScopeFactory.CreateScope())
{
// 从新作用域解析服务
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
await mediator.Publish(new SystemDocumentPublishEvent { Ids = inDto.Ids });
}
});
return ResponseOutput.Result(true);
@@ -27,6 +27,7 @@ namespace IRaCIS.Core.Application.Services
[ApiExplorerSettings(GroupName = "Trial")]
public class TrialDocumentService(IRepository<TrialDocument> _trialDocumentRepository,
IRepository<Trial> _trialRepository,
IScopedMediator _mediatorScoped,
IRepository<AuditRecord> _auditRecordRepository,
IRepository<TrialDocumentAttachment> _trialDocumentAttachmentRepository,
ISystemDocumentService _systemDocumentService,
@@ -105,18 +106,11 @@ namespace IRaCIS.Core.Application.Services
IsDeleted = false,
}, false, true);
await _trialDocumentRepository.SaveChangesAsync();
Console.WriteLine("开始 发布项目文档");
Serilog.Log.Logger.Warning("开始 发布项目文档");
Task.Run(async () =>
{
// 创建独立作用域
using (var scope = serviceScopeFactory.CreateScope())
{
// 从新作用域解析服务
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
await mediator.Publish(new TrialDocumentPublishEvent { Ids = inDto.Ids });
}
});
await _mediatorScoped.Publish(new TrialDocumentPublishEvent { Ids = inDto.Ids });
return ResponseOutput.Result(true);
@@ -128,32 +122,20 @@ namespace IRaCIS.Core.Application.Services
/// <returns></returns>
public async Task<IResponseOutput> TestPush()
{
Task.Run(async () =>
{
// 创建独立作用域
using (var scope = serviceScopeFactory.CreateScope())
{
// 从新作用域解析服务
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
await mediator.Publish(new TrialDocumentErverDayEvent { });
}
});
await _mediatorScoped.Publish(new TrialDocumentErverDayEvent { });
return ResponseOutput.Result(true);
}
public async Task<IResponseOutput> TestSendEmail()
{
Task.Run(async () =>
{
// 创建独立作用域
using (var scope = serviceScopeFactory.CreateScope())
{
// 从新作用域解析服务
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
await mediator.Publish(new ImageQCRecurringEvent { TrialId = Guid.Parse("08de2254-5d7d-581a-0242-0a0001000000") });
}
});
await _mediatorScoped.Publish(new ImageQCRecurringEvent { TrialId = Guid.Parse("08de2254-5d7d-581a-0242-0a0001000000") });
return ResponseOutput.Result(true);
}
@@ -1170,21 +1152,13 @@ namespace IRaCIS.Core.Application.Services
Console.WriteLine("开始 发送项目文档更新邮件给新增角色");
Console.WriteLine(string.Join(",", newUserTypeIds));
Task.Run(async () =>
await _mediatorScoped.Publish(new TrialDocumentPublishEvent
{
// 创建独立作用域
using (var scope = serviceScopeFactory.CreateScope())
{
// 从新作用域解析服务
var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
// 只发送给新增的角色
await mediator.Publish(new TrialDocumentPublishEvent
{
Ids = new List<Guid> { document.Id },
NewUserTypeIds = newUserTypeIds
});
}
Ids = new List<Guid> { document.Id },
NewUserTypeIds = newUserTypeIds
});
}
}
return ResponseOutput.Ok(document.Id.ToString());