Пример #1
0
 private void FailedExecution(IEnumerable <TaskExecutionResult> taskFailureInfos)
 {
     _session.Transact(session => taskFailureInfos.ForEach(
                           taskFailureInfo =>
     {
         IExecutableTask executableTask = taskFailureInfo.Task;
         executableTask.Entity.OnFailure(executableTask, taskFailureInfo.Exception);
         session.Update(executableTask.Entity);
     }));
 }
 private TaskExecutionResult Execute(IExecutableTask executableTask)
 {
     try
     {
         return(executableTask.Execute());
     }
     catch (Exception exception)
     {
         CurrentRequestData.ErrorSignal.Raise(exception);
         return(TaskExecutionResult.Failure(executableTask, exception));
     }
 }
Пример #3
0
 private TaskExecutionResult Execute(IExecutableTask executableTask)
 {
     try
     {
         return executableTask.Execute();
     }
     catch (Exception exception)
     {
         CurrentRequestData.ErrorSignal.Raise(exception);
         return TaskExecutionResult.Failure(executableTask, exception);
     }
 }
Пример #4
0
 public virtual void OnFailure(IExecutableTask executableTask, Exception exception)
 {
     executableTask.OnFailure(exception);
     if (Tries < 5)
         Status = TaskExecutionStatus.Pending;
     else
     {
         Status = TaskExecutionStatus.Failed;
         FailedAt = CurrentRequestData.Now;
         executableTask.OnFinalFailure(exception);
     }
     Tries++;
 }
Пример #5
0
 public virtual void OnFailure(IExecutableTask executableTask, Exception exception)
 {
     executableTask.OnFailure(exception);
     if (Tries < 5)
     {
         Status = TaskExecutionStatus.Pending;
     }
     else
     {
         Status   = TaskExecutionStatus.Failed;
         FailedAt = CurrentRequestData.Now;
         executableTask.OnFinalFailure(exception);
     }
     Tries++;
 }
Пример #6
0
        public IList <IExecutableTask> GetTasksToExecute(IList <QueuedTask> pendingQueuedTasks, IList <ScheduledTask> pendingScheduledTasks)
        {
            List <IExecutableTask> executableTasks = new List <IExecutableTask>();
            List <QueuedTask>      failedTasks     = new List <QueuedTask>();

            foreach (QueuedTask queuedTask in pendingQueuedTasks)
            {
                try
                {
                    IExecutableTask task = _kernel.Get(queuedTask.GetTaskType()) as IExecutableTask;
                    task.Site   = queuedTask.Site;
                    task.Entity = queuedTask;
                    task.SetData(queuedTask.Data);
                    executableTasks.Add(task);
                }
                catch (Exception exception)
                {
                    CurrentRequestData.ErrorSignal.Raise(exception);
                    failedTasks.Add(queuedTask);
                }
            }
            if (failedTasks.Any())
            {
                _session.Transact(session => failedTasks.ForEach(task =>
                {
                    task.Status   = TaskExecutionStatus.Failed;
                    task.FailedAt = CurrentRequestData.Now;
                    session.Update(task);
                }));
            }
            foreach (ScheduledTask scheduledTask in pendingScheduledTasks)
            {
                Type            taskType = TypeHelper.GetAllTypes().FirstOrDefault(type => type.FullName == scheduledTask.Type);
                IExecutableTask task     = _kernel.Get(taskType) as IExecutableTask;
                task.Site   = scheduledTask.Site;
                task.Entity = scheduledTask;
                executableTasks.Add(task);
            }
            return(executableTasks);
        }
Пример #7
0
 public virtual void OnStarting(IExecutableTask executableTask)
 {
     Status    = TaskExecutionStatus.Executing;
     StartedAt = CurrentRequestData.Now;
     executableTask.OnStarting();
 }
 public GoUpTheMountainOfDoomTask(IExecutableTask originalTask)
 {
     this.originalTask = originalTask;
     monster = new NonCodingArchitect();
 }
Пример #9
0
 public virtual void OnSuccess(IExecutableTask executableTask)
 {
     Status = TaskExecutionStatus.Pending;
     LastComplete = CurrentRequestData.Now;
     executableTask.OnSuccess();
 }
 public EnterForbiddenForestTask(IExecutableTask originalTask)
 {
     this.originalTask = originalTask;
     monster = new GrumpyDatabaseAdministrator();
 }
Пример #11
0
 public virtual void OnStarting(IExecutableTask executableTask)
 {
     Status = TaskExecutionStatus.Executing;
     executableTask.OnStarting();
 }
Пример #12
0
 public virtual void OnStarting(IExecutableTask executableTask)
 {
     Status = TaskExecutionStatus.Executing;
     executableTask.OnStarting();
 }
Пример #13
0
 public static TaskExecutionResult Failure(IExecutableTask task, Exception exception)
 {
     return(new TaskExecutionResult {
         Success = false, Task = task, Exception = exception
     });
 }
Пример #14
0
 public virtual void OnSuccess(IExecutableTask executableTask)
 {
     Status = TaskExecutionStatus.Completed;
     CompletedAt = CurrentRequestData.Now;
     executableTask.OnSuccess();
 }
Пример #15
0
 public static TaskExecutionResult Failure(IExecutableTask task, Exception exception)
 {
     return new TaskExecutionResult {Success = false, Task = task, Exception = exception};
 }
Пример #16
0
 public virtual void OnStarting(IExecutableTask executableTask)
 {
     Status = TaskExecutionStatus.Executing;
     StartedAt = CurrentRequestData.Now;
     executableTask.OnStarting();
 }
Пример #17
0
 public Choice(string code, string description, IExecutableTask task)
 {
     this.task = task;
     Code = code;
     Description = description;
 }
Пример #18
0
 public virtual void OnFailure(IExecutableTask executableTask, Exception exception)
 {
     Status = TaskExecutionStatus.Pending;
     executableTask.OnFailure(exception);
 }
Пример #19
0
 public virtual void OnSuccess(IExecutableTask executableTask)
 {
     Status       = TaskExecutionStatus.Pending;
     LastComplete = CurrentRequestData.Now;
     executableTask.OnSuccess();
 }
 public AttackTask(IMonster monster, IExecutableTask originalTask)
 {
     this.monster = monster;
     this.originalTask = originalTask;
 }
Пример #21
0
 public NullChoice(IExecutableTask task)
 {
     this.task = task;
 }
 public void ExecuteChoice(string code)
 {
     currentTask = currentTask.Execute(code, this);
 }
Пример #23
0
 public virtual void OnFailure(IExecutableTask executableTask, Exception exception)
 {
     Status = TaskExecutionStatus.Pending;
     executableTask.OnFailure(exception);
 }
Пример #24
0
 public static TaskExecutionResult Successful(IExecutableTask task)
 {
     return new TaskExecutionResult {Success = true, Task = task};
 }
Пример #25
0
 public virtual void OnSuccess(IExecutableTask executableTask)
 {
     Status      = TaskExecutionStatus.Completed;
     CompletedAt = CurrentRequestData.Now;
     executableTask.OnSuccess();
 }
 public EnterThePrancingPoneyTask(IExecutableTask originalTask)
 {
     this.originalTask = originalTask;
     monster = new CertifiedDotNetDeveloper();
 }
Пример #27
0
 public static TaskExecutionResult Successful(IExecutableTask task)
 {
     return(new TaskExecutionResult {
         Success = true, Task = task
     });
 }