diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 50aa9433d..0ef066477 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -22,6 +22,7 @@ using Microsoft.Extensions.Options; using MiniExcelLibs; using NPOI.SS.Formula.Functions; using NPOI.XWPF.UserModel; +using System.Globalization; using System.Runtime.InteropServices; using System.Text; using Tea; @@ -178,7 +179,16 @@ namespace IRaCIS.Core.Application.Service } public async Task TestMasstransitHangfire([FromServices] IMessageScheduler _scheduler) { - await _scheduler.SchedulePublish(DateTime.Now.AddSeconds(10), new MasstransitHangfireTest() { value = "message at " + DateTime.Now.ToString() }); + var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; + + var aa = CultureInfo.CurrentCulture.Name; + + CultureInfo.CurrentCulture = new CultureInfo(StaticData.CultureInfo.en_US); + + var bb = CultureInfo.CurrentCulture.Name; + var isEn_US2 = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; + + //await _scheduler.SchedulePublish(DateTime.Now.AddSeconds(10), new MasstransitHangfireTest() { value = "message at " + DateTime.Now.ToString() }); return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs b/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs index e867ee572..3eac599a3 100644 --- a/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs +++ b/IRaCIS.Core.Domain/BaseModel/DomainEvent.cs @@ -1,6 +1,7 @@ using IRaCIS.Core.Domain.Models; using MassTransit; using System.ComponentModel; +using System.Globalization; namespace IRaCIS.Core.Domain.BaseModel; @@ -22,6 +23,8 @@ public abstract class DomainEvent /// 在事件产生多少s后开始消费该事件 /// public int DelaySeconds{ get; set; } + + public string CultureInfoName { get; set; } = CultureInfo.CurrentCulture.Name; } /// diff --git a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs index 85e70c383..b1ac9cc9a 100644 --- a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs +++ b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs @@ -50,7 +50,7 @@ public static class DBContext_Ext } //添加进记录 - eventStoreList.AddRange(trialSiteSurvey.DomainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventData = t.ToJsonStr() })); + eventStoreList.AddRange(GetStoreEvents(trialSiteSurvey.DomainEvents)); } @@ -86,10 +86,8 @@ public static class DBContext_Ext subjectVisit.AddDomainEvent(new CheckStateChangedToAuditEvent() { SubjectVisitId = subjectVisit.Id }); } - - //添加进记录 - eventStoreList.AddRange(subjectVisit.DomainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventData = t.ToJsonStr() })); + eventStoreList.AddRange(GetStoreEvents(subjectVisit.DomainEvents)); } } @@ -117,7 +115,7 @@ public static class DBContext_Ext } //添加进记录 - eventStoreList.AddRange(qCChallengeDialog.DomainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventData = t.ToJsonStr() })); + eventStoreList.AddRange(GetStoreEvents(qCChallengeDialog.DomainEvents)); } } @@ -143,7 +141,7 @@ public static class DBContext_Ext } //添加进记录 - eventStoreList.AddRange(checkChallengeDialog.DomainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventData = t.ToJsonStr() })); + eventStoreList.AddRange(GetStoreEvents(checkChallengeDialog.DomainEvents)); } } @@ -180,7 +178,7 @@ public static class DBContext_Ext taskMedicalReview.AddDomainEvent(new UrgentMedicalReviewAddedEvent() { MedicalReviewId = taskMedicalReview.Id, VisitTaskId = taskMedicalReview.VisitTaskId }); //添加进记录 - eventStoreList.AddRange(taskMedicalReview.DomainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventData = t.ToJsonStr() })); + eventStoreList.AddRange(GetStoreEvents(taskMedicalReview.DomainEvents)); } } } @@ -221,7 +219,7 @@ public static class DBContext_Ext } //添加进记录 - eventStoreList.AddRange(readingMedicalReviewDialog.DomainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventData = t.ToJsonStr() })); + eventStoreList.AddRange(GetStoreEvents(readingMedicalReviewDialog.DomainEvents)); } } @@ -259,7 +257,7 @@ public static class DBContext_Ext visitTask.AddDomainEvent(new UrgentIRApplyedReReading() { VisitTaskId = visitTask.Id }); //添加进记录 - eventStoreList.AddRange(visitTask.DomainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventData = t.ToJsonStr() })); + eventStoreList.AddRange(GetStoreEvents(visitTask.DomainEvents)); } } @@ -270,6 +268,10 @@ public static class DBContext_Ext dbContext.EventStoreRecord.AddRange(eventStoreList); } + private static List GetStoreEvents(IReadOnlyCollection domainEvents) + { + return domainEvents.Select(t => new EventStoreRecord() { Id = t.EventId, EventType = t.GetType().AssemblyQualifiedName, EventData = t.ToJsonStr() }).ToList(); + } public class EnrollmentConfirmAndPD { public bool IsEnrollmentConfirm { get; set; }