diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/AbpQuartzMySqlInstallerModule.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/AbpQuartzMySqlInstallerModule.cs index ad7e167e9..4e2568aea 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/AbpQuartzMySqlInstallerModule.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/AbpQuartzMySqlInstallerModule.cs @@ -1,8 +1,4 @@ using LINGYUN.Abp.Quartz.SqlInstaller; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using System.Threading.Tasks; -using Volo.Abp; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; @@ -20,16 +16,4 @@ public class AbpQuartzMySqlInstallerModule : AbpModule options.FileSets.AddEmbedded(); }); } - - public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context) - { - var configuration = context.ServiceProvider.GetRequiredService(); - if (configuration.GetValue("Quartz:UsePersistentStore", false)) - { - // 初始化 Quartz Mysql 数据库 - await context.ServiceProvider - .GetRequiredService() - .InstallAsync(); - } - } } \ No newline at end of file diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/QuartzMySqlInstaller.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/MySqlQuartzSqlInstaller.cs similarity index 96% rename from aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/QuartzMySqlInstaller.cs rename to aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/MySqlQuartzSqlInstaller.cs index 38f870cbd..1a5c29e28 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/QuartzMySqlInstaller.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/MySqlQuartzSqlInstaller.cs @@ -17,16 +17,16 @@ using static Quartz.SchedulerBuilder; namespace LINGYUN.Abp.Quartz.MySqlInstaller; -public class QuartzMySqlInstaller : ITransientDependency +public class MySqlQuartzSqlInstaller : IQuartzSqlInstaller, ITransientDependency { - public ILogger Logger { protected get; set; } + public ILogger Logger { protected get; set; } private readonly IVirtualFileProvider _virtualFileProvider; private readonly AbpQuartzSqlInstallerOptions _installerOptions; private readonly AbpQuartzOptions _quartzOptions; private readonly IConfiguration _configuration; - public QuartzMySqlInstaller( + public MySqlQuartzSqlInstaller( IConfiguration configuration, IVirtualFileProvider virtualFileProvider, IOptions quartzOptions, @@ -37,7 +37,7 @@ public class QuartzMySqlInstaller : ITransientDependency _virtualFileProvider = virtualFileProvider; _installerOptions = installerOptions.Value; - Logger = NullLogger.Instance; + Logger = NullLogger.Instance; } public async virtual Task InstallAsync() diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/AbpQuartzSqlInstallerModule.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/AbpQuartzSqlInstallerModule.cs index 4f5fd6a66..75dc7ca18 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/AbpQuartzSqlInstallerModule.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/AbpQuartzSqlInstallerModule.cs @@ -1,4 +1,8 @@ -using Volo.Abp.Modularity; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Modularity; using Volo.Abp.Quartz; namespace LINGYUN.Abp.Quartz.SqlInstaller; @@ -6,4 +10,15 @@ namespace LINGYUN.Abp.Quartz.SqlInstaller; [DependsOn(typeof(AbpQuartzModule))] public class AbpQuartzSqlInstallerModule : AbpModule { + public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context) + { + var configuration = context.ServiceProvider.GetRequiredService(); + if (configuration.GetValue("Quartz:UsePersistentStore", false)) + { + // 初始化 Quartz 数据库 + await context.ServiceProvider + .GetService() + ?.InstallAsync(); + } + } } diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/IQuartzSqlInstaller.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/IQuartzSqlInstaller.cs new file mode 100644 index 000000000..6ef2947d9 --- /dev/null +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/IQuartzSqlInstaller.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace LINGYUN.Abp.Quartz.SqlInstaller; + +public interface IQuartzSqlInstaller +{ + Task InstallAsync(); +} diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/AbpQuartzSqlServerInstallerModule.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/AbpQuartzSqlServerInstallerModule.cs index 51c23e512..58d2ebc2b 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/AbpQuartzSqlServerInstallerModule.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/AbpQuartzSqlServerInstallerModule.cs @@ -1,8 +1,4 @@ using LINGYUN.Abp.Quartz.SqlInstaller; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using System.Threading.Tasks; -using Volo.Abp; using Volo.Abp.Modularity; using Volo.Abp.VirtualFileSystem; @@ -20,16 +16,4 @@ public class AbpQuartzSqlServerInstallerModule : AbpModule options.FileSets.AddEmbedded(); }); } - - public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context) - { - var configuration = context.ServiceProvider.GetRequiredService(); - if (configuration.GetValue("Quartz:UsePersistentStore", false)) - { - // 初始化 Quartz SqlServer 数据库 - await context.ServiceProvider - .GetRequiredService() - .InstallAsync(); - } - } } \ No newline at end of file diff --git a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/QuartzSqlServerInstaller.cs b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/SqlServerQuartzSqlInstaller.cs similarity index 95% rename from aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/QuartzSqlServerInstaller.cs rename to aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/SqlServerQuartzSqlInstaller.cs index 9265c37a5..cc1d54703 100644 --- a/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/QuartzSqlServerInstaller.cs +++ b/aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/SqlServerQuartzSqlInstaller.cs @@ -16,15 +16,15 @@ using static Quartz.SchedulerBuilder; namespace LINGYUN.Abp.Quartz.SqlServerInstaller; -public class QuartzSqlServerInstaller : ITransientDependency +public class SqlServerQuartzSqlInstaller : IQuartzSqlInstaller, ITransientDependency { - public ILogger Logger { protected get; set; } + public ILogger Logger { protected get; set; } private readonly IVirtualFileProvider _virtualFileProvider; private readonly AbpQuartzSqlInstallerOptions _installerOptions; private readonly AbpQuartzOptions _quartzOptions; - public QuartzSqlServerInstaller( + public SqlServerQuartzSqlInstaller( IVirtualFileProvider virtualFileProvider, IOptions quartzOptions, IOptions installerOptions) @@ -33,7 +33,7 @@ public class QuartzSqlServerInstaller : ITransientDependency _virtualFileProvider = virtualFileProvider; _installerOptions = installerOptions.Value; - Logger = NullLogger.Instance; + Logger = NullLogger.Instance; } public async virtual Task InstallAsync()