void OnImportCompletedSuccessfully(object sender, PipelineEngineEventArgs u, CohortIdentificationConfiguration cic)
        {
            //see if we can associate the cic with the project
            var cmd = new ExecuteCommandAssociateCohortIdentificationConfigurationWithProject(BasicActivator).SetTarget((Project)Project).SetTarget(cic);

            //we can!
            if (!cmd.IsImpossible)
            {
                cmd.Execute();
            }
        }
Beispiel #2
0
        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;
            }
        }