Пример #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());
     }
 }
Пример #5
0
 public static TaskExecutionResult Failure(AdHocTask task, Exception exception)
 {
     return(new TaskExecutionResult {
         Success = false, Task = task, Exception = exception
     });
 }
Пример #6
0
 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();
 }