Skip to content

Commit 7c74566

Browse files
committed
SchedulerDialog create method tested and fixed
1 parent b0e0459 commit 7c74566

File tree

30 files changed

+466
-320
lines changed

30 files changed

+466
-320
lines changed
Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
{
2-
"$schema": "https://json.schemastore.org/launchsettings.json",
3-
"profiles": {
4-
"https": {
5-
"commandName": "Project",
6-
"dotnetRunMessages": true,
7-
"launchBrowser": true,
8-
"applicationUrl": "https://localhost:15179;http://localhost:15178",
9-
"environmentVariables": {
10-
"ASPNETCORE_ENVIRONMENT": "Development",
11-
"DOTNET_ENVIRONMENT": "Development",
12-
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16224",
13-
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22123"
14-
}
15-
},
16-
"http": {
17-
"commandName": "Project",
18-
"dotnetRunMessages": true,
19-
"launchBrowser": true,
20-
"applicationUrl": "http://localhost:15178",
21-
"environmentVariables": {
22-
"ASPNETCORE_ENVIRONMENT": "Development",
23-
"DOTNET_ENVIRONMENT": "Development",
24-
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16223",
25-
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:21123"
26-
}
27-
}
28-
}
29-
}
1+
{
2+
"profiles": {
3+
"https": {
4+
"commandName": "Project",
5+
"launchBrowser": true,
6+
"environmentVariables": {
7+
"ASPNETCORE_ENVIRONMENT": "Development",
8+
"DOTNET_ENVIRONMENT": "Development",
9+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:16224",
10+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22123"
11+
},
12+
"dotnetRunMessages": true,
13+
"applicationUrl": "https://localhost:15179;http://localhost:15178",
14+
"nativeDebugging": true,
15+
"jsWebView2Debugging": true
16+
},
17+
"http": {
18+
"commandName": "Project",
19+
"launchBrowser": true,
20+
"environmentVariables": {
21+
"ASPNETCORE_ENVIRONMENT": "Development",
22+
"DOTNET_ENVIRONMENT": "Development",
23+
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:16223",
24+
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:21123"
25+
},
26+
"dotnetRunMessages": true,
27+
"applicationUrl": "http://localhost:15178",
28+
"jsWebView2Debugging": true,
29+
"nativeDebugging": true
30+
}
31+
},
32+
"$schema": "https://json.schemastore.org/launchsettings.json"
33+
}

demos/MainDemo/host/Syrna.QuartzAdmin.MainDemo.Blazor.Host.Client/MainDemoBlazorHostClientModule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ private void ConfigureBlazorise(ServiceConfigurationContext context)
7676

7777
private void ConfigureQuartzAdmin(ServiceConfigurationContext context)
7878
{
79+
var configuration = context.Services.GetConfiguration();
80+
context.Services.AddQuartzAdminMain(configuration.GetSection("QuartzAdmin"));
7981
context.Services.AddTransient<ITriggerDetailModelValidator, TriggerDetailModelValidator>();
8082
context.Services.AddSingleton<IJobUIProvider, JobUIProvider>();
8183
}

demos/MainDemo/host/Syrna.QuartzAdmin.MainDemo.Blazor.Host.Client/ServiceCollectionExtensions.cs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
using System.Collections.Generic;
77
using System.Reflection;
88

9-
namespace Syrna.QuartzAdmin.MainDemo;
9+
namespace Syrna.QuartzAdmin.MainDemo.Blazor.Host.Client;
1010

1111
public static class ServiceCollectionExtensions
1212
{
13-
public static IServiceCollection AddQuartzAdmin(
13+
public static IServiceCollection AddQuartzAdminMain(
1414
this IServiceCollection services,
1515
IConfiguration quartzAdminUIConfiguration,
1616
Func<List<Assembly>> jobsasmlist = null)
@@ -19,15 +19,41 @@ public static IServiceCollection AddQuartzAdmin(
1919

2020
var uiOptions = quartzAdminUIConfiguration.Get<QuartzAdminUIOptions>();
2121

22-
services.AddSingleton<IJobFactory, ServiceCollectionJobFactory>();
22+
//services.AddSingleton<IJobFactory, ServiceCollectionJobFactory>();
2323
var bb = new JobRegistrator(services);
2424
var types = JobsListHelper.GetQuartzAdminJobs(jobsasmlist?.Invoke());
2525
types.ForEach(t =>
2626
{
2727
var so = t.GetCustomAttribute<QuartzTriggerAttribute>();
28-
services.AddQuartzJob(t, so.Identity ?? t.Name, so.Desciption ?? t.FullName);
28+
if (so == null)
29+
{
30+
services.AddQuartzJob(t, t.Name, t.FullName);
31+
}
32+
else
33+
{
34+
services.AddQuartzJob(t, so.Identity ?? t.Name, so.Desciption ?? t.FullName);
35+
}
2936
});
37+
services.AddQuartzAdmin(quartzAdminUIConfiguration);
3038

3139
return services;
3240
}
41+
42+
public static IServiceCollection AddQuartzAdmin(this IServiceCollection services, IConfiguration? config = null)
43+
{
44+
QuartzAdminCoreOptions coreOptions = null;
45+
if (config != null)
46+
{
47+
services.Configure<QuartzAdminCoreOptions>(config);
48+
coreOptions = config.Get<QuartzAdminCoreOptions>();
49+
}
50+
else
51+
{
52+
services.AddOptions<QuartzAdminCoreOptions>()
53+
.Configure(opt =>
54+
{
55+
});
56+
}
57+
return services;
58+
}
3359
}

demos/MainDemo/host/Syrna.QuartzAdmin.MainDemo.Blazor.Host.Client/Syrna.QuartzAdmin.MainDemo.Blazor.Host.Client.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
<TargetFramework>net9.0</TargetFramework>
88
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
99
<LangVersion>latest</LangVersion>
10+
<DebuggerSupport>true</DebuggerSupport>
11+
<CopyOutputSymbolsToPublishDirectory>true</CopyOutputSymbolsToPublishDirectory>
1012
</PropertyGroup>
1113

1214
<ItemGroup>
1315
<Compile Remove="Components\CustomUserMenu.razor.cs" />
1416
<Compile Remove="RemoteExternalLocalizationStore.cs" />
15-
<Compile Remove="ServiceCollectionExtensions.cs" />
1617
<Compile Remove="UserExceptionInformer.cs" />
1718
</ItemGroup>
1819

demos/MainDemo/host/Syrna.QuartzAdmin.MainDemo.Blazor.Host.Client/wwwroot/appsettings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,11 @@
2121

2222
}
2323
}
24+
},
25+
"QuartzAdmin": {
26+
"AllowedJobAssemblyFiles": [
27+
"Syrna.QuartzAdmin.MainDemo.Jobs",
28+
"Syrna.QuartzAdmin.Blazor"
29+
]
2430
}
2531
}

demos/MainDemo/host/Syrna.QuartzAdmin.MainDemo.HttpApi.Host/SampleSchedulerListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public override async Task SchedulerStarted(CancellationToken cancellationToken
3333
public async Task UseQuartzAdmin()
3434
{
3535
var type = typeof(IJob);
36-
var types = JobsListHelper.GetQuartzAdminJobs();
36+
var types = AutoJobsListHelper.GetQuartzAdminJobs();
3737
foreach (var t in types)
3838
{
3939
var so = t.GetCustomAttribute<QuartzTriggerAttribute>();

demos/MainDemo/host/Syrna.QuartzAdmin.MainDemo.HttpApi.Host/ServiceCollectionExtensions.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using LiteDB;
2-
using Microsoft.EntityFrameworkCore;
3-
using Microsoft.EntityFrameworkCore.Infrastructure;
41
using Quartz.Spi;
52
using Syrna.QuartzAdmin.Jobs.Abstractions;
3+
using Syrna.QuartzAdmin.Scheduler;
64
using System.Reflection;
75

86
namespace Syrna.QuartzAdmin.MainDemo;
@@ -18,13 +16,23 @@ public static IServiceCollection AddQuartzAdminMain(
1816

1917
var uiOptions = quartzAdminUIConfiguration.Get<QuartzAdminUIOptions>();
2018

19+
services.AddQuartzAdminJobs();
20+
services.AddSingleton<ISchedulerDefinitionService, SchedulerDefinitionService>();
2121
services.AddSingleton<IJobFactory, ServiceCollectionJobFactory>();
22+
2223
var bb = new JobRegistrator(services);
2324
var types = JobsListHelper.GetQuartzAdminJobs(jobsasmlist?.Invoke());
2425
types.ForEach(t =>
2526
{
2627
var so = t.GetCustomAttribute<QuartzTriggerAttribute>();
27-
services.AddQuartzJob(t, so.Identity ?? t.Name, so.Desciption ?? t.FullName);
28+
if (so == null)
29+
{
30+
services.AddQuartzJob(t, t.Name, t.FullName);
31+
}
32+
else
33+
{
34+
services.AddQuartzJob(t, so.Identity ?? t.Name, so.Desciption ?? t.FullName);
35+
}
2836
});
2937
services.AddQuartzAdmin(quartzAdminUIConfiguration);
3038

modules/src/Syrna.QuartzAdmin.Application.Contracts/Syrna/QuartzAdmin/Jobs/JobDetailModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class JobDetailModel
1010

1111
public string Group { get; set; } = Constants.DEFAULT_GROUP;
1212
public string Description { get; set; }
13-
public Type JobClass { get; set; }
13+
public string JobClassName { get; set; }
1414
public IDictionary<string, object> JobDataMap { get; set; } = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
1515
/// <summary>
1616
/// Flag indicate whether Job should stay in scheduler even there are no more triggers assgined to it.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Syrna.QuartzAdmin.Jobs;
2+
using Syrna.QuartzAdmin.Triggers;
3+
4+
namespace Syrna.QuartzAdmin.Scheduler
5+
{
6+
public class CreateScheduleArgs
7+
{
8+
public JobDetailModel JobDetailModel { get; set; }
9+
public TriggerDetailModel TriggerDetailModel { get; set; }
10+
}
11+
}

modules/src/Syrna.QuartzAdmin.Application.Contracts/Syrna/QuartzAdmin/Scheduler/ISchedulerAppService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface ISchedulerAppService : IApplicationService
2525

2626
Task<ScheduleModel> GetScheduleModelAsync(ITrigger trigger);
2727
Task<List<ScheduleModel>> GetAllJobsAsync(ScheduleJobFilter filter);
28-
Task CreateSchedule(JobDetailModel jobDetailModel, TriggerDetailModel triggerDetailModel);
28+
Task CreateSchedule(CreateScheduleArgs createScheduleArgs);
2929
Task<IReadOnlyCollection<string>> GetJobGroups();
3030
Task<IReadOnlyCollection<string>> GetTriggerGroups();
3131
Task<JobDetailModel> GetJobDetail(string jobName, string groupName);

0 commit comments

Comments
 (0)