Merge branch 'Test_IRC_Net8' of https://gitea.frp.extimaging.com/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-10-28 15:15:21 +08:00
23 changed files with 21435 additions and 8 deletions
@@ -47,6 +47,8 @@ public class SystemEmailSendConfig
public int Port { get; set; }
public string Host { get; set; } = string.Empty;
public string Imap { get; set; } = string.Empty;
public string FromEmail { get; set; } = string.Empty;
public string FromName { get; set; } = string.Empty;
@@ -16549,11 +16549,17 @@
系统邮件配置表
</summary>
</member>
<member name="M:IRaCIS.Core.Application.Contracts.EmailNoticeConfigService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailNoticeConfig},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailNoticeUserType},AutoMapper.IMapper,IRaCIS.Core.Domain.Share.IUserInfo,Microsoft.Extensions.Localization.IStringLocalizer)">
<member name="M:IRaCIS.Core.Application.Contracts.EmailNoticeConfigService.#ctor(IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailNoticeConfig},IRaCIS.Core.Infra.EFCore.IRepository{IRaCIS.Core.Domain.Models.EmailNoticeUserType},Microsoft.Extensions.Options.IOptionsMonitor{IRaCIS.Core.Domain.Share.SystemEmailSendConfig},AutoMapper.IMapper,IRaCIS.Core.Domain.Share.IUserInfo,Microsoft.Extensions.Localization.IStringLocalizer)">
<summary>
系统邮件配置表
</summary>
</member>
<member name="M:IRaCIS.Core.Application.Contracts.EmailNoticeConfigService.GetEmailList">
<summary>
获取邮件列表
</summary>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Contracts.EmailNoticeConfigService.BatchUpdateEmail(System.Collections.Generic.List{IRaCIS.Core.Application.Contracts.BatchUpdateEmailTopicCommand})">
<summary>
批量更新邮件主题中英文
@@ -0,0 +1,72 @@
//--------------------------------------------------------------------
// 此代码由liquid模板自动生成 byzhouhang 20240909
// 生成时间 2025-10-28 06:22:47Z
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using System;
using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
namespace IRaCIS.Core.Application.ViewModel;
public class EmailLogView : EmailLogAddOrEdit
{
public DateTime CreateTime { get; set; }
public DateTime UpdateTime { get; set; }
}
public class EmailLogAddOrEdit
{
public Guid? Id { get; set; }
public string Attachments { get; set; }
public string CcRecipients { get; set; }
public DateTime? EmailDate { get; set; }
public EmailState EmailStateEnum { get; set; }
public string EmailSubject { get; set; }
public string ErrorInfo { get; set; }
public string MessageId { get; set; }
public string SenderAddress { get; set; }
public string ToRecipients { get; set; }
public string UniqueId { get; set; }
}
public class EmailLogQuery:PageInput
{
public string Attachments { get; set; }
public string CcRecipients { get; set; }
public DateTime? EmailDate { get; set; }
public EmailState? EmailStateEnum { get; set; }
public string? EmailSubject { get; set; }
public string? ErrorInfo { get; set; }
public string? MessageId { get; set; }
public string? SenderAddress { get; set; }
public string ToRecipients { get; set; }
public string? UniqueId { get; set; }
}
@@ -0,0 +1,116 @@
//--------------------------------------------------------------------
// 此代码由liquid模板自动生成 byzhouhang 20240909
// 生成时间 2025-10-28 06:22:42Z
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using IRaCIS.Core.Application.Interfaces;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Infra.EFCore;
using IRaCIS.Core.Infrastructure.Extention;
using MailKit;
using MailKit.Net.Imap;
using MailKit.Search;
using MailKit.Security;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using System.Threading.Tasks;
namespace IRaCIS.Core.Application.Service;
[ ApiExplorerSettings(GroupName = "Test")]
public class EmailLogService(IRepository<EmailLog> _emailLogRepository,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer): BaseService, IEmailLogService
{
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
[HttpPost]
public async Task<PageOutput<EmailLogView>> GetEmailLogList(EmailLogQuery inQuery)
{
List<IMessageSummary> emailList = new List<IMessageSummary>();
using (var client = new ImapClient())
{
try
{
// 连接阿里邮箱 IMAP 服务器(使用 SSL)
client.Connect(_systemEmailConfig.Imap, 993, SecureSocketOptions.SslOnConnect);
// 登录
client.Authenticate(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode);
// 3. 获取发件箱文件夹 - 使用你找到的“已发送”
var sentFolder = client.GetFolder("已发送");
sentFolder.Open(FolderAccess.ReadOnly);
// 4. 搜索所有邮件(你可以在这里添加更精确的搜索条件)
var uids = sentFolder.Search(SearchQuery.All);
Console.WriteLine($"找到 {uids.Count} 封已发送邮件");
// 5. 遍历并处理邮件(示例中处理前10封)
foreach (var uid in uids.Take(10))
{
var message = sentFolder.GetMessage(uid);
// 输出邮件基本信息
Console.WriteLine($"主题: {message.Subject}");
Console.WriteLine($"收件人: {string.Join(", ", message.To.Mailboxes.Select(m => m.Address))}");
Console.WriteLine($"日期: {message.Date.LocalDateTime:yyyy-MM-dd HH:mm:ss}");
Console.WriteLine($"发件人: {message.From}");
Console.WriteLine("----------------------------------");
}
sentFolder.Close();
}
catch (Exception ex)
{
Console.WriteLine($"操作失败: {ex.Message}");
}
finally
{
client.Disconnect(true);
}
}
var emailLogQueryable =_emailLogRepository
.ProjectTo<EmailLogView>(_mapper.ConfigurationProvider);
var pageList= await emailLogQueryable.ToPagedListAsync(inQuery);
return pageList;
}
public async Task<IResponseOutput> AddOrUpdateEmailLog(EmailLogAddOrEdit addOrEditEmailLog)
{
var entity = await _emailLogRepository.InsertOrUpdateAsync(addOrEditEmailLog, true);
return ResponseOutput.Ok(entity.Id.ToString());
}
[HttpDelete("{emailLogId:guid}")]
public async Task<IResponseOutput> DeleteEmailLog(Guid emailLogId)
{
var success = await _emailLogRepository.DeleteFromQueryAsync(t => t.Id == emailLogId,true);
return ResponseOutput.Ok();
}
}
@@ -4,9 +4,18 @@
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using DocumentFormat.OpenXml.Spreadsheet;
using IRaCIS.Core.Application.Helper;
using IRaCIS.Core.Domain.Share;
using MailKit;
using MailKit.Net.Imap;
using MailKit.Search;
using MailKit.Security;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using System.Text.RegularExpressions;
@@ -17,8 +26,75 @@ namespace IRaCIS.Core.Application.Contracts
/// </summary>
[ApiExplorerSettings(GroupName = "Common")]
public class EmailNoticeConfigService(IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
IRepository<EmailNoticeUserType> _emailNoticeUserTypeRepository, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IEmailNoticeConfigService
IRepository<EmailNoticeUserType> _emailNoticeUserTypeRepository,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IEmailNoticeConfigService
{
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
/// <summary>
/// 获取邮件列表
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task<object> GetEmailList()
{
List<IMessageSummary> emailList = new List<IMessageSummary>();
using (var client = new ImapClient())
{
try
{
// 连接阿里邮箱 IMAP 服务器(使用 SSL)
client.Connect(_systemEmailConfig.Imap, 993, SecureSocketOptions.SslOnConnect);
// 登录
client.Authenticate(_systemEmailConfig.FromEmail, _systemEmailConfig.AuthorizationCode);
// 3. 获取发件箱文件夹 - 使用你找到的“已发送”
var sentFolder = client.GetFolder("已发送");
sentFolder.Open(FolderAccess.ReadOnly);
// 4. 搜索所有邮件(你可以在这里添加更精确的搜索条件)
var uids = sentFolder.Search(SearchQuery.All);
Console.WriteLine($"找到 {uids.Count} 封已发送邮件");
// 5. 遍历并处理邮件(示例中处理前10封)
foreach (var uid in uids.Take(10))
{
var message = sentFolder.GetMessage(uid);
// 输出邮件基本信息
Console.WriteLine($"主题: {message.Subject}");
Console.WriteLine($"收件人: {string.Join(", ", message.To.Mailboxes.Select(m => m.Address))}");
Console.WriteLine($"日期: {message.Date.LocalDateTime:yyyy-MM-dd HH:mm:ss}");
Console.WriteLine($"发件人: {message.From}");
Console.WriteLine("----------------------------------");
}
sentFolder.Close();
}
catch (Exception ex)
{
Console.WriteLine($"操作失败: {ex.Message}");
}
finally
{
client.Disconnect(true);
}
}
return true;
}
[HttpPost]
public async Task<PageOutput<EmailNoticeConfigView>> GetEmailNoticeConfigList(EmailNoticeConfigQuery inQuery)
@@ -0,0 +1,23 @@
//--------------------------------------------------------------------
// 此代码由liquid模板自动生成 byzhouhang 20240909
// 生成时间 2025-10-28 06:22:47Z
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using System;
using IRaCIS.Core.Infrastructure.Extention;
using System.Threading.Tasks;
using IRaCIS.Core.Application.ViewModel;
namespace IRaCIS.Core.Application.Interfaces;
public interface IEmailLogService
{
Task<PageOutput<EmailLogView>> GetEmailLogList(EmailLogQuery inQuery);
Task<IResponseOutput> AddOrUpdateEmailLog(EmailLogAddOrEdit addOrEditEmailLog);
Task<IResponseOutput> DeleteEmailLog(Guid emailLogId);
}
@@ -5,9 +5,13 @@ using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using MailKit;
using MailKit.Net.Imap;
using MailKit.Search;
using MailKit.Security;
using Medallion.Threading;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using MimeKit;
using System.Net.Mail;
@@ -78,7 +82,7 @@ namespace IRaCIS.Core.Application.Service
Task SiteSuervyUpdateUser(Guid trialSiteId, string email, string name, string url);
}
[ApiExplorerSettings(GroupName = "Common")]
public class MailVerificationService(IRepository<VerificationCode> _verificationCodeRepository,
IRepository<SystemBasicData> _systemBasicDatarepository,
IRepository<VisitTask> _visitTaskRepository,
@@ -93,16 +97,14 @@ namespace IRaCIS.Core.Application.Service
IRepository<UserType> _userTypeRepository,
IRepository<Doctor> _doctorTypeRepository,
IRepository<Dictionary> _dictionaryRepository,
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig,
IDistributedLockProvider _distributedLockProvider, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IMailVerificationService
{
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
//public async Task<object> GetEmailList()
//{
//}
private async Task<EmailNoticeConfig> GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario scenario, MimeMessage messageToSend,
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailFunc)
@@ -10,7 +10,10 @@ namespace IRaCIS.Core.Application.Service
{
public CommonConfig()
{
// 在此处拷贝automapper 映射
CreateMap<EmailLog, EmailLogView>();
CreateMap<EmailLog, EmailLogAddOrEdit>().ReverseMap();
CreateMap<FrontAuditConfig, FrontAuditConfigAddOrEdit>().ReverseMap();
@@ -3767,7 +3767,8 @@ namespace IRaCIS.Core.Application.Service
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
await _readingTaskQuestionMarkRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
await _readingNoneDicomMarkRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
await _readingNoneDicomMarkBindingRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId);
await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => x.Id == inDto.VisitTaskId, x => new VisitTask()
{
ReadingTaskState = ReadingTaskState.WaitReading