Browse Source
Move job execution disabling to abstractions module
Resolve #23398
pull/23400/head
maliming
1 year ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
12 additions and
12 deletions
-
framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/AbpBackgroundJobsAbstractionsModule.cs
-
framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/AbpBackgroundJobsModule.cs
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Volo.Abp.Json; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
@ -19,6 +20,17 @@ public class AbpBackgroundJobsAbstractionsModule : AbpModule |
|
|
|
RegisterJobs(context.Services); |
|
|
|
} |
|
|
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
if (context.Services.IsDataMigrationEnvironment()) |
|
|
|
{ |
|
|
|
Configure<AbpBackgroundJobOptions>(options => |
|
|
|
{ |
|
|
|
options.IsJobExecutionEnabled = false; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static void RegisterJobs(IServiceCollection services) |
|
|
|
{ |
|
|
|
var jobTypes = new List<Type>(); |
|
|
|
|
|
|
|
@ -2,7 +2,6 @@ |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
|
using Volo.Abp.BackgroundWorkers; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Volo.Abp.DistributedLocking; |
|
|
|
using Volo.Abp.Guids; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
@ -22,17 +21,6 @@ namespace Volo.Abp.BackgroundJobs; |
|
|
|
)] |
|
|
|
public class AbpBackgroundJobsModule : AbpModule |
|
|
|
{ |
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
if (context.Services.IsDataMigrationEnvironment()) |
|
|
|
{ |
|
|
|
Configure<AbpBackgroundJobOptions>(options => |
|
|
|
{ |
|
|
|
options.IsJobExecutionEnabled = false; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context) |
|
|
|
{ |
|
|
|
if (context.ServiceProvider.GetRequiredService<IOptions<AbpBackgroundJobOptions>>().Value.IsJobExecutionEnabled) |
|
|
|
|