merge historyitem and statusitem
This commit is contained in:
@@ -16,7 +16,7 @@ Namespace Scheduler.Jobs
|
||||
Friend ExecutionId As String
|
||||
Friend Name As String
|
||||
|
||||
Friend ResultItems As New List(Of HistoryItem.HistoryStep)
|
||||
Friend JobSteps As New List(Of StatusItem.HistoryStep)
|
||||
|
||||
Private ctx As IJobExecutionContext
|
||||
|
||||
@@ -34,8 +34,10 @@ Namespace Scheduler.Jobs
|
||||
ExecutionId = Guid.NewGuid.ToString()
|
||||
Id = Integer.Parse(oArgs.Item("Id"))
|
||||
Name = oArgs.Item("Name")
|
||||
|
||||
State.JobStatus.Start(ctx)
|
||||
|
||||
Logger.Info("Job [{0}] is starting!", Id)
|
||||
|
||||
Return oJobData.Item(Constants.Scheduler.JOB_CONFIG_ARGUMENTS)
|
||||
End Function
|
||||
|
||||
@@ -43,43 +45,47 @@ Namespace Scheduler.Jobs
|
||||
State.JobStatus.Update(ctx, pCurrentValue, pTotalValue)
|
||||
End Sub
|
||||
|
||||
Public Sub LogStep(pLevel As HistoryItem.StepLevel, pMessage As String, ParamArray pArgs As String())
|
||||
ResultItems.Add(New HistoryItem.HistoryStep With {
|
||||
Public Sub LogDebug(pMessage As String, ParamArray pArgs As String())
|
||||
Logger.Debug(pMessage, pArgs)
|
||||
JobSteps.Add(New StatusItem.HistoryStep With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = pLevel
|
||||
.Level = StatusItem.STEP_DEBUG
|
||||
})
|
||||
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)
|
||||
Public Sub LogInfo(pMessage As String, ParamArray pArgs As String())
|
||||
Logger.Info(pMessage, pArgs)
|
||||
JobSteps.Add(New StatusItem.HistoryStep With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = StatusItem.STEP_INFO
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Sub LogWarning(pMessage As String, ParamArray pArgs As String())
|
||||
Logger.Warn(pMessage, pArgs)
|
||||
JobSteps.Add(New StatusItem.HistoryStep With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = StatusItem.STEP_WARNING
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Sub LogError(pMessage As String, ParamArray pArgs As String())
|
||||
Logger.Error(pMessage, pArgs)
|
||||
JobSteps.Add(New StatusItem.HistoryStep With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = StatusItem.STEP_ERROR
|
||||
})
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function CompleteJob(pMessage As String) As Task(Of Boolean)
|
||||
ctx.Result = State.JobStatus.CompleteWithSuccess(ctx, JobSteps, pMessage)
|
||||
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)
|
||||
|
||||
Public Function CompleteJobWithError(pException As Exception) As Task(Of Boolean)
|
||||
ctx.Result = State.JobStatus.CompleteWithError(ctx, JobSteps, pException)
|
||||
Return Task.FromResult(False)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user