public async Task Execute(IEnumerable <FundingDto> fundingDtos, IFundingServiceContext fundingServiceContext, CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Starting {_taskName} Task");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            List <Task <TOut> > taskList = new List <Task <TOut> >();

            foreach (FundingDto fundingDto in fundingDtos)
            {
                taskList.Add(Process(fundingDto, cancellationToken));
            }

            await Task.WhenAll(taskList).ConfigureAwait(false);

            IEnumerable <TOut> results = taskList.Select(t => t.Result) ?? Enumerable.Empty <TOut>();
            var output = _fundingOutputCondenserService.Condense(results, fundingServiceContext.Ukprn, fundingServiceContext.Year);

            fundingServiceContext.FundingOutputKeys.TryGetValue(_outputKey, out var outputFileName);

            await _filePersistanceService.PersistAsync(outputFileName, fundingServiceContext.Container, output, cancellationToken).ConfigureAwait(false);

            _logger.LogDebug($"Persisted {_taskName} results - {stopWatch.ElapsedMilliseconds}");
        }
        public async Task ExecuteAsync(IFundingServiceContext fundingServiceContext, CancellationToken cancellationToken)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var stopWatchSteps = new Stopwatch();

            stopWatchSteps.Start();

            var message = await _ilrFileProviderService.ProvideAsync(fundingServiceContext, cancellationToken).ConfigureAwait(false);

            _logger.LogDebug($"Funding Service got file in: {stopWatchSteps.ElapsedMilliseconds}");
            stopWatchSteps.Restart();

            cancellationToken.ThrowIfCancellationRequested();

            var refereceData = await _ilrReferenceDataProviderService.ProvideAsync(fundingServiceContext, cancellationToken).ConfigureAwait(false);

            cancellationToken.ThrowIfCancellationRequested();

            stopWatchSteps.Restart();

            cancellationToken.ThrowIfCancellationRequested();

            string externalDataCache = _jsonSerializationService.Serialize(_externalCachePopulationService.PopulateAsync(refereceData, cancellationToken));

            _logger.LogDebug($"Funding Service got external data: {stopWatchSteps.ElapsedMilliseconds}");

            await _fundingTaskProvider.ProvideAsync(fundingServiceContext, message, externalDataCache, cancellationToken);

            _logger.LogDebug($"Completed Funding Service for given rule bases in: {stopWatch.ElapsedMilliseconds}");
        }
Ejemplo n.º 3
0
        public async Task <ReferenceDataRoot> ProvideAsync(IFundingServiceContext fundingServiceContext, CancellationToken cancellationToken)
        {
            ReferenceDataRoot referenceData;

            using (var fileStream = await _fileService.OpenReadStreamAsync(fundingServiceContext.IlrReferenceDataKey, fundingServiceContext.Container, cancellationToken))
            {
                referenceData = _jsonSerializationService.Deserialize <ReferenceDataRoot>(fileStream);
            }

            return(referenceData);
        }
        public async Task <IMessage> ProvideAsync(IFundingServiceContext fundingServiceContext, CancellationToken cancellationToken)
        {
            Message message;

            using (var fileStream = await _fileService.OpenReadStreamAsync(fundingServiceContext.FileReference, fundingServiceContext.Container, cancellationToken))
            {
                message = _xmlSerializationService.Deserialize <Message>(fileStream);
            }

            return(message);
        }
 public List <FundingDto> Provide(IFundingServiceContext fundingServiceContext, IMessage message, string externalDataCache, CancellationToken cancellationToken)
 {
     return(_learnerPagingService
            .ProvideDtos(fundModelFilter, message)
            .Select(p =>
                    new FundingDto
     {
         JobId = fundingServiceContext.JobId,
         Container = fundingServiceContext.Container,
         OutputKey = fundingServiceContext.FundingFm70OutputKey,
         UKPRN = message.LearningProviderEntity.UKPRN,
         ExternalDataCache = externalDataCache,
         ValidLearners = _jsonSerializationService.Serialize(p)
     }).ToList());
 }
Ejemplo n.º 6
0
        public async Task Execute(IEnumerable <FundingDto> fundingDtos, IFundingServiceContext fundingServiceContext, CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Starting {_taskName} Task");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            var output = _fundingOutputCondenserService.Condense(Enumerable.Empty <TOut>(), fundingServiceContext.Ukprn, fundingServiceContext.Year);

            fundingServiceContext.FundingOutputKeys.TryGetValue(_outputKey, out var outputFileName);

            await _filePersistanceService.PersistAsync(outputFileName, fundingServiceContext.Container, output, cancellationToken).ConfigureAwait(false);

            _logger.LogDebug($"Persisted {_taskName} results - {stopWatch.ElapsedMilliseconds}");
        }
Ejemplo n.º 7
0
        public async Task Execute(IEnumerable <FundingDto> fundingActorDtos, IFundingServiceContext fundingServiceContext, CancellationToken cancellationToken)
        {
            _logger.LogDebug($"Starting {_actorName} Actors");

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            List <Task <string> > taskList = new List <Task <string> >();
            List <IFM70Actor>     actors   = new List <IFM70Actor>();

            foreach (FundingDto fundingActorDto in fundingActorDtos)
            {
                IFM70Actor actor = _fundingActorProvider.Provide();
                actors.Add(actor);
                taskList.Add(actor.Process(fundingActorDto, cancellationToken));
            }

            await Task.WhenAll(taskList).ConfigureAwait(false);

            IEnumerable <FM70Global> results = taskList.Select(t => _jsonSerializationService.Deserialize <FM70Global>(t.Result));

            _logger.LogDebug($"Completed {taskList.Count} {_actorName} Actors - {stopWatch.ElapsedMilliseconds}");

            List <Task> tasksDestroy = new List <Task>();

            foreach (IFM70Actor actor in actors)
            {
                tasksDestroy.Add(_fundingActorProvider.DestroyAsync(actor, cancellationToken));
            }

            await Task.WhenAll(tasksDestroy).ConfigureAwait(false);

            _logger.LogDebug($"Destroyed {taskList.Count} {_actorName} Actors - {stopWatch.ElapsedMilliseconds}");

            stopWatch.Restart();

            var output = _fundingOutputCondenserService.Condense(results, fundingServiceContext.Ukprn, fundingServiceContext.Year);

            await _filePersistanceService.PersistAsync(fundingServiceContext.FundingFm70OutputKey, fundingServiceContext.Container, output, cancellationToken).ConfigureAwait(false);

            _logger.LogDebug($"Persisted {_actorName} results - {stopWatch.ElapsedMilliseconds}");
        }
Ejemplo n.º 8
0
        public async Task ProvideAsync(IFundingServiceContext fundingServiceContext, IMessage message, string externalDataCache, CancellationToken cancellationToken)
        {
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var stopWatchSteps = new Stopwatch();

            stopWatchSteps.Start();

            List <Task> fundingTasks = new List <Task>();

            foreach (var taskName in fundingServiceContext.TaskKeys.ToList())
            {
                fundingTasks.Add(_taskIndex[taskName].Execute(
                                     _taskProviderIndex[taskName].Provide(fundingServiceContext, message, externalDataCache, cancellationToken), fundingServiceContext, cancellationToken));
            }

            await Task.WhenAll(fundingTasks).ConfigureAwait(false);

            _logger.LogDebug($"Completed Funding Service for given rule bases in: {stopWatch.ElapsedMilliseconds}");
        }