Пример #1
0
        public PipelineWorkAreaUI(IActivateItems activator, IPipeline pipeline, IPipelineUseCase useCase, ICatalogueRepository catalogueRepository)
        {
            _activator           = activator;
            _pipeline            = pipeline;
            _useCase             = useCase;
            _catalogueRepository = catalogueRepository;

            InitializeComponent();

            olvComponents.BuildGroups(olvRole, SortOrder.Ascending);
            olvComponents.AlwaysGroupByColumn = olvRole;

            _pipelineDiagram = new PipelineDiagramUI();
            _pipelineDiagram.AllowSelection            = true;
            _pipelineDiagram.AllowReOrdering           = true;
            _pipelineDiagram.SelectedComponentChanged += _pipelineDiagram_SelectedComponentChanged;
            _pipelineDiagram.Dock = DockStyle.Fill;
            diagramPanel.Controls.Add(_pipelineDiagram);

            _arumentsCollection1      = new ArgumentCollectionUI();
            _arumentsCollection1.Dock = DockStyle.Fill;
            gbArguments.Controls.Add(_arumentsCollection1);

            olvComponents.RowFormatter += RowFormatter;
            var context = _useCase.GetContext();

            try
            {
                //middle and destination components
                var allComponentTypes = _catalogueRepository.MEF.GetGenericTypes(typeof(IDataFlowComponent <>), context.GetFlowType());

                //source components (list of all types with MEF exports of )
                var allSourceTypes = _catalogueRepository.MEF.GetGenericTypes(typeof(IDataFlowSource <>), context.GetFlowType());

                olvComponents.AddObjects(allComponentTypes.Select(t => new AdvertisedPipelineComponentTypeUnderContext(t, _useCase)).ToArray());
                olvComponents.AddObjects(allSourceTypes.Select(t => new AdvertisedPipelineComponentTypeUnderContext(t, useCase)).ToArray());
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show("Failed to get list of supported MEF components that could be added to the pipeline ", exception);
            }

            gbArguments.Enabled = false;
        }
Пример #2
0
        protected override ICoreChildProvider GetChildProvider()
        {
            //constructor call in base class
            if (PluginUserInterfaces == null)
            {
                return(null);
            }

            //Dispose the old one
            ICoreChildProvider temp = null;

            //prefer a linked repository with both
            if (RepositoryLocator.DataExportRepository != null)
            {
                try
                {
                    temp = new DataExportChildProvider(RepositoryLocator, PluginUserInterfaces.ToArray(), GlobalErrorCheckNotifier, CoreChildProvider as DataExportChildProvider);
                }
                catch (Exception e)
                {
                    ExceptionViewer.Show(e);
                }
            }

            //there was an error generating a data export repository or there was no repository specified

            //so just create a catalogue one
            if (temp == null)
            {
                temp = new CatalogueChildProvider(RepositoryLocator.CatalogueRepository, PluginUserInterfaces.ToArray(), GlobalErrorCheckNotifier, CoreChildProvider as CatalogueChildProvider);
            }

            // first time
            if (CoreChildProvider == null)
            {
                CoreChildProvider = temp;
            }
            else
            {
                CoreChildProvider.UpdateTo(temp);
            }

            return(CoreChildProvider);
        }
Пример #3
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (rbCreateNew.Checked)
            {
                try
                {
                    var dir = new DirectoryInfo(tbCreateNew.Text);

                    if (!dir.Exists)
                    {
                        dir.Create();
                    }

                    Result = LoadDirectory.CreateDirectoryStructure(dir.Parent, dir.Name).RootPath.FullName;

                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception exception)
                {
                    ExceptionViewer.Show(exception);
                }
            }

            if (rbUseExisting.Checked)
            {
                try
                {
                    var dir = new LoadDirectory(tbUseExisting.Text);
                    Result       = dir.RootPath.FullName;
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception exception)
                {
                    if (Activator.YesNo($"Path is invalid, use anyway? ({exception.Message})", "Invalid Path"))
                    {
                        Result       = tbUseExisting.Text;
                        DialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
            }
        }
Пример #4
0
        public void StartThisTaskOnly(IMapsDirectlyToDatabaseTable configOrContainer)
        {
            var task = Compiler.AddTask(configOrContainer, _globals);

            if (task.State == CompilationState.Crashed)
            {
                ExceptionViewer.Show("Task failed to build", task.CrashMessage);
                return;
            }
            //Cancel the task and remove it from the Compilers task list - so it no longer knows about it
            Compiler.CancelTask(task, true);

            RecreateAllTasks(false);

            task = Compiler.AddTask(configOrContainer, _globals);

            //Task is now in state NotScheduled so we can start it
            Compiler.LaunchSingleTask(task, _timeoutControls.Timeout, true);
        }
Пример #5
0
        private void SynchronizeANOConfiguration_Click(TableInfo tableInfo)
        {
            //let use check the TableInfo accurately reflects the underlying database first
            if (_activator.YesNo("Check that TableInfo is synchronized with underlying database first?", "Check database first?"))
            {
                try
                {
                    TableInfoSynchronizer synchronizer = new TableInfoSynchronizer(tableInfo);
                    bool isSynchronized = synchronizer.Synchronize(new ThrowImmediatelyCheckNotifier());
                    if (!isSynchronized)
                    {
                        MessageBox.Show("Unable to synchronize with ANO database because TableInfo is not synchronized with underlying database.");
                        return;
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(
                        "Unable to check synchronization of TableInfo with underlying database (this check must be performed before checking ANO synchronization):" +
                        exception.Message);
                    return;
                }
            }

            var ANOSynchronizer = new ANOTableInfoSynchronizer(tableInfo);

            try
            {
                ANOSynchronizer.Synchronize(new MakeChangePopup(new YesNoYesToAllDialog()));

                MessageBox.Show("ANO synchronization successful");
            }
            catch (ANOConfigurationException e)
            {
                ExceptionViewer.Show(e);
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show("Fatal error while attempting to synchronize (" + exception.Message + ")", exception);
            }

            Publish(tableInfo);
        }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        public void RemoveAll()
        {
            List <Guid> wGuids = new List <Guid>();

            foreach (DataGridViewRow row in grdLogs.Rows)
            {
                wGuids.Add((Guid)row.Cells["Id"].Value);
            }
            try
            {
                _Target.Remove(wGuids);
                currentEvents.Remove(wGuids);
                grdLogs.Refresh();
            }
            catch (Exception ex)
            {
                ExceptionViewer.Show(ex);
            }
        }
Пример #7
0
        private void AddExplicit(object value)
        {
            var role = DataFlowComponentVisualisation.GetRoleFor(value.GetType());

            var component = new DataFlowComponentVisualisation(role, value, null);

            flpPipelineDiagram.Controls.Add(component);//add the explicit component
            component.IsLocked = true;
            try
            {
                if (!_useCase.IsDesignTime)
                {
                    _useCase.GetContext().PreInitializeGeneric(new ThrowImmediatelyDataLoadEventListener(), component.Value, _useCase.GetInitializationObjects().ToArray());
                }
            }
            catch (Exception e)
            {
                ExceptionViewer.Show("PreInitialize failed on Explicit (locked component) " + component.Value.GetType().Name, e);
            }
        }
Пример #8
0
        private void btnDeleteCredentials_Click(object sender, EventArgs e)
        {
            try
            {
                if (_ticketingSystemConfiguration.DataAccessCredentials_ID != null)
                {
                    var toDelete = _ticketingSystemConfiguration.DataAccessCredentials;

                    if (Activator.YesNo("Confirm deleting Encrypted Credentials " + toDelete.Name + "?", "Confirm delete?"))
                    {
                        toDelete.DeleteInDatabase();
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionViewer.Show(ex);
            }
            RefreshUIFromDatabase();
        }
        void LoadMenuFile()
        {
            try
            {
                treeList2.BeginUpdate();
                menu = Health.Front.Bases.Helper.LoadMenuFromFile(@"dat\m_patient.xml");
                this.treeMenuBindingSource.DataSource = menu.ItemList;


                treeList2.RefreshDataSource();
                treeList2.EndUpdate();
            }
            catch (InvalidOperationException e)
            {
                ExceptionViewer.Show(e);
            }
            catch (Exception ex2)
            {
                ExceptionViewer.Show(ex2);
            }
        }
Пример #10
0
        public bool OnCheckPerformed(CheckEventArgs args)
        {
            //if there is a fix suggest it to the user
            if (args.ProposedFix != null)
            {
                return(ShowYesNoMessageBoxToApplyFix(_dialog, args.Message, args.ProposedFix));
            }

            //else show an Exception
            if (args.Ex != null)
            {
                ExceptionViewer.Show(args.Ex);
            }
            else
            if (args.Result == CheckResult.Fail)
            {
                WideMessageBox.Show(args.Message, "", environmentDotStackTrace: Environment.StackTrace);
            }

            return(false);
        }
Пример #11
0
        void LoadMenuFile()
        {
            try
            {
                treeList2.BeginUpdate();
                menu = Common.LoadMenuFromFile(@"m_patient.xml");
                this.treeMenuBindingSource.DataSource = menu.ItemList;


                treeList2.RefreshDataSource();
                treeList2.EndUpdate();
            }
            //catch (InvalidOperationException e)
            //{
            //    ExceptionViewer.Show(e);
            //}
            catch (Exception ex2)
            {
                ExceptionViewer.Show(ex2);
            }
        }
Пример #12
0
        public override void Execute()
        {
            base.Execute();

            Catalogue cata = _catalogueIfKnown;

            if (cata == null)
            {
                try
                {
                    //make sure they really wanted to do this?
                    if (YesNo(GetLookupConfirmationText(), "Create Lookup"))
                    {
                        //get them to pick a Catalogue the table provides descriptions for
                        if (!SelectOne(_lookupTableInfoIfKnown.Repository, out cata))
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                catch (Exception exception)
                {
                    ExceptionViewer.Show("Error creating Lookup", exception);
                    return;
                }
            }

            //they now deifnetly have a Catalogue!
            var t = Activator.Activate <LookupConfigurationUI, Catalogue>(cata);

            if (_lookupTableInfoIfKnown != null)
            {
                t.SetLookupTableInfo(_lookupTableInfoIfKnown);
            }
        }
Пример #13
0
        private void ClearCacheFor(ICacheableTask[] tasks)
        {
            var manager = new CachedAggregateConfigurationResultsManager(_queryCachingServer);

            int successes = 0;

            foreach (ICacheableTask t in tasks)
            {
                try
                {
                    t.ClearYourselfFromCache(manager);
                    Compiler.CancelTask(t, true);
                    successes++;
                }
                catch (Exception exception)
                {
                    ExceptionViewer.Show("Could not clear cache for task " + t, exception);
                }
            }

            RecreateAllTasks();
        }
        private void btnCreateKeyFile_Click(object sender, EventArgs e)
        {
            try
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.FileName        = "MyRDMPKey.key";
                sfd.Filter          = "*.key|RDMP RSA Parameters Key File";
                sfd.CreatePrompt    = true;
                sfd.CheckPathExists = true;

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    _location.CreateNewKeyFile(sfd.FileName);
                }

                SetEnabledness();
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show(exception);
            }
        }
Пример #15
0
        private void ddPrimaryConstraints_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (bSuppressChangeEvents)
            {
                return;
            }

            if (SelectedColumnItemValidator == null)
            {
                return;
            }

            bSuppressChangeEvents = true;

            if (ddPrimaryConstraints.Text == _noPrimaryConstraintText)
            {
                SelectedColumnItemValidator.PrimaryConstraint = null;
                ddConsequence.SelectedItem = Consequence.Missing;
            }
            else
            {
                try
                {
                    SelectedColumnItemValidator.PrimaryConstraint =
                        Validator.CreateConstraint(ddPrimaryConstraints.Text, (Consequence)ddConsequence.SelectedValue) as PrimaryConstraint;
                }
                catch (Exception ex)
                {
                    ExceptionViewer.Show("Failed to create PrimaryConstraint '" + ddPrimaryConstraints.Text + "'", ex);
                }
            }

            //Make consequence selection only possible if there is a priary constraint selected
            ddConsequence.Enabled = ddPrimaryConstraints.Text != _noPrimaryConstraintText;


            bSuppressChangeEvents = false;
            ObjectSaverButton1.Enable(true);
        }
        private void btnCreateSuiteWithTemplate_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Imaging Template|*.it";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    var yaml = File.ReadAllText(ofd.FileName);

                    var template = ImageTableTemplateCollection.LoadFrom(yaml);

                    CreateSuite(template);
                }
                catch (Exception exception)
                {
                    ExceptionViewer.Show(exception);
                }
            }
        }
Пример #17
0
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            if (_dqeServer == null)
            {
                var cmdCreateDb = new ExecuteCommandCreateNewExternalDatabaseServer(_activator, new DataQualityEnginePatcher(), PermissableDefaults.DQE);
                cmdCreateDb.Execute();
            }
            else
            {
                Exception ex;
                if (!_dqeServer.Discover(DataAccessContext.InternalDataProcessing).Server.RespondsWithinTime(5, out ex))
                {
                    ExceptionViewer.Show(ex);
                }
                else
                {
                    new ExecuteCommandRunDQEOnCatalogue(_activator, _catalogue).Execute();
                }
            }
        }
Пример #18
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (rbCreateNew.Checked)
            {
                try
                {
                    var dir = new DirectoryInfo(tbCreateNew.Text);

                    if (!dir.Exists)
                    {
                        dir.Create();
                    }

                    Result = LoadDirectory.CreateDirectoryStructure(dir.Parent, dir.Name);

                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception exception)
                {
                    ExceptionViewer.Show(exception);
                }
            }

            if (rbUseExisting.Checked)
            {
                try
                {
                    Result       = new LoadDirectory(tbUseExisting.Text);
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception exception)
                {
                    ExceptionViewer.Show(exception);
                }
            }
        }
Пример #19
0
        private void PickCatalogueAndLaunchForTableInfo(TableInfo tbl)
        {
            try
            {
                var dr = MessageBox.Show(
                    @"You have chosen to make '" + tbl + @"' a Lookup Table (e.g T = Tayside, F=Fife etc).  In order to do this you will need to pick which Catalogue the column
provides a description for (a given TableInfo can be a Lookup for many columns in many datasets)."
                    , "Create Lookup", MessageBoxButtons.OKCancel);

                if (dr == DialogResult.OK)
                {
                    Catalogue cata;
                    if (SelectOne(tbl.Repository, out cata))
                    {
                        Activator.ActivateLookupConfiguration(this, cata, tbl);
                    }
                }
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show("Error creating Lookup", exception);
            }
        }
Пример #20
0
        private void DragDropProvider_Dropped(object sender, OlvDropEventArgs e)
        {
            try
            {
                var dataObject = (DataObject)e.DataObject;

                if (dataObject is OLVDataObject)
                {
                    return;  //should be handled by ModelDropped
                }
                //is it a non model drop (in which case ModelDropped won't be called) e.g. it could be a file drop
                var execution = GetExecutionCommandIfAnyForNonModelObjects(dataObject, e.DropTargetItem.RowObject);

                if (execution != null && !execution.IsImpossible)
                {
                    execution.Execute();
                }
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show(exception);
            }
        }
Пример #21
0
        private void CallConstructor(ConstructorInfo constructorInfo)
        {
            List <object> parameterValues = new List <object>();

            foreach (var parameterInfo in constructorInfo.GetParameters())
            {
                var paramType = parameterInfo.ParameterType;

                var value = GetValueForParameterOfType(parameterInfo, paramType);

                //if it's a null and not a default null
                if (value == null && !parameterInfo.HasDefaultValue)
                {
                    throw new OperationCanceledException("Could not figure out a value for property '" + parameterInfo + "' for constructor '" + constructorInfo + "'.  Parameter Type was '" + paramType + "'");
                }

                parameterValues.Add(value);
            }

            var instance = (IAtomicCommand)constructorInfo.Invoke(parameterValues.ToArray());

            try
            {
                if (instance.IsImpossible)
                {
                    MessageBox.Show(instance.ReasonCommandImpossible);
                    return;
                }

                instance.Execute();
                Close();
            }
            catch (Exception e)
            {
                ExceptionViewer.Show(e);
            }
        }
Пример #22
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            try
            {
                var engine = new ForwardEngineerANOCatalogueEngine(Activator.RepositoryLocator, _planManager);
                engine.Execute();

                if (engine.NewCatalogue != null && engine.LoadMetadata != null)
                {
                    foreach (KeyValuePair <ITableInfo, QueryBuilder> sqls in engine.SelectSQLForMigrations)
                    {
                        CreateAttacher(sqls.Key, sqls.Value, engine.LoadMetadata, sqls.Key.IsLookupTable()? null:engine.LoadProgressIfAny);
                    }

                    foreach (KeyValuePair <PreLoadDiscardedColumn, IDilutionOperation> dilutionOps in engine.DilutionOperationsForMigrations)
                    {
                        CreateDilutionMutilation(dilutionOps, engine.LoadMetadata);
                    }

                    Publish(engine.NewCatalogue);

                    if (Activator.YesNo("Successfully created Catalogue '" + engine.NewCatalogue + "', close form?", "Success"))
                    {
                        Activator.WindowArranger.SetupEditAnything(this, engine.LoadMetadata);
                    }
                }
                else
                {
                    throw new Exception("Engine did not create a NewCatalogue/LoadMetadata");
                }
            }
            catch (Exception ex)
            {
                ExceptionViewer.Show(ex);
            }
        }
Пример #23
0
        private void btnCache_Click(object sender, EventArgs e)
        {
            try
            {
                CachedAggregateConfigurationResultsManager cacheManager = GetCacheManager();

                var args = new CacheCommitExtractableAggregate(AggregateConfiguration, QueryEditor.Text, (DataTable)dataGridView1.DataSource, Timeout);
                cacheManager.CommitResults(args);

                var result = cacheManager.GetLatestResultsTable(AggregateConfiguration, AggregateOperation.ExtractableAggregateResults, QueryEditor.Text);

                if (result == null)
                {
                    throw new NullReferenceException("CommitResults passed but GetLatestResultsTable returned false (when we tried to refetch the table name from the cache)");
                }

                MessageBox.Show("DataTable successfully submitted to:" + result.GetFullyQualifiedName());
                btnClearFromCache.Enabled = true;
            }
            catch (Exception exception)
            {
                ExceptionViewer.Show(exception);
            }
        }
Пример #24
0
        private void btnAddCatalogue_Click(object sender, EventArgs e)
        {
            var alreadyMappedCatalogues = olvCatalogues.Objects.Cast <Catalogue>();
            var allCatalogues           = Activator.RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>();

            var availableToSelect =
                allCatalogues.Where(c => !alreadyMappedCatalogues.Contains(c)).ToArray();

            SelectIMapsDirectlyToDatabaseTableDialog selector = new SelectIMapsDirectlyToDatabaseTableDialog(availableToSelect, false, false);

            selector.AllowMultiSelect = true;

            if (selector.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    AddCatalogues(selector.MultiSelected.Cast <Catalogue>().ToArray());
                }
                catch (Exception ex)
                {
                    ExceptionViewer.Show("Could not add relationship to Catalogue:" + selector.Selected, ex);
                }
            }
        }
Пример #25
0
        private DataTable LoadDatagridFor(Project value)
        {
            if (value == null)
            {
                return(null);
            }

            IExtractionConfiguration[] configurations = value.ExtractionConfigurations;

            if (configurations == null || configurations.Length == 0)
            {
                return(null);
            }

            DataTable dtToReturn = new DataTable();

            dtToReturn.Columns.Add("ID");
            dtToReturn.Columns.Add("Name");
            dtToReturn.Columns.Add("Date Created");
            dtToReturn.Columns.Add("Username");
            dtToReturn.Columns.Add("Status");
            dtToReturn.Columns.Add("Description");
            dtToReturn.Columns.Add("Separator");

            dtToReturn.Columns.Add("Cohort");

            dtToReturn.Columns.Add("RequestTicket");
            dtToReturn.Columns.Add("ReleaseTicket");
            dtToReturn.Columns.Add("ClonedFrom");


            dtToReturn.Columns.Add("Datasets");

            foreach (ExtractionConfiguration configuration in configurations)
            {
                DataRow r = dtToReturn.Rows.Add();

                r["ID"]           = configuration.ID;
                r["Name"]         = configuration.Name;
                r["Date Created"] = configuration.dtCreated;
                r["Username"]     = configuration.Username;

                if (configuration.IsReleased)
                {
                    r["Status"] = "Frozen (Because Released)";
                }
                else
                {
                    r["Status"] = "Editable";
                }

                r["Description"] = configuration.Description;
                r["Separator"]   = configuration.Separator;

                if (configuration.Cohort_ID == null)
                {
                    r["Cohort"] = "None";
                }
                else
                {
                    try
                    {
                        r["Cohort"] = configuration.Cohort.ToString();
                    }
                    catch (Exception ex)
                    {
                        ExceptionViewer.Show(ex);
                        r["Cohort"] = "Error retrieving Cohort";
                    }
                }

                r["RequestTicket"] = configuration.RequestTicket;
                r["ReleaseTicket"] = configuration.ReleaseTicket;
                r["ClonedFrom"]    = configuration.ClonedFrom_ID;


                r["Datasets"] =
                    string.Join(",", configuration.GetAllExtractableDataSets().Select(ds => ds.ToString()));
            }

            return(dtToReturn);
        }
Пример #26
0
        private void PopulateAsEmptyDescriptionsChart()
        {
            try
            {
                ExtractionInformation[] allExtractionInformation;

                if (!_collection.IsSingleCatalogueMode)
                {
                    //get the active (non depricated etc) Catalogues
                    var activeCatalogues = _activator.CoreChildProvider.AllCatalogues.Where(ShouldHaveDescription).ToArray();

                    //if there are some
                    if (activeCatalogues.Any())
                    {
                        allExtractionInformation = activeCatalogues.SelectMany(c => c.GetAllExtractionInformation(ExtractionCategory.Any)).ToArray();//get the extractable columns
                    }
                    else
                    {
                        allExtractionInformation = new ExtractionInformation[0];//there weren't any so Catalogues so wont be any ExtractionInformationsEither
                    }
                }
                else
                {
                    allExtractionInformation = _collection.GetSingleCatalogueModeCatalogue().GetAllExtractionInformation(ExtractionCategory.Any);
                }

                if (!allExtractionInformation.Any())
                {
                    chart1.DataSource   = null;
                    chart1.Visible      = false;
                    lblNoIssues.Visible = true;

                    return;
                }

                int countPopulated    = 0;
                int countNotPopulated = 0;

                foreach (ExtractionInformation information in allExtractionInformation)
                {
                    if (string.IsNullOrWhiteSpace(information.CatalogueItem.Description))
                    {
                        countNotPopulated++;
                    }
                    else
                    {
                        countPopulated++;
                    }
                }

                DataTable dt = new DataTable();
                dt.Columns.Add("Count");
                dt.Columns.Add("State");


                dt.Rows.Add(new object[] { countNotPopulated, "Missing (" + countNotPopulated + ")" });
                dt.Rows.Add(new object[] { countPopulated, "Populated (" + countPopulated + ")" });

                chart1.Series[0].XValueMember  = dt.Columns[1].ColumnName;
                chart1.Series[0].YValueMembers = dt.Columns[0].ColumnName;

                chart1.DataSource = dt;
                chart1.DataBind();
                chart1.Visible      = true;
                lblNoIssues.Visible = false;
            }
            catch (Exception e)
            {
                ExceptionViewer.Show(this.GetType().Name + " failed to load data", e);
            }
        }
Пример #27
0
 public override void ShowException(string errorText, Exception exception)
 {
     ExceptionViewer.Show(errorText, exception);
 }
Пример #28
0
 public void KillForm(Form f, string reason)
 {
     f.Close();
     ExceptionViewer.Show("Window Closed", reason);
 }
Пример #29
0
        private void UpdateValidityAssesment(bool actuallyDoIt)
        {
            btnCreateLookup.Enabled = false;
            ragSmiley1.Reset();

            try
            {
                if (pk1.SelectedColumn == null)
                {
                    throw new Exception("No Primary key column selected");
                }

                if (fk1.SelectedColumn == null)
                {
                    throw new Exception("No Foreign key column selected");
                }

                var allExtractionInformations       = olvExtractionInformations.Objects.Cast <ExtractionInformation>().ToArray();
                var foreignKeyExtractionInformation = allExtractionInformations.SingleOrDefault(e => e.ColumnInfo != null && e.ColumnInfo.Equals(fk1.SelectedColumn));

                if (foreignKeyExtractionInformation == null)
                {
                    throw new Exception("Foreign key column(s) must come from the Catalogue ExtractionInformation columns");
                }

                if ((pk2.SelectedColumn == null) != (fk2.SelectedColumn == null))
                {
                    throw new Exception("If you want to have secondary joins you must have them in pairs");
                }

                if ((pk3.SelectedColumn == null) != (fk3.SelectedColumn == null))
                {
                    throw new Exception("If you want to have secondary joins you must have them in pairs");
                }

                var p1 = pk1.SelectedColumn;
                var f1 = fk1.SelectedColumn;

                var p2 = pk2.SelectedColumn;
                var f2 = fk2.SelectedColumn;

                var p3 = pk3.SelectedColumn;
                var f3 = fk3.SelectedColumn;

                var uniqueIDs = new[] { p1, p2, p3, f1, f2, f3 }.Where(o => o != null).Select(c => c.ID).ToArray();

                if (uniqueIDs.Distinct().Count() != uniqueIDs.Count())
                {
                    throw new Exception("Columns can only appear once in any given key box");
                }

                if (new[] { p1, p2, p3 }.Where(o => o != null).Select(c => c.TableInfo_ID).Distinct().Count() != 1)
                {
                    throw new Exception("All primary key columns must come from the same Lookup table");
                }

                if (new[] { f1, f2, f3 }.Where(o => o != null).Select(c => c.TableInfo_ID).Distinct().Count() != 1)
                {
                    throw new Exception("All foreign key columns must come from the same Lookup table");
                }

                var descs = olvSelectedDescriptionColumns.Objects.Cast <ColumnInfo>().ToArray();

                if (!descs.Any())
                {
                    throw new Exception("You must have at least one Description column from the Lookup table");
                }

                if (descs.Any(d => d.TableInfo_ID != p1.TableInfo_ID))
                {
                    throw new Exception("All Description columns must come from the Lookup table");
                }

                if (actuallyDoIt)
                {
                    bool alsoCreateExtractionInformation =
                        Activator.YesNo(
                            "Also create a virtual extractable column(s) in '" + _catalogue + "' called '<Column>_Desc'",
                            "Create Extractable Column?");

                    var keyPairs = new List <Tuple <ColumnInfo, ColumnInfo> >();
                    keyPairs.Add(Tuple.Create(f1, p1));

                    if (p2 != null)
                    {
                        keyPairs.Add(Tuple.Create(f2, p2));
                    }

                    if (p3 != null)
                    {
                        keyPairs.Add(Tuple.Create(f3, p3));
                    }

                    var cmd = new ExecuteCommandCreateLookup(Activator.RepositoryLocator.CatalogueRepository, foreignKeyExtractionInformation, descs,
                                                             keyPairs, tbCollation.Text, alsoCreateExtractionInformation);

                    cmd.Execute();

                    Activator.RefreshBus.Publish(this, new RefreshObjectEventArgs(_catalogue));
                    SetDatabaseObject(Activator, _catalogue);

                    MessageBox.Show("Lookup created successfully, fields will now be cleared");
                    pk1.Clear();
                    pk2.Clear();
                    pk3.Clear();

                    fk1.Clear();
                    fk2.Clear();
                    fk3.Clear();

                    olvSelectedDescriptionColumns.ClearObjects();
                    SetStage(LookupCreationStage.DragAPrimaryKey);
                }
                btnCreateLookup.Enabled = true;
            }
            catch (Exception e)
            {
                if (actuallyDoIt)
                {
                    ExceptionViewer.Show(e);
                }

                ragSmiley1.Fatal(e);
            }
        }
Пример #30
0
        void olvSelectColumns_CellClick(object sender, CellClickEventArgs e)
        {
            if (e.Column == olvAddRemove)
            {
                var countColumn      = e.Model as AggregateCountColumn;
                var importableColumn = e.Model as ExtractionInformation;
                var dimensionColumn  = e.Model as AggregateDimension;

                if (countColumn == null && importableColumn == null && dimensionColumn == null)
                {
                    throw new Exception("Object in list view of type that wasn't IColumn, it was " + e.Model.GetType().Name);
                }

                //if it is an add
                if (_availableColumns.Contains(e.Model))
                {
                    //count column added
                    if (countColumn != null)
                    {
                        if (_options.GetCountColumnRequirement(_aggregate) == CountColumnRequirement.CannotHaveOne)
                        {
                            WideMessageBox.Show("Cohort Sets cannot have count columns", "A count column is a SELECT column with an aggregate function (count(*), sum(x) etc).  The SELECT component for cohort identification must be the patient id column only.");
                        }
                        else
                        {
                            Save(countColumn);
                        }
                    }

                    //regular column added
                    if (importableColumn != null)
                    {
                        var dimension = new AggregateDimension(Activator.RepositoryLocator.CatalogueRepository, importableColumn, _aggregate);

                        _availableColumns.Remove(importableColumn);
                        _includedColumns.Add(dimension);

                        olvSelectColumns.RemoveObject(importableColumn);
                        olvSelectColumns.AddObject(dimension);
                        olvSelectColumns.EnsureModelVisible(dimension);

                        Save(dimension);

                        //object doesn't exist, that might cause problems
                        return;
                    }
                }
                else
                {
                    //it is a removal

                    //user is trying to remove count column
                    if (countColumn != null)
                    {
                        if (_options.GetCountColumnRequirement(_aggregate) == CountColumnRequirement.MustHaveOne)
                        {
                            return; //leave it checked - removal is forbidden
                        }
                        _aggregate.CountSQL = "";
                        _aggregate.SaveToDatabase();
                        _includedColumns.Remove(countColumn);
                        _availableColumns.Add(countColumn);

                        olvSelectColumns.RemoveObject(countColumn);
                        olvSelectColumns.AddObject(countColumn);
                        olvSelectColumns.EnsureModelVisible(countColumn);

                        Activator.RefreshBus.Publish(this, new RefreshObjectEventArgs(_aggregate));
                    }


                    //user is trying to remove a dimension
                    if (dimensionColumn != null)
                    {
                        dimensionColumn.DeleteInDatabase();

                        //get the master it was based on
                        var extractionInformation = dimensionColumn.ExtractionInformation;
                        try
                        {
                            dimensionColumn.DeleteInDatabase();
                        }
                        catch (Exception ex)
                        {
                            //couldn't delete it so don't update the UI just tell the user why
                            ExceptionViewer.Show(ex);
                            return;
                        }

                        //remove it from the inclusion list
                        _includedColumns.Remove(dimensionColumn);
                        olvSelectColumns.RemoveObject(dimensionColumn);

                        //add the master importable version it was based on into available columns again
                        _availableColumns.Add(extractionInformation);
                        olvSelectColumns.AddObject(extractionInformation);

                        Save(extractionInformation);
                    }
                }
            }
        }