Exemplo n.º 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);
     }));
 }
Exemplo n.º 2
0
 private TaskExecutionResult Execute(AdHocTask executableTask)
 {
     try
     {
         return(executableTask.Execute());
     }
     catch (Exception exception)
     {
         CurrentRequestData.ErrorSignal.Raise(exception);
         return(TaskExecutionResult.Failure(executableTask, exception));
     }
 }
Exemplo n.º 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++;
 }
Exemplo n.º 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());
     }
 }
Exemplo n.º 5
0
 public static TaskExecutionResult Failure(AdHocTask task, Exception exception)
 {
     return(new TaskExecutionResult {
         Success = false, Task = task, Exception = exception
     });
 }
Exemplo n.º 6
0
 public static TaskExecutionResult Successful(AdHocTask task)
 {
     return(new TaskExecutionResult {
         Success = true, Task = task
     });
 }
Exemplo n.º 7
0
 public virtual void OnSuccess(AdHocTask executableTask)
 {
     Status      = TaskExecutionStatus.Completed;
     CompletedAt = CurrentRequestData.Now;
     executableTask.OnSuccess();
 }
Exemplo n.º 8
0
 public virtual void OnStarting(AdHocTask executableTask)
 {
     Status    = TaskExecutionStatus.Executing;
     StartedAt = CurrentRequestData.Now;
     executableTask.OnStarting();
 }