09-12-2022

This commit is contained in:
Jonathan Jenne
2022-12-09 17:29:08 +01:00
parent 0a25b0925c
commit 8d6d81f488
30 changed files with 640 additions and 91 deletions

View File

@@ -1,5 +1,6 @@
Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Windream
Imports ECM.JobRunner.Common
Imports Quartz
@@ -8,11 +9,14 @@ Namespace Scheduler.Jobs
Friend LogConfig As LogConfig
Friend Logger As Logger
Friend Database As MSSQLServer
Friend Windream As Windream
Friend State As State
Friend Id As Integer
Friend Name As String
Friend ResultItems As New List(Of HistoryItem.HistoryStep)
Private ctx As IJobExecutionContext
Public Function InitializeJob(context As IJobExecutionContext) As Dictionary(Of String, String)
@@ -23,6 +27,7 @@ Namespace Scheduler.Jobs
LogConfig = oJobData.Item(Constants.Scheduler.JOB_CONFIG_LOGCONFIG)
Database = oJobData.Item(Constants.Scheduler.JOB_CONFIG_DATABASE)
State = oJobData.Item(Constants.Scheduler.JOB_CONFIG_STATE)
Windream = oJobData.Item(Constants.Scheduler.JOB_CONFIG_WINDREAM)
Logger = LogConfig.GetLogger()
Id = Integer.Parse(oArgs.Item("Id"))
@@ -36,9 +41,45 @@ Namespace Scheduler.Jobs
State.JobStatus.Update(ctx, pCurrentValue, pTotalValue)
End Sub
Public Sub CompleteJob()
State.JobStatus.Complete(ctx)
Public Sub LogStep(pLevel As HistoryItem.StepLevel, pMessage As String, ParamArray pArgs As String())
ResultItems.Add(New HistoryItem.HistoryStep With {
.Message = String.Format(pMessage, pArgs),
.Level = pLevel
})
End Sub
Public Function CompleteJob() As Task(Of Boolean)
ctx.Result = New JobResult With {
.Successful = True,
.Steps = ResultItems,
.Description = "Job completed."
}
State.JobStatus.Complete(ctx)
Return Task.FromResult(True)
End Function
Public Function CompleteJob(pCompletionMessage As String) As Task(Of Boolean)
ctx.Result = New JobResult With {
.Successful = True,
.Steps = ResultItems,
.Description = pCompletionMessage
}
State.JobStatus.Complete(ctx)
Return Task.FromResult(True)
End Function
Public Function CompleteJob(pException As Exception) As Task(Of Boolean)
ctx.Result = New JobResult With {
.Successful = False,
.Steps = ResultItems,
.Description = pException.Message
}
State.JobStatus.Complete(ctx)
Return Task.FromResult(False)
End Function
End Class
End Namespace