From d29c150081eda4858b4f34edf7a04f199cee7443 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Thu, 6 Nov 2025 10:47:57 +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/Common/EmailLogService.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/EmailLogService.cs b/IRaCIS.Core.Application/Service/Common/EmailLogService.cs index 872f51684..da2efe709 100644 --- a/IRaCIS.Core.Application/Service/Common/EmailLogService.cs +++ b/IRaCIS.Core.Application/Service/Common/EmailLogService.cs @@ -34,6 +34,7 @@ namespace IRaCIS.Core.Application.Service; /// [ApiExplorerSettings(GroupName = "Common")] public class EmailLogService(IRepository _emailLogRepository, + IRepository _trialRepository, IOSSService oSSService, IRepository _emailRecipientLogRepository, IOptionsMonitor systemEmailConfig, @@ -49,8 +50,14 @@ public class EmailLogService(IRepository _emailLogRepository, [HttpPost] public async Task> GetEmailLogList(EmailLogQuery inDto) { + var emailFromEmail = await _trialRepository.Where(x=>x.Id==inDto.TrialId).Select(x=>x.EmailFromEmail).FirstOrDefaultAsync(); + if (emailFromEmail.IsNullOrEmpty()) + { + emailFromEmail = _systemEmailConfig.FromEmail; + } var emailLogQueryable = _emailLogRepository + .Where(x=>x.SenderAddress== emailFromEmail) .WhereIf(inDto.EmailStartDate.HasValue, x => x.EmailDate >= inDto.EmailStartDate.Value) .WhereIf(inDto.EmailEndDate.HasValue, x => x.EmailDate <= inDto.EmailEndDate.Value) .WhereIf(inDto.EmailStateEnum.HasValue, x => x.EmailStateEnum == inDto.EmailStateEnum.Value) @@ -77,7 +84,7 @@ public class EmailLogService(IRepository _emailLogRepository, var emailInfo=await _emailLogRepository .Where(x => x.Id == inDto.Id).Include(x=>x.EmailRecipientLogList) - .ProjectTo(_mapper.ConfigurationProvider) + .ProjectTo(_mapper.ConfigurationProvider).AsNoTracking() .FirstNotNullAsync(); if (emailInfo.UniqueId.IsNotNullOrEmpty()) @@ -123,10 +130,13 @@ public class EmailLogService(IRepository _emailLogRepository, } - await _emailLogRepository.UpdatePartialFromQueryAsync(emailInfo.Id.Value, x => new EmailLog() + var emailLog = await _emailLogRepository.FirstOrDefaultAsync(x => x.Id == emailInfo.Id.Value); + if (emailLog != null) { - Attachments = attachmentInfos - }); + emailLog.Attachments = attachmentInfos; + await _emailLogRepository.SaveChangesAsync() ; + } + emailInfo.Attachments = attachmentInfos; }