修改
continuous-integration/drone/push Build is passing Details

Test_IRC_Net8
he 2025-11-06 10:47:57 +08:00
parent 4d3ecd05dc
commit d29c150081
1 changed files with 14 additions and 4 deletions

View File

@ -34,6 +34,7 @@ namespace IRaCIS.Core.Application.Service;
/// <param name="_localizer"></param> /// <param name="_localizer"></param>
[ApiExplorerSettings(GroupName = "Common")] [ApiExplorerSettings(GroupName = "Common")]
public class EmailLogService(IRepository<EmailLog> _emailLogRepository, public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
IRepository<Trial> _trialRepository,
IOSSService oSSService, IOSSService oSSService,
IRepository<EmailRecipientLog> _emailRecipientLogRepository, IRepository<EmailRecipientLog> _emailRecipientLogRepository,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig, IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
@ -49,8 +50,14 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
[HttpPost] [HttpPost]
public async Task<PageOutput<EmailLogView>> GetEmailLogList(EmailLogQuery inDto) public async Task<PageOutput<EmailLogView>> 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 var emailLogQueryable = _emailLogRepository
.Where(x=>x.SenderAddress== emailFromEmail)
.WhereIf(inDto.EmailStartDate.HasValue, x => x.EmailDate >= inDto.EmailStartDate.Value) .WhereIf(inDto.EmailStartDate.HasValue, x => x.EmailDate >= inDto.EmailStartDate.Value)
.WhereIf(inDto.EmailEndDate.HasValue, x => x.EmailDate <= inDto.EmailEndDate.Value) .WhereIf(inDto.EmailEndDate.HasValue, x => x.EmailDate <= inDto.EmailEndDate.Value)
.WhereIf(inDto.EmailStateEnum.HasValue, x => x.EmailStateEnum == inDto.EmailStateEnum.Value) .WhereIf(inDto.EmailStateEnum.HasValue, x => x.EmailStateEnum == inDto.EmailStateEnum.Value)
@ -77,7 +84,7 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
var emailInfo=await _emailLogRepository var emailInfo=await _emailLogRepository
.Where(x => x.Id == inDto.Id).Include(x=>x.EmailRecipientLogList) .Where(x => x.Id == inDto.Id).Include(x=>x.EmailRecipientLogList)
.ProjectTo<GetEmailInfoOutDto>(_mapper.ConfigurationProvider) .ProjectTo<GetEmailInfoOutDto>(_mapper.ConfigurationProvider).AsNoTracking()
.FirstNotNullAsync(); .FirstNotNullAsync();
if (emailInfo.UniqueId.IsNotNullOrEmpty()) if (emailInfo.UniqueId.IsNotNullOrEmpty())
@ -123,10 +130,13 @@ public class EmailLogService(IRepository<EmailLog> _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; emailInfo.Attachments = attachmentInfos;
} }