From 23bb0a177ce015b48c95b972411b199b6face45e Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 12 Jul 2022 11:13:51 +0800 Subject: [PATCH] upgrade abp framework to 5.3.2 --- aspnet-core/Directory.Build.props | 4 ++-- aspnet-core/common.props | 2 +- .../Abp/Notifications/AbpNotificationOptions.cs | 10 +++++++++- .../MessageService/Notifications/NotificationStore.cs | 10 ++++++++-- .../Notifications/EfCoreNotificationRepository.cs | 3 ++- .../Abp/BackgroundTasks/Quartz/QuartzJobListener.cs | 11 +++++------ common.props | 2 +- gateways/Directory.Build.props | 4 ++-- gateways/common.props | 2 +- 9 files changed, 31 insertions(+), 17 deletions(-) diff --git a/aspnet-core/Directory.Build.props b/aspnet-core/Directory.Build.props index 084393b42..986aee29d 100644 --- a/aspnet-core/Directory.Build.props +++ b/aspnet-core/Directory.Build.props @@ -1,7 +1,7 @@  - 5.3.0 - 5.3.0 + 5.3.2 + 5.3.2 1.7.0 1.0.1 6.0.1 diff --git a/aspnet-core/common.props b/aspnet-core/common.props index 3e799f4fa..8ee00186e 100644 --- a/aspnet-core/common.props +++ b/aspnet-core/common.props @@ -1,7 +1,7 @@ latest - 5.3.0 + 5.3.2 colin $(NoWarn);CS1591;CS0436 https://github.com/colinin/abp-next-admin diff --git a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationOptions.cs b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationOptions.cs index 6720bf3d6..097e6f337 100644 --- a/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationOptions.cs +++ b/aspnet-core/modules/common/LINGYUN.Abp.Notifications/LINGYUN/Abp/Notifications/AbpNotificationOptions.cs @@ -1,4 +1,5 @@ -using Volo.Abp.Collections; +using System; +using Volo.Abp.Collections; namespace LINGYUN.Abp.Notifications { @@ -17,11 +18,18 @@ namespace LINGYUN.Abp.Notifications /// 可以自定义某个通知的格式 /// public NotificationDataMappingDictionary NotificationDataMappings { get; } + /// + /// 过期时间 + /// 默认60天 + /// + public TimeSpan ExpirationTime { get; set; } public AbpNotificationOptions() { PublishProviders = new TypeList(); DefinitionProviders = new TypeList(); NotificationDataMappings = new NotificationDataMappingDictionary(); + + ExpirationTime = TimeSpan.FromDays(60); } } } diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs index 72c77c354..b11e79445 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.Domain/LINGYUN/Abp/MessageService/Notifications/NotificationStore.cs @@ -1,6 +1,7 @@ using LINGYUN.Abp.MessageService.Subscriptions; using LINGYUN.Abp.Notifications; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using System; using System.Collections.Generic; using System.Linq; @@ -32,6 +33,8 @@ namespace LINGYUN.Abp.MessageService.Notifications private readonly IUserSubscribeRepository _userSubscribeRepository; + private readonly AbpNotificationOptions _options; + public NotificationStore( IClock clock, IObjectMapper objectMapper, @@ -39,7 +42,8 @@ namespace LINGYUN.Abp.MessageService.Notifications IUnitOfWorkManager unitOfWorkManager, INotificationRepository notificationRepository, IUserSubscribeRepository userSubscribeRepository, - IUserNotificationRepository userNotificationRepository + IUserNotificationRepository userNotificationRepository, + IOptions options ) { _clock = clock; @@ -49,6 +53,8 @@ namespace LINGYUN.Abp.MessageService.Notifications _notificationRepository = notificationRepository; _userSubscribeRepository = userSubscribeRepository; _userNotificationRepository = userNotificationRepository; + + _options = options.Value; } public virtual async Task ChangeUserNotificationReadStateAsync( @@ -336,7 +342,7 @@ namespace LINGYUN.Abp.MessageService.Notifications CreationTime = _clock.Now, Type = notification.Type, // TODO: 通知过期时间应该可以配置 - ExpirationTime = _clock.Now.AddDays(60) + ExpirationTime = _clock.Now.Add(_options.ExpirationTime) }; await _notificationRepository.InsertAsync(notify, cancellationToken: cancellationToken); diff --git a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs index 4abeb50c5..a40ba8f31 100644 --- a/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs +++ b/aspnet-core/modules/message/LINGYUN.Abp.MessageService.EntityFrameworkCore/LINGYUN/Abp/MessageService/Notifications/EfCoreNotificationRepository.cs @@ -25,7 +25,8 @@ namespace LINGYUN.Abp.MessageService.Notifications CancellationToken cancellationToken = default) { return await (await GetDbSetAsync()) - .Where(x => x.ExpirationTime.Value.CompareTo(DateTime.Now) <= 0) + .Where(x => x.ExpirationTime < DateTime.Now) + .OrderBy(x => x.ExpirationTime) .Take(batchCount) .ToListAsync(GetCancellationToken(cancellationToken)); } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs index fb3d08356..af8c81e43 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.BackgroundTasks.Quartz/LINGYUN/Abp/BackgroundTasks/Quartz/QuartzJobListener.cs @@ -57,12 +57,8 @@ public class QuartzJobListener : JobListenerSupport, ISingletonDependency if (context.Trigger is ISimpleTrigger simpleTrigger) { - // 增量数据写入临时数据 - if (context.MergedJobDataMap.TryGetValue(nameof(JobInfo.TriggerCount), out var count) && - int.TryParse(count?.ToString(), out var triggerCount)) - { - context.Put(nameof(JobInfo.TriggerCount), triggerCount + simpleTrigger.TimesTriggered); - } + // 增量数据写入临时数据, 仅对长期作业有效, 一次性作业永远为1 + context.Put(nameof(JobInfo.TriggerCount), simpleTrigger.TimesTriggered); } using var scope = ServiceScopeFactory.CreateScope(); @@ -76,6 +72,9 @@ public class QuartzJobListener : JobListenerSupport, ISingletonDependency Result = context.Result?.ToString() }; + context.TryGetMultiTenantId(out var tenantId); + jobEventData.TenantId = tenantId; + var eventContext = new JobEventContext( scope.ServiceProvider, jobEventData); diff --git a/common.props b/common.props index cf79ae579..80f7bcdb3 100644 --- a/common.props +++ b/common.props @@ -1,7 +1,7 @@ latest - 5.3.0 + 5.3.2 LINGYUN $(NoWarn);CS1591;CS0436 https://github.com/colinin/abp-next-admin diff --git a/gateways/Directory.Build.props b/gateways/Directory.Build.props index b7b678b57..0adb60c1e 100644 --- a/gateways/Directory.Build.props +++ b/gateways/Directory.Build.props @@ -1,7 +1,7 @@  - 5.3.0 - 5.3.0 + 5.3.2 + 5.3.2 1.7.0 6.0.1 1.5.10 diff --git a/gateways/common.props b/gateways/common.props index 636058f1d..cc688a385 100644 --- a/gateways/common.props +++ b/gateways/common.props @@ -1,7 +1,7 @@ latest - 5.3.0 + 5.3.2 $(NoWarn);CS1591;CS0436 \ No newline at end of file