public async Task ExecuteAsync(IReferenceDataContext referenceDataContext, CancellationToken cancellationToken) { try { // Retrieving ILR File _logger.LogInfo("Starting ILR File Retrieval"); var message = await _messageProvider.ProvideAsync(referenceDataContext, cancellationToken); _logger.LogInfo("Finished retirieving ILR File"); // get frm reference data and build model _logger.LogInfo("Starting Learner Reference Data Population"); var referenceData = await _learnerDataRetrievalService.RetrieveAsync(message, cancellationToken); _logger.LogInfo("Finished Learner Reference Data Population"); // output model. _logger.LogInfo("Starting Learner Reference Data Output"); await _filePersister.StoreAsync(referenceDataContext.LearnerReferenceDataFileKey, referenceDataContext.Container, referenceData, compressOutput, cancellationToken); _logger.LogInfo("Finished Learner Reference Data Output"); } catch (Exception exception) { _logger.LogError("Learner Reference Data Service Output Exception", exception); throw; } }
public async Task <IMessage> ProvideAsync(IReferenceDataContext referenceDataContext, CancellationToken cancellationToken) { using (var stream = await _fileService.OpenReadStreamAsync(referenceDataContext.FileReference, referenceDataContext.Container, cancellationToken)) { stream.Position = 0; return(_xmlSerializationService.Deserialize <Message>(stream)); } }
public void UpdateCollectionPeriod(IReferenceDataContext referenceDataContext, DateTime filePrepDate, IReadOnlyCollection <ReturnPeriod> returnPeriods) { var r01 = returnPeriods.First(rp => rp.Period == 1).Start; var r14 = returnPeriods.First(rp => rp.Period == 14).End; var submissionDate = filePrepDate <r01?r01 : filePrepDate> r14 ? r14 : filePrepDate; referenceDataContext.ReturnPeriod = returnPeriods.First(rp => rp.Start <= submissionDate && rp.End >= submissionDate).Period; }
public async Task <ReferenceDataRoot> PopulateAsync(IReferenceDataContext referenceDataContext, IMessage message, CancellationToken cancellationToken) { _logger.LogInfo("Starting Reference Data Parameter Mapping from Message"); var mapperData = _messageMapperService.MapFromMessage(message); _logger.LogInfo("Finished Reference Data Parameter Mapping from Message"); _logger.LogInfo("Starting Reference Data Retrieval from sources"); var desktopReferenceData = await _desktopReferenceDataRootMapperService.MapReferenceData(referenceDataContext, mapperData, cancellationToken); _logger.LogInfo("Finished Reference Data Retrieval from sources"); return(desktopReferenceData); }
public async Task ExecuteAsync(IReferenceDataContext referenceDataContext, CancellationToken cancellationToken) { try { // Retrieving ILR File _logger.LogInfo("Starting ILR File Retrieval"); var message = await _messageProvider.ProvideAsync(referenceDataContext, cancellationToken); _logger.LogInfo("Finished retirieving ILR File"); // get reference data and build model. _logger.LogInfo("Starting Reference Data Population"); var referenceData = await _referenceDataPopulationService.PopulateAsync(referenceDataContext, message, cancellationToken); _logger.LogInfo("Finished Reference Data Population"); try { if (Convert.ToBoolean(_featureConfiguration.EDRSAPIEnabled)) { _logger.LogInfo("Starting EDRS API validation"); var apiData = await _edrsApiService.ValidateErnsAsync(message, cancellationToken); _logger.LogInfo("Finished EDRS API validation"); _logger.LogInfo("Starting EDRS API Output"); var key = string.Format(TempFileKey, referenceDataContext.Ukprn, referenceDataContext.JobId); await _filePersister.StoreAsync(key, referenceDataContext.Container, apiData, compressOutput, cancellationToken); _logger.LogInfo("Finished EDRS API Output"); } } catch (Exception ex) { _logger.LogError("EDRS API path failed", ex); } // output model. _logger.LogInfo("Starting Reference Data Output"); await _filePersister.StoreAsync(referenceDataContext.OutputIlrReferenceDataFileKey, referenceDataContext.Container, referenceData, compressOutput, cancellationToken); _logger.LogInfo("Finished Reference Data Output"); } catch (Exception exception) { _logger.LogError("Reference Data Service Output Exception", exception); throw; } }
public async Task ExecuteAsync(IReferenceDataContext context, CancellationToken cancellationToken) { _logger.LogInfo("Starting Retrieval of Validation Messages Csv data"); var csvRecords = await _csvRetrievalService.RetrieveCsvData <ValidationMessagesModel, ValidationMessagesMapper>(context.ValidationMessagesFileReference, context.Container, cancellationToken); if (csvRecords.Any()) { _logger.LogInfo("Finished Retrieval of Validation Messages Csv data"); await _validationMessagesTransaction.WriteValidationMessagesAsync(BuildRules(csvRecords), cancellationToken); } else { _logger.LogInfo("Validation Messages Csv is empty - exiting validation messages task"); } }
public async Task <ReferenceDataRoot> MapReferenceData(IReferenceDataContext referenceDataContext, MapperData mapperData, CancellationToken cancellationToken) { var desktopReferenceData = new DesktopReferenceDataRoot(); using (var zipFileStream = await _fileService.OpenReadStreamAsync(referenceDataContext.DesktopInputReferenceDataFileKey, referenceDataContext.Container, cancellationToken)) { using (var zip = new ZipArchive(zipFileStream, ZipArchiveMode.Read)) { _logger.LogInfo("Reference Data - Retrieve MetaData"); desktopReferenceData.MetaDatas = _zipArchiveFileService.RetrieveModel <MetaData>(zip, DesktopReferenceDataConstants.MetaDataFile); _logger.LogInfo("Reference Data - Retrieve Devolved Postcodes"); desktopReferenceData.DevolvedPostcodes = GetDevolvedPostcodes(zip, mapperData.Postcodes); _logger.LogInfo("Reference Data - Retrieve Employers"); desktopReferenceData.Employers = _zipArchiveFileService.RetrieveModels <Employer>(zip, DesktopReferenceDataConstants.EmployersFile, x => mapperData.EmployerIds.Contains(x.ERN)); _logger.LogInfo("Reference Data - Retrieve Epa Organisations"); desktopReferenceData.EPAOrganisations = _zipArchiveFileService.RetrieveModels <EPAOrganisation>(zip, DesktopReferenceDataConstants.EPAOrganisationsFile, x => mapperData.EpaOrgIds.Contains(x.ID)); _logger.LogInfo("Reference Data - Retrieve Lars Frameworks"); desktopReferenceData.LARSFrameworks = _zipArchiveFileService.RetrieveModels <LARSFrameworkDesktop>(zip, DesktopReferenceDataConstants.LARSFrameworksFile); _logger.LogInfo("Reference Data - Retrieve Lars Framework Aims"); desktopReferenceData.LARSFrameworkAims = _zipArchiveFileService.RetrieveModels <LARSFrameworkAimDesktop>(zip, DesktopReferenceDataConstants.LARSFrameworkAimsFile); _logger.LogInfo("Reference Data - Retrieve Lars Learning Deliveries"); desktopReferenceData.LARSLearningDeliveries = _zipArchiveFileService.RetrieveModels <LARSLearningDelivery>(zip, DesktopReferenceDataConstants.LARSLearningDeliveriesFile, x => mapperData.LARSLearningDeliveryKeys.Select(l => l.LearnAimRef).Contains(x.LearnAimRef, StringComparer.OrdinalIgnoreCase)); _logger.LogInfo("Reference Data - Retrieve Lars Standards"); desktopReferenceData.LARSStandards = _zipArchiveFileService.RetrieveModels <LARSStandard>(zip, DesktopReferenceDataConstants.LARSStandardsFile, x => mapperData.StandardCodes.Contains(x.StandardCode)); _logger.LogInfo("Reference Data - Retrieve Organisations"); desktopReferenceData.Organisations = _zipArchiveFileService.RetrieveModels <Organisation>(zip, DesktopReferenceDataConstants.OrganisationsFile, x => mapperData.UKPRNs.Contains(x.UKPRN)); _logger.LogInfo("Reference Data - Retrieve Postcodes"); desktopReferenceData.Postcodes = _zipArchiveFileService.RetrieveModels <Postcode>(zip, DesktopReferenceDataConstants.PostcodesFile, x => mapperData.Postcodes.Contains(x.PostCode)); } } var referenceDataRoot = MapData(desktopReferenceData, mapperData); return(referenceDataRoot); }
public async Task <ReferenceDataRoot> PopulateAsync(IReferenceDataContext referenceDataContext, IMessage message, CancellationToken cancellationToken) { var messageData = _messageMapperService.MapFromMessage(message); return(new ReferenceDataRoot { MetaDatas = await _metaDataRetrievalService.RetrieveAsync(messageData.LearningProviderUKPRN, cancellationToken), AppsEarningsHistories = await _appEarningsHistoryRepositoryService.RetrieveAsync(messageData.FM36Ulns, cancellationToken), DevolvedPostcodes = await _devolvedPostcodesRepositoryService.RetrieveAsync(messageData.Postcodes, cancellationToken), EasFundingLines = await _easRepositoryService.RetrieveAsync(messageData.LearningProviderUKPRN, cancellationToken), Employers = await _employersRepositoryService.RetrieveAsync(messageData.EmployerIds, cancellationToken), EPAOrganisations = await _epaOrganisationsRepositoryService.RetrieveAsync(messageData.EpaOrgIds, cancellationToken), FCSContractAllocations = await _fcsRepositoryService.RetrieveAsync(messageData.LearningProviderUKPRN, cancellationToken), LARSLearningDeliveries = await _larsLearningDeliveryRepositoryService.RetrieveAsync(messageData.LARSLearningDeliveryKeys, cancellationToken), LARSStandards = await _larsStandardRepositoryService.RetrieveAsync(messageData.StandardCodes, cancellationToken), McaDevolvedContracts = await _mcaDevolvedContractRepositoryService.RetrieveAsync(messageData.LearningProviderUKPRN, cancellationToken), Organisations = await _organisationsRepositoryService.RetrieveAsync(messageData.UKPRNs, cancellationToken), Postcodes = await _postcodesRepositoryService.RetrieveAsync(messageData.Postcodes, cancellationToken), ULNs = await _ulnRepositoryService.RetrieveAsync(messageData.ULNs, cancellationToken) }); }
public async Task ExecuteAsync(IReferenceDataContext referenceDataContext, CancellationToken cancellationToken) { try { // get frm reference data and build model _logger.LogInfo("Starting Frm Reference Data Population"); var referenceData = await _frmDataRetrievalService.RetrieveAsync(referenceDataContext.Ukprn, cancellationToken); _logger.LogInfo("Finished Frm Reference Data Population"); // output model. _logger.LogInfo("Starting Reference Data Output"); await _filePersister.StoreAsync(referenceDataContext.FrmReferenceDataFileKey, referenceDataContext.Container, referenceData, compressOutput, cancellationToken); _logger.LogInfo("Finished Reference Data Output"); } catch (Exception exception) { _logger.LogError("Reference Data Service Output Exception", exception); throw; } }