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 <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { // Create context IReferenceDataContext referenceDataContext = new ReferenceDataJobContextMessageContext(desktopContext); // Retrieving ILR File _logger.LogInfo("Starting ILR File Retrieval"); var message = await _messageProvider.ProvideAsync(referenceDataContext, cancellationToken); _logger.LogInfo("Finished ILR File Retrieval"); // 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"); // output model. _logger.LogInfo("Starting Reference Data Output"); await _filePersister.StoreAsync(referenceDataContext.OutputIlrReferenceDataFileKey, referenceDataContext.Container, referenceData, compressOutput, cancellationToken); _logger.LogInfo("Finished Reference Data Output"); // set return period _logger.LogInfo("Adding Return Period and Ukprn to Context"); _desktopContextReturnPeriodUpdateService.UpdateCollectionPeriod( referenceDataContext, message.HeaderEntity.CollectionDetailsEntity.FilePreparationDate, referenceData.MetaDatas.CollectionDates.ReturnPeriods); var ukprn = message?.HeaderEntity?.SourceEntity?.UKPRN; if (ukprn != null) { referenceDataContext.Ukprn = ukprn.Value; } _logger.LogInfo($"Finished adding Return Period : {referenceDataContext.ReturnPeriod} and Ukprn : {referenceDataContext.Ukprn} to Context"); return(desktopContext); }