示例#1
0
 private void FailedExecution(IEnumerable <TaskExecutionResult> taskFailureInfos)
 {
     _session.Transact(session => taskFailureInfos.ForEach(
                           taskFailureInfo =>
     {
         AdHocTask executableTask = taskFailureInfo.Task;
         executableTask.Entity.OnFailure(executableTask, taskFailureInfo.Exception);
         session.Update(executableTask.Entity);
     }));
 }
示例#2
0
 private TaskExecutionResult Execute(AdHocTask executableTask)
 {
     try
     {
         return(executableTask.Execute());
     }
     catch (Exception exception)
     {
         CurrentRequestData.ErrorSignal.Raise(exception);
         return(TaskExecutionResult.Failure(executableTask, exception));
     }
 }
示例#3
0
 public virtual void OnFailure(AdHocTask executableTask, Exception exception)
 {
     executableTask.OnFailure(exception);
     if (Tries < 5)
     {
         Status = TaskExecutionStatus.Pending;
     }
     else
     {
         Status   = TaskExecutionStatus.Failed;
         FailedAt = CurrentRequestData.Now;
         executableTask.OnFinalFailure(exception);
     }
     Tries++;
 }
示例#4
0
     public BatchExecutionResult Execute(AdHocTask task)
     {
         if (task != null)
         {
             IList <AdHocTask> tasksToExecute = new List <AdHocTask> {
                 task
             };
             foreach (var handler in _executionHandlers.OrderByDescending(handler => handler.Priority))
             {
                 var tasks = handler.ExtractTasksToHandle(ref tasksToExecute);
                 if (tasks.Any())
                 {
                     return new BatchExecutionResult {
                                Results = handler.ExecuteTasks(tasks)
                     }
                 }
                 ;
             }
         }
         return(new BatchExecutionResult());
     }
 }
 public static TaskExecutionResult Failure(AdHocTask task, Exception exception)
 {
     return(new TaskExecutionResult {
         Success = false, Task = task, Exception = exception
     });
 }
 public static TaskExecutionResult Successful(AdHocTask task)
 {
     return(new TaskExecutionResult {
         Success = true, Task = task
     });
 }
示例#7
0
 public virtual void OnSuccess(AdHocTask executableTask)
 {
     Status      = TaskExecutionStatus.Completed;
     CompletedAt = CurrentRequestData.Now;
     executableTask.OnSuccess();
 }
示例#8
0
 public virtual void OnStarting(AdHocTask executableTask)
 {
     Status    = TaskExecutionStatus.Executing;
     StartedAt = CurrentRequestData.Now;
     executableTask.OnStarting();
 }