public MessagingService( IIndex <JobType, ITopicPublishService <JobContextDto> > topicPublishServices, JobContextMapper jobContextMapper, ILogger logger) { _topicPublishServices = topicPublishServices; _jobContextMapper = jobContextMapper; _logger = logger; }
public void TestJobContextMappingDtoToInterface() { DateTime now = DateTime.UtcNow; JobContextDto jobContextDto = new JobContextDto { SubmissionDateTimeUtc = now, JobId = 12, KeyValuePairs = new Dictionary <string, object> { { JobContextMessageKey.UkPrn, 12345 } }, TopicPointer = 3, Topics = new List <TopicItemDto> { new TopicItemDto { Tasks = new List <TaskItemDto> { new TaskItemDto { Tasks = new List <string> { "Task A" }, SupportsParallelExecution = true } }, SubscriptionName = "Subscription A" } } }; JobContextMapper mapper = new JobContextMapper(); JobContextMessage message = mapper.MapTo(jobContextDto); message.SubmissionDateTimeUtc.Should().Be(now); message.JobId.Should().Be(12); message.KeyValuePairs.Should().BeEquivalentTo(jobContextDto.KeyValuePairs); message.Topics.Should().BeEquivalentTo(jobContextDto.Topics); message.TopicPointer.Should().Be(3); }
public void TestJobContextMappingInterfaceToDto() { DateTime now = DateTime.UtcNow; List <ITaskItem> tasks = new List <ITaskItem>() { new TaskItem { Tasks = new List <string> { "Task A" }, SupportsParallelExecution = true } }; var topicItem = new TopicItem("Topic A", "SqlFilter A", tasks); JobContextMessage jobContextMessage = new JobContextMessage { JobId = 12, KeyValuePairs = new Dictionary <string, object> { { JobContextMessageKey.UkPrn, 12345 } }, SubmissionDateTimeUtc = now, TopicPointer = 3, Topics = new List <ITopicItem> { topicItem } }; JobContextMapper mapper = new JobContextMapper(); JobContextDto dto = mapper.MapFrom(jobContextMessage); dto.SubmissionDateTimeUtc.Should().Be(now); dto.JobId.Should().Be(12); dto.KeyValuePairs.Should().BeEquivalentTo(jobContextMessage.KeyValuePairs); dto.Topics.Should().BeEquivalentTo(jobContextMessage.Topics); dto.TopicPointer.Should().Be(3); }
public async Task <bool> HandleAsync(JobContextMessage jobContextMessage, CancellationToken cancellationToken) { var jobContextModel = JobContextMapper.MapJobContextToModel(jobContextMessage); using (var childLifetimeScope = _lifetimeScope.BeginLifetimeScope(s => RegisterYearSpecificServices(s, jobContextModel))) { _logger.LogInfo("ESF R2 callback invoked"); if (!jobContextModel.Tasks.Any()) { _logger.LogInfo("ESF R2. No tasks to run."); return(true); } cancellationToken.ThrowIfCancellationRequested(); var controller = childLifetimeScope.Resolve <IServiceController>(); await controller.RunTasks(jobContextModel, cancellationToken); return(true); } }