public JobResult(Job objJob, JobResultType enuResult, DateTime dtStartTime, DateTime dtEndTime, TaskResultList objTaskResults) { Job = objJob; Result = enuResult; StartTime = dtStartTime; EndTime = dtEndTime; TaskResults = objTaskResults; }
public override void ReadData(BinaryReaderExtension objBinaryReader) { base.ReadData(objBinaryReader); Job = objBinaryReader.ReadTransportableObject <Job>(); StartTime = objBinaryReader.ReadDateTime(); EndTime = objBinaryReader.ReadDateTime(); Result = (JobResultType)objBinaryReader.ReadByte(); TaskResults = objBinaryReader.ReadTransportableObject <TaskResultList>(); }
public override void ReadData(SerializedObject objSerializedObject) { base.ReadData(objSerializedObject); Job = objSerializedObject.Objects.GetObject <Job>("Job", null); StartTime = objSerializedObject.Values.GetValue <DateTime>("StartTime", DateTime.MinValue); EndTime = objSerializedObject.Values.GetValue <DateTime>("EndTime", DateTime.MinValue); Result = objSerializedObject.Values.GetValue <JobResultType>("Result", JobResultType.Unknown); TaskResults = objSerializedObject.Objects.GetObject <TaskResultList>("TaskResults", null); }
private void StartThread() { DateTime dtJobStartTime = DateTime.Now; TaskResultList objTaskResults = new TaskResultList(); Status = JobStatusType.Running; OnJobBegin(); JobResultType enuJobResult = JobResultType.Completed; int intTaskIndex = 0; int intTaskCount = _objTasks.Count; bool blnHasBeenCancelled = false; while (intTaskIndex < intTaskCount) { ITask objTask = _objTasks[intTaskIndex]; blnHasBeenCancelled = HasBeenCancelled(); if (blnHasBeenCancelled == true) { enuJobResult = JobResultType.Cancelled; break; } DateTime dtTaskStartTime = DateTime.Now; JobTicket objJobTicket = new JobTicket(dtTaskStartTime, HasBeenCancelled, TaskProgressChanged); ITaskResult objTaskResult = null; try { OnTaskBegin(objTask, intTaskIndex, intTaskCount); objTaskResult = objTask.Execute(objJobTicket); } catch (Exception objException) { string strErrorMessage = objException.ToString(); TaskStats objTaskStats = new TaskStats(objTask, dtTaskStartTime, DateTime.Now); objTaskResult = new TaskResult(objTask, objTaskStats, TaskResultType.Failed, strErrorMessage); } if (objTaskResult == null) { string strErrorMessage = "A null value was returned by the task."; TaskStats objTaskStats = new TaskStats(objTask, dtTaskStartTime, DateTime.Now); objTaskResult = new TaskResult(objTask, objTaskStats, TaskResultType.Failed, strErrorMessage); } blnHasBeenCancelled = HasBeenCancelled(); if (blnHasBeenCancelled == true) { objTaskResults.Add(objTaskResult); break; } else { TaskActionType enuTaskActionType = OnTaskEnd(objTaskResult, intTaskIndex); if (enuTaskActionType == TaskActionType.Retry) { continue; } else if (enuTaskActionType == TaskActionType.Continue) { objTaskResults.Add(objTaskResult); intTaskIndex++; if (objTaskResult.Result == TaskResultType.RebootRequired) { enuJobResult = JobResultType.RebootRequired; break; } continue; } else if (enuTaskActionType == TaskActionType.Cancel) { objTaskResults.Add(objTaskResult); enuJobResult = JobResultType.Cancelled; break; } } } if (blnHasBeenCancelled == true) { for (int intRemainingTaskIndex = intTaskIndex + 1; intRemainingTaskIndex < intTaskCount; intRemainingTaskIndex++) { ITask objRemainingTask = _objTasks[intRemainingTaskIndex]; TaskStats objTaskStats = new TaskStats(objRemainingTask, dtJobStartTime, DateTime.Now); ITaskResult objRemainingTaskResult = new TaskResult(objRemainingTask, objTaskStats, TaskResultType.Cancelled); objTaskResults.Add(objRemainingTaskResult); } } Thread.Sleep(200); JobResult objJobResult = new JobResult(this, enuJobResult, dtJobStartTime, DateTime.Now, new TaskResultList(objTaskResults)); OnJobEnd(objJobResult); Thread.Sleep(200); Status = JobStatusType.Completed; }