From d162b563bd7105e4faaf3657eead0ed5e3436f92 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 4 Jan 2022 11:42:51 +0800 Subject: [PATCH 1/9] Make more DTO classes extensible. --- .../Dtos/LimitedResultRequestDto.cs | 56 +++++++++++++++++-- .../Abp/Application/Dtos/ListResultDto.cs | 34 ++++++++++- .../Dtos/PagedAndSortedResultRequestDto.cs | 11 +++- .../Abp/Application/Dtos/PagedResultDto.cs | 32 ++++++++++- .../Application/Dtos/PagedResultRequestDto.cs | 12 +++- 5 files changed, 136 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs index 95c55174ad..eb646c5ceb 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/LimitedResultRequestDto.cs @@ -39,14 +39,62 @@ namespace Volo.Abp.Application.Dtos yield return new ValidationResult( localizer[ - "MaxResultCountExceededExceptionMessage", + "MaxResultCountExceededExceptionMessage", nameof(MaxResultCount), - MaxMaxResultCount, - typeof(LimitedResultRequestDto).FullName, + MaxMaxResultCount, + typeof(LimitedResultRequestDto).FullName, nameof(MaxMaxResultCount) ], new[] { nameof(MaxResultCount) }); } } } -} \ No newline at end of file + + /// + /// Simply implements . + /// + [Serializable] + public class ExtensibleLimitedResultRequestDto : ExtensibleEntityDto, ILimitedResultRequest, IValidatableObject + { + /// + /// Default value: 10. + /// + public static int DefaultMaxResultCount { get; set; } = 10; + + /// + /// Maximum possible value of the . + /// Default value: 1,000. + /// + public static int MaxMaxResultCount { get; set; } = 1000; + + /// + /// Maximum result count should be returned. + /// This is generally used to limit result count on paging. + /// + [Range(1, int.MaxValue)] + public virtual int MaxResultCount { get; set; } = DefaultMaxResultCount; + + public override IEnumerable Validate(ValidationContext validationContext) + { + foreach(var result in base.Validate(validationContext)) + { + yield return result; + } + + if (MaxResultCount > MaxMaxResultCount) + { + var localizer = validationContext.GetRequiredService>(); + + yield return new ValidationResult( + localizer[ + "MaxResultCountExceededExceptionMessage", + nameof(MaxResultCount), + MaxMaxResultCount, + typeof(ExtensibleLimitedResultRequestDto).FullName, + nameof(MaxMaxResultCount) + ], + new[] { nameof(MaxResultCount) }); + } + } + } +} diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs index 6b3c897aa9..0dc9c56568 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/ListResultDto.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using Volo.Abp.ObjectExtending; namespace Volo.Abp.Application.Dtos { @@ -19,7 +20,7 @@ namespace Volo.Abp.Application.Dtos /// public ListResultDto() { - + } /// @@ -31,4 +32,33 @@ namespace Volo.Abp.Application.Dtos Items = items; } } -} \ No newline at end of file + + [Serializable] + public class ExtensibleListResultDto : ExtensibleObject, IListResult + { + /// + public IReadOnlyList Items + { + get { return _items ?? (_items = new List()); } + set { _items = value; } + } + private IReadOnlyList _items; + + /// + /// Creates a new object. + /// + public ExtensibleListResultDto() + { + + } + + /// + /// Creates a new object. + /// + /// List of items + public ExtensibleListResultDto(IReadOnlyList items) + { + Items = items; + } + } +} diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs index 4f8d843046..1e87a6574a 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedAndSortedResultRequestDto.cs @@ -10,4 +10,13 @@ namespace Volo.Abp.Application.Dtos { public virtual string Sorting { get; set; } } -} \ No newline at end of file + + /// + /// Simply implements . + /// + [Serializable] + public class ExtensiblePagedAndSortedResultRequestDto : ExtensiblePagedResultRequestDto, IPagedAndSortedResultRequest + { + public virtual string Sorting { get; set; } + } +} diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultDto.cs index b10d64211a..66348fc95d 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultDto.cs @@ -32,4 +32,34 @@ namespace Volo.Abp.Application.Dtos TotalCount = totalCount; } } -} \ No newline at end of file + + /// + /// Implements . + /// + /// Type of the items in the list + [Serializable] + public class ExtensiblePagedResultDto : ExtensibleListResultDto, IPagedResult + { + /// + public long TotalCount { get; set; } //TODO: Can be a long value..? + + /// + /// Creates a new object. + /// + public ExtensiblePagedResultDto() + { + + } + + /// + /// Creates a new object. + /// + /// Total count of Items + /// List of items in current page + public ExtensiblePagedResultDto(long totalCount, IReadOnlyList items) + : base(items) + { + TotalCount = totalCount; + } + } +} diff --git a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultRequestDto.cs b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultRequestDto.cs index e028dd3f8d..6a05cceede 100644 --- a/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultRequestDto.cs +++ b/framework/src/Volo.Abp.Ddd.Application.Contracts/Volo/Abp/Application/Dtos/PagedResultRequestDto.cs @@ -12,4 +12,14 @@ namespace Volo.Abp.Application.Dtos [Range(0, int.MaxValue)] public virtual int SkipCount { get; set; } } -} \ No newline at end of file + + /// + /// Simply implements . + /// + [Serializable] + public class ExtensiblePagedResultRequestDto : ExtensibleLimitedResultRequestDto, IPagedResultRequest + { + [Range(0, int.MaxValue)] + public virtual int SkipCount { get; set; } + } +} From 775acd13a173519183c787cd928d08b35e81fcbb Mon Sep 17 00:00:00 2001 From: Enis Necipoglu Date: Tue, 4 Jan 2022 13:40:57 +0300 Subject: [PATCH 2/9] Update CMSKit document --- docs/en/Modules/Cms-Kit/Index.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/en/Modules/Cms-Kit/Index.md b/docs/en/Modules/Cms-Kit/Index.md index 7d773973e0..46ecaad8c8 100644 --- a/docs/en/Modules/Cms-Kit/Index.md +++ b/docs/en/Modules/Cms-Kit/Index.md @@ -19,15 +19,14 @@ Click to a feature to understand and learn how to use it. All features are individually usable. If you disable a feature, it completely disappears from your application, even from the database tables, by the help of the [Global Features](../../Global-Features.md) system. ## Pre Requirements +- This module depends on [BlobStoring](../../Blob-Storing.md) module for keeping media content. +> Make sure `BlobStoring` module is installed and at leats one provider is configured properly. For more information, check the [documentation](../../Blob-Storing.md). -CMS Kit uses [distributed cache](../../Caching.md) for responding faster. - +- CMS Kit uses [distributed cache](../../Caching.md) for responding faster. > Using a distributed cache, such as [Redis](../../Redis-Cache.md), is highly recommended for data consistency in distributed/clustered deployments. ## How to Install -> This module is depends on [BlobStoring](../../Blob-Storing.md) module, please install `BlobStoring` module first and add a provider. For more information, check the [documentation](../../Blob-Storing.md). - [ABP CLI](../../CLI.md) allows installing a module to a solution using the `add-module` command. You can install the CMS Kit module in a command-line terminal with the following command: ```bash @@ -77,4 +76,4 @@ All tables/collections use the `Cms` prefix by default. Set static properties on This module uses `CmsKit` for the connection string name. If you don't define a connection string with this name, it fallbacks to the `Default` connection string. -See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-Strings) documentation for details. \ No newline at end of file +See the [connection strings](https://docs.abp.io/en/abp/latest/Connection-Strings) documentation for details. From e4ddd7d47c286e6d71791fb398dc22a69708e1d7 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 5 Jan 2022 15:52:27 +0800 Subject: [PATCH 3/9] Support proxy class --- .../HangfireBackgroundWorkerManager.cs | 3 ++- .../Quartz/QuartzBackgroundWorkerManager.cs | 3 ++- .../QuartzPeriodicBackgroundWorkerAdapter.cs | 7 ++++--- .../Volo/Abp/DynamicProxy/ProxyHelper.cs | 20 ++++++++++++++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs b/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs index 2a9cb33a10..f9ff0eb4aa 100644 --- a/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs +++ b/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs @@ -4,6 +4,7 @@ using System.Threading; using System.Threading.Tasks; using Hangfire; using Volo.Abp.DependencyInjection; +using Volo.Abp.DynamicProxy; using Volo.Abp.Threading; namespace Volo.Abp.BackgroundWorkers.Hangfire @@ -64,7 +65,7 @@ namespace Volo.Abp.BackgroundWorkers.Hangfire return; } - var adapterType = typeof(HangfirePeriodicBackgroundWorkerAdapter<>).MakeGenericType(worker.GetType()); + var adapterType = typeof(HangfirePeriodicBackgroundWorkerAdapter<>).MakeGenericType(ProxyHelper.GetUnProxiedType(worker)); var workerAdapter = Activator.CreateInstance(adapterType) as IHangfireBackgroundWorker; RecurringJob.AddOrUpdate(() => workerAdapter.DoWorkAsync(), GetCron(period.Value)); diff --git a/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs b/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs index 582a7dd520..a2b51e0177 100644 --- a/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs +++ b/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs @@ -3,6 +3,7 @@ using System.Threading; using System.Threading.Tasks; using Quartz; using Volo.Abp.DependencyInjection; +using Volo.Abp.DynamicProxy; using Volo.Abp.Threading; namespace Volo.Abp.BackgroundWorkers.Quartz @@ -56,7 +57,7 @@ namespace Volo.Abp.BackgroundWorkers.Quartz } else { - var adapterType = typeof(QuartzPeriodicBackgroundWorkerAdapter<>).MakeGenericType(worker.GetType()); + var adapterType = typeof(QuartzPeriodicBackgroundWorkerAdapter<>).MakeGenericType(ProxyHelper.GetUnProxiedType(worker)); var workerAdapter = Activator.CreateInstance(adapterType) as IQuartzBackgroundWorkerAdapter; diff --git a/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzPeriodicBackgroundWorkerAdapter.cs b/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzPeriodicBackgroundWorkerAdapter.cs index 16286d3153..582370b192 100644 --- a/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzPeriodicBackgroundWorkerAdapter.cs +++ b/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzPeriodicBackgroundWorkerAdapter.cs @@ -2,6 +2,7 @@ using System.Reflection; using System.Threading.Tasks; using Quartz; +using Volo.Abp.DynamicProxy; using Volo.Abp.Threading; namespace Volo.Abp.BackgroundWorkers.Quartz @@ -26,16 +27,16 @@ namespace Volo.Abp.BackgroundWorkers.Quartz public void BuildWorker(IBackgroundWorker worker) { int? period; - var workerType = worker.GetType(); + var workerType = ProxyHelper.GetUnProxiedType(worker); if (worker is AsyncPeriodicBackgroundWorkerBase or PeriodicBackgroundWorkerBase) { - if (typeof(TWorker) != worker.GetType()) + if (typeof(TWorker) != workerType) { throw new ArgumentException($"{nameof(worker)} type is different from the generic type"); } - var timer = worker.GetType().GetProperty("Timer", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(worker); + var timer = workerType.GetProperty("Timer", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(worker); if (worker is AsyncPeriodicBackgroundWorkerBase) { diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/ProxyHelper.cs b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/ProxyHelper.cs index db7ff4b869..1f5db0b071 100644 --- a/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/ProxyHelper.cs +++ b/framework/src/Volo.Abp.Core/Volo/Abp/DynamicProxy/ProxyHelper.cs @@ -7,9 +7,9 @@ namespace Volo.Abp.DynamicProxy public static class ProxyHelper { private const string ProxyNamespace = "Castle.Proxies"; - + /// - /// Returns dynamic proxy target object if this is a proxied object, otherwise returns the given object. + /// Returns dynamic proxy target object if this is a proxied object, otherwise returns the given object. /// It supports Castle Dynamic Proxies. /// public static object UnProxy(object obj) @@ -33,7 +33,21 @@ namespace Volo.Abp.DynamicProxy public static Type GetUnProxiedType(object obj) { - return UnProxy(obj).GetType(); + if (obj.GetType().Namespace == ProxyNamespace) + { + var target = UnProxy(obj); + if (target != null) + { + if (target == obj) + { + return obj.GetType().GetTypeInfo().BaseType; + } + + return target.GetType(); + } + } + + return obj.GetType(); } } } From 8ded6446321ee284bb5fc80a9b90fc5f1e9c456f Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 5 Jan 2022 17:12:38 +0800 Subject: [PATCH 4/9] Update HangfireBackgroundWorkerManager.cs --- .../Hangfire/HangfireBackgroundWorkerManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs b/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs index f9ff0eb4aa..e6745e977b 100644 --- a/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs +++ b/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs @@ -26,14 +26,14 @@ namespace Volo.Abp.BackgroundWorkers.Hangfire { if (worker is IHangfireBackgroundWorker hangfireBackgroundWorker) { + var unProxyWorker = ProxyHelper.UnProxy(hangfireBackgroundWorker); if (hangfireBackgroundWorker.RecurringJobId.IsNullOrWhiteSpace()) { - RecurringJob.AddOrUpdate(() => hangfireBackgroundWorker.DoWorkAsync(), - hangfireBackgroundWorker.CronExpression); + RecurringJob.AddOrUpdate(() => ((IHangfireBackgroundWorker)unProxyWorker).DoWorkAsync(),hangfireBackgroundWorker.CronExpression); } else { - RecurringJob.AddOrUpdate(hangfireBackgroundWorker.RecurringJobId,() => hangfireBackgroundWorker.DoWorkAsync(), + RecurringJob.AddOrUpdate(hangfireBackgroundWorker.RecurringJobId,() => ((IHangfireBackgroundWorker)unProxyWorker).DoWorkAsync(), hangfireBackgroundWorker.CronExpression); } } From 5fd645bfabc4ed81a7dd309a6459f27adc7bb7ef Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Wed, 5 Jan 2022 17:43:51 +0800 Subject: [PATCH 5/9] update docucment --- docs/en/Background-Workers-Hangfire.md | 30 +++++++++++++++++++++ docs/zh-Hans/Background-Workers-Hangfire.md | 30 +++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/docs/en/Background-Workers-Hangfire.md b/docs/en/Background-Workers-Hangfire.md index e1e6fc71ad..2ea7fd633e 100644 --- a/docs/en/Background-Workers-Hangfire.md +++ b/docs/en/Background-Workers-Hangfire.md @@ -66,6 +66,33 @@ public class MyLogWorker : HangfireBackgroundWorkerBase > You can directly implement the `IHangfireBackgroundWorker`, but `HangfireBackgroundWorkerBase` provides some useful properties like Logger. +### UnitOfWork + +For use with `UnitOfWorkAttribute`, you need to define an interface for worker: + +```csharp +public interface IMyLogWorker : IHangfireBackgroundWorker +{ +} + +[ExposeServices(typeof(IMyLogWorker))] +public class MyLogWorker : HangfireBackgroundWorkerBase, IMyLogWorker +{ + public MyLogWorker() + { + RecurringJobId = nameof(MyLogWorker); + CronExpression = Cron.Daily(); + } + + [UnitOfWork] + public override Task DoWorkAsync() + { + Logger.LogInformation("Executed MyLogWorker..!"); + return Task.CompletedTask; + } +} +``` + ## Register BackgroundWorkerManager After creating a background worker class, you should add it to the `IBackgroundWorkerManager`. The most common place is the `OnApplicationInitialization` method of your module class: @@ -78,6 +105,9 @@ public class MyModule : AbpModule ApplicationInitializationContext context) { context.AddBackgroundWorker(); + + //If the interface is defined + //context.AddBackgroundWorker(); } } ```` diff --git a/docs/zh-Hans/Background-Workers-Hangfire.md b/docs/zh-Hans/Background-Workers-Hangfire.md index bd63ff91e9..5e53928ca1 100644 --- a/docs/zh-Hans/Background-Workers-Hangfire.md +++ b/docs/zh-Hans/Background-Workers-Hangfire.md @@ -67,6 +67,33 @@ public class MyLogWorker : HangfireBackgroundWorkerBase > 你可以直接实现 `IHangfireBackgroundWorker`, 但是 `HangfireBackgroundWorkerBase` 提供了一些有用的属性,例如 `Logger`. +### UnitOfWork + +使用 `UnitOfWorkAttribute` 你需要为工作者定义一个接口: + +```csharp +public interface IMyLogWorker : IHangfireBackgroundWorker +{ +} + +[ExposeServices(typeof(IMyLogWorker))] +public class MyLogWorker : HangfireBackgroundWorkerBase, IMyLogWorker +{ + public MyLogWorker() + { + RecurringJobId = nameof(MyLogWorker); + CronExpression = Cron.Daily(); + } + + [UnitOfWork] + public override Task DoWorkAsync() + { + Logger.LogInformation("Executed MyLogWorker..!"); + return Task.CompletedTask; + } +} +``` + ## 注册到后台工作者管理器 创建一个后台工作者后, 你应该添加到 `IBackgroundWorkerManager`, 最常用的地方是在你模块类的 `OnApplicationInitialization` 方法中: @@ -79,6 +106,9 @@ public class MyModule : AbpModule ApplicationInitializationContext context) { context.AddBackgroundWorker(); + + //如果定义了接口 + //context.AddBackgroundWorker(); } } ```` From 5dfca00c452d723a7a847c609a714fc5d84f8d45 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 5 Jan 2022 18:25:39 +0800 Subject: [PATCH 6/9] Add Web module as `CompiledRazorAssemblyPart`. Resolve #11183 --- .../MyProjectNameWebTestModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs index 8f7b9e2daa..15244f7e4b 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs @@ -27,7 +27,7 @@ namespace MyCompanyName.MyProjectName { context.Services.PreConfigure(builder => { - builder.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(MyProjectNameWebModule).Assembly)); + builder.PartManager.ApplicationParts.Add(new CompiledRazorAssemblyPart(typeof(MyProjectNameWebModule).Assembly)); }); } From b7d59cb8147e5215bf75a6fb5a5d73158df331e3 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 5 Jan 2022 20:27:33 +0800 Subject: [PATCH 7/9] Update QuartzBackgroundWorkerManager.cs --- .../BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs b/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs index f7b2c17c69..060afd3ac6 100644 --- a/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs +++ b/framework/src/Volo.Abp.BackgroundWorkers.Quartz/Volo/Abp/BackgroundWorkers/Quartz/QuartzBackgroundWorkerManager.cs @@ -34,9 +34,9 @@ public class QuartzBackgroundWorkerManager : IBackgroundWorkerManager, ISingleto } } - public virtual void Add(IBackgroundWorker worker) + public virtual async Task AddAsync(IBackgroundWorker worker) { - AsyncHelper.RunSync(() => ReScheduleJobAsync(worker)); + await ReScheduleJobAsync(worker); } protected virtual async Task ReScheduleJobAsync(IBackgroundWorker worker) From 3aee2f00dc23e429cd1eff8c04784b3210903324 Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 5 Jan 2022 20:28:53 +0800 Subject: [PATCH 8/9] Update HangfireBackgroundWorkerManager.cs --- .../Hangfire/HangfireBackgroundWorkerManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs b/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs index ba6c9d83ba..2a4e0277cf 100644 --- a/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs +++ b/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs @@ -22,7 +22,7 @@ public class HangfireBackgroundWorkerManager : IBackgroundWorkerManager, ISingle return Task.CompletedTask; } - public void Add(IBackgroundWorker worker) + public Task AddAsync(IBackgroundWorker worker) { if (worker is IHangfireBackgroundWorker hangfireBackgroundWorker) { @@ -57,12 +57,12 @@ public class HangfireBackgroundWorkerManager : IBackgroundWorkerManager, ISingle } else { - return; + return Task.CompletedTask; } if (period == null) { - return; + return Task.CompletedTask; } var adapterType = typeof(HangfirePeriodicBackgroundWorkerAdapter<>).MakeGenericType(ProxyHelper.GetUnProxiedType(worker)); From b3757ad43742f1916ca559fd203d30f4105e6b9b Mon Sep 17 00:00:00 2001 From: maliming Date: Wed, 5 Jan 2022 20:29:31 +0800 Subject: [PATCH 9/9] Update HangfireBackgroundWorkerManager.cs --- .../Hangfire/HangfireBackgroundWorkerManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs b/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs index 2a4e0277cf..8449dc3df0 100644 --- a/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs +++ b/framework/src/Volo.Abp.BackgroundWorkers.Hangfire/Volo/Abp/BackgroundWorkers/Hangfire/HangfireBackgroundWorkerManager.cs @@ -70,6 +70,8 @@ public class HangfireBackgroundWorkerManager : IBackgroundWorkerManager, ISingle RecurringJob.AddOrUpdate(() => workerAdapter.DoWorkAsync(), GetCron(period.Value)); } + + return Task.CompletedTask; } protected virtual string GetCron(int period)