merge historyitem and statusitem
This commit is contained in:
@@ -19,6 +19,7 @@ Public Class JobStatus
|
||||
If oStatus IsNot Nothing Then
|
||||
oStatus.Name = pJob.JobDetail.Key.Name
|
||||
oStatus.StartTime = Date.Now
|
||||
oStatus.UpdateTime = Date.Now
|
||||
oStatus.Executing = True
|
||||
End If
|
||||
End Sub
|
||||
@@ -32,28 +33,56 @@ Public Class JobStatus
|
||||
oStatus.ProgressTotal = pTotal
|
||||
oStatus.ProgressCurrent = pCurrent
|
||||
oStatus.ExecutionTime = pJob.JobRunTime
|
||||
oStatus.UpdateTime = Date.Now
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub Complete(pJob As Quartz.IJobExecutionContext)
|
||||
Public Function CompleteWithError(pJob As Quartz.IJobExecutionContext, pSteps As List(Of StatusItem.HistoryStep), pException As Exception) As StatusItem
|
||||
Return CompleteWithError(pJob, pSteps, pException.Message)
|
||||
End Function
|
||||
|
||||
Public Function CompleteWithError(pJob As Quartz.IJobExecutionContext, pSteps As List(Of StatusItem.HistoryStep), pMessage As String) As StatusItem
|
||||
Dim oStatus = GetJobStatus(pJob)
|
||||
|
||||
Logger.Info("Completing Job [{0}]", oStatus.Id)
|
||||
Logger.Info("Completing Job [{0}] with Error", oStatus.Id)
|
||||
|
||||
If oStatus IsNot Nothing Then
|
||||
oStatus.ProgressCurrent = oStatus.ProgressTotal
|
||||
oStatus.ExecutionTime = pJob.JobRunTime
|
||||
oStatus.Executing = False
|
||||
oStatus.CompleteTime = Date.Now
|
||||
oStatus.FailureMessage = pMessage
|
||||
oStatus.Successful = False
|
||||
oStatus.Steps = pSteps
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Return oStatus
|
||||
End Function
|
||||
|
||||
Public Function CompleteWithSuccess(pJob As Quartz.IJobExecutionContext, pSteps As List(Of StatusItem.HistoryStep), pMessage As String) As StatusItem
|
||||
Dim oStatus = GetJobStatus(pJob)
|
||||
|
||||
Logger.Info("Completing Job [{0}] with Success", oStatus.Id)
|
||||
|
||||
If oStatus IsNot Nothing Then
|
||||
oStatus.ProgressCurrent = oStatus.ProgressTotal
|
||||
oStatus.ExecutionTime = pJob.JobRunTime
|
||||
oStatus.Executing = False
|
||||
oStatus.CompleteTime = Date.Now
|
||||
oStatus.SuccessMessage = pMessage
|
||||
oStatus.Successful = False
|
||||
oStatus.Steps = pSteps
|
||||
End If
|
||||
|
||||
Return oStatus
|
||||
End Function
|
||||
|
||||
Private Function GetJobStatus(pJob As Quartz.IJobExecutionContext) As StatusItem
|
||||
Dim oJobId = GetJobId(pJob)
|
||||
Dim oExists = Entries.Where(Function(e) e.Id = oJobId).Any()
|
||||
Dim oExists = Entries.Where(Function(e) e.JobId = oJobId).Any()
|
||||
|
||||
If Not oExists Then
|
||||
Entries.Add(New StatusItem With {.Id = oJobId})
|
||||
Entries.Add(New StatusItem(oJobId))
|
||||
End If
|
||||
|
||||
Return Entries.Where(Function(e) e.Id = oJobId).SingleOrDefault()
|
||||
|
||||
Reference in New Issue
Block a user