09-01-2023

This commit is contained in:
Jonathan Jenne
2023-01-17 08:43:08 +01:00
parent 7e7eee7299
commit 0b98902a7f
8 changed files with 58 additions and 35 deletions

View File

@@ -94,7 +94,6 @@ Namespace Scheduler
End Function
Private Async Sub ScheduleJobs()
Logger.Info("Loading [{0}] Job Definitions..", State.JobDefinitions.Count)
For Each oJob In State.JobDefinitions
@@ -109,11 +108,11 @@ Namespace Scheduler
Select Case pJob.TypeId
Case JOB_TYPE_IMPORT
Dim oJobConfig = BuildJobConfig(Of Jobs.FileImportJob)(pJob)
Await ScheduleJob(Of Jobs.FileImportJob)(oJobConfig)
Await ScheduleJob(Of Jobs.FileImportJob)(oJobConfig, pStartManually)
Case JOB_TYPE_INDEX
Dim oJobConfig = BuildJobConfig(Of Jobs.FileIndexJob)(pJob)
Await ScheduleJob(Of Jobs.FileIndexJob)(oJobConfig)
Await ScheduleJob(Of Jobs.FileIndexJob)(oJobConfig, pStartManually)
Case Else
Logger.Warn("Job for TypeId [{0}] is not implemented!", pJob.TypeId)
@@ -182,25 +181,20 @@ Namespace Scheduler
Private Async Function DoScheduleJobWithoutDelay(Of T As IJob)(pJobConfig As JobConfig) As Task
Dim oJobName As String = GetJobName(pJobConfig)
Dim oJobData As JobDataMap = BuildJobData(pJobConfig)
Dim oJob As IJobDetail = BuildJob(Of T)(pJobConfig, oJobData)
Dim oTriggerName As String = GetTriggerName(pJobConfig)
Dim oNoDelayTrigger = TriggerBuilder.Create().
WithIdentity(oTriggerName & "-NO-DELAY").
StartAt(DateBuilder.FutureDate(10, IntervalUnit.Second)).
Build()
Logger.Info("Job {0} will start in 10 Seconds.", oJobName)
Await Scheduler.ScheduleJob(oJob, oNoDelayTrigger)
Logger.Info("Job [{0}] will start now.", oJobName)
Await Scheduler.TriggerJob(New JobKey(oJobName))
End Function
Private Function BuildJob(Of T As IJob)(pJobConfig As JobConfig, pJobData As JobDataMap) As IJobDetail
Dim oJobName = GetJobName(pJobConfig)
Return JobBuilder.Create(Of T)().
Dim oJob = JobBuilder.Create(Of T)().
WithIdentity(pJobConfig.Name).
UsingJobData(pJobData).
StoreDurably().
Build()
Return oJob
End Function
Private Function BuildTrigger(pJobConfig As JobConfig) As ITrigger