public Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var preProcessingDesktopTaskContext = new PreProcessingDesktopTaskContext(desktopContext); DeleteSandboxIfExists(preProcessingDesktopTaskContext.Container); var fileName = Path.GetFileName(preProcessingDesktopTaskContext.FileName); var refDataFileName = Path.GetFileName(preProcessingDesktopTaskContext.ReferenceDataFileName); var newFilePath = Path.Combine(preProcessingDesktopTaskContext.Container, fileName); var newRefDataFilePath = Path.Combine(preProcessingDesktopTaskContext.Container, refDataFileName); CreateAndPopulateSandbox(preProcessingDesktopTaskContext, newFilePath, newRefDataFilePath); preProcessingDesktopTaskContext.FileName = fileName; preProcessingDesktopTaskContext.OriginalFileName = fileName; preProcessingDesktopTaskContext.ReferenceDataFileName = refDataFileName; if (TryGetUkprnFromFileName(fileName, out var ukprn)) { preProcessingDesktopTaskContext.Ukprn = ukprn; } var fileSizeInBytes = new FileInfo(newFilePath).Length; preProcessingDesktopTaskContext.FileSizeInBytes = fileSizeInBytes; return(Task.FromResult(desktopContext)); }
public IDesktopContext Execute(ContextMutatorKeys contextMutatorKey, IDesktopContext context) { using (var executionLifetimeScope = _lifetimeScope.BeginLifetimeScope()) { return(executionLifetimeScope.ResolveKeyed <IContextMutator>(contextMutatorKey).Mutate(context)); } }
public async Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var context = _validationContextFactory.Build(desktopContext); using (var childLifeTimeScope = _parentLifetimeScope.BeginLifetimeScope()) { var logger = childLifeTimeScope.Resolve <ILogger>(); try { logger.LogDebug("Validation start"); var orchestrationService = childLifeTimeScope.Resolve <IPreValidationOrchestrationService>(); try { await orchestrationService.ExecuteAsync(context, cancellationToken); } catch (ValidationSeverityFailException ex) { logger.LogError(ex.Message); throw; } logger.LogDebug("Validation complete"); return(desktopContext); } catch (Exception ex) { logger.LogError("Error while processing job", ex); throw; } } }
public async Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var datastoreContext = _dataStoreContextFactory.Build(desktopContext); await _databaseDeploymentService.DeployAsync(string.Format(MdbConstants.MdbConnectionStringTemplate, datastoreContext.ExportOutputLocation), cancellationToken); return(desktopContext); }
public async Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var dataStoreContext = _dataStoreContextFactory.Build(desktopContext); await _databaseDeploymentService.DeployAsync(dataStoreContext.IlrDatabaseConnectionString, cancellationToken); return(desktopContext); }
public async Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var dataStoreContext = _dataStoreContextFactory.Build(desktopContext); await _entryPoint.Callback(dataStoreContext, cancellationToken); return(desktopContext); }
public async Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var reportServiceContext = _reportServiceContextFactory.Build(desktopContext); using (var childLifetimeScope = _lifeTimeScope.BeginLifetimeScope()) { var entryPoint = childLifetimeScope.Resolve <IEntryPoint>(); await entryPoint.Callback(reportServiceContext, cancellationToken); } return(desktopContext); }
public async Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var outputPath = Path.Combine(desktopContext.KeyValuePairs[ILRContextKeys.Container].ToString(), "DesktopContext.json"); using (var writeStream = await _fileService.OpenWriteStreamAsync(outputPath, null, cancellationToken)) { _jsonSerializationService.Serialize(desktopContext, writeStream); } _logger.LogInfo($"Saved Desktop context To : {outputPath}"); return(await Task.FromResult(desktopContext)); }
public Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var context = new PublishMdbDesktopTaskContext(desktopContext); var outputDirectory = Path.Combine(context.OutputDirectory, Path.GetFileNameWithoutExtension(context.OriginalFilename)); var sourceMdb = Path.Combine(context.Container, context.ExportDirectory, context.MdbFileName); var destinationMdb = Path.Combine(outputDirectory, $"FIS {context.DateTime:yyyyMMdd-HHmmss}.mdb"); _logger.LogInfo($"Copying Access : {sourceMdb} to {destinationMdb}"); if (File.Exists(sourceMdb)) { _logger.LogInfo($"Copying Access : {sourceMdb} to {destinationMdb}"); Directory.CreateDirectory(outputDirectory); File.Copy(sourceMdb, destinationMdb, true); } else { _logger.LogInfo($"No File Found : {sourceMdb}"); } // CSV Exports var exportDirectory = Path.Combine(context.Container, context.ExportDirectory); var csvFileNames = Directory.GetFiles(exportDirectory, "*.csv"); var sourceArchive = Path.Combine(exportDirectory, "FISExportCSV.zip"); ArchiveFiles(csvFileNames, sourceArchive); var destinationArchive = Path.Combine(outputDirectory, $"FIS-CSV {context.DateTime:yyyyMMdd-HHmmss}.zip"); if (File.Exists(sourceArchive)) { _logger.LogInfo($"Copying Exports : {sourceArchive} to {destinationArchive}"); File.Copy(sourceArchive, destinationArchive, true); } else { _logger.LogInfo($"No File Found : {sourceArchive}"); } return(Task.FromResult(desktopContext)); }
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); }
public Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { _logger.LogInfo("Started export Mdb Process"); ProcessStartInfo startInfo = new ProcessStartInfo(@"ESFA.DC.ILR.Desktop.ExportDatabase.Console.exe") { CreateNoWindow = true, UseShellExecute = false, Arguments = $"-f DesktopContext.json -c {desktopContext.KeyValuePairs[ILRContextKeys.Container]}" }; Process p = Process.Start(startInfo); p.WaitForExit(); if (p.ExitCode != 0) { throw new Exception("Export Access process failed with error, see logs"); } return(Task.FromResult(desktopContext)); }
public async Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { // Create context var fundingServiceContext = new FundingServiceContext(desktopContext); using (var cacheLifetimeScope = _lifeTimeScope.BeginLifetimeScope()) { var refereceData = await cacheLifetimeScope.Resolve <IFileProviderService <ReferenceDataRoot> >().ProvideAsync(fundingServiceContext, cancellationToken); var externalDataCache = BuildExternalDataCache(cacheLifetimeScope.Resolve <IExternalDataCachePopulationService>().PopulateAsync(refereceData, cancellationToken)); using (var orchestratorLifetimeScope = cacheLifetimeScope.BeginLifetimeScope(c => c.RegisterInstance(externalDataCache).As <IExternalDataCache>())) { // resolve Orchestrator var orchestrator = orchestratorLifetimeScope.Resolve <IFundingOrchestrationService>(); await orchestrator.ExecuteAsync(fundingServiceContext, cancellationToken); } } return(desktopContext); }
public async Task <IDesktopContext> ExecuteAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var postProcessingDesktopTaskContext = new PostProcessingDesktopTaskContext(desktopContext); var outputDirectory = Path.Combine(postProcessingDesktopTaskContext.OutputDirectory, Path.GetFileNameWithoutExtension(postProcessingDesktopTaskContext.OriginalFilename)); Directory.CreateDirectory(outputDirectory); if (postProcessingDesktopTaskContext.ReportFileNames != null) { foreach (var fileName in postProcessingDesktopTaskContext.ReportFileNames.Where(r => !string.IsNullOrWhiteSpace(r))) { var source = Path.Combine(postProcessingDesktopTaskContext.Container, fileName); var destination = Path.Combine(outputDirectory, fileName); File.Copy(source, destination, true); _logger.LogInfo($"Copying {source} to {destination}"); } } return(desktopContext); }
public FundingServiceContext(IDesktopContext desktopContext) { _desktopContext = desktopContext; }
public DataStoreDesktopContext(IDesktopContext desktopContext, string taskKey) { _desktopContext = desktopContext; _taskKey = taskKey; }
public IDesktopContext Mutate(IDesktopContext desktopContext) { desktopContext.KeyValuePairs[ILRContextKeys.ReportTasks] = ReportTaskNameConstants.ValidationSchemaErrorReport; return(desktopContext); }
private PostProcessingDesktopTaskContext NewContext(IDesktopContext desktopContext) { return(new PostProcessingDesktopTaskContext(desktopContext)); }
private async Task <IDesktopContext> ExecuteAsyncAction(IlrDesktopTaskKeys ilrDesktopTaskKey, IDesktopContext desktopContext, CancellationToken cancellationToken) { using (var executionLifetimeScope = _lifetimeScope.BeginLifetimeScope(c => { _keyedModules.TryGetValue(ilrDesktopTaskKey, out var module); if (module != null) { c.RegisterModule(module()); } })) { return(await executionLifetimeScope .ResolveKeyed <IDesktopTask>(ilrDesktopTaskKey) .ExecuteAsync(desktopContext, cancellationToken) .ConfigureAwait(false)); } }
public async Task <IDesktopContext> ExecuteAsync(IlrDesktopTaskKeys ilrDesktopTaskKey, IDesktopContext desktopContext, CancellationToken cancellationToken) { Task <IDesktopContext> task = ExecuteAsyncAction(ilrDesktopTaskKey, desktopContext, cancellationToken); return(await Task.Run(() => task, cancellationToken).ConfigureAwait(false)); }
public PublishMdbDesktopTaskContext(IDesktopContext desktopContext) { _desktopContext = desktopContext; }
public DesktopContextValidationContext(IDesktopContext desktopContext) { _desktopContext = desktopContext; }
public ReportServiceJobContextDesktopContext(IDesktopContext desktopContext, IEnumerable <IReportFilterQuery> reportFilters) { _desktopContext = desktopContext; ReportFilters = reportFilters; }
public PreProcessingDesktopTaskContext(IDesktopContext desktopContext) { _desktopContext = desktopContext; }
public async Task <ICompletionContext> ProcessAsync(IDesktopContext desktopContext, CancellationToken cancellationToken) { var completionContext = new CompletionContext() { OutputDirectory = desktopContext.OutputDirectory, ProcessingCompletionState = ProcessingCompletionStates.Success, }; var stepsList = _ilrPipelineProvider.Provide(); var step = 0; while (step < stepsList.Count) { var desktopTaskDefinition = stepsList[step]; _messengerService.Send(new TaskProgressMessage(desktopTaskDefinition.Key.GetDisplayText(), step, stepsList.Count)); try { desktopContext = await _desktopTaskExecutionService .ExecuteAsync(desktopTaskDefinition.Key, desktopContext, cancellationToken) .ConfigureAwait(false); cancellationToken.ThrowIfCancellationRequested(); step++; } catch (TaskCanceledException taskCanceledException) { completionContext.ProcessingCompletionState = ProcessingCompletionStates.Cancelled; _logger.LogError($"Task Cancelled - Step {step}", taskCanceledException); return(completionContext); } catch (Exception exception) { if (desktopTaskDefinition.FailureKey != null) { if (desktopTaskDefinition.FailureContextMutatorKey != null) { desktopContext = _contextMutatorExecutor.Execute(desktopTaskDefinition.FailureContextMutatorKey.Value, desktopContext); } step = _ilrPipelineProvider.IndexFor(desktopTaskDefinition.FailureKey.Value, stepsList); completionContext.ProcessingCompletionState = ProcessingCompletionStates.HandledFail; _logger.LogError($"Task Execution Handled Failure - Step {step}", exception); } else { completionContext.ProcessingCompletionState = ProcessingCompletionStates.UnhandledFail; _logger.LogError($"Task Execution Unhandled Failure - Step {step}", exception); return(completionContext); } } } _messengerService.Send(new TaskProgressMessage("Processing Complete", stepsList.Count, stepsList.Count)); return(completionContext); }
private ReportServiceJobContextDesktopContext NewContext(IDesktopContext desktopContext, IEnumerable <IReportFilterQuery> reportFilterQueries) { return(new ReportServiceJobContextDesktopContext(desktopContext, reportFilterQueries)); }
public ReferenceDataJobContextMessageContext(IDesktopContext desktopContext) { _desktopContext = desktopContext; }