From 6f295fba79fa3124908d6330fbe8bd0cc62d2af0 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Mon, 27 Mar 2023 19:18:54 +0800 Subject: [PATCH] Enhanced commit * The DbSet needs to be added to the aggregate root entity * The time serialization format is changed through the configuration --- .../background-jobs/components/JobTable.vue | 4 +- .../ILocalizationDbContext.cs | 6 +- .../IMessageServiceDbContext.cs | 11 +++- .../MessageServiceDbContext.cs | 11 +++- .../EfCoreUserNotificationRepository.cs | 57 ++++++++++++------- .../INotificationsDbContext.cs | 9 ++- .../NotificationsDbContext.cs | 7 +++ .../EntityFrameworkCore/IPlatformDbContext.cs | 13 +++-- .../EntityFrameworkCore/PlatformDbContext.cs | 14 +++-- .../ITaskManagementDbContext.cs | 5 +- .../TaskManagementDbContext.cs | 3 + .../WebhookSendRecordAppService.cs | 40 +++++++++---- .../Expressions/ExpressionFuncExtensions.cs | 32 +++++++++++ .../IWebhookSendRecordRepository.cs | 7 ++- .../WebhookSendAttemptStore.cs | 28 +++++++-- .../Expressions/ExpressionFuncExtensions.cs | 32 +++++++++++ .../EfCoreWebhookSendRecordRepository.cs | 20 +++++-- .../IWebhooksManagementDbContext.cs | 6 +- .../WebhooksManagementDbContext.cs | 3 + ...rviceApplicationsSingleModule.Configure.cs | 8 ++- .../MicroServiceApplicationsSingleModule.cs | 2 +- .../appsettings.json | 7 +++ .../AuthServerHttpApiHostModule.Configure.cs | 8 ++- .../AuthServerHttpApiHostModule.cs | 2 +- .../appsettings.json | 7 +++ .../AuthServerModule.Configure.cs | 8 ++- .../AuthServerModule.cs | 2 +- .../appsettings.json | 7 +++ ...BackendAdminHttpApiHostModule.Configure.cs | 8 ++- .../BackendAdminHttpApiHostModule.cs | 2 +- .../appsettings.json | 7 +++ ...onManagementHttpApiHostModule.Configure.cs | 8 ++- ...LocalizationManagementHttpApiHostModule.cs | 2 +- .../appsettings.json | 7 +++ ...rmManagementHttpApiHostModule.Configure.cs | 8 ++- .../PlatformManagementHttpApiHostModule.cs | 2 +- .../appsettings.json | 7 +++ ...ltimeMessageHttpApiHostModule.Configure.cs | 8 ++- .../RealtimeMessageHttpApiHostModule.cs | 2 +- .../appsettings.json | 7 +++ ...skManagementHttpApiHostModule.Configure.cs | 10 +++- .../TaskManagementHttpApiHostModule.cs | 2 +- .../appsettings.json | 12 ++-- ...ksManagementHttpApiHostModule.Configure.cs | 10 +++- .../WebhooksManagementHttpApiHostModule.cs | 2 +- .../appsettings.json | 12 ++-- ...owManagementHttpApiHostModule.Configure.cs | 10 +++- .../WorkflowManagementHttpApiHostModule.cs | 2 +- .../appsettings.json | 12 ++-- ...entityServerHttpApiHostModule.Configure.cs | 8 ++- .../IdentityServerHttpApiHostModule.cs | 2 +- .../appsettings.json | 7 +++ .../IdentityServerModule.Configure.cs | 8 ++- .../IdentityServerModule.cs | 2 +- .../appsettings.json | 7 +++ .../ProjectNameHttpApiHostModule.Configure.cs | 12 ++-- .../ProjectNameHttpApiHostModule.cs | 2 +- .../appsettings.json | 12 ++-- 58 files changed, 426 insertions(+), 133 deletions(-) create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs create mode 100644 aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs diff --git a/apps/vue/src/views/task-management/background-jobs/components/JobTable.vue b/apps/vue/src/views/task-management/background-jobs/components/JobTable.vue index 8c16935bc..2a867e142 100644 --- a/apps/vue/src/views/task-management/background-jobs/components/JobTable.vue +++ b/apps/vue/src/views/task-management/background-jobs/components/JobTable.vue @@ -72,7 +72,7 @@ { auth: 'TaskManagement.BackgroundJobs.Pause', label: L('BackgroundJobs:Pause'), - ifShow: [JobStatus.Running, JobStatus.FailedRetry].includes(record.status), + ifShow: [JobStatus.Queuing, JobStatus.Running, JobStatus.FailedRetry].includes(record.status), onClick: handlePause.bind(null, record), }, { @@ -84,7 +84,7 @@ { auth: 'TaskManagement.BackgroundJobs.Trigger', label: L('BackgroundJobs:Trigger'), - ifShow: [JobStatus.Running, JobStatus.Completed, JobStatus.FailedRetry].includes( + ifShow: [JobStatus.Queuing, JobStatus.Running, JobStatus.Completed, JobStatus.FailedRetry].includes( record.status, ), onClick: handleTrigger.bind(null, record), diff --git a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/ILocalizationDbContext.cs b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/ILocalizationDbContext.cs index 0c0c2b334..c3ad8e58b 100644 --- a/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/ILocalizationDbContext.cs +++ b/aspnet-core/modules/lt/LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore/LINGYUN/Abp/LocalizationManagement/EntityFrameworkCore/ILocalizationDbContext.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Data; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; namespace LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore @@ -6,5 +7,8 @@ namespace LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore [ConnectionStringName(LocalizationDbProperties.ConnectionStringName)] public interface ILocalizationDbContext : IEfCoreDbContext { + DbSet Resources { get; } + DbSet Languages { get; } + DbSet Texts { get; } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs index 075e8af18..a39c6921e 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/IMessageServiceDbContext.cs @@ -9,7 +9,14 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore [ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)] public interface IMessageServiceDbContext : IEfCoreDbContext { - DbSet UserChatCards { get; set; } - DbSet UserGroupCards { get; set; } + DbSet UserMessages { get; } + DbSet GroupMessages { get; } + DbSet UserChatFriends { get; } + DbSet UserChatSettings { get; } + DbSet GroupChatBlacks { get; } + DbSet ChatGroups { get; } + DbSet UserChatGroups { get; } + DbSet UserChatCards { get; } + DbSet UserGroupCards { get; } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs index 183315046..ebe7db13e 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/EntityFrameworkCore/MessageServiceDbContext.cs @@ -9,6 +9,13 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore [ConnectionStringName(AbpMessageServiceDbProperties.ConnectionStringName)] public class MessageServiceDbContext : AbpDbContext, IMessageServiceDbContext { + public DbSet UserMessages { get; set; } + public DbSet GroupMessages { get; set; } + public DbSet UserChatFriends { get; set; } + public DbSet UserChatSettings { get; set; } + public DbSet GroupChatBlacks { get; set; } + public DbSet ChatGroups { get; set; } + public DbSet UserChatGroups { get; set; } public DbSet UserChatCards { get; set; } public DbSet UserGroupCards { get; set; } @@ -18,13 +25,13 @@ namespace LINGYUN.Abp.MessageService.EntityFrameworkCore } protected override void OnModelCreating(ModelBuilder modelBuilder) { + base.OnModelCreating(modelBuilder); + modelBuilder.ConfigureMessageService(options => { options.TablePrefix = AbpMessageServiceDbProperties.DefaultTablePrefix; options.Schema = AbpMessageServiceDbProperties.DefaultSchema; }); - - base.OnModelCreating(modelBuilder); } } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs index c458cb2de..577fcac76 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/EfCoreUserNotificationRepository.cs @@ -115,21 +115,29 @@ public class EfCoreUserNotificationRepository : EfCoreRepository() - .Where(x => x.UserId == userId) - .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); - - var notificationQuery = dbContext.Set() - .WhereIf(!filter.IsNullOrWhiteSpace(), nf => - nf.NotificationName.Contains(filter) || - nf.NotificationTypeName.Contains(filter)); - - var notifilerQuery = from un in userNotifilerQuery - join n in notificationQuery - on un.NotificationId equals n.NotificationId - select n; + var notifilerQuery = from un in dbContext.Set() + join n in dbContext.Set() + on un.NotificationId equals n.NotificationId + where un.UserId == userId + select new UserNotificationInfo + { + Id = n.NotificationId, + TenantId = n.TenantId, + Name = n.NotificationName, + ExtraProperties = n.ExtraProperties, + CreationTime = n.CreationTime, + NotificationTypeName = n.NotificationTypeName, + Severity = n.Severity, + State = un.ReadStatus, + Type = n.Type, + ContentType = n.ContentType + }; return await notifilerQuery + .WhereIf(readState.HasValue, x => x.State == readState.Value) + .WhereIf(!filter.IsNullOrWhiteSpace(), nf => + nf.Name.Contains(filter) || + nf.NotificationTypeName.Contains(filter)) .CountAsync(GetCancellationToken(cancellationToken)); } @@ -144,18 +152,19 @@ public class EfCoreUserNotificationRepository : EfCoreRepository() - .Where(x => x.UserId == userId) - .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); + //var userNotifilerQuery = dbContext.Set() + // .Where(x => x.UserId == userId) + // .WhereIf(readState.HasValue, x => x.ReadStatus == readState.Value); - var notificationQuery = dbContext.Set() - .WhereIf(!filter.IsNullOrWhiteSpace(), nf => - nf.NotificationName.Contains(filter) || - nf.NotificationTypeName.Contains(filter)); + //var notificationQuery = dbContext.Set() + // .WhereIf(!filter.IsNullOrWhiteSpace(), nf => + // nf.NotificationName.Contains(filter) || + // nf.NotificationTypeName.Contains(filter)); - var notifilerQuery = from un in userNotifilerQuery - join n in notificationQuery + var notifilerQuery = from un in dbContext.Set() + join n in dbContext.Set() on un.NotificationId equals n.NotificationId + where un.UserId == userId select new UserNotificationInfo { Id = n.NotificationId, @@ -171,6 +180,10 @@ public class EfCoreUserNotificationRepository : EfCoreRepository x.State == readState.Value) + .WhereIf(!filter.IsNullOrWhiteSpace(), nf => + nf.Name.Contains(filter) || + nf.NotificationTypeName.Contains(filter)) .OrderBy(sorting) .PageBy(skipCount, maxResultCount) .AsNoTracking() diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDbContext.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDbContext.cs index d20b6ff7d..7bc6c524a 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDbContext.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDbContext.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Data; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; @@ -6,4 +7,10 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; [ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)] public interface INotificationsDbContext : IEfCoreDbContext { + DbSet Notifications { get; } + DbSet UserNotifications { get; } + DbSet UserSubscribes { get; } + + DbSet NotificationDefinitionGroupRecords { get; } + DbSet NotificationDefinitionRecords { get; } } diff --git a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs index 65f429e19..d520d37c4 100644 --- a/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs +++ b/aspnet-core/modules/notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDbContext.cs @@ -7,6 +7,13 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore; [ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)] public class NotificationsDbContext : AbpDbContext, INotificationsDbContext { + public DbSet Notifications { get; set; } + public DbSet UserNotifications { get; set; } + public DbSet UserSubscribes { get; set; } + + public DbSet NotificationDefinitionGroupRecords { get; set; } + public DbSet NotificationDefinitionRecords { get; set; } + public NotificationsDbContext(DbContextOptions options) : base(options) { diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs index 675f3eb06..acfac2339 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/IPlatformDbContext.cs @@ -11,9 +11,14 @@ namespace LINGYUN.Platform.EntityFrameworkCore [ConnectionStringName(PlatformDbProperties.ConnectionStringName)] public interface IPlatformDbContext : IEfCoreDbContext { - DbSet Menus { get; set; } - DbSet Layouts { get; set; } - DbSet Datas { get; set; } - DbSet Packages { get; set; } + DbSet Menus { get; } + DbSet Layouts { get; } + DbSet RoleMenus { get; } + DbSet UserMenus { get; } + DbSet UserFavoriteMenus { get; } + DbSet Datas { get; } + DbSet DataItems { get; } + DbSet Packages { get; } + DbSet PackageBlobs { get; } } } diff --git a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs index db9aa5b5c..7899dcf4f 100644 --- a/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs +++ b/aspnet-core/modules/platform/LINGYUN.Platform.EntityFrameworkCore/LINGYUN/Platform/EntityFrameworkCore/PlatformDbContext.cs @@ -11,11 +11,15 @@ namespace LINGYUN.Platform.EntityFrameworkCore [ConnectionStringName(PlatformDbProperties.ConnectionStringName)] public class PlatformDbContext : AbpDbContext, IPlatformDbContext { + public DbSet RoleMenus { get; set; } + public DbSet UserMenus { get; set; } + public DbSet UserFavoriteMenus { get; set; } public DbSet Menus { get; set; } public DbSet Layouts { get; set; } - public DbSet Datas { get; set; } - public DbSet Packages { get; set; } - + public DbSet Datas { get; set; } + public DbSet DataItems { get; set; } + public DbSet Packages { get; set; } + public DbSet PackageBlobs { get; set; } public PlatformDbContext(DbContextOptions options) : base(options) { @@ -24,9 +28,9 @@ namespace LINGYUN.Platform.EntityFrameworkCore protected override void OnModelCreating(ModelBuilder builder) { - builder.ConfigurePlatform(); - base.OnModelCreating(builder); + + builder.ConfigurePlatform(); } } } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/ITaskManagementDbContext.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/ITaskManagementDbContext.cs index c6284c0ab..268adb1fb 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/ITaskManagementDbContext.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/ITaskManagementDbContext.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Data; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; namespace LINGYUN.Abp.TaskManagement.EntityFrameworkCore; @@ -6,4 +7,6 @@ namespace LINGYUN.Abp.TaskManagement.EntityFrameworkCore; [ConnectionStringName(TaskManagementDbProperties.ConnectionStringName)] public interface ITaskManagementDbContext :IEfCoreDbContext { + DbSet BackgroundJobInfos { get; } + DbSet BackgroundJobAction { get; } } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/TaskManagementDbContext.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/TaskManagementDbContext.cs index 87fb41052..9804d3de3 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/TaskManagementDbContext.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.TaskManagement.EntityFrameworkCore/LINGYUN/Abp/TaskManagement/EntityFrameworkCore/TaskManagementDbContext.cs @@ -7,6 +7,9 @@ namespace LINGYUN.Abp.TaskManagement.EntityFrameworkCore; [ConnectionStringName(TaskManagementDbProperties.ConnectionStringName)] public class TaskManagementDbContext : AbpDbContext, ITaskManagementDbContext { + public DbSet BackgroundJobInfos { get; set; } + public DbSet BackgroundJobAction { get; set; } + public TaskManagementDbContext( DbContextOptions options) : base(options) diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSendRecordAppService.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSendRecordAppService.cs index 25f1d00bb..29ff364c7 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSendRecordAppService.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSendRecordAppService.cs @@ -6,6 +6,7 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; +using System.Linq.Expressions; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; using Volo.Abp.BackgroundJobs; @@ -51,20 +52,35 @@ public class WebhookSendRecordAppService : WebhooksManagementAppServiceBase, IWe await RecordRepository.DeleteManyAsync(sendRecords); } - public async virtual Task> GetListAsync(WebhookSendRecordGetListInput input) + private class WebhookSendRecordGetListSpecification : Volo.Abp.Specifications.Specification { - var filter = new WebhookSendRecordFilter + protected WebhookSendRecordGetListInput Filter { get; } + + public WebhookSendRecordGetListSpecification(WebhookSendRecordGetListInput filter) + { + Filter = filter; + } + + public override Expression> ToExpression() { - TenantId = input.TenantId, - SubscriptionId = input.SubscriptionId, - ResponseStatusCode = input.ResponseStatusCode, - BeginCreationTime = input.BeginCreationTime, - EndCreationTime = input.EndCreationTime, - WebhookEventId = input.WebhookEventId, - Filter = input.Filter - }; - var totalCount = await RecordRepository.GetCountAsync(filter); - var sendRecords = await RecordRepository.GetListAsync(filter, + Expression> expression = _ => true; + + return expression + .AndIf(Filter.TenantId.HasValue, x => x.TenantId == Filter.TenantId) + .AndIf(Filter.WebhookEventId.HasValue, x => x.WebhookEventId == Filter.WebhookEventId) + .AndIf(Filter.SubscriptionId.HasValue, x => x.WebhookSubscriptionId == Filter.SubscriptionId) + .AndIf(Filter.ResponseStatusCode.HasValue, x => x.ResponseStatusCode == Filter.ResponseStatusCode) + .AndIf(Filter.BeginCreationTime.HasValue, x => x.CreationTime.CompareTo(Filter.BeginCreationTime) >= 0) + .AndIf(Filter.EndCreationTime.HasValue, x => x.CreationTime.CompareTo(Filter.EndCreationTime) <= 0) + .AndIf(!Filter.Filter.IsNullOrWhiteSpace(), x => x.Response.Contains(Filter.Filter)); + } + } + + public async virtual Task> GetListAsync(WebhookSendRecordGetListInput input) + { + var specification = new WebhookSendRecordGetListSpecification(input); + var totalCount = await RecordRepository.GetCountAsync(specification); + var sendRecords = await RecordRepository.GetListAsync(specification, input.Sorting, input.MaxResultCount, input.SkipCount); return new PagedResultDto(totalCount, diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs new file mode 100644 index 000000000..74e3c828a --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/System/Linq/Expressions/ExpressionFuncExtensions.cs @@ -0,0 +1,32 @@ +using Volo.Abp.Specifications; + +namespace System.Linq.Expressions; + +internal static class ExpressionFuncExtensions +{ + public static Expression> AndIf( + this Expression> first, + bool condition, + Expression> second) + { + if (condition) + { + return ExpressionFuncExtender.And(first, second); + } + + return first; + } + + public static Expression> OrIf( + this Expression> first, + bool condition, + Expression> second) + { + if (condition) + { + return ExpressionFuncExtender.Or(first, second); + } + + return first; + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookSendRecordRepository.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookSendRecordRepository.cs index a94eb35ee..f33ff3090 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookSendRecordRepository.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookSendRecordRepository.cs @@ -3,18 +3,19 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; +using Volo.Abp.Specifications; namespace LINGYUN.Abp.WebhooksManagement; public interface IWebhookSendRecordRepository : IRepository { Task GetCountAsync( - WebhookSendRecordFilter filter, + ISpecification specification, CancellationToken cancellationToken = default); Task> GetListAsync( - WebhookSendRecordFilter filter, - string sorting = nameof(WebhookSendRecord.CreationTime), + ISpecification specification, + string sorting = $"{nameof(WebhookSendRecord.CreationTime)} DESC", int maxResultCount = 10, int skipCount = 10, bool includeDetails = false, diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSendAttemptStore.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSendAttemptStore.cs index 1b469c105..bfd70d104 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSendAttemptStore.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSendAttemptStore.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; +using System.Linq.Expressions; using System.Net; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories; @@ -14,6 +15,24 @@ namespace LINGYUN.Abp.WebhooksManagement; public class WebhookSendAttemptStore : DomainService, IWebhookSendAttemptStore { + private class WebhookSendRecordSpecification : Volo.Abp.Specifications.Specification + { + protected Guid SubscriptionId { get; } + + public WebhookSendRecordSpecification( + Guid subscriptionId) + { + SubscriptionId = subscriptionId; + } + + public override Expression> ToExpression() + { + Expression> expression = _ => true; + + return expression.And(x => x.WebhookSubscriptionId == SubscriptionId); + } + } + protected IObjectMapper ObjectMapper => LazyServiceProvider.LazyGetRequiredService>(); protected IWebhookSendRecordRepository WebhookSendAttemptRepository { get; } @@ -33,14 +52,11 @@ public class WebhookSendAttemptStore : DomainService, IWebhookSendAttemptStore { using (CurrentTenant.Change(tenantId)) { - var filter = new WebhookSendRecordFilter - { - SubscriptionId = subscriptionId, - }; - var totalCount = await WebhookSendAttemptRepository.GetCountAsync(filter); + var specification = new WebhookSendRecordSpecification(subscriptionId); + var totalCount = await WebhookSendAttemptRepository.GetCountAsync(specification); var list = await WebhookSendAttemptRepository.GetListAsync( - filter, + specification, maxResultCount: maxResultCount, skipCount: skipCount); diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs new file mode 100644 index 000000000..74e3c828a --- /dev/null +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/System/Linq/Expressions/ExpressionFuncExtensions.cs @@ -0,0 +1,32 @@ +using Volo.Abp.Specifications; + +namespace System.Linq.Expressions; + +internal static class ExpressionFuncExtensions +{ + public static Expression> AndIf( + this Expression> first, + bool condition, + Expression> second) + { + if (condition) + { + return ExpressionFuncExtender.And(first, second); + } + + return first; + } + + public static Expression> OrIf( + this Expression> first, + bool condition, + Expression> second) + { + if (condition) + { + return ExpressionFuncExtender.Or(first, second); + } + + return first; + } +} diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookSendRecordRepository.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookSendRecordRepository.cs index 4bdcde442..706542a0b 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookSendRecordRepository.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookSendRecordRepository.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Specifications; namespace LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; @@ -21,24 +22,31 @@ public class EfCoreWebhookSendRecordRepository : } public async virtual Task GetCountAsync( - WebhookSendRecordFilter filter, + ISpecification specification, CancellationToken cancellationToken = default) { - return await ApplyFilter(await GetDbSetAsync(), filter) + return await (await GetDbSetAsync()) + .Where(specification.ToExpression()) .CountAsync(GetCancellationToken(cancellationToken)); } public async virtual Task> GetListAsync( - WebhookSendRecordFilter filter, - string sorting = "CreationTime", + ISpecification specification, + string sorting = $"{nameof(WebhookSendRecord.CreationTime)} DESC", int maxResultCount = 10, int skipCount = 10, bool includeDetails = false, CancellationToken cancellationToken = default) { - return await ApplyFilter((await GetDbSetAsync()).IncludeDetails(includeDetails), filter) - .OrderBy(sorting ?? $"{nameof(WebhookSendRecord.CreationTime)} DESC") + if (sorting.IsNullOrWhiteSpace()) + { + sorting = $"{nameof(WebhookSendRecord.CreationTime)} DESC"; + } + return await (await GetDbSetAsync()) + .IncludeDetails(includeDetails) + .Where(specification.ToExpression()) + .OrderBy(sorting) .PageBy(skipCount, maxResultCount) .ToListAsync(GetCancellationToken(cancellationToken)); } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/IWebhooksManagementDbContext.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/IWebhooksManagementDbContext.cs index 86642632e..891a8f118 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/IWebhooksManagementDbContext.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/IWebhooksManagementDbContext.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Data; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.MultiTenancy; @@ -8,4 +9,7 @@ namespace LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; [ConnectionStringName(WebhooksManagementDbProperties.ConnectionStringName)] public interface IWebhooksManagementDbContext : IEfCoreDbContext { + DbSet WebhookSendRecord { get; } + DbSet WebhookGroupDefinitionRecords { get; } + DbSet WebhookDefinitionRecords { get; } } diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContext.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContext.cs index 3854f1176..f089116cd 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContext.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/WebhooksManagementDbContext.cs @@ -9,6 +9,9 @@ namespace LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore; [ConnectionStringName(WebhooksManagementDbProperties.ConnectionStringName)] public class WebhooksManagementDbContext : AbpDbContext, IWebhooksManagementDbContext { + public DbSet WebhookSendRecord { get; set; } + public DbSet WebhookGroupDefinitionRecords { get; set; } + public DbSet WebhookDefinitionRecords { get; set; } public WebhooksManagementDbContext( DbContextOptions options) : base(options) { diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs index fb96cb3e6..83e34846a 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs @@ -348,12 +348,16 @@ public partial class MicroServiceApplicationsSingleModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs index fa265d816..1ce3ddbff 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs +++ b/aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs @@ -278,7 +278,6 @@ public partial class MicroServiceApplicationsSingleModule : AbpModule ConfigureBlobStoring(); ConfigureLocalization(); ConfigureKestrelServer(); - ConfigureJsonSerializer(); ConfigureTextTemplating(); ConfigureBackgroundTasks(); ConfigureFeatureManagement(); @@ -290,6 +289,7 @@ public partial class MicroServiceApplicationsSingleModule : AbpModule ConfigureSwagger(context.Services); ConfigureEndpoints(context.Services); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLock(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.json b/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.json index 9627039ce..a613c88ab 100644 --- a/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.json +++ b/aspnet-core/services/LY.MicroService.Applications.Single/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "AllowedHosts": "*", "Hosting": { "BasePath": "" diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs index e65c75eb3..8b29ea297 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.Configure.cs @@ -103,12 +103,16 @@ public partial class AuthServerHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs index 1cde28844..3776c5920 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/AuthServerHttpApiHostModule.cs @@ -81,7 +81,6 @@ public partial class AuthServerHttpApiHostModule : AbpModule ConfigureDbContext(); ConfigureLocalization(); - ConfigureJsonSerializer(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); @@ -91,6 +90,7 @@ public partial class AuthServerHttpApiHostModule : AbpModule ConfigureAuditing(configuration); ConfigureSwagger(context.Services); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLocking(context.Services, configuration); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.json index 873315f9a..d62fe101e 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.AuthServer.HttpApi.Host/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "Serilog": { "MinimumLevel": { "Default": "Debug", diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs index 3f436d880..6001fcee7 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.Configure.cs @@ -183,12 +183,16 @@ public partial class AuthServerModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs index 1446881f0..809d9cfad 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs +++ b/aspnet-core/services/LY.MicroService.AuthServer/AuthServerModule.cs @@ -97,7 +97,6 @@ public partial class AuthServerModule : AbpModule var configuration = context.Services.GetConfiguration(); ConfigureDbContext(); - ConfigureJsonSerializer(); ConfigureCaching(configuration); ConfigureIdentity(configuration); ConfigureVirtualFileSystem(); @@ -107,6 +106,7 @@ public partial class AuthServerModule : AbpModule ConfigureUrls(configuration); ConfigureAuditing(configuration); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLocking(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.AuthServer/appsettings.json b/aspnet-core/services/LY.MicroService.AuthServer/appsettings.json index 61952cf75..c6877dddb 100644 --- a/aspnet-core/services/LY.MicroService.AuthServer/appsettings.json +++ b/aspnet-core/services/LY.MicroService.AuthServer/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "Serilog": { "MinimumLevel": { "Default": "Debug", diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs index 7a115cf17..e6d57476a 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.Configure.cs @@ -113,12 +113,16 @@ public partial class BackendAdminHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs index 851ec6abf..69d8376c2 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/BackendAdminHttpApiHostModule.cs @@ -117,7 +117,6 @@ public partial class BackendAdminHttpApiHostModule : AbpModule ConfigureDbContext(); ConfigureLocalization(); - ConfigureJsonSerializer(); ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureTextTemplating(); @@ -127,6 +126,7 @@ public partial class BackendAdminHttpApiHostModule : AbpModule ConfigureAuditing(configuration); ConfigureSwagger(context.Services); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLocking(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.json index e113587b1..ccc098a62 100644 --- a/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.BackendAdmin.HttpApi.Host/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "Serilog": { "MinimumLevel": { "Default": "Information", diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs index 9ab597ce3..c69f53218 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.Configure.cs @@ -95,12 +95,16 @@ public partial class LocalizationManagementHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs index cfda98277..3af1fe12d 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/LocalizationManagementHttpApiHostModule.cs @@ -75,7 +75,6 @@ namespace LY.MicroService.LocalizationManagement ConfigureDbContext(); ConfigureLocalization(); - ConfigureJsonSerializer(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); @@ -83,6 +82,7 @@ namespace LY.MicroService.LocalizationManagement ConfigureAuditing(configuration); ConfigureSwagger(context.Services); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLocking(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/appsettings.json index 7d29039dd..73dc2c636 100644 --- a/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.LocalizationManagement.HttpApi.Host/appsettings.json @@ -5,6 +5,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "Serilog": { "MinimumLevel": { "Default": "Debug", diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs index f09f6d410..971eebe0e 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.Configure.cs @@ -100,12 +100,16 @@ public partial class PlatformManagementHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs index fa7858839..2761d51c6 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/PlatformManagementHttpApiHostModule.cs @@ -111,7 +111,6 @@ public partial class PlatformManagementHttpApiHostModule : AbpModule ConfigureBlobStoring(); ConfigureLocalization(); ConfigureKestrelServer(); - ConfigureJsonSerializer(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); @@ -119,6 +118,7 @@ public partial class PlatformManagementHttpApiHostModule : AbpModule ConfigureAuditing(configuration); ConfigureSwagger(context.Services); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLocking(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/appsettings.json index 7d29039dd..73dc2c636 100644 --- a/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.PlatformManagement.HttpApi.Host/appsettings.json @@ -5,6 +5,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "Serilog": { "MinimumLevel": { "Default": "Debug", diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs index f7a322e91..a6cd89866 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs @@ -147,12 +147,16 @@ public partial class RealtimeMessageHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs index ed73ad8c0..34a2eef24 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.cs @@ -124,7 +124,6 @@ public partial class RealtimeMessageHttpApiHostModule : AbpModule ConfigureDbContext(); ConfigureLocalization(); ConfigureNotifications(); - ConfigureJsonSerializer(); ConfigureBackgroundTasks(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); @@ -133,6 +132,7 @@ public partial class RealtimeMessageHttpApiHostModule : AbpModule ConfigureAuditing(configuration); ConfigureSwagger(context.Services); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLocking(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.json index 7d29039dd..73dc2c636 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/appsettings.json @@ -5,6 +5,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "Serilog": { "MinimumLevel": { "Default": "Debug", diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs index 56602315c..dc7648a30 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.Configure.cs @@ -144,12 +144,16 @@ public partial class TaskManagementHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { - // 解决某些不支持类型的序列化 + // 统一时间日期格式 Configure(options => { - // options.DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs index d379ff410..e7c7cab93 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs @@ -97,7 +97,6 @@ public partial class TaskManagementHttpApiHostModule : AbpModule ConfigureDbContext(); ConfigureLocalization(); - ConfigureJsonSerializer(); ConfigureBackgroundTasks(); ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); @@ -106,6 +105,7 @@ public partial class TaskManagementHttpApiHostModule : AbpModule ConfigureAuditing(configuration); ConfigureMultiTenancy(configuration); ConfigureSwagger(context.Services); + ConfigureJsonSerializer(configuration); ConfigureDistributedLock(context.Services, configuration); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); } diff --git a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.json index 1e85dd7a6..67182abbb 100644 --- a/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "AllowedHosts": "*", "Serilog": { "MinimumLevel": { @@ -31,7 +38,6 @@ "path": "Logs/Debug-.log", "restrictedToMinimumLevel": "Debug", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -41,7 +47,6 @@ "path": "Logs/Info-.log", "restrictedToMinimumLevel": "Information", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -51,7 +56,6 @@ "path": "Logs/Warn-.log", "restrictedToMinimumLevel": "Warning", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -61,7 +65,6 @@ "path": "Logs/Error-.log", "restrictedToMinimumLevel": "Error", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -71,7 +74,6 @@ "path": "Logs/Fatal-.log", "restrictedToMinimumLevel": "Fatal", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } } diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs index 069951ab4..57dabb683 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.Configure.cs @@ -151,12 +151,16 @@ public partial class WebhooksManagementHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { - // 解决某些不支持类型的序列化 + // 统一时间日期格式 Configure(options => { - // options.DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs index a4b308aec..50766b859 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/WebhooksManagementHttpApiHostModule.cs @@ -98,7 +98,6 @@ public partial class WebhooksManagementHttpApiHostModule : AbpModule ConfigureWrapper(); ConfigureDbContext(); ConfigureLocalization(); - ConfigureJsonSerializer(); ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); @@ -107,6 +106,7 @@ public partial class WebhooksManagementHttpApiHostModule : AbpModule ConfigureMultiTenancy(configuration); ConfigureSwagger(context.Services); ConfigureWebhooks(context.Services); + ConfigureJsonSerializer(configuration); ConfigureBackgroundTasks(context.Services); ConfigureOpenTelemetry(context.Services, configuration); ConfigureDistributedLock(context.Services, configuration); diff --git a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.json index 67e1bc4bd..8c18b4a5a 100644 --- a/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.WebhooksManagement.HttpApi.Host/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "AllowedHosts": "*", "Serilog": { "MinimumLevel": { @@ -31,7 +38,6 @@ "path": "Logs/Debug-.log", "restrictedToMinimumLevel": "Debug", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -41,7 +47,6 @@ "path": "Logs/Info-.log", "restrictedToMinimumLevel": "Information", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -51,7 +56,6 @@ "path": "Logs/Warn-.log", "restrictedToMinimumLevel": "Warning", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -61,7 +65,6 @@ "path": "Logs/Error-.log", "restrictedToMinimumLevel": "Error", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -71,7 +74,6 @@ "path": "Logs/Fatal-.log", "restrictedToMinimumLevel": "Fatal", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } } diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs index c6e134fa1..9681f20ec 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.Configure.cs @@ -234,12 +234,16 @@ public partial class WorkflowManagementHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { - // 解决某些不支持类型的序列化 + // 统一时间日期格式 Configure(options => { - // options.DefaultDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs index dabeb4ae3..62f90c7cf 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/WorkflowManagementHttpApiHostModule.cs @@ -102,7 +102,6 @@ public partial class WorkflowManagementHttpApiHostModule : AbpModule ConfigureDbContext(); ConfigureLocalization(); - ConfigureJsonSerializer(); ConfigureBackgroundTasks(); ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); @@ -111,6 +110,7 @@ public partial class WorkflowManagementHttpApiHostModule : AbpModule ConfigureMultiTenancy(configuration); ConfigureSwagger(context.Services); ConfigureEndpoints(context.Services); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureBlobStoring(context.Services, configuration); ConfigureDistributedLock(context.Services, configuration); diff --git a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.json index 1c74e3798..ff718312f 100644 --- a/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.WorkflowManagement.HttpApi.Host/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "AllowedHosts": "*", "Hosting": { "BasePath": "" @@ -34,7 +41,6 @@ "path": "Logs/Debug-.log", "restrictedToMinimumLevel": "Debug", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -44,7 +50,6 @@ "path": "Logs/Info-.log", "restrictedToMinimumLevel": "Information", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -54,7 +59,6 @@ "path": "Logs/Warn-.log", "restrictedToMinimumLevel": "Warning", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -64,7 +68,6 @@ "path": "Logs/Error-.log", "restrictedToMinimumLevel": "Error", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -74,7 +77,6 @@ "path": "Logs/Fatal-.log", "restrictedToMinimumLevel": "Fatal", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } } diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs index ec6f496d7..3e3649c58 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.Configure.cs @@ -101,12 +101,16 @@ public partial class IdentityServerHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs index 71c228cf7..03f79789b 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/IdentityServerHttpApiHostModule.cs @@ -83,7 +83,6 @@ public partial class IdentityServerHttpApiHostModule : AbpModule ConfigureDbContext(); ConfigureLocalization(); - ConfigureJsonSerializer(); ConfigreExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureFeatureManagement(); @@ -93,6 +92,7 @@ public partial class IdentityServerHttpApiHostModule : AbpModule ConfigureAuditing(configuration); ConfigureSwagger(context.Services); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLocking(context.Services, configuration); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/appsettings.json b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/appsettings.json index 873315f9a..d62fe101e 100644 --- a/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/appsettings.json +++ b/aspnet-core/services/LY.MicroService.identityServer.HttpApi.Host/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "Serilog": { "MinimumLevel": { "Default": "Debug", diff --git a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs index 2a58c3f12..fa892797b 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.Configure.cs @@ -133,12 +133,16 @@ public partial class IdentityServerModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs index 664a90681..8d454d555 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs +++ b/aspnet-core/services/LY.MicroService.identityServer/IdentityServerModule.cs @@ -98,7 +98,6 @@ public partial class IdentityServerModule : AbpModule var configuration = context.Services.GetConfiguration(); ConfigureDbContext(); - ConfigureJsonSerializer(); ConfigureCaching(configuration); ConfigureIdentity(configuration); ConfigureVirtualFileSystem(); @@ -109,6 +108,7 @@ public partial class IdentityServerModule : AbpModule ConfigureMvcUiTheme(); ConfigureUrls(configuration); ConfigureMultiTenancy(configuration); + ConfigureJsonSerializer(configuration); ConfigureCors(context.Services, configuration); ConfigureDistributedLocking(context.Services, configuration); ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/services/LY.MicroService.identityServer/appsettings.json b/aspnet-core/services/LY.MicroService.identityServer/appsettings.json index 61952cf75..c6877dddb 100644 --- a/aspnet-core/services/LY.MicroService.identityServer/appsettings.json +++ b/aspnet-core/services/LY.MicroService.identityServer/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "Serilog": { "MinimumLevel": { "Default": "Debug", diff --git a/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.Configure.cs b/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.Configure.cs index a13c42307..3583bb67d 100644 --- a/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.Configure.cs +++ b/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.Configure.cs @@ -106,14 +106,16 @@ public partial class ProjectNameHttpApiHostModule }); } - private void ConfigureJsonSerializer() + private void ConfigureJsonSerializer(IConfiguration configuration) { - // 解决某些不支持类型的序列化 + // 统一时间日期格式 Configure(options => { - options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; - options.InputDateTimeFormats.AddIfNotContains("yyyy-MM-dd HH:mm:ss"); - options.InputDateTimeFormats.AddIfNotContains("yyyy-MM-ddTHH:mm:ss"); + var jsonConfiguration = configuration.GetSection("Json"); + if (jsonConfiguration.Exists()) + { + jsonConfiguration.Bind(options); + } }); // 中文序列化的编码问题 Configure(options => diff --git a/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs b/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs index 65dde60c7..0abe6ab24 100644 --- a/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs +++ b/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/ProjectNameHttpApiHostModule.cs @@ -81,13 +81,13 @@ public partial class ProjectNameHttpApiHostModule : AbpModule ConfigureWrapper(); ConfigureLocalization(); - ConfigureJsonSerializer(); ConfigureExceptionHandling(); ConfigureVirtualFileSystem(); ConfigureCaching(configuration); ConfigureAuditing(configuration); ConfigureMultiTenancy(configuration); ConfigureSwagger(context.Services); + ConfigureJsonSerializer(configuration); ConfigureOpenTelemetry(context.Services, configuration); ConfigureDistributedLock(context.Services, configuration); ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); diff --git a/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/appsettings.json b/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/appsettings.json index d3d63c269..357fd2346 100644 --- a/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/appsettings.json +++ b/aspnet-core/templates/content/host/PackageName.CompanyName.ProjectName.HttpApi.Host/appsettings.json @@ -4,6 +4,13 @@ "InitVectorBytes": "s83ng0abvd02js84", "DefaultSalt": "sf&5)s3#" }, + "Json": { + "OutputDateTimeFormat": "yyyy-MM-dd HH:mm:ss", + "InputDateTimeFormats": [ + "yyyy-MM-dd HH:mm:ss", + "yyyy-MM-ddTHH:mm:ss" + ] + }, "AllowedHosts": "*", "Serilog": { "MinimumLevel": { @@ -31,7 +38,6 @@ "path": "Logs/Debug-.log", "restrictedToMinimumLevel": "Debug", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -41,7 +47,6 @@ "path": "Logs/Info-.log", "restrictedToMinimumLevel": "Information", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -51,7 +56,6 @@ "path": "Logs/Warn-.log", "restrictedToMinimumLevel": "Warning", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -61,7 +65,6 @@ "path": "Logs/Error-.log", "restrictedToMinimumLevel": "Error", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }, @@ -71,7 +74,6 @@ "path": "Logs/Fatal-.log", "restrictedToMinimumLevel": "Fatal", "rollingInterval": "Day", - "fileSizeLimitBytes": 5242880, "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" } }