EDMIService: Refactor service so that cron job details a read from database on every job run
This commit is contained in:
@@ -59,48 +59,28 @@ Public Class Scheduler
|
||||
Dim oDefinition As String = oRow.Item("CRON_DEFINITION")
|
||||
Dim oTitle As String = oRow.Item("TITLE")
|
||||
Dim oGuid As Integer = oRow.Item("GUID")
|
||||
Dim oCronDetails As DataTable = Await GetCronJobDetails(oGuid)
|
||||
|
||||
If oCronDetails IsNot Nothing Then
|
||||
_Logger.Debug("Loaded job [{0}]", oTitle)
|
||||
_Logger.Debug("Job details: {0}", oCronDetails.Rows.Count)
|
||||
_Logger.Debug("Job definition: {0}", oDefinition)
|
||||
Dim oTrigger As ITrigger
|
||||
Dim oJob As IJobDetail
|
||||
Dim oIdentity As String = $"CRON-JOB-{oGuid}"
|
||||
|
||||
For Each oRowDetail As DataRow In oCronDetails.Rows
|
||||
Dim oTrigger As ITrigger
|
||||
Dim oJob As IJobDetail
|
||||
Dim oDataTableName As String = oRowDetail.Item("DT_NAME")
|
||||
Dim oRunOnStartup As Boolean = oRowDetail.Item("RUN_ON_STARTUP")
|
||||
Dim oJobIdentity As String = $"{oGuid}~{oDataTableName}"
|
||||
oTrigger = TriggerBuilder.Create().
|
||||
WithIdentity(oIdentity, JOB_GROUP).
|
||||
WithCronSchedule(oDefinition).
|
||||
Build()
|
||||
|
||||
Dim oBaseTrigger = TriggerBuilder.Create().
|
||||
WithIdentity(oJobIdentity, JOB_GROUP).
|
||||
WithCronSchedule(oDefinition)
|
||||
oJob = JobBuilder.Create(Of DatatableJob)().
|
||||
WithIdentity(oIdentity, JOB_GROUP).
|
||||
UsingJobData(New JobDataMap From {
|
||||
{"LogConfig", _LogConfig},
|
||||
{"MSSQL", _MSSQL},
|
||||
{"CronJobId", oGuid},
|
||||
{"CronJobTitle", oTitle}
|
||||
}).
|
||||
Build()
|
||||
|
||||
' Run directly at startup if configured
|
||||
If oRunOnStartup Then
|
||||
oBaseTrigger = oBaseTrigger.StartNow()
|
||||
End If
|
||||
|
||||
oTrigger = oBaseTrigger.Build()
|
||||
|
||||
oJob = JobBuilder.Create(Of DatatableJob)().
|
||||
WithIdentity(oJobIdentity, JOB_GROUP).
|
||||
UsingJobData(New JobDataMap() From {
|
||||
{"LogConfig", _LogConfig},
|
||||
{"MSSQL", _MSSQL},
|
||||
{"CronJobId", oGuid},
|
||||
{"CronJobTitle", oTitle},
|
||||
{"CronJobDetails", oRowDetail}
|
||||
}).
|
||||
Build()
|
||||
|
||||
Await _Scheduler.ScheduleJob(oJob, oTrigger)
|
||||
_Logger.Debug("Scheduled a new job for Cron Job Id [{0}]", oGuid)
|
||||
Next
|
||||
Else
|
||||
_Logger.Warn("CronJob Details for CronJob [{0}] could not be fetched!", oGuid)
|
||||
End If
|
||||
Await _Scheduler.ScheduleJob(oJob, oTrigger)
|
||||
_Logger.Debug("Scheduled a new job for Cron Job [{0}]", oTitle)
|
||||
Next
|
||||
Else
|
||||
_Logger.Warn("CronJobs could not be fetched!")
|
||||
|
||||
Reference in New Issue
Block a user