Browse Source

feat(quartz): Optimized database install

pull/1163/head
colin 12 months ago
parent
commit
ddb71b98c0
  1. 16
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/AbpQuartzMySqlInstallerModule.cs
  2. 8
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/MySqlQuartzSqlInstaller.cs
  3. 17
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/AbpQuartzSqlInstallerModule.cs
  4. 8
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/IQuartzSqlInstaller.cs
  5. 16
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/AbpQuartzSqlServerInstallerModule.cs
  6. 8
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/SqlServerQuartzSqlInstaller.cs

16
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<AbpQuartzMySqlInstallerModule>();
});
}
public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context)
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
if (configuration.GetValue("Quartz:UsePersistentStore", false))
{
// 初始化 Quartz Mysql 数据库
await context.ServiceProvider
.GetRequiredService<QuartzMySqlInstaller>()
.InstallAsync();
}
}
}

8
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/QuartzMySqlInstaller.cs → 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<QuartzMySqlInstaller> Logger { protected get; set; }
public ILogger<MySqlQuartzSqlInstaller> 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<AbpQuartzOptions> quartzOptions,
@ -37,7 +37,7 @@ public class QuartzMySqlInstaller : ITransientDependency
_virtualFileProvider = virtualFileProvider;
_installerOptions = installerOptions.Value;
Logger = NullLogger<QuartzMySqlInstaller>.Instance;
Logger = NullLogger<MySqlQuartzSqlInstaller>.Instance;
}
public async virtual Task InstallAsync()

17
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<IConfiguration>();
if (configuration.GetValue("Quartz:UsePersistentStore", false))
{
// 初始化 Quartz 数据库
await context.ServiceProvider
.GetService<IQuartzSqlInstaller>()
?.InstallAsync();
}
}
}

8
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();
}

16
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<AbpQuartzSqlServerInstallerModule>();
});
}
public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context)
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
if (configuration.GetValue("Quartz:UsePersistentStore", false))
{
// 初始化 Quartz SqlServer 数据库
await context.ServiceProvider
.GetRequiredService<QuartzSqlServerInstaller>()
.InstallAsync();
}
}
}

8
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/QuartzSqlServerInstaller.cs → 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<QuartzSqlServerInstaller> Logger { protected get; set; }
public ILogger<SqlServerQuartzSqlInstaller> Logger { protected get; set; }
private readonly IVirtualFileProvider _virtualFileProvider;
private readonly AbpQuartzSqlInstallerOptions _installerOptions;
private readonly AbpQuartzOptions _quartzOptions;
public QuartzSqlServerInstaller(
public SqlServerQuartzSqlInstaller(
IVirtualFileProvider virtualFileProvider,
IOptions<AbpQuartzOptions> quartzOptions,
IOptions<AbpQuartzSqlInstallerOptions> installerOptions)
@ -33,7 +33,7 @@ public class QuartzSqlServerInstaller : ITransientDependency
_virtualFileProvider = virtualFileProvider;
_installerOptions = installerOptions.Value;
Logger = NullLogger<QuartzSqlServerInstaller>.Instance;
Logger = NullLogger<SqlServerQuartzSqlInstaller>.Instance;
}
public async virtual Task InstallAsync()
Loading…
Cancel
Save