From f1acb787f5cd3b95efede055b28f0f70f7035f16 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 17 Oct 2024 13:37:57 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=85=8D=E5=90=88hangfire=20=E5=91=A8?= =?UTF-8?q?=E6=9C=9F=E4=BB=BB=E5=8A=A1=E6=9A=82=E6=97=B6=E6=9C=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20--=E5=BE=85=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.API/Progranm.cs | 2 +- .../_PipelineExtensions/LocalizationConfig.cs | 28 +++++++++++++++++-- .../_ServiceExtensions/MassTransitSetup.cs | 15 ++++++---- .../BackGroundJob/IRaCISCHangfireJob.cs | 23 ++++++--------- .../IRaCIS.Core.Application.xml | 4 +-- .../Consumer/ReadingRelationEmailConsumer.cs | 2 +- .../MassTransit/Consumer/TestConsumer.cs | 2 +- .../Recurring/RecurringEmailConsumer.cs | 18 ++++++++++-- irc_api.drone.yml | 2 +- 9 files changed, 65 insertions(+), 31 deletions(-) diff --git a/IRaCIS.Core.API/Progranm.cs b/IRaCIS.Core.API/Progranm.cs index a242c3902..b57a9bd78 100644 --- a/IRaCIS.Core.API/Progranm.cs +++ b/IRaCIS.Core.API/Progranm.cs @@ -207,7 +207,7 @@ app.UseExceptionHandler(o => { }); app.UseIRacisHostStaticFileStore(env); //本地化 -app.UseLocalization(app.Services); + await app.UseLocalization(app.Services); app.UseForwardedHeaders(); diff --git a/IRaCIS.Core.API/_PipelineExtensions/LocalizationConfig.cs b/IRaCIS.Core.API/_PipelineExtensions/LocalizationConfig.cs index 260c3bb6c..564fb7262 100644 --- a/IRaCIS.Core.API/_PipelineExtensions/LocalizationConfig.cs +++ b/IRaCIS.Core.API/_PipelineExtensions/LocalizationConfig.cs @@ -1,18 +1,24 @@ -using IRaCIS.Core.Domain.Share; +using IRaCIS.Core.Application.Helper; +using IRaCIS.Core.Domain.Models; +using IRaCIS.Core.Domain.Share; +using IRaCIS.Core.Infra.EFCore; using IRaCIS.Core.Infrastructure.Extention; using Microsoft.AspNetCore.Builder; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Localization; using System; using System.Collections.Generic; using System.Globalization; +using System.Linq; +using System.Threading.Tasks; namespace IRaCIS.Core.API { public static class LocalizationConfig { - public static void UseLocalization(this IApplicationBuilder app,IServiceProvider serviceProvider) + public static async Task UseLocalization(this IApplicationBuilder app,IServiceProvider serviceProvider) { var supportedCultures = new List { @@ -38,6 +44,24 @@ namespace IRaCIS.Core.API //设置国际化I18n var localizer = serviceProvider.GetRequiredService(); I18n.SetLocalizer(localizer); + + //初始化国际化 + + var _internationalizationRepository = serviceProvider.GetRequiredService>(); + + //查询数据库的数据 + var toJsonList = await _internationalizationRepository.Where(t => t.InternationalizationType == 1).Select(t => new IRCGlobalInfoDTO() + { + Code = t.Code, + Value = t.Value, + ValueCN = t.ValueCN, + Description = t.Description + }).ToListAsync(); + + + await InternationalizationHelper.BatchAddJsonKeyValueAsync(toJsonList); + + } } } diff --git a/IRaCIS.Core.API/_ServiceExtensions/MassTransitSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/MassTransitSetup.cs index 9fa85fb74..57f7b0f5f 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/MassTransitSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/MassTransitSetup.cs @@ -2,6 +2,7 @@ using IRaCIS.Core.Domain.BaseModel; using MassTransit; using Microsoft.Extensions.DependencyInjection; +using System; namespace IRaCIS.Core.API { @@ -30,12 +31,13 @@ namespace IRaCIS.Core.API // 自动扫描程序集中的消费者并进行注册 cfg.AddConsumers(typeof(UserSiteSurveySubmitedEventConsumer).Assembly); - //// 注册消费者 - //cfg.AddConsumer(); // 替换为你的消费者类 - //cfg.AddConsumer(); + + + //Uri schedulerEndpoint = new Uri("queue:scheduler"); + //cfg.AddMessageScheduler(schedulerEndpoint); cfg.AddPublishMessageScheduler(); - //cfg.AddHangfireConsumers(); + cfg.AddHangfireConsumers(); @@ -45,8 +47,11 @@ namespace IRaCIS.Core.API //https://github.com/MassTransit/Sample-Hangfire/blob/master/src/Sample.Hangfire.Console/Program.cs cfg.UsePublishMessageScheduler(); + //cfg.UseMessageScheduler(schedulerEndpoint); + + //使用 Hangfire 进行消息调度 - cfg.UseHangfireScheduler(); + //cfg.UseHangfireScheduler(); cfg.UseConsumeFilter(typeof(CultureInfoFilter<>), context, x => x.Include(type => type.IsAssignableTo(typeof(DomainEvent)))); diff --git a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs index 18b02bbf5..1be20a1e4 100644 --- a/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs +++ b/IRaCIS.Core.Application/BackGroundJob/IRaCISCHangfireJob.cs @@ -1,9 +1,11 @@ using Hangfire; using Hangfire.Storage; using IRaCIS.Core.Application.Helper; +using IRaCIS.Core.Application.MassTransit.Consumer; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using MassTransit; +using MassTransit.Mediator; using MassTransit.Scheduling; using Microsoft.Extensions.Logging; @@ -18,7 +20,8 @@ namespace IRaCIS.Core.Application.Service.BackGroundJob public class IRaCISCHangfireJob(ILogger _logger, IRepository _internationalizationRepository, IRepository _trialEmailNoticeConfigRepository, - IMessageScheduler _IMessageScheduler + IMessageScheduler _iMessageScheduler, + IBus _bus ) : IIRaCISHangfireJob { public static string JsonFileFolder = Path.Combine(AppContext.BaseDirectory, StaticData.Folder.Resources); @@ -28,19 +31,7 @@ namespace IRaCIS.Core.Application.Service.BackGroundJob { _logger.LogInformation("项目启动 hangfire 任务初始化 执行开始~"); - //初始化国际化 - //查询数据库的数据 - var toJsonList = await _internationalizationRepository.Where(t => t.InternationalizationType == 1).Select(t => new IRCGlobalInfoDTO() - { - Code = t.Code, - Value = t.Value, - ValueCN = t.ValueCN, - Description = t.Description - }).ToListAsync(); - - - await InternationalizationHelper.BatchAddJsonKeyValueAsync(toJsonList); //创建邮件定时任务 await InitSysAndTrialCronJobAsync(); @@ -80,7 +71,9 @@ namespace IRaCIS.Core.Application.Service.BackGroundJob break; } - + //var schedulerEndpoint = await _bus.GetSendEndpoint(new Uri("queue:hangfire")); + //await schedulerEndpoint.ScheduleRecurringSend(new Uri("queue:mt-message-queue"), new QCImageQuestionSchedule() { ScheduleId = jobId, CronExpression = "0 0/1 * 1/1 * ? *" }, new PollExternalSystem { }); + //await schedulerEndpoint.ScheduleRecurringSend(new Uri("queue:hangfire"), new QCImageQuestionSchedule() { ScheduleId = jobId + jobId, CronExpression = "0 0/1 * 1/1 * ? *" }, new PollExternalSystem { }); HangfireJobHelper.AddOrUpdateTrialCronJob(jobId, task.TrialId, task.BusinessScenarioEnum, task.EmailCron); @@ -88,7 +81,7 @@ namespace IRaCIS.Core.Application.Service.BackGroundJob } - + public class PollExternalSystem { } } diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 21ebebc56..90b381918 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -12902,14 +12902,14 @@ 加急的医学反馈任务 通知MIM - + 加急的医学反馈任务 通知MIM - 加急的医学反馈任务 通知MIM + 加急的医学反馈任务 通知MIM (026,027) diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs index 962d5d6c3..0b90b7909 100644 --- a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs @@ -107,7 +107,7 @@ public class UrgentMedicalReviewAddedEventConsumer( dictionValue[0], // 任务类型 {5} //dictionValue[1], // 阅片人是否同意 {6} dictionValue[2], // 审核状态 {6} - dictionValue[3], // 是否加急 {7} + dictionValue[3] // 是否加急 {7} ); diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/TestConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/TestConsumer.cs index 0dbef2b9d..09d06fea3 100644 --- a/IRaCIS.Core.Application/MassTransit/Consumer/TestConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Consumer/TestConsumer.cs @@ -70,7 +70,7 @@ public class TestMasstransitService : BaseService await _mediatorScoped.Publish(new MasstransiTestCommand { value = "message at " + DateTime.Now.ToString() }); - //await _scheduler.SchedulePublish(DateTime.Now.AddSeconds(10), new MasstransitHangfireTest() { value = "message at " + DateTime.Now.ToString() }); + await _scheduler.SchedulePublish(DateTime.Now.AddSeconds(10), new MasstransiTestCommand() { value = "message at " + DateTime.Now.ToString() }); return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/MassTransit/Recurring/RecurringEmailConsumer.cs b/IRaCIS.Core.Application/MassTransit/Recurring/RecurringEmailConsumer.cs index fb35a334a..61ec2a89a 100644 --- a/IRaCIS.Core.Application/MassTransit/Recurring/RecurringEmailConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Recurring/RecurringEmailConsumer.cs @@ -1,4 +1,5 @@ -using MassTransit; +using IRaCIS.Core.Application.MassTransit.Command; +using MassTransit; using MassTransit.Scheduling; using System; using System.Collections.Generic; @@ -22,9 +23,9 @@ public abstract class IRCRecurringSchedule : public string TimeZoneId { get; protected set; } public DateTimeOffset StartTime { get; protected set; } public DateTimeOffset? EndTime { get; protected set; } - public string ScheduleId { get; private set; } + public string ScheduleId { get; set; } public string ScheduleGroup { get; private set; } - public string CronExpression { get; protected set; } + public string CronExpression { get; set; } public string Description { get; protected set; } } @@ -53,4 +54,15 @@ public class ImageQCSchedule : IRCRecurringSchedule } +public class QCImageQuestionScheduleConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + Console.WriteLine(DateTime.Now); + + return Task.CompletedTask; + } +} + + diff --git a/irc_api.drone.yml b/irc_api.drone.yml index a6e09d6e3..5fcacf26d 100644 --- a/irc_api.drone.yml +++ b/irc_api.drone.yml @@ -78,7 +78,7 @@ steps: trigger: branch: - - Test_IRC_Net8 + - Test_IRC_Net8—_SCP_Disable --- kind: pipeline From 05693d090d1da1645d5a853b48cffc18f2078000 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 17 Oct 2024 14:32:46 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A4=84=E7=90=86=E5=BB=B6=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 5 +++++ .../SubjectVisitQCAndCheckConsumer.cs | 10 ++++++++++ .../DTO/TrialEmailNoticeConfigViewModel.cs | 4 +++- IRaCIS.Core.Domain/BaseModel/DomainEvent.cs | 5 +++-- .../Common/EmailNoticeConfig.cs | 4 ++++ .../Document/TrialEmailNoticeConfig.cs | 4 ++++ .../SubjectVisitStateChangedEvent.cs | 10 ++++++++++ .../Interceptor/AddDomainExt.cs | 19 +++++++++++++++---- .../DispatchDomainEventsInterceptor.cs | 4 ++-- 9 files changed, 56 insertions(+), 9 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 90b381918..6b84b2d21 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -12985,6 +12985,11 @@ 通知PM 进行一致性核查 + + + QC 领取了质控任务 + + meditor send 的时候,请求流会先到消费者,返回后才会执行后续代码 diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs index 8dd211249..7ce433edd 100644 --- a/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Consumer/SubjectVisitQCAndCheckConsumer.cs @@ -83,3 +83,13 @@ public class CheckStateChangedToAuditEventConsumer : IConsumer +/// QC 领取了质控任务 +/// +public class QCClaimTaskEventConsumer : IConsumer +{ + public Task Consume(ConsumeContext context) + { + throw new NotImplementedException(); + } +} diff --git a/IRaCIS.Core.Application/Service/Document/DTO/TrialEmailNoticeConfigViewModel.cs b/IRaCIS.Core.Application/Service/Document/DTO/TrialEmailNoticeConfigViewModel.cs index 321c33568..b31de2b4d 100644 --- a/IRaCIS.Core.Application/Service/Document/DTO/TrialEmailNoticeConfigViewModel.cs +++ b/IRaCIS.Core.Application/Service/Document/DTO/TrialEmailNoticeConfigViewModel.cs @@ -184,6 +184,9 @@ namespace IRaCIS.Core.Application.ViewModel public string EmailHtmlContent { get; set; } = string.Empty; public string EmailHtmlContentCN { get; set; } = string.Empty; + + public int? EmailDelaySeconds { get; set; } + } @@ -206,7 +209,6 @@ namespace IRaCIS.Core.Application.ViewModel public string FromEmail { get; set; } = string.Empty; public List BlackUserIdList { get; set; } - } diff --git a/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs b/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs index 3eac599a3..aa8ffda7b 100644 --- a/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs +++ b/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs @@ -17,12 +17,13 @@ public abstract class DomainEvent public Guid EventId { get; set; } = NewId.NextSequentialGuid(); //是不是延迟消费的事件,需要用定时任务调度 - public bool IsScheduleEvent { get; set; }=false; + public bool IsDelayScheduleEvent => DelaySeconds!=null && DelaySeconds > 0; + /// /// 在事件产生多少s后开始消费该事件 /// - public int DelaySeconds{ get; set; } + public int? DelaySeconds{ get; set; } public string CultureInfoName { get; set; } = CultureInfo.CurrentCulture.Name; } diff --git a/IRaCIS.Core.Domain/Common/EmailNoticeConfig.cs b/IRaCIS.Core.Domain/Common/EmailNoticeConfig.cs index 617d20635..8b8235438 100644 --- a/IRaCIS.Core.Domain/Common/EmailNoticeConfig.cs +++ b/IRaCIS.Core.Domain/Common/EmailNoticeConfig.cs @@ -40,6 +40,10 @@ public class EmailNoticeConfig : BaseFullDeleteAuditEntity [Comment("发送周期")] public string EmailCron { get; set; } = null!; + + [Comment("邮件延时秒数,比如一个事件触发,延迟多少s后才发邮件")] + public int? EmailDelaySeconds { get; set; } = null!; + [MaxLength] public string EmailHtmlContent { get; set; } = null!; [MaxLength] diff --git a/IRaCIS.Core.Domain/Document/TrialEmailNoticeConfig.cs b/IRaCIS.Core.Domain/Document/TrialEmailNoticeConfig.cs index 5b86c4bfa..7831bbaca 100644 --- a/IRaCIS.Core.Domain/Document/TrialEmailNoticeConfig.cs +++ b/IRaCIS.Core.Domain/Document/TrialEmailNoticeConfig.cs @@ -82,6 +82,10 @@ public class TrialEmailNoticeConfig : BaseFullDeleteAuditEntity public Guid? TrialReadingCriterionId { get; set; } + + [Comment("邮件延时秒数,比如一个事件触发,延迟多少s后才发邮件")] + public int? EmailDelaySeconds { get; set; } = null!; + } [Comment("项目 - 项目邮件用户黑名单")] diff --git a/IRaCIS.Core.Domain/_DomainEvent/SubjectVisitStateChangedEvent.cs b/IRaCIS.Core.Domain/_DomainEvent/SubjectVisitStateChangedEvent.cs index 30d6474af..fb6c3cb06 100644 --- a/IRaCIS.Core.Domain/_DomainEvent/SubjectVisitStateChangedEvent.cs +++ b/IRaCIS.Core.Domain/_DomainEvent/SubjectVisitStateChangedEvent.cs @@ -76,4 +76,14 @@ public class CheckStateChangedToAuditEvent : DomainEvent { public Guid SubjectVisitId { get; set; } +} + +/// +/// QC 领取了质控任务 +/// +public class QCClaimTaskEvent : DomainEvent +{ + public Guid SubjectVisitId { get; set; } + + public Guid CurrentActionUserId { get; set; } } \ No newline at end of file diff --git a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs index 0135866e8..ac68121c6 100644 --- a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs +++ b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs @@ -71,6 +71,7 @@ public static class DBContext_Ext var originSubmitState = entry.Property(p => p.SubmitState).OriginalValue; var originAuditState = entry.Property(p => p.AuditState).OriginalValue; var originCheckState = entry.Property(p => p.CheckState).OriginalValue; + var originCurrentActionUserId = entry.Property(p => p.CurrentActionUserId).OriginalValue; //入组或者PD 才执行下面的逻辑 if ((subjectVisit.IsEnrollmentConfirm || subjectVisit.PDState == PDStateEnum.PDProgress)) @@ -91,6 +92,16 @@ public static class DBContext_Ext subjectVisit.AddDomainEvent(new CheckStateChangedToAuditEvent() { SubjectVisitId = subjectVisit.Id }); } + if (originCurrentActionUserId == null && subjectVisit.CurrentActionUserId != null) + { + var delaySeconds = dbContext.TrialEmailNoticeConfig.Where(t => t.BusinessScenarioEnum == EmailBusinessScenario.EligibilityVerification_PendingClaim) + .Select(t => t.EmailDelaySeconds).FirstOrDefault(); + + subjectVisit.AddDomainEvent(new QCClaimTaskEvent() { SubjectVisitId = subjectVisit.Id, DelaySeconds= delaySeconds, CurrentActionUserId = (Guid)subjectVisit.CurrentActionUserId }); + + } + + //添加进记录 eventStoreList.AddRange(GetStoreEvents(subjectVisit.DomainEvents)); } @@ -180,7 +191,7 @@ public static class DBContext_Ext if (findSubjectVisit.IsEnrollmentConfirm || findSubjectVisit.PDState == PDStateEnum.PDProgress) { - taskMedicalReview.AddDomainEvent(new UrgentMedicalReviewAddedEvent() { IsPD= findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId = taskMedicalReview.Id, VisitTaskId = taskMedicalReview.VisitTaskId }); + taskMedicalReview.AddDomainEvent(new UrgentMedicalReviewAddedEvent() { IsPD = findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId = taskMedicalReview.Id, VisitTaskId = taskMedicalReview.VisitTaskId }); //添加进记录 eventStoreList.AddRange(GetStoreEvents(taskMedicalReview.DomainEvents)); @@ -220,7 +231,7 @@ public static class DBContext_Ext } else if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) { - readingMedicalReviewDialog.AddDomainEvent(new UrgentIRRepliedMedicalReview() { IsPD= findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId= readingMedicalReviewDialog.TaskMedicalReviewId, ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id }); + readingMedicalReviewDialog.AddDomainEvent(new UrgentIRRepliedMedicalReview() { IsPD = findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId = readingMedicalReviewDialog.TaskMedicalReviewId, ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id }); } //添加进记录 @@ -259,7 +270,7 @@ public static class DBContext_Ext if (findSubjectVisit.IsEnrollmentConfirm || findSubjectVisit.PDState == PDStateEnum.PDProgress) { - visitTask.AddDomainEvent(new UrgentApplyedReReading() { VisitTaskId = visitTask.Id, ReReadingApplyState= visitTask.ReReadingApplyState }); + visitTask.AddDomainEvent(new UrgentApplyedReReading() { VisitTaskId = visitTask.Id, ReReadingApplyState = visitTask.ReReadingApplyState }); //添加进记录 eventStoreList.AddRange(GetStoreEvents(visitTask.DomainEvents)); @@ -275,7 +286,7 @@ public static class DBContext_Ext private static List GetStoreEvents(IReadOnlyCollection domainEvents) { - return domainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventTypeName=t.GetType().Name, EventData = t.ToJsonStr() }).ToList(); + return domainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventTypeName = t.GetType().Name, EventData = t.ToJsonStr() }).ToList(); } public class EnrollmentConfirmAndPD { diff --git a/IRaCIS.Core.Infra.EFCore/Interceptor/DispatchDomainEventsInterceptor.cs b/IRaCIS.Core.Infra.EFCore/Interceptor/DispatchDomainEventsInterceptor.cs index 70818ee0e..efd08cb85 100644 --- a/IRaCIS.Core.Infra.EFCore/Interceptor/DispatchDomainEventsInterceptor.cs +++ b/IRaCIS.Core.Infra.EFCore/Interceptor/DispatchDomainEventsInterceptor.cs @@ -58,10 +58,10 @@ namespace IRaCIS.Core.Infra.EFCore.Interceptor //这种方式会导致消息没处理 //await publishEndpoint.Publish(domainEvent); - if (domainEvent.IsScheduleEvent) + if (domainEvent.IsDelayScheduleEvent) { //延迟调度的消息,比如1h后再消费 - await _scheduler.SchedulePublish(DateTime.Now.AddSeconds(domainEvent.DelaySeconds), (object)domainEvent); + await _scheduler.SchedulePublish(DateTime.Now.AddSeconds((int)domainEvent.DelaySeconds!), (object)domainEvent); } await _mediator.Publish(domainEvent.GetType(), domainEvent);