protected async Task PerformUndo(PublishedFundingUndoJobParameters parameters)
        {
            try
            {
                IPublishedFundingUndoTaskFactory taskFactory = _factoryLocator.GetTaskFactoryFor(parameters);

                IPublishedFundingUndoJobTask initialiseContextTask            = taskFactory.CreateContextInitialisationTask();
                IPublishedFundingUndoJobTask undoPublishedProviderTask        = taskFactory.CreatePublishedProviderUndoTask();
                IPublishedFundingUndoJobTask undoPublishedProviderVersionTask = taskFactory.CreatePublishedProviderVersionUndoTask();
                IPublishedFundingUndoJobTask undoPublishedFundingTask         = taskFactory.CreatePublishedFundingUndoTask();
                IPublishedFundingUndoJobTask undoPublishedFundingVersionTask  = taskFactory.CreatePublishedFundingVersionUndoTask();

                PublishedFundingUndoTaskContext taskContext = new PublishedFundingUndoTaskContext(parameters);

                await initialiseContextTask.Run(taskContext);

                Task[] undoTasks = new[]
                {
                    undoPublishedFundingTask.Run(taskContext), undoPublishedFundingVersionTask.Run(taskContext), undoPublishedProviderTask.Run(taskContext), undoPublishedProviderVersionTask.Run(taskContext)
                };

                await TaskHelper.WhenAllAndThrow(undoTasks);

                EnsureNoTaskErrors(taskContext);
            }
            catch (Exception e)
            {
                string errorMessage = $"Unable to complete {PublishedFundingUndoJob} for correlationId: {parameters.ForCorrelationId}.\n{e.Message}";
                throw new NonRetriableException(errorMessage, e);
            }
        }
Beispiel #2
0
 protected async Task WhenTheTaskIsRun()
 {
     await Task.Run(TaskContext);
 }