Skip to content

Commit c454c60

Browse files
committed
AutoJob2 added. test for auto long jobs. Charts does not display issue fixed
1 parent 551877c commit c454c60

File tree

30 files changed

+191
-81
lines changed

30 files changed

+191
-81
lines changed

Syrna.QuartzAdmin.slnLaunch

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
"Name": "New Profile",
4+
"Projects": [
5+
{
6+
"Path": "demos\\MainDemo\\host\\Syrna.QuartzAdmin.MainDemo.HttpApi.Host\\Syrna.QuartzAdmin.MainDemo.HttpApi.Host.csproj",
7+
"Action": "Start"
8+
},
9+
{
10+
"Path": "demos\\MainDemo\\host\\Syrna.QuartzAdmin.MainDemo.AuthServer\\Syrna.QuartzAdmin.MainDemo.AuthServer.csproj",
11+
"Action": "Start"
12+
},
13+
{
14+
"Path": "demos\\MainDemo\\host\\Syrna.QuartzAdmin.MainDemo.Blazor.Host\\Syrna.QuartzAdmin.MainDemo.Blazor.Host.csproj",
15+
"Action": "Start"
16+
}
17+
]
18+
}
19+
]

demos/MainDemo/host/Syrna.QuartzAdmin.MainDemo.Blazor.Host.Client/Properties/launchSettings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
}
1010
},
1111
"profiles": {
12+
"https": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
17+
"applicationUrl": "https://localhost:44307;http://localhost:44306",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
1222
"IIS Express": {
1323
"commandName": "IISExpress",
1424
"launchBrowser": true,
Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
11
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"nativeDebugging": true,
6+
"iisExpress": {
7+
"applicationUrl": "https://localhost:44305",
8+
"sslPort": 44305
9+
}
10+
},
211
"profiles": {
12+
"https": {
13+
"commandName": "Project",
14+
"dotnetRunMessages": true,
15+
"launchBrowser": true,
16+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
17+
"applicationUrl": "https://localhost:44305;http://localhost:44304",
18+
"environmentVariables": {
19+
"ASPNETCORE_ENVIRONMENT": "Development"
20+
}
21+
},
322
"IIS Express": {
423
"commandName": "IISExpress",
524
"launchBrowser": true,
25+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
26+
"nativeDebugging": true,
627
"environmentVariables": {
728
"ASPNETCORE_ENVIRONMENT": "Development"
829
},
9-
"applicationUrl": "https://localhost:44305;http://localhost:44304",
30+
"applicationUrl": "https://localhost:44305",
1031
"sslPort": 44305
1132
},
1233
"Syrna.QuartzAdmin.MainDemo.Blazor.Host": {
1334
"commandName": "Project",
1435
"launchBrowser": true,
36+
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
37+
"applicationUrl": "https://localhost:44305",
38+
"nativeDebugging": true,
1539
"environmentVariables": {
1640
"ASPNETCORE_ENVIRONMENT": "Development"
17-
},
18-
"applicationUrl": "https://localhost:44305;https://localhost:44304"
19-
}
20-
},
21-
"iisSettings": {
22-
"windowsAuthentication": false,
23-
"anonymousAuthentication": true,
24-
"iisExpress": {
25-
"applicationUrl": "https://localhost:44305/",
26-
"sslPort": 44305
41+
}
2742
}
2843
}
29-
}
44+
}

demos/MainDemo/host/Syrna.QuartzAdmin.MainDemo.HttpApi.Host/appsettings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@
2828
"AllowedHosts": "*",
2929
"Quartz": {
3030
"Enabled": true
31+
},
32+
"QuartzAdmin": {
33+
"AllowedJobAssemblyFiles": [
34+
"Syrna.QuartzAdmin.MainDemo.Jobs"
35+
]
3136
}
3237
}

demos/MainDemo/src/Syrna.QuartzAdmin.MainDemo.Jobs/AutoJob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace Syrna.QuartzAdmin.MainDemo.Jobs
55
{
6-
[QuartzTrigger(5, "this e sq test", "_hellojobauto")]
6+
[QuartzTrigger(5, "this is an job test", "_jobauto")]
77
public class AutoJob : IJob
88
{
99
public async Task CanFireIt()

demos/MainDemo/src/Syrna.QuartzAdmin.MainDemo.Jobs/AutoJob1.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ public Task Execute(IJobExecutionContext context)
1616
context.SetExecutionDetails("Executed successfully");
1717

1818
context.Result = $"Hello from Auto Job1 {DateTime.Now}";
19-
//context.JobDetail.JobDataMap[JobDataMapKeys.IsSuccess] = true;
20-
//context.JobDetail.JobDataMap[JobDataMapKeys.ReturnCode] = 0;
21-
//context.JobDetail.JobDataMap[JobDataMapKeys.ExecutionDetails] = "Executed successfully";
2219
return Task.CompletedTask;
2320
}
2421
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using Microsoft.Extensions.Logging;
2+
using Quartz;
3+
using Syrna.QuartzAdmin.Jobs.Abstractions;
4+
using System.Threading;
5+
6+
namespace Syrna.QuartzAdmin.MainDemo.Jobs
7+
{
8+
[QuartzTrigger(120, "this is an long job test", "_longjobauto")]
9+
public class AutoJob2 : IJob
10+
{
11+
private readonly ILogger<HelloJob> _logger;
12+
13+
public AutoJob2(ILogger<HelloJob> logger)
14+
{
15+
_logger = logger;
16+
}
17+
18+
public async Task Execute(IJobExecutionContext context)
19+
{
20+
Console.WriteLine($"Hello from AutoJob {DateTime.Now}");
21+
context.CancellationToken.ThrowIfCancellationRequested();
22+
23+
context.SetExecutionDetails("Executing first delay 30s");
24+
_logger.LogInformation("Delaying {delay} sec", 30);
25+
await Task.Delay(30000);
26+
27+
context.SetExecutionDetails("Executing second delay 40s");
28+
_logger.LogInformation("Delaying {delay} sec", 40);
29+
await Task.Delay(40000);
30+
31+
context.SetExecutionDetails("Executing third delay 50s");
32+
_logger.LogInformation("Delaying {delay} sec", 50);
33+
await Task.Delay(50000);
34+
35+
context.SetExecutionDetails("Executing third delay 60s");
36+
_logger.LogInformation("Delaying {delay} sec", 60);
37+
await Task.Delay(60000);
38+
39+
context.SetIsSuccess(true);
40+
context.SetReturnCode(0);
41+
context.SetExecutionDetails("Executed successfully");
42+
context.Result = $"Hello from AutoJob {DateTime.Now}";
43+
44+
await Task.CompletedTask;
45+
}
46+
}
47+
}

demos/MainDemo/src/Syrna.QuartzAdmin.MainDemo.Jobs/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
namespace Syrna.BlazoriseQuartz.Jobs
2+
namespace Syrna.QuartzAdmin.Jobs
33
{
44
public abstract class Constants
55
{

demos/MainDemo/src/Syrna.QuartzAdmin.MainDemo.Jobs/HttpAction.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using System;
2-
namespace Syrna.BlazoriseQuartz.Jobs
2+
namespace Syrna.QuartzAdmin.Jobs
33
{
44
public enum HttpAction
55
{

demos/MainDemo/src/Syrna.QuartzAdmin.MainDemo.Jobs/HttpJob.cs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.Extensions.Logging;
22
using Quartz;
3-
using Syrna.BlazoriseQuartz.Jobs;
3+
using Syrna.QuartzAdmin.Jobs;
44
using Syrna.QuartzAdmin.Jobs.Abstractions;
55
using System.Text;
66
using System.Text.Json;
@@ -12,24 +12,14 @@ public class HttpJob(IHttpClientFactory httpClientFactory,
1212
ILogger<HttpJob> logger,
1313
IDataMapValueResolver dmvResolver) : IJob
1414
{
15-
public const string PropertyRequestAction = "requestAction";
16-
public const string PropertyRequestUrl = "requestUrl";
17-
public const string PropertyRequestParameters = "requestParams";
18-
public const string PropertyRequestHeaders = "requestHeaders";
19-
public const string PropertyIgnoreVerifySsl = "ignoreSsl";
20-
/// <summary>
21-
/// HTTP request timeout. Negative value to indicate infinite timeout.
22-
/// </summary>
23-
public const string PropertyRequestTimeoutInSec = "requestTimeout";
24-
2515
public async Task Execute(IJobExecutionContext context)
2616
{
2717
try
2818
{
2919
var data = context.MergedJobDataMap;
3020

31-
int? timeoutInSec = data.TryGetInt(PropertyRequestTimeoutInSec, out var x) ? x : null;
32-
var dmvUrl = data.GetDataMapValue(PropertyRequestUrl);
21+
int? timeoutInSec = data.TryGetInt(HttpJobKeys.PropertyRequestTimeoutInSec, out var x) ? x : null;
22+
var dmvUrl = data.GetDataMapValue(HttpJobKeys.PropertyRequestUrl);
3323
var url = dmvResolver.Resolve(dmvUrl);
3424
if (string.IsNullOrEmpty(url))
3525
{
@@ -39,12 +29,12 @@ public async Task Execute(IJobExecutionContext context)
3929
}
4030
url = url.StartsWith("http") ? url : "http://" + url;
4131

42-
var parameters = dmvResolver.Resolve(data.GetDataMapValue(PropertyRequestParameters));
43-
var strHeaders = dmvResolver.Resolve(data.GetDataMapValue(PropertyRequestHeaders));
32+
var parameters = dmvResolver.Resolve(data.GetDataMapValue(HttpJobKeys.PropertyRequestParameters));
33+
var strHeaders = dmvResolver.Resolve(data.GetDataMapValue(HttpJobKeys.PropertyRequestHeaders));
4434
var headers = string.IsNullOrEmpty(strHeaders) ? null :
4535
JsonSerializer.Deserialize<Dictionary<string, string>>(strHeaders.Trim());
4636

47-
var strAction = data.GetString(PropertyRequestAction);
37+
var strAction = data.GetString(HttpJobKeys.PropertyRequestAction);
4838
HttpAction action;
4939
if (strAction == null)
5040
{
@@ -56,7 +46,7 @@ public async Task Execute(IJobExecutionContext context)
5646

5747
logger.LogDebug("[{runInstanceId}]. Creating HttpClient...", context.FireInstanceId);
5848
HttpClient httpClient;
59-
if (data.TryGetBoolean(PropertyIgnoreVerifySsl, out var IgnoreVerifySsl) && IgnoreVerifySsl)
49+
if (data.TryGetBoolean(HttpJobKeys.PropertyIgnoreVerifySsl, out var IgnoreVerifySsl) && IgnoreVerifySsl)
6050
{
6151
httpClient = httpClientFactory.CreateClient(Constants.HttpClientIgnoreVerifySsl);
6252
logger.LogInformation("[{runInstanceId}]. Created ignore SSL validation HttpClient.",

0 commit comments

Comments
 (0)