邮件日志
continuous-integration/drone/push Build is passing Details

Test_IRC_Net8
he 2025-11-05 16:58:02 +08:00
parent 955ca4a1a6
commit 4d2f04b30e
11 changed files with 21549 additions and 187 deletions

View File

@ -991,7 +991,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},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.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>
@ -1001,6 +1001,33 @@
<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.GetEmailLogList(IRaCIS.Core.Application.ViewModel.EmailLogQuery)">
<summary>
获取邮件日志列表
</summary>
<param name="inQuery"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.GetEmailInfo(IRaCIS.Core.Application.ViewModel.GetEmailInfoInDto)">
<summary>
获取单挑邮件日志详情
</summary>
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.ResendEmail(IRaCIS.Core.Application.ViewModel.ResendEmailInDto)">
<summary>
重发邮件
</summary>
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.SynchronizationEmail">
<summary>
同步邮件
</summary>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.EmailLogService.BuildSearchQuery(IRaCIS.Core.Application.ViewModel.EmailLogQuery)"> <member name="M:IRaCIS.Core.Application.Service.EmailLogService.BuildSearchQuery(IRaCIS.Core.Application.ViewModel.EmailLogQuery)">
<summary> <summary>
邮件筛选条件构建 邮件筛选条件构建
@ -15495,6 +15522,31 @@
<member name="T:IRaCIS.Core.Application.ViewModel.CommonDocumentAddOrEdit"> <member name="T:IRaCIS.Core.Application.ViewModel.CommonDocumentAddOrEdit">
<summary> CommonDocumentAddOrEdit 列表查询参数模型</summary> <summary> CommonDocumentAddOrEdit 列表查询参数模型</summary>
</member> </member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailRecipientLogView.EmailLogId">
<summary>
邮件Id
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailRecipientLogView.RecipientName">
<summary>
收件人姓名
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailRecipientLogView.RecipientAddress">
<summary>
收件人地址
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailRecipientLogView.RecipientTypeEnum">
<summary>
收件人类型
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailRecipientLogView.Sort">
<summary>
排序
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.MessageId"> <member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.MessageId">
<summary> <summary>
邮件Id 邮件Id
@ -15510,16 +15562,6 @@
邮件主题 邮件主题
</summary> </summary>
</member> </member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.ToRecipients">
<summary>
收件人
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.CcRecipients">
<summary>
抄送人
</summary>
</member>
<member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.Attachments"> <member name="P:IRaCIS.Core.Application.ViewModel.EmailLogAddOrEdit.Attachments">
<summary> <summary>
附件 附件

View File

@ -16,7 +16,40 @@ public class EmailLogView : EmailLogAddOrEdit
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
public DateTime UpdateTime { get; set; } public DateTime UpdateTime { get; set; }
public List<EmailRecipientLogView> RecipientList { get; set; }
}
public class EmailRecipientLogView
{
public Guid Id { get; set; }
/// <summary>
/// 邮件Id
/// </summary>
public Guid EmailLogId { get; set; }
/// <summary>
/// 收件人姓名
/// </summary>
public string RecipientName { get; set; }
/// <summary>
/// 收件人地址
/// </summary>
public string RecipientAddress { get; set; }
/// <summary>
/// 收件人类型
/// </summary>
public RecipientType RecipientTypeEnum { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
} }
@ -39,16 +72,6 @@ public class EmailLogAddOrEdit
/// </summary> /// </summary>
public string EmailSubject { get; set; } = string.Empty; public string EmailSubject { get; set; } = string.Empty;
/// <summary>
/// 收件人
/// </summary>
public List<EmaliSendInfo> ToRecipients { get; set; }
/// <summary>
/// 抄送人
/// </summary>
public List<EmaliSendInfo> CcRecipients { get; set; }
/// <summary> /// <summary>
/// 附件 /// 附件
/// </summary> /// </summary>
@ -85,19 +108,37 @@ public class EmailLogAddOrEdit
public EmailState EmailStateEnum { get; set; } public EmailState EmailStateEnum { get; set; }
} }
public class GetEmailInfoOutDto:EmailLogView
{
}
public class GetEmailInfoInDto
{
public Guid Id { get; set; }
}
public class ResendEmailInDto
{
public Guid Id { get; set; }
}
public class EmailLogQuery:PageInput public class EmailLogQuery:PageInput
{ {
public Guid? TrialId { get; set; }
public DateTime? EmailStartDate { get; set; } public DateTime? EmailStartDate { get; set; }
public DateTime? EmailEndDate { get; set; } public DateTime? EmailEndDate { get; set; }
public EmailState EmailStateEnum { get; set; } public EmailState? EmailStateEnum { get; set; }
public string? ToRecipientName { get; set; } public string ToRecipientName { get; set; } = string.Empty;
public string CcRecipientName { get; set; } = string.Empty;
public string? CcRecipientName { get; set; }
} }

View File

@ -4,6 +4,7 @@
// 生成时间 2025-10-28 06:22:42Z // 生成时间 2025-10-28 06:22:42Z
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//-------------------------------------------------------------------- //--------------------------------------------------------------------
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.Interfaces;
using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Models;
@ -31,92 +32,247 @@ 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<EmailRecipientLog> _emailRecipientLogRepository,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig, IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IEmailLogService IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IEmailLogService
{ {
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue; private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
/// <summary>
/// 获取邮件日志列表
/// </summary>
/// <param name="inQuery"></param>
/// <returns></returns>
[HttpPost] [HttpPost]
public async Task<PageOutput<EmailLogView>> GetEmailLogList(EmailLogQuery inQuery) public async Task<PageOutput<EmailLogView>> GetEmailLogList(EmailLogQuery inDto)
{ {
PageOutput<EmailLogView> pageOutput = new PageOutput<EmailLogView>(); var emailLogQueryable = _emailLogRepository
.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)
.WhereIf(inDto.CcRecipientName.IsNotNullOrEmpty(),x=>x.EmailRecipientLogList.Any(x=>x.RecipientTypeEnum==RecipientType.Cc&&x.RecipientName.Contains(inDto.CcRecipientName)))
.WhereIf(inDto.ToRecipientName.IsNotNullOrEmpty(), x => x.EmailRecipientLogList.Any(x => x.RecipientTypeEnum == RecipientType.To && x.RecipientName.Contains(inDto.ToRecipientName)))
.ProjectTo<EmailLogView>(_mapper.ConfigurationProvider);
switch (inQuery.EmailStateEnum) var defalutSortArray = new string[] { nameof(EmailLogView.EmailDate) + " desc" };
var pageList = await emailLogQueryable.ToPagedListAsync(inDto, defalutSortArray);
return pageList;
}
/// <summary>
/// 获取单挑邮件日志详情
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<GetEmailInfoOutDto> GetEmailInfo(GetEmailInfoInDto inDto)
{
var emailInfo=await _emailLogRepository
.Where(x => x.Id == inDto.Id)
.ProjectTo<GetEmailInfoOutDto>(_mapper.ConfigurationProvider)
.FirstNotNullAsync();
if (emailInfo.UniqueId.IsNotNullOrEmpty())
{ {
case EmailState.Success: using (var client = new ImapClient())
{
using (var client = new ImapClient()) try
{
client.Connect(_systemEmailConfig.Imap, 993, SecureSocketOptions.SslOnConnect);
client.Authenticate(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode);
var sentFolder = client.GetFolder("已发送");
sentFolder.Open(FolderAccess.ReadOnly);
var uid = new UniqueId(uint.Parse(emailInfo.UniqueId));
var message = sentFolder.GetMessage(uid);
emailInfo.Content = message.HtmlBody ?? string.Empty;
sentFolder.Close();
}
catch (Exception ex)
{
}
finally
{
client.Disconnect(true);
}
}
}
return emailInfo;
}
/// <summary>
/// 重发邮件
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> ResendEmail(ResendEmailInDto inDto)
{
var emailInfo = await _emailLogRepository
.Where(x => x.Id == inDto.Id)
.ProjectTo<GetEmailInfoOutDto>(_mapper.ConfigurationProvider)
.FirstNotNullAsync();
if (emailInfo.UniqueId.IsNotNullOrEmpty())
{
using (var client = new ImapClient())
{
try
{
client.Connect(_systemEmailConfig.Imap, 993, SecureSocketOptions.SslOnConnect);
client.Authenticate(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode);
var sentFolder = client.GetFolder("已发送");
sentFolder.Open(FolderAccess.ReadOnly);
var uid = new UniqueId(uint.Parse(emailInfo.UniqueId));
var message = sentFolder.GetMessage(uid);
emailInfo.Content = message.HtmlBody ?? string.Empty;
sentFolder.Close();
}
catch (Exception ex)
{
}
finally
{
client.Disconnect(true);
}
}
}
var messageToSend = new MimeMessage();
// 发件地址
messageToSend.From.Add(new MailboxAddress(emailInfo.SenderName, emailInfo.SenderAddress));
foreach (var item in emailInfo.RecipientList.Where(x => x.RecipientTypeEnum == RecipientType.To))
{
messageToSend.To.Add(new MailboxAddress(item.RecipientName, item.RecipientAddress));
}
foreach (var item in emailInfo.RecipientList.Where(x => x.RecipientTypeEnum == RecipientType.Cc))
{
messageToSend.Cc.Add(new MailboxAddress(item.RecipientName, item.RecipientAddress));
}
messageToSend.Subject = emailInfo.EmailSubject;
var builder = new BodyBuilder();
builder.HtmlBody = emailInfo.Content;
messageToSend.Body = builder.ToMessageBody();
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
return ResponseOutput.Ok();
}
/// <summary>
/// 同步邮件
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> SynchronizationEmail()
{
var maxTime=await _emailLogRepository.MaxAsync(t => t.EmailDate);
List<EmailLog> emailList = new List<EmailLog>();
List<EmailRecipientLog> EmailRecipientLogList = new List<EmailRecipientLog>();
using (var client = new ImapClient())
{
try
{
client.Connect(_systemEmailConfig.Imap, 993, SecureSocketOptions.SslOnConnect);
client.Authenticate(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode);
var sentFolder = client.GetFolder("已发送");
sentFolder.Open(FolderAccess.ReadOnly);
var startDate = maxTime ?? DateTime.MinValue;
var searchQuery = SearchQuery.All.And(SearchQuery.DeliveredAfter(startDate));
var uids = sentFolder.Search(searchQuery).ToList();
foreach (var uid in uids)
{ {
try try
{ {
client.Connect(_systemEmailConfig.Imap, 993, SecureSocketOptions.SslOnConnect); //var message = sentFolder.GetMessage(uid);
client.Authenticate(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode); // var emailView = ConvertToEmailLogView(uid, message);
var sentFolder = client.GetFolder("已发送");
sentFolder.Open(FolderAccess.ReadOnly);
// 构建搜索查询条件 var message = sentFolder.GetMessage(uid);
var searchQuery = BuildSearchQuery(inQuery); var emaillog = new EmailLog
var orderBy = new[] { OrderBy.ReverseDate };
// 搜索符合条件的邮件UID
if (client.Capabilities.HasFlag(ImapCapabilities.Sort))
{ {
Console.WriteLine("服务器支持 SORT 扩展"); UniqueId = uid.ToString(),
} MessageId = message.MessageId ?? string.Empty,
else EmailSubject = message.Subject ?? string.Empty,
EmailDate = message.Date.UtcDateTime,
EmailStateEnum = EmailState.Success,
};
var fromMailbox = message.From.Mailboxes.FirstOrDefault();
if (fromMailbox != null)
{ {
Console.WriteLine("服务器不支持 SORT需本地排序"); emaillog.SenderAddress = fromMailbox.Address;
emaillog.SenderName = fromMailbox.Name ?? string.Empty;
} }
List<EmailRecipientLog> recipientLogs= new List<EmailRecipientLog>();
//var uids = sentFolder.Sort(searchQuery, orderBy).Skip((inQuery.PageIndex - 1) * inQuery.PageSize).Take(inQuery.PageSize).ToList(); int sort = 0;
message.To.Mailboxes.ForEach(x =>
{
recipientLogs.Add(new EmailRecipientLog()
{
RecipientName = x.Name ?? string.Empty,
RecipientAddress = x.Address,
EmailLogId= emaillog.Id,
RecipientTypeEnum = RecipientType.To,
Sort= sort++,
});
});
sort = 0;
message.Cc.Mailboxes.ForEach(x =>
{
recipientLogs.Add(new EmailRecipientLog()
{
RecipientName = x.Name ?? string.Empty,
RecipientAddress = x.Address,
EmailLogId = emaillog.Id,
RecipientTypeEnum = RecipientType.Cc,
Sort = sort++,
});
});
emailList.Add(emaillog);
EmailRecipientLogList.AddRange(recipientLogs);
pageOutput.TotalCount = sentFolder.Search(searchQuery).Count();
// 在内存中分页倒序
var uids = sentFolder.Search(searchQuery).Skip(CalcReverseSkip(inQuery.PageIndex, inQuery.PageSize, (int)pageOutput.TotalCount)).Take(inQuery.PageSize).ToList();
uids.Reverse();
// 获取邮件并排序(按时间倒序)
var emailList = GetEmailsWithSorting(sentFolder, uids);
pageOutput.PageIndex = inQuery.PageIndex;
pageOutput.PageSize = inQuery.PageSize;
pageOutput.CurrentPageData = emailList;
sentFolder.Close();
} }
catch (Exception ex) catch (Exception ex)
{ {
} Console.WriteLine($"处理邮件 {uid} 失败: {ex.Message}");
finally
{
client.Disconnect(true);
} }
} }
return pageOutput;
case EmailState.Error:
var emailLogQueryable = _emailLogRepository
.ProjectTo<EmailLogView>(_mapper.ConfigurationProvider);
var pageList = await emailLogQueryable.ToPagedListAsync(inQuery); sentFolder.Close();
}
return pageList; catch (Exception ex)
{
}
finally
{
client.Disconnect(true);
}
await _emailLogRepository.AddRangeAsync(emailList);
await _emailRecipientLogRepository.AddRangeAsync(EmailRecipientLogList);
await _emailLogRepository.SaveChangesAsync();
return ResponseOutput.Ok();
} }
return pageOutput;
} }
// 取skip的值 // 取skip的值
@ -236,19 +392,19 @@ public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
emailView.SenderName = fromMailbox.Name ?? string.Empty; emailView.SenderName = fromMailbox.Name ?? string.Empty;
} }
// 处理收件人 //// 处理收件人
emailView.ToRecipients = message.To.Mailboxes.Select(address => new EmaliSendInfo //emailView.ToRecipients = message.To.Mailboxes.Select(address => new EmaliSendInfo
{ //{
Name = address.Name ?? string.Empty, // Name = address.Name ?? string.Empty,
Address = address.Address // Address = address.Address
}).ToList(); //}).ToList();
// 处理抄送人 //// 处理抄送人
emailView.CcRecipients = message.Cc.Mailboxes.Select(address => new EmaliSendInfo //emailView.CcRecipients = message.Cc.Mailboxes.Select(address => new EmaliSendInfo
{ //{
Name = address.Name ?? string.Empty, // Name = address.Name ?? string.Empty,
Address = address.Address // Address = address.Address
}).ToList(); //}).ToList();
//// 处理密送人 //// 处理密送人
//emailView.BccRecipients = message.Bcc.Mailboxes.Select(address => new EmaliSendInfo //emailView.BccRecipients = message.Bcc.Mailboxes.Select(address => new EmaliSendInfo

View File

@ -12,7 +12,11 @@ namespace IRaCIS.Core.Application.Service
{ {
// 在此处拷贝automapper 映射 // 在此处拷贝automapper 映射
CreateMap<EmailLog, EmailLogView>(); CreateMap<EmailRecipientLog, EmailRecipientLogView>();
CreateMap<EmailLog, EmailLogView>()
.ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList));
CreateMap<EmailLog, GetEmailInfoOutDto>()
.ForMember(t => t.RecipientList, u => u.MapFrom(c => c.EmailRecipientLogList));
CreateMap<EmailLog, EmailLogAddOrEdit>().ReverseMap(); CreateMap<EmailLog, EmailLogAddOrEdit>().ReverseMap();
CreateMap<FrontAuditConfig, FrontAuditConfigAddOrEdit>().ReverseMap(); CreateMap<FrontAuditConfig, FrontAuditConfigAddOrEdit>().ReverseMap();

View File

@ -44,6 +44,24 @@ namespace IRaCIS.Core.Domain.Share
} }
/// <summary>
/// 收件人类型
/// </summary>
public enum RecipientType
{
/// <summary>
/// 收件人
/// </summary>
To = 0,
/// <summary>
/// 抄送人
/// </summary>
Cc = 1,
}
public enum GenerateTaskCategory public enum GenerateTaskCategory
{ {
//访视 //访视

View File

@ -6,6 +6,9 @@ namespace IRaCIS.Core.Domain.Models;
[Table("EmailLog")] [Table("EmailLog")]
public class EmailLog : BaseFullAuditEntity public class EmailLog : BaseFullAuditEntity
{ {
public List<EmailRecipientLog> EmailRecipientLogList { get; set; } = new List<EmailRecipientLog>();
/// <summary> /// <summary>
/// 邮件Id /// 邮件Id
/// </summary> /// </summary>
@ -21,16 +24,6 @@ public class EmailLog : BaseFullAuditEntity
/// </summary> /// </summary>
public string EmailSubject { get; set; } = string.Empty; public string EmailSubject { get; set; } = string.Empty;
/// <summary>
/// 收件人
/// </summary>
public List<EmaliSendInfo> ToRecipients { get; set; }
/// <summary>
/// 抄送人
/// </summary>
public List<EmaliSendInfo> CcRecipients { get; set; }
/// <summary> /// <summary>
/// 附件 /// 附件
/// </summary> /// </summary>
@ -69,10 +62,4 @@ public class EmailLog : BaseFullAuditEntity
} }
public class EmaliSendInfo
{
public string Name { get; set; }
public string Address { get; set; }
}

View File

@ -0,0 +1,40 @@
using IRaCIS.Core.Domain.Share;
namespace IRaCIS.Core.Domain.Models;
[Comment("邮件收件人")]
[Table("EmailRecipientLog")]
public class EmailRecipientLog : BaseFullAuditEntity
{
[JsonIgnore]
[ForeignKey("EmailLogId")]
public EmailLog EmailLog { get; set; }
/// <summary>
/// 邮件Id
/// </summary>
public Guid EmailLogId { get; set; }
/// <summary>
/// 收件人姓名
/// </summary>
public string RecipientName { get; set; }
/// <summary>
/// 收件人地址
/// </summary>
public string RecipientAddress { get; set; }
/// <summary>
/// 收件人类型
/// </summary>
public RecipientType RecipientTypeEnum { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
}

View File

@ -95,18 +95,7 @@ public class IRaCISDBContext : DbContext
}); });
}); });
modelBuilder.Entity<EmailLog>(entity =>
{
entity.OwnsMany(x => x.ToRecipients, ownedNavigationBuilder =>
{
ownedNavigationBuilder.ToJson();
});
entity.OwnsMany(x => x.CcRecipients, ownedNavigationBuilder =>
{
ownedNavigationBuilder.ToJson();
});
});
#region pgsql codefirst 配置 暂时屏蔽 #region pgsql codefirst 配置 暂时屏蔽
@ -570,6 +559,7 @@ public class IRaCISDBContext : DbContext
#region 未分类 #region 未分类
public virtual DbSet<EmailLog> EmailLog { get; set; } public virtual DbSet<EmailLog> EmailLog { get; set; }
public virtual DbSet<EmailRecipientLog> EmailRecipientLog { get; set; }
public virtual DbSet<ShortcutKey> ShortcutKey { get; set; } public virtual DbSet<ShortcutKey> ShortcutKey { get; set; }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,85 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IRaCIS.Core.Infra.EFCore.Migrations
{
/// <inheritdoc />
public partial class EmailRecipientLog : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CcRecipients",
table: "EmailLog");
migrationBuilder.DropColumn(
name: "ToRecipients",
table: "EmailLog");
migrationBuilder.CreateTable(
name: "EmailRecipientLog",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
EmailLogId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
RecipientName = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
RecipientAddress = table.Column<string>(type: "nvarchar(400)", maxLength: 400, nullable: false),
RecipientTypeEnum = table.Column<int>(type: "int", nullable: false),
Sort = table.Column<int>(type: "int", nullable: false),
CreateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreateTime = table.Column<DateTime>(type: "datetime2", nullable: false),
UpdateUserId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_EmailRecipientLog", x => x.Id);
table.ForeignKey(
name: "FK_EmailRecipientLog_EmailLog_EmailLogId",
column: x => x.EmailLogId,
principalTable: "EmailLog",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_EmailRecipientLog_User_CreateUserId",
column: x => x.CreateUserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
},
comment: "邮件收件人");
migrationBuilder.CreateIndex(
name: "IX_EmailRecipientLog_CreateUserId",
table: "EmailRecipientLog",
column: "CreateUserId");
migrationBuilder.CreateIndex(
name: "IX_EmailRecipientLog_EmailLogId",
table: "EmailRecipientLog",
column: "EmailLogId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "EmailRecipientLog");
migrationBuilder.AddColumn<string>(
name: "CcRecipients",
table: "EmailLog",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ToRecipients",
table: "EmailLog",
type: "nvarchar(max)",
nullable: true);
}
}
}

View File

@ -2527,6 +2527,54 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
}); });
}); });
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailRecipientLog", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreateTime")
.HasColumnType("datetime2");
b.Property<Guid>("CreateUserId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("EmailLogId")
.HasColumnType("uniqueidentifier");
b.Property<string>("RecipientAddress")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<string>("RecipientName")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b.Property<int>("RecipientTypeEnum")
.HasColumnType("int");
b.Property<int>("Sort")
.HasColumnType("int");
b.Property<DateTime>("UpdateTime")
.HasColumnType("datetime2");
b.Property<Guid>("UpdateUserId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id");
b.HasIndex("CreateUserId");
b.HasIndex("EmailLogId");
b.ToTable("EmailRecipientLog", t =>
{
t.HasComment("邮件收件人");
});
});
modelBuilder.Entity("IRaCIS.Core.Domain.Models.Enroll", b => modelBuilder.Entity("IRaCIS.Core.Domain.Models.Enroll", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
@ -16467,69 +16515,7 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.OwnsMany("IRaCIS.Core.Domain.Models.EmaliSendInfo", "CcRecipients", b1 =>
{
b1.Property<Guid>("EmailLogId")
.HasColumnType("uniqueidentifier");
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b1.Property<string>("Address")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("Name")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.HasKey("EmailLogId", "Id");
b1.ToTable("EmailLog");
b1.ToJson("CcRecipients");
b1.WithOwner()
.HasForeignKey("EmailLogId");
});
b.OwnsMany("IRaCIS.Core.Domain.Models.EmaliSendInfo", "ToRecipients", b1 =>
{
b1.Property<Guid>("EmailLogId")
.HasColumnType("uniqueidentifier");
b1.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
b1.Property<string>("Address")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.Property<string>("Name")
.IsRequired()
.HasMaxLength(400)
.HasColumnType("nvarchar(400)");
b1.HasKey("EmailLogId", "Id");
b1.ToTable("EmailLog");
b1.ToJson("ToRecipients");
b1.WithOwner()
.HasForeignKey("EmailLogId");
});
b.Navigation("CcRecipients");
b.Navigation("CreateUserRole"); b.Navigation("CreateUserRole");
b.Navigation("ToRecipients");
}); });
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailNoticeConfig", b => modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailNoticeConfig", b =>
@ -16554,6 +16540,25 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
b.Navigation("EmailNoticeConfig"); b.Navigation("EmailNoticeConfig");
}); });
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailRecipientLog", b =>
{
b.HasOne("IRaCIS.Core.Domain.Models.UserRole", "CreateUserRole")
.WithMany()
.HasForeignKey("CreateUserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("IRaCIS.Core.Domain.Models.EmailLog", "EmailLog")
.WithMany("EmailRecipientLogList")
.HasForeignKey("EmailLogId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("CreateUserRole");
b.Navigation("EmailLog");
});
modelBuilder.Entity("IRaCIS.Core.Domain.Models.Enroll", b => modelBuilder.Entity("IRaCIS.Core.Domain.Models.Enroll", b =>
{ {
b.HasOne("IRaCIS.Core.Domain.Models.UserRole", "CreateUserRole") b.HasOne("IRaCIS.Core.Domain.Models.UserRole", "CreateUserRole")
@ -20568,6 +20573,11 @@ namespace IRaCIS.Core.Infra.EFCore.Migrations
.IsRequired(); .IsRequired();
}); });
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailLog", b =>
{
b.Navigation("EmailRecipientLogList");
});
modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailNoticeConfig", b => modelBuilder.Entity("IRaCIS.Core.Domain.Models.EmailNoticeConfig", b =>
{ {
b.Navigation("EmailNoticeUserTypeList"); b.Navigation("EmailNoticeUserTypeList");