From c77682a9adc9ce535e217ebeed00ce058f401d97 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Fri, 28 Nov 2025 16:15:58 +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 --- .../Helper/Email/SendEmailHelper.cs | 9 ++++- .../IRaCIS.Core.Application.xml | 9 ++++- .../Service/Common/DTO/EmailLogViewModel.cs | 5 +++ .../Service/Common/EmailLogService.cs | 37 ++++++++++++++++++- IRaCIS.Core.Domain/Common/EmailReSendLog.cs | 19 ++++++++++ .../Context/IRaCISDBContext.cs | 1 + 6 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 IRaCIS.Core.Domain/Common/EmailReSendLog.cs diff --git a/IRaCIS.Core.Application/Helper/Email/SendEmailHelper.cs b/IRaCIS.Core.Application/Helper/Email/SendEmailHelper.cs index b954cb4f3..c8f0fe9f0 100644 --- a/IRaCIS.Core.Application/Helper/Email/SendEmailHelper.cs +++ b/IRaCIS.Core.Application/Helper/Email/SendEmailHelper.cs @@ -9,12 +9,15 @@ namespace IRaCIS.Core.Application.Helper; public static class SendEmailHelper { - public static async Task SendEmailAsync(MimeMessage messageToSend, SystemEmailSendConfig _systemEmailConfig, EventHandler? messageSentSuccess = null) + public static async Task SendEmailAsync(MimeMessage messageToSend, SystemEmailSendConfig _systemEmailConfig, EventHandler? messageSentSuccess = null) { + string result = string.Empty; + result = messageToSend.MessageId; + //没有收件人 那么不发送 if (messageToSend.To.Count == 0) { - return; + return string.Empty; } try @@ -52,6 +55,8 @@ public static class SendEmailHelper throw new Exception(I18n.T("SendEmail_SendFail"), new Exception(ex.Message)); } + return result; + } diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index a52be5e68..63010b3f7 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1446,7 +1446,7 @@ - + 邮件日志 @@ -1463,6 +1463,13 @@ + + + 获取重发信息 + + + + 获取单条邮件日志详情 diff --git a/IRaCIS.Core.Application/Service/Common/DTO/EmailLogViewModel.cs b/IRaCIS.Core.Application/Service/Common/DTO/EmailLogViewModel.cs index e564e7887..4ee085d5b 100644 --- a/IRaCIS.Core.Application/Service/Common/DTO/EmailLogViewModel.cs +++ b/IRaCIS.Core.Application/Service/Common/DTO/EmailLogViewModel.cs @@ -10,6 +10,11 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace IRaCIS.Core.Application.ViewModel; + +public class GetReSendEmailInDto : PageInput +{ + public Guid Id { get; set; } +} public class EmailLogView : EmailLogAddOrEdit { diff --git a/IRaCIS.Core.Application/Service/Common/EmailLogService.cs b/IRaCIS.Core.Application/Service/Common/EmailLogService.cs index 956f3dcb3..257619e5e 100644 --- a/IRaCIS.Core.Application/Service/Common/EmailLogService.cs +++ b/IRaCIS.Core.Application/Service/Common/EmailLogService.cs @@ -38,6 +38,8 @@ public class EmailLogService(IRepository _emailLogRepository, IRepository _trialRepository, IRepository _emailAttachmentLogRepository, IOSSService oSSService, + IRepository _emailReSendLog, + IRepository _emailRecipientLogRepository, IOptionsMonitor systemEmailConfig, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IEmailLogService @@ -75,6 +77,28 @@ public class EmailLogService(IRepository _emailLogRepository, } + /// + /// 获取重发信息 + /// + /// + /// + [HttpPost] + public async Task> GetReSendEmail(GetReSendEmailInDto inDto) + { + var messageId = await _emailLogRepository.Where(x => x.Id == inDto.Id).Select(x => x.MessageId).FirstOrDefaultAsync(); + + var reSendMessagelist = await _emailReSendLog.Where(x => x.MainMailMessageId == messageId).Select(x => x.ReMailMessageId).ToListAsync(); + var emailLogQueryable = _emailLogRepository + + .Where(x => reSendMessagelist.Contains(x.MessageId)) + .ProjectTo(_mapper.ConfigurationProvider); + + var defalutSortArray = new string[] { nameof(EmailLogView.EmailDate) + " desc" }; + var pageList = await emailLogQueryable.ToPagedListAsync(inDto, defalutSortArray); + + return pageList; + + } /// /// 获取单条邮件日志详情 /// @@ -222,7 +246,18 @@ public class EmailLogService(IRepository _emailLogRepository, messageToSend.Body = builder.ToMessageBody(); - await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig); + var msgid= await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig); + + + await _emailReSendLog.AddAsync(new EmailReSendLog() + { + MainMailMessageId= emailInfo.MessageId, + ReMailMessageId= msgid + }); + + await _emailReSendLog.SaveChangesAsync(); + + await SynchronizationEmail(); return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Domain/Common/EmailReSendLog.cs b/IRaCIS.Core.Domain/Common/EmailReSendLog.cs new file mode 100644 index 000000000..2817cb6f1 --- /dev/null +++ b/IRaCIS.Core.Domain/Common/EmailReSendLog.cs @@ -0,0 +1,19 @@ +using IRaCIS.Core.Domain.Share; + +namespace IRaCIS.Core.Domain.Models; + +[Comment("邮件重发日志")] +[Table("EmailReSendLog")] +public class EmailReSendLog : BaseFullAuditEntity +{ + /// + /// 邮件Id + /// + public string MainMailMessageId { get; set; } + + public string ReMailMessageId { get; set; } + + +} + + diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index d6d88e738..d0fb4b2dc 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -562,6 +562,7 @@ public class IRaCISDBContext : DbContext #region 未分类 public virtual DbSet EmailLog { get; set; } + public virtual DbSet EmailReSendLog { get; set; } public virtual DbSet EmailRecipientLog { get; set; } public virtual DbSet ShortcutKey { get; set; }