Beispiel #1
0
        public IPublishedFundingUndoTaskFactory GetTaskFactoryFor(PublishedFundingUndoJobParameters parameters)
        {
            _logger.Information($"Requested PublishedFundingUndoTaskFactory for '{parameters}'");

            return(_factories.SingleOrDefault(_ => _.IsForJob(parameters)) ??
                   throw new ArgumentOutOfRangeException(nameof(parameters), $"No configured task factory for {parameters}"));
        }
        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 #3
0
 public bool IsForJob(PublishedFundingUndoJobParameters parameters)
 {
     return(!parameters.IsHardDelete);
 }
        public PublishedFundingUndoTaskContext(PublishedFundingUndoJobParameters parameters)
        {
            Guard.ArgumentNotNull(parameters, nameof(parameters));

            Parameters = parameters;
        }
        public override async Task Process(Message message)
        {
            PublishedFundingUndoJobParameters parameters = message;

            await PerformUndo(parameters);
        }