public override void Execute() { base.Execute(); if (_userMustPick) { ExtractableDataSet[] selected; if (!SelectMany(_toadd.Cast <ExtractableDataSet>().ToArray(), out selected)) { return; } foreach (var ds in selected) { _targetExtractionConfiguration.AddDatasetToConfiguration(ds); } } else { foreach (var ds in _toadd) { _targetExtractionConfiguration.AddDatasetToConfiguration(ds); } } Publish(_targetExtractionConfiguration); }
public override void Execute() { base.Execute(); foreach (var ds in _toadd) { _targetExtractionConfiguration.AddDatasetToConfiguration(ds); } Publish(_targetExtractionConfiguration); }
private ExtractionConfiguration CreateExtractionConfiguration(Project project, ExtractableCohort cohort, string name, bool isReleased, ICheckNotifier notifier, params Catalogue[] catalogues) { var extractionConfiguration = new ExtractionConfiguration(_repos.DataExportRepository, project); extractionConfiguration.Name = name; extractionConfiguration.Cohort_ID = cohort.ID; extractionConfiguration.SaveToDatabase(); foreach (var c in catalogues) { //Get it's extractableness var eds = _repos.DataExportRepository.GetAllObjectsWithParent <ExtractableDataSet>(c).SingleOrDefault() ?? new ExtractableDataSet(_repos.DataExportRepository, c); //or make it extractable extractionConfiguration.AddDatasetToConfiguration(eds); } var extractionPipeline = _repos.CatalogueRepository.GetAllObjects <Pipeline>().FirstOrDefault(p => p?.Destination?.Class == typeof(ExecuteDatasetExtractionFlatFileDestination).FullName); if (isReleased && extractionConfiguration != null) { var optsExtract = new ExtractionOptions() { Pipeline = extractionPipeline.ID, ExtractionConfiguration = extractionConfiguration.ID }; var runnerExtract = new ExtractionRunner(optsExtract); try { runnerExtract.Run(_repos, new ThrowImmediatelyDataLoadEventListener(), notifier, new GracefulCancellationToken()); } catch (Exception ex) { notifier.OnCheckPerformed(new CheckEventArgs("Could not run ExtractionConfiguration (nevermind)", CheckResult.Warning, ex)); } extractionConfiguration.IsReleased = true; extractionConfiguration.SaveToDatabase(); } return(extractionConfiguration); }
private void SetupDataExport(string testDbName, ICatalogue catalogue, out ExtractionConfiguration extractionConfiguration, out IExtractableDataSet extractableDataSet, out IProject project) { extractableDataSet = new ExtractableDataSet(DataExportRepository, catalogue); project = new Project(DataExportRepository, testDbName); project.ProjectNumber = 1; Directory.CreateDirectory(ProjectDirectory); project.ExtractionDirectory = ProjectDirectory; project.SaveToDatabase(); extractionConfiguration = new ExtractionConfiguration(DataExportRepository, project); extractionConfiguration.AddDatasetToConfiguration(extractableDataSet); foreach (var ei in _catalogue.GetAllExtractionInformation(ExtractionCategory.Supplemental)) { extractionConfiguration.AddColumnToExtraction(extractableDataSet, ei); } }
private void btnExecute_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; string problem = AllRequiredDataPresent(); try { if (problem != null) { MessageBox.Show(problem); return; } ragExecute.Reset(); //create the project if (_project == null) { _project = new Project(Activator.RepositoryLocator.DataExportRepository, tbProjectName.Text); } _project.ProjectNumber = int.Parse(tbProjectNumber.Text); _project.ExtractionDirectory = tbExtractionDirectory.Text; if (!Directory.Exists(_project.ExtractionDirectory)) { Directory.CreateDirectory(_project.ExtractionDirectory); } _project.SaveToDatabase(); if (_configuration == null) { _configuration = new ExtractionConfiguration(Activator.RepositoryLocator.DataExportRepository, _project); _configuration.Name = "Cases"; _configuration.SaveToDatabase(); } foreach (ExtractableDataSet ds in _selectedDatasets) { _configuration.AddDatasetToConfiguration(ds); } ICommandExecution cmdAssociateCicWithProject = null; if (_cohortCreated == null && cbDefineCohort.Checked) { var cohortDefinition = new CohortDefinition(null, tbCohortName.Text, 1, _project.ProjectNumber.Value, (ExternalCohortTable)ddCohortSources.SelectedItem); //execute the cohort creation bit var cohortRequest = new CohortCreationRequest(_project, cohortDefinition, (DataExportRepository)Activator.RepositoryLocator.DataExportRepository, tbCohortName.Text); ComboBox dd; if (_cohortFile != null) { //execute cohort creation from file. cohortRequest.FileToLoad = new FlatFileToLoad(_cohortFile); dd = ddFilePipeline; } else { //execute cohort creation from cic cohortRequest.CohortIdentificationConfiguration = (CohortIdentificationConfiguration)cbxCohort.SelectedItem; dd = ddCicPipeline; //since we are about to execute a cic and store the results we should associate it with the Project (if successful) cmdAssociateCicWithProject = new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(Activator).SetTarget( _project).SetTarget(cohortRequest.CohortIdentificationConfiguration); } var engine = cohortRequest.GetEngine((Pipeline)dd.SelectedItem, new ThrowImmediatelyDataLoadEventListener()); engine.ExecutePipeline(new GracefulCancellationToken()); _cohortCreated = cohortRequest.CohortCreatedIfAny; } if (cbDefineCohort.Checked) { //associate the configuration with the cohort _configuration.Cohort_ID = _cohortCreated.ID; //set the pipeline to use var pipeline = (Pipeline)ddExtractionPipeline.SelectedItem; if (pipeline != null) { _configuration.DefaultPipeline_ID = pipeline.ID; } _configuration.SaveToDatabase(); //User defined cohort if it came from cic then associate the cic with the project if (cmdAssociateCicWithProject != null && !cmdAssociateCicWithProject.IsImpossible) { cmdAssociateCicWithProject.Execute(); } } Cursor = Cursors.Default; ExtractionConfigurationCreatedIfAny = _configuration; DialogResult = DialogResult.OK; MessageBox.Show("Project Created Successfully"); Close(); } catch (Exception exception) { ragExecute.Fatal(exception); } finally { Cursor = Cursors.Default; } }