修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
8e0ff1f2b2
commit
c77682a9ad
|
|
@ -9,12 +9,15 @@ namespace IRaCIS.Core.Application.Helper;
|
||||||
public static class SendEmailHelper
|
public static class SendEmailHelper
|
||||||
{
|
{
|
||||||
|
|
||||||
public static async Task SendEmailAsync(MimeMessage messageToSend, SystemEmailSendConfig _systemEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
public static async Task<string> SendEmailAsync(MimeMessage messageToSend, SystemEmailSendConfig _systemEmailConfig, EventHandler<MessageSentEventArgs>? messageSentSuccess = null)
|
||||||
{
|
{
|
||||||
|
string result = string.Empty;
|
||||||
|
result = messageToSend.MessageId;
|
||||||
|
|
||||||
//没有收件人 那么不发送
|
//没有收件人 那么不发送
|
||||||
if (messageToSend.To.Count == 0)
|
if (messageToSend.To.Count == 0)
|
||||||
{
|
{
|
||||||
return;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -52,6 +55,8 @@ public static class SendEmailHelper
|
||||||
throw new Exception(I18n.T("SendEmail_SendFail"), new Exception(ex.Message));
|
throw new Exception(I18n.T("SendEmail_SendFail"), new Exception(ex.Message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1446,7 +1446,7 @@
|
||||||
<param name="_userInfo"></param>
|
<param name="_userInfo"></param>
|
||||||
<param name="_localizer"></param>
|
<param name="_localizer"></param>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailLog},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Trial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailAttachmentLog},IRaCIS.Core.Application.Helper.IOSSService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailRecipientLog},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig},AutoMapper.IMapper,IRaCIS.Core.Domain.Share.IUserInfo,Microsoft.Extensions.Localization.IStringLocalizer)">
|
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailLog},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.Trial},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailAttachmentLog},IRaCIS.Core.Application.Helper.IOSSService,IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailReSendLog},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailRecipientLog},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig},AutoMapper.IMapper,IRaCIS.Core.Domain.Share.IUserInfo,Microsoft.Extensions.Localization.IStringLocalizer)">
|
||||||
<summary>
|
<summary>
|
||||||
邮件日志
|
邮件日志
|
||||||
</summary>
|
</summary>
|
||||||
|
|
@ -1463,6 +1463,13 @@
|
||||||
<param name="inQuery"></param>
|
<param name="inQuery"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.GetReSendEmail(IRaCIS.Core.Application.ViewModel.GetReSendEmailInDto)">
|
||||||
|
<summary>
|
||||||
|
获取重发信息
|
||||||
|
</summary>
|
||||||
|
<param name="inDto"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.GetEmailInfo(IRaCIS.Core.Application.ViewModel.GetEmailInfoInDto)">
|
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.GetEmailInfo(IRaCIS.Core.Application.ViewModel.GetEmailInfoInDto)">
|
||||||
<summary>
|
<summary>
|
||||||
获取单条邮件日志详情
|
获取单条邮件日志详情
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,11 @@ using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
namespace IRaCIS.Core.Application.ViewModel;
|
namespace IRaCIS.Core.Application.ViewModel;
|
||||||
|
|
||||||
|
|
||||||
|
public class GetReSendEmailInDto : PageInput
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
}
|
||||||
public class EmailLogView : EmailLogAddOrEdit
|
public class EmailLogView : EmailLogAddOrEdit
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
|
||||||
IRepository<Trial> _trialRepository,
|
IRepository<Trial> _trialRepository,
|
||||||
IRepository<EmailAttachmentLog> _emailAttachmentLogRepository,
|
IRepository<EmailAttachmentLog> _emailAttachmentLogRepository,
|
||||||
IOSSService oSSService,
|
IOSSService oSSService,
|
||||||
|
IRepository<EmailReSendLog> _emailReSendLog,
|
||||||
|
|
||||||
IRepository<EmailRecipientLog> _emailRecipientLogRepository,
|
IRepository<EmailRecipientLog> _emailRecipientLogRepository,
|
||||||
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
|
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
|
||||||
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IEmailLogService
|
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IEmailLogService
|
||||||
|
|
@ -75,6 +77,28 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取重发信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<PageOutput<EmailLogView>> 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<EmailLogView>(_mapper.ConfigurationProvider);
|
||||||
|
|
||||||
|
var defalutSortArray = new string[] { nameof(EmailLogView.EmailDate) + " desc" };
|
||||||
|
var pageList = await emailLogQueryable.ToPagedListAsync(inDto, defalutSortArray);
|
||||||
|
|
||||||
|
return pageList;
|
||||||
|
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取单条邮件日志详情
|
/// 获取单条邮件日志详情
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -222,7 +246,18 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
|
||||||
|
|
||||||
messageToSend.Body = builder.ToMessageBody();
|
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();
|
return ResponseOutput.Ok();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
|
||||||
|
namespace IRaCIS.Core.Domain.Models;
|
||||||
|
|
||||||
|
[Comment("邮件重发日志")]
|
||||||
|
[Table("EmailReSendLog")]
|
||||||
|
public class EmailReSendLog : BaseFullAuditEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 邮件Id
|
||||||
|
/// </summary>
|
||||||
|
public string MainMailMessageId { get; set; }
|
||||||
|
|
||||||
|
public string ReMailMessageId { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -562,6 +562,7 @@ public class IRaCISDBContext : DbContext
|
||||||
#region 未分类
|
#region 未分类
|
||||||
|
|
||||||
public virtual DbSet<EmailLog> EmailLog { get; set; }
|
public virtual DbSet<EmailLog> EmailLog { get; set; }
|
||||||
|
public virtual DbSet<EmailReSendLog> EmailReSendLog { get; set; }
|
||||||
public virtual DbSet<EmailRecipientLog> EmailRecipientLog { get; set; }
|
public virtual DbSet<EmailRecipientLog> EmailRecipientLog { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<ShortcutKey> ShortcutKey { get; set; }
|
public virtual DbSet<ShortcutKey> ShortcutKey { get; set; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue