Compare commits

...

2 Commits

Author SHA1 Message Date
c96bbc3495 Update nuget packages 2022-12-22 09:17:56 +01:00
302862fee4 Fix example 2022-12-22 08:32:15 +01:00
6 changed files with 78 additions and 12 deletions

View File

@@ -44,7 +44,7 @@
<PackageReference Include="GerstITS.IoC" Version="2022.11.5" />
<PackageReference Include="GerstITS.IoC.DotNetCore" Version="2022.11.5" />
<PackageReference Include="GerstITS.Job" Version="2022.11.5" />
<PackageReference Include="GerstITS.Job.Scheduling" Version="2022.12.4" />
<PackageReference Include="GerstITS.Job.Scheduling" Version="2022.12.5" />
<PackageReference Include="GerstITS.Logging.Serilog" Version="2022.12.1" />
<PackageReference Include="GerstITS.Mapping.AutoMapper" Version="2022.11.5" />
<PackageReference Include="GerstITS.Search" Version="2022.11.5" />

View File

@@ -17,7 +17,7 @@
}
},
"EntityFrameworkmigration": {
"AutoMigrate": true
"AutoMigrate": true
},
"Server": {
"UseCors": true,
@@ -64,9 +64,14 @@
}
}
},
"SayHelloWorldJob": {
"CronExpression": "*/30 * * * * ? *",
"Name": "Example Job"
"Jobs": {
"SayHelloWorldJob": {
"CronExpression": "*/30 * * * * ? *",
"Name": "Example Job With Specific Name"
},
"SayHelloWorldWithDefaultNameUsageJob": {
"CronExpression": "*/30 * * * * ? *"
}
},
"Serilog": {
"Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.RollingFile" ],

View File

@@ -0,0 +1,26 @@
using GerstITS.Job.Scheduling;
using GerstITS.System.Configurations;
using Microsoft.Extensions.Configuration;
namespace GerstITS.Examples.Jobs.SayHelloWorld.Configurations;
public class SayHelloWorldWithDefaultNameUsageJobConfiguration : JobSchedulingConfigurationBase
{
#region Properties
public string Name { get; }
#endregion
#region Constructors
public SayHelloWorldWithDefaultNameUsageJobConfiguration(Microsoft.Extensions.Configuration.IConfiguration configuration)
: base(configuration)
{
var prefix = this.ToConfigurationPrefix();
Name = configuration.GetValue<string>($"{prefix}:{nameof(Name)}");
}
#endregion
}

View File

@@ -36,7 +36,7 @@
<PackageReference Include="GerstITS.IoC" Version="2022.11.5" />
<PackageReference Include="GerstITS.IoC.DotNetCore" Version="2022.11.5" />
<PackageReference Include="GerstITS.Job" Version="2022.11.5" />
<PackageReference Include="GerstITS.Job.Scheduling" Version="2022.12.4" />
<PackageReference Include="GerstITS.Job.Scheduling" Version="2022.12.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.1" />
</ItemGroup>

View File

@@ -15,19 +15,14 @@ namespace GerstITS.Examples.Jobs.SayHelloWorld.Jobs
private readonly SayHelloWorldJobConfiguration _configuration;
private readonly Stopwatch _stopWatch;
private readonly IRepository _repository;
private readonly ISystemClock _systemClock;
#endregion
#region Cosntructors
public SayHelloWorldJob(SayHelloWorldJobConfiguration configuration,
IRepository repository,
ISystemClock systemClock)
{
_systemClock = systemClock;
_repository = repository;
_configuration = configuration;
_stopWatch = new Stopwatch();
}
@@ -40,7 +35,6 @@ namespace GerstITS.Examples.Jobs.SayHelloWorld.Jobs
{
_stopWatch.Restart();
Thread.Sleep(4000);
var now = _systemClock.UtcNow;
_stopWatch.Stop();
Debug.WriteLine($"---> Say hello to world from {_configuration.Name}, Duration: {_stopWatch.ElapsedMilliseconds / 1000}s");

View File

@@ -0,0 +1,41 @@
using System.Diagnostics;
using System.Threading;
using GerstITS.Examples.Jobs.SayHelloWorld.Configurations;
using GerstITS.Job;
using Quartz;
namespace GerstITS.Examples.Jobs.SayHelloWorld.Jobs;
[DisallowConcurrentExecution]
public class SayHelloWorldWithDefaultNameUsageJob : JobBase
{
#region Fields
private readonly SayHelloWorldWithDefaultNameUsageJobConfiguration _configuration;
private readonly Stopwatch _stopWatch;
#endregion
#region Cosntructors
public SayHelloWorldWithDefaultNameUsageJob(SayHelloWorldWithDefaultNameUsageJobConfiguration configuration)
{
_configuration = configuration;
_stopWatch = new Stopwatch();
}
#endregion
#region Methods
protected override void Execute()
{
_stopWatch.Restart();
Thread.Sleep(4000);
_stopWatch.Stop();
Debug.WriteLine($"---> Say hello to world from {_configuration.Name}, Duration: {_stopWatch.ElapsedMilliseconds / 1000}s");
}
#endregion
}