Skip to content

Commit a32c01e

Browse files
committed
allow all job types
1 parent 7ebdd3d commit a32c01e

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/BlazorAdmin/BlazorAdmin.Core/Data/DatabaseExtension.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Quartz;
2020
using CrystalQuartz.Application;
2121
using BlazorAdmin.Core.Services;
22+
using System.Reflection;
2223

2324
namespace BlazorAdmin.Core.Data
2425
{
@@ -66,10 +67,15 @@ public static void InitialDatabase(this WebApplication app)
6667
app.UseCrystalQuartz(() => app.Services.GetRequiredService<ISchedulerFactory>().GetScheduler(),
6768
new CrystalQuartzOptions
6869
{
69-
AllowedJobTypes = new[]
70-
{
71-
typeof(TestJob)
72-
}
70+
AllowedJobTypes = Assembly.GetEntryAssembly()?
71+
.GetReferencedAssemblies()
72+
.SelectMany(a => Assembly.Load(a).GetExportedTypes())
73+
.Where(x =>
74+
x.IsPublic &&
75+
x.IsClass &&
76+
!x.IsAbstract &&
77+
typeof(IJob).IsAssignableFrom(x))
78+
.ToArray() ?? new Type[0],
7379
});
7480
}
7581
}

0 commit comments

Comments
 (0)