예제 #1
0
        private void treeView1_ItemActivate(object sender, EventArgs e)
        {
            var o = treeView1.SelectedObject;

            if (o == null)
            {
                return;
            }

            if (o is ArchivalDataLoadInfo dli)
            {
                new ExecuteCommandViewLoggedData(Activator, new LogViewerFilter(LoggingTables.DataLoadRun)
                {
                    Run = dli.ID
                }).Execute();
            }
            else
            if (o is LoadEventsTreeView_Category cat)
            {
                new ExecuteCommandViewLoggedData(Activator, new LogViewerFilter(cat.AssociatedTable)
                {
                    Run = cat.RunId
                }).Execute();
            }
            else
            if (o is IHasSummary s)
            {
                WideMessageBox.Show(s);
            }
        }
예제 #2
0
        private void btnFetchData_Click(object sender, EventArgs e)
        {
            fetchDataResultedInNoErrors = true;
            var fetcher = new DiffDatabaseDataFetcher(_batchSizeToGet, _toInterrogate, _dataLoadRunID, _timeout);

            fetcher.FetchData(this);

            dgInserts.DataSource = fetcher.Inserts;

            if (fetcher.Updates_New == null || fetcher.Updates_Replaced == null)
            {
                diffDataTables1.Clear();
            }
            else
            {
                diffDataTables1.PopulateWith(fetcher.Updates_New, fetcher.Updates_Replaced);
            }

            //if user is already viewing the updates we will need to re-highlight
            if (tabControl1.SelectedTab == tpViewUpdates)
            {
                diffDataTables1.HighlightDiffCells();
            }

            //we didn't see any errors so probably everything was fine
            if (fetchDataResultedInNoErrors)
            {
                WideMessageBox.Show("Data Ready", "Data ready for you to view in the Inserts / Updates tabs", WideMessageBoxTheme.Help);
            }
        }
예제 #3
0
        public void ShowHelp(IActivateItems activator)
        {
            var typeDocs = activator.RepositoryLocator.CatalogueRepository.CommentStore;

            StringBuilder sb = new StringBuilder();

            string firstMatch = null;

            foreach (var c in Controls)
            {
                if (typeDocs.ContainsKey(c.GetType().Name))
                {
                    if (firstMatch == null)
                    {
                        firstMatch = c.GetType().Name;
                    }

                    sb.AppendLine(typeDocs.GetDocumentationIfExists(c.GetType().Name, false, true));
                    sb.AppendLine();
                }
            }

            if (sb.Length > 0)
            {
                WideMessageBox.Show(firstMatch, sb.ToString(), Environment.StackTrace, true, firstMatch, WideMessageBoxTheme.Help);
            }
        }
예제 #4
0
        private void DataGridView1OnCellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            if (e.Button == MouseButtons.Right)
            {
                var menu = new ContextMenuStrip();

                foreach (ExecuteCommandViewLoggedData cmd in GetCommands(e.RowIndex))
                {
                    ExecuteCommandViewLoggedData cmd1 = cmd;
                    var mi = new ToolStripMenuItem(cmd.GetCommandName(), null, (s, x) => cmd1.Execute());
                    menu.Items.Add(mi);
                }

                if (menu.Items.Count != 0)
                {
                    menu.Items.Add(new ToolStripSeparator());
                }

                menu.Items.Add("View as text", null, (s, ex) => WideMessageBox.Show("Full Text", dataGridView1.Rows[e.RowIndex]));

                menu.Show(Cursor.Position.X, Cursor.Position.Y);
            }
        }
예제 #5
0
        public void SetLookupTableInfo(TableInfo t, bool setComboBox = true)
        {
            if (t != null && t.IsTableValuedFunction)
            {
                WideMessageBox.Show("Lookup table not valid", "Table '" + t + "' is a TableValuedFunction, you cannot use it as a lookup table");
                return;
            }

            if (setComboBox)
            {
                cbxLookup.SelectedItem = t;
            }

            olvLookupColumns.ClearObjects();

            if (t != null)
            {
                olvLookupColumns.AddObjects(t.ColumnInfos);

                SetStage(LookupCreationStage.DragAPrimaryKey);

                pk1.IsValidGetter = c => c.TableInfo_ID == t.ID;
                pk2.IsValidGetter = c => c.TableInfo_ID == t.ID;
                pk3.IsValidGetter = c => c.TableInfo_ID == t.ID;

                fk1.IsValidGetter = c => c.TableInfo_ID != t.ID;
                fk2.IsValidGetter = c => c.TableInfo_ID != t.ID;
                fk3.IsValidGetter = c => c.TableInfo_ID != t.ID;
            }
            else
            {
                SetStage(LookupCreationStage.ChooseLookupTable);
            }
        }
예제 #6
0
        public void Test_WideMessageBox_LargeStrings()
        {
            StringBuilder sb = new StringBuilder();

            //send wide message box a million characters
            for (int i = 0; i < 1_000_000; i++)
            {
                sb.Append("f");
            }

            var s    = sb.ToString();
            var args = new WideMessageBoxArgs(s, s, s, s, WideMessageBoxTheme.Help);

            //it is important that the args retain the original length e.g. so user can copy to clipboard the text
            Assert.AreEqual(1_000_000, args.Title.Length);
            Assert.AreEqual(1_000_000, args.Message.Length);

            var wmb = new WideMessageBox(args);

            //pretend like we launched it
            LastUserInterfaceLaunched = wmb;

            //the title and body should be a reasonable length
            Assert.AreEqual(WideMessageBox.MAX_LENGTH_TITLE, GetControl <Label>().Single().Text.Length);
            Assert.AreEqual(WideMessageBox.MAX_LENGTH_BODY, GetControl <RichTextBox>().Single().Text.Length);

            //when shown on screen it should not go off the edge of the screen

            //find the widest screen
            var availableWidth = Screen.AllScreens.Select(sc => sc.Bounds.Width).Max();

            Assert.LessOrEqual(wmb.Width, availableWidth);
        }
예제 #7
0
        void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            WideMessageBox.Show("Full Text", dataGridView1.Rows[e.RowIndex]);
        }
예제 #8
0
        void lbCohortDatabaseTable_ButtonClick(object sender, CellClickEventArgs e)
        {
            var ecd = e.Model as ExtractableCohortDescription;

            if (e.Column == olvViewLog && ecd != null)
            {
                WideMessageBox.Show("Cohort audit log", ecd.Cohort.AuditLog, WideMessageBoxTheme.Help);
            }
        }
예제 #9
0
        private void btnPrimaryKeyCompositeHelp_Click(object sender, EventArgs e)
        {
            WideMessageBox.Show("Lookup help",
                                @"Usually you only need one primary key/foreign key relationship e.g. M=Male, F=Female in which z_GenderLookup..Sex is the primary key and Demography..PatientGender is the foreign key.  However sometimes you need additional lookup joins.

For example:
if the Drug Code 'TIB' is reused in Tayside and Fife healthboard with different meanings then the primary key/foreign key would of the Lookup table would have to be both the 'Code' (TIB) and the 'Prescribing Healthboard' (T or F).

Only define secondary columns if you really need them! if any of the key fields do not match between the Lookup table and the Dataset table then no lookup description will be recorded",
                                null, true, null, WideMessageBoxTheme.Help);
        }
예제 #10
0
파일: ProgressUI.cs 프로젝트: rkm/RDMP
        void olvProgressEvents_ItemActivate(object sender, EventArgs e)
        {
            var model = olvProgressEvents.SelectedObject as ProgressUIEntry;

            if (model != null)
            {
                if (model.Exception != null)
                {
                    ExceptionViewer.Show(model.Message, model.Exception, false);
                }
                else
                {
                    WideMessageBox.Show("Progress Message", model.Message, model.Args.StackTrace, false, theme: model.GetTheme());
                }
            }
        }
예제 #11
0
파일: ChecksUI.cs 프로젝트: lulzzz/RDMP
        void olvChecks_ItemActivate(object sender, EventArgs e)
        {
            var args = olvChecks.SelectedObject as CheckEventArgs;

            if (args != null)
            {
                if (args.Ex != null)
                {
                    ExceptionViewer.Show(args.Message, args.Ex);
                }
                else
                {
                    WideMessageBox.Show(args, false);
                }
            }
        }
예제 #12
0
        private void MenuBuilt(object sender, MenuBuiltEventArgs e)
        {
            var c = GetKey(e.Obj);

            if (c != null)
            {
                e.Menu.Items.Add(new ToolStripSeparator());

                e.Menu.Items.Add(
                    BuildItem("View Sql", c, a => !string.IsNullOrWhiteSpace(a.CountSQL),
                              a => WideMessageBox.Show($"Sql {c}", a.CountSQL, WideMessageBoxTheme.Help))
                    );


                e.Menu.Items.Add(
                    new ToolStripMenuItem("View Crash Message", null,
                                          (s, ev) => ViewCrashMessage(c))
                {
                    Enabled = c.CrashMessage != null
                });

                e.Menu.Items.Add(
                    new ToolStripMenuItem("View Build Log", null,
                                          (s, ev) => WideMessageBox.Show($"Build Log {c}", c.Log, WideMessageBoxTheme.Help)));

                e.Menu.Items.Add(
                    BuildItem("View Results", c, a => a.Identifiers != null,
                              a =>
                {
                    Activator.ShowWindow(new DataTableViewerUI(a.Identifiers, $"Results {c}"));
                })
                    );


                e.Menu.Items.Add(
                    BuildItem("Clear Cache", c, a => a.SubqueriesCached > 0,
                              a =>
                {
                    if (c is ICacheableTask cacheable)
                    {
                        ClearCacheFor(new[] { cacheable });
                    }
                })
                    );
            }
        }
예제 #13
0
        void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }

            var cmd = GetCommands(e.RowIndex).FirstOrDefault();

            if (cmd != null)
            {
                cmd.Execute();
            }
            else
            {
                WideMessageBox.Show("Full Text", dataGridView1.Rows[e.RowIndex]);
            }
        }
예제 #14
0
        public void Test_WideMessageBox_TinyStrings()
        {
            var args = new WideMessageBoxArgs("1", "2", "3", "4", WideMessageBoxTheme.Help);

            //it is important that the args retain the original length e.g. so user can copy to clipboard the text
            Assert.AreEqual(1, args.Title.Length);
            Assert.AreEqual(1, args.Message.Length);

            var wmb = new WideMessageBox(args);

            //pretend like we launched it
            LastUserInterfaceLaunched = wmb;

            //the title and body should be a reasonable length
            Assert.AreEqual(1, GetControl <Label>().Single().Text.Length);
            Assert.AreEqual(1, GetControl <RichTextBox>().Single().Text.Length);

            //dialog shouldn't go thinner than 600 pixels
            Assert.AreEqual(600, wmb.Width);
        }
예제 #15
0
        public override void Execute()
        {
            base.Execute();

            string title = null;
            string docs  = null;

            //get docs from masquerader if it has any
            if (_args.Masquerader != null)
            {
                title = GetTypeName(_args.Masquerader.GetType());
                docs  = Activator.RepositoryLocator.CatalogueRepository.CommentStore.GetTypeDocumentationIfExists(_args.Masquerader.GetType());
            }

            //if not get them from the actual class
            if (docs == null)
            {
                title = GetTypeName(_args.Model.GetType());

                var knows = _args.Model as IKnowWhatIAm;
                //does the class have state dependent alternative to xmldoc?
                if (knows != null)
                {
                    docs = knows.WhatIsThis(); //yes
                }
                else
                {
                    docs = Activator.RepositoryLocator.CatalogueRepository.CommentStore.GetTypeDocumentationIfExists(_args.Model.GetType());
                }
            }

            //if we have docs show them otherwise just the Type name
            if (docs != null)
            {
                WideMessageBox.ShowKeywordHelp(title, docs);
            }
            else
            {
                MessageBox.Show(title);
            }
        }
예제 #16
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);
        }
예제 #17
0
        /// <summary>
        /// Creates a new instance of the given RDMPCollectionUI specified by the Enum collectionToCreate at the specified dock position
        /// </summary>
        /// <param name="collectionToCreate"></param>
        /// <param name="position"></param>
        /// <returns></returns>
        public PersistableToolboxDockContent Create(RDMPCollection collectionToCreate, DockState position = DockState.DockLeft)
        {
            PersistableToolboxDockContent toReturn;
            RDMPCollectionUI collection;

            switch (collectionToCreate)
            {
            case RDMPCollection.Catalogue:
                collection = new CatalogueCollectionUI();
                toReturn   = Show(RDMPCollection.Catalogue, collection, "Catalogues", CatalogueIcons.Catalogue);
                break;

            case RDMPCollection.DataLoad:
                collection = new LoadMetadataCollectionUI();
                toReturn   = Show(RDMPCollection.DataLoad, collection, "Load Configurations", CatalogueIcons.LoadMetadata);
                break;

            case RDMPCollection.Tables:
                collection = new TableInfoCollectionUI();
                toReturn   = Show(RDMPCollection.Tables, collection, "Tables", CatalogueIcons.TableInfo);
                break;

            case RDMPCollection.DataExport:
                if (RepositoryLocator.DataExportRepository == null)
                {
                    WideMessageBox.Show("Data export database unavailable", "Cannot create DataExport Toolbox because DataExportRepository has not been set/created yet");
                    return(null);
                }

                collection = new DataExportCollectionUI();
                toReturn   = Show(RDMPCollection.DataExport, collection, "Data Export", CatalogueIcons.Project);
                break;

            case RDMPCollection.Cohort:
                collection = new CohortIdentificationCollectionUI();
                toReturn   = Show(RDMPCollection.Cohort, collection, "Cohort Builder", CatalogueIcons.CohortIdentificationConfiguration);
                break;

            case RDMPCollection.SavedCohorts:
                collection = new SavedCohortsCollectionUI();
                toReturn   = Show(RDMPCollection.SavedCohorts, collection, "Saved Cohorts", CatalogueIcons.AllCohortsNode);
                break;

            case RDMPCollection.Favourites:
                collection = new FavouritesCollectionUI();
                toReturn   = Show(RDMPCollection.Favourites, collection, "Favourites", CatalogueIcons.Favourite);
                break;

            default: throw new ArgumentOutOfRangeException("collectionToCreate");
            }

            toReturn.DockState = position;

            collection.SetItemActivator(ActivateItems);

            if (CollectionCreated != null)
            {
                CollectionCreated(this, new RDMPCollectionCreatedEventHandlerArgs(collectionToCreate));
            }

            return(toReturn);
        }
예제 #18
0
파일: ActivateItems.cs 프로젝트: HDRUK/RDMP
 public override void Show(string message)
 {
     WideMessageBox.Show("Message", message, Environment.StackTrace, true, null, WideMessageBoxTheme.Help);
 }
예제 #19
0
파일: ActivateItems.cs 프로젝트: HDRUK/RDMP
        public override bool DeleteWithConfirmation(IDeleteable deleteable)
        {
            var databaseObject = deleteable as DatabaseEntity;

            //If there is some special way of describing the effects of deleting this object e.g. Selected Datasets
            var customMessageDeletable = deleteable as IDeletableWithCustomMessage;

            if (databaseObject is Catalogue c)
            {
                if (c.GetExtractabilityStatus(RepositoryLocator.DataExportRepository).IsExtractable)
                {
                    if (YesNo("Catalogue must first be made non extractable before it can be deleted, mark non extractable?", "Make Non Extractable"))
                    {
                        var cmd = new ExecuteCommandChangeExtractability(this, c);
                        cmd.Execute();
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            if (databaseObject is AggregateConfiguration ac && ac.IsJoinablePatientIndexTable())
            {
                var users = ac.JoinableCohortAggregateConfiguration?.Users?.Select(u => u.AggregateConfiguration);
                if (users != null)
                {
                    users = users.ToArray();
                    if (users.Any())
                    {
                        WideMessageBox.Show("Cannot Delete", $"Cannot Delete '{ac.Name}' because it is linked to by the following AggregateConfigurations:{Environment.NewLine}{string.Join(Environment.NewLine,users)}");
                        return(false);
                    }
                }
            }

            string overrideConfirmationText = null;

            if (customMessageDeletable != null)
            {
                overrideConfirmationText = "Are you sure you want to " + customMessageDeletable.GetDeleteMessage() + "?";
            }

            //it has already been deleted before
            if (databaseObject != null && !databaseObject.Exists())
            {
                return(false);
            }

            string idText = "";

            if (databaseObject != null)
            {
                idText = " ID=" + databaseObject.ID;
            }

            if (databaseObject != null)
            {
                var exports = RepositoryLocator.CatalogueRepository.GetReferencesTo <ObjectExport>(databaseObject).ToArray();
                if (exports.Any(e => e.Exists()))
                {
                    if (YesNo("This object has been shared as an ObjectExport.  Deleting it may prevent you loading any saved copies.  Do you want to delete the ObjectExport definition?", "Delete ObjectExport"))
                    {
                        foreach (ObjectExport e in exports)
                        {
                            e.DeleteInDatabase();
                        }
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            if (
                YesNo(
                    overrideConfirmationText ?? ("Are you sure you want to delete '" + deleteable + "'?")
                    + Environment.NewLine + "(" + deleteable.GetType().Name + idText + ")",
                    "Delete " + deleteable.GetType().Name))
            {
                deleteable.DeleteInDatabase();

                if (databaseObject == null)
                {
                    var descendancy = CoreChildProvider.GetDescendancyListIfAnyFor(deleteable);
                    if (descendancy != null)
                    {
                        databaseObject = descendancy.Parents.OfType <DatabaseEntity>().LastOrDefault();
                    }
                }

                if (deleteable is IMasqueradeAs)
                {
                    databaseObject = databaseObject ?? ((IMasqueradeAs)deleteable).MasqueradingAs() as DatabaseEntity;
                }

                if (databaseObject == null)
                {
                    throw new NotSupportedException("IDeletable " + deleteable +
                                                    " was not a DatabaseObject and it did not have a Parent in it's tree which was a DatabaseObject (DescendancyList)");
                }

                RefreshBus.Publish(this, new RefreshObjectEventArgs(databaseObject)
                {
                    DeletedObjectDescendancy = CoreChildProvider.GetDescendancyListIfAnyFor(databaseObject)
                });

                return(true);
            }

            return(false);
        }
예제 #20
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);
                    }
                }
            }
        }
예제 #21
0
 public override void Execute()
 {
     base.Execute();
     WideMessageBox.Show(_title, _help, WideMessageBoxTheme.Help);
 }
        private void btnExecute_Click(object sender, EventArgs e)
        {
            var pipeline = CreateAndInitializePipeline();

            //if it is already executing
            if (btnExecute.Text == "Stop")
            {
                _cancel.Cancel();//set the cancellation token
                return;
            }

            btnExecute.Text = "Stop";

            _cancel = new CancellationTokenSource();

            //clear any old results
            progressUI1.Clear();

            if (PipelineExecutionStarted != null)
            {
                PipelineExecutionStarted(this, new PipelineEngineEventArgs(pipeline));
            }

            progressUI1.ShowRunning(true);

            bool      success   = false;
            Exception exception = null;

            //start a new thread
            Task t = new Task(() =>
            {
                try
                {
                    pipeline.ExecutePipeline(new GracefulCancellationToken(_cancel.Token, _cancel.Token));
                    success = true;
                }
                catch (Exception ex)
                {
                    fork.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Pipeline execution failed", ex));
                    exception = ex;
                }
            }



                              );

            t.ContinueWith(x =>
            {
                if (success)
                {
                    //if it successfully got here then Thread has run the engine to completion successfully
                    if (PipelineExecutionFinishedsuccessfully != null)
                    {
                        PipelineExecutionFinishedsuccessfully(this, new PipelineEngineEventArgs(pipeline));
                    }
                }

                progressUI1.ShowRunning(false);

                btnExecute.Text = "Execute"; //make it so user can execute again

                if (UserSettings.ShowPipelineCompletedPopup)
                {
                    if (success)
                    {
                        WideMessageBox.Show("Pipeline Completed", "Pipeline execution completed", WideMessageBoxTheme.Help);
                    }
                    else
                    {
                        var worst = progressUI1.GetWorst();

                        if (UserSettings.ShowPipelineCompletedPopup)
                        {
                            ExceptionViewer.Show("Pipeline crashed", exception ?? worst?.Exception);
                        }
                    }
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            t.Start();
        }
예제 #23
0
        public override void Execute()
        {
            base.Execute();

            var db = SelectDatabase("Import all Tables form Database...");

            if (db == null)
            {
                return;
            }


            ShareManager shareManager = new ShareManager(Activator.RepositoryLocator, LocalReferenceGetter);

            List <ICatalogue> catalogues = new List <ICatalogue>();

            //don't do any double importing!
            var existing      = Activator.RepositoryLocator.CatalogueRepository.GetAllObjects <TableInfo>();
            var ignoredTables = new List <TableInfo>();

            if (YesNo("Would you also like to import ShareDefinitions (metadata)?", "Import Metadata From File(s)"))
            {
                OpenFileDialog ofd = new OpenFileDialog()
                {
                    Multiselect = true
                };
                ofd.Filter = "Share Definitions|*.sd";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    foreach (var f in ofd.FileNames)
                    {
                        using (var stream = File.Open(f, FileMode.Open))
                        {
                            var newObjects = shareManager.ImportSharedObject(stream);

                            if (newObjects != null)
                            {
                                catalogues.AddRange(newObjects.OfType <ICatalogue>());
                            }
                        }
                    }
                }
            }

            bool generateCatalogues = false;

            if (YesNo("Would you like to try to guess non-matching Catalogues by Name?", "Guess by name"))
            {
                catalogues.AddRange(Activator.RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>());
            }
            else if (YesNo("Would you like to generate empty Catalogues for non-matching tables instead?", "Generate New Catalogues"))
            {
                generateCatalogues = true;
            }

            var married = new Dictionary <CatalogueItem, ColumnInfo>();

            TableInfo anyNewTable = null;

            foreach (DiscoveredTable discoveredTable in db.DiscoverTables(includeViews: false))
            {
                var collide = existing.FirstOrDefault(t => t.Is(discoveredTable));
                if (collide != null)
                {
                    ignoredTables.Add(collide);
                    continue;
                }

                var          importer = new TableInfoImporter(Activator.RepositoryLocator.CatalogueRepository, discoveredTable);
                TableInfo    ti;
                ColumnInfo[] cis;

                //import the table
                importer.DoImport(out ti, out cis);

                anyNewTable = anyNewTable ?? ti;

                //find a Catalogue of the same name (possibly imported from Share Definition)
                var matchingCatalogues = catalogues.Where(c => c.Name.Equals(ti.GetRuntimeName(), StringComparison.CurrentCultureIgnoreCase)).ToArray();

                //if theres 1 Catalogue with the same name
                if (matchingCatalogues.Length == 1)
                {
                    //we know we want to import all these ColumnInfos
                    var unmatched = new List <ColumnInfo>(cis);

                    //But hopefully most already have orphan CatalogueItems we can hook them together to
                    foreach (var cataItem in matchingCatalogues[0].CatalogueItems)
                    {
                        if (cataItem.ColumnInfo_ID == null)
                        {
                            var matches = cataItem.GuessAssociatedColumn(cis, allowPartial: false).ToArray();

                            if (matches.Length == 1)
                            {
                                cataItem.SetColumnInfo(matches[0]);
                                unmatched.Remove(matches[0]); //we married them together
                                married.Add(cataItem, matches[0]);
                            }
                        }
                    }

                    //is anyone unmarried? i.e. new ColumnInfos that don't have CatalogueItems with the same name
                    foreach (ColumnInfo columnInfo in unmatched)
                    {
                        var cataItem = new CatalogueItem(Activator.RepositoryLocator.CatalogueRepository, (Catalogue)matchingCatalogues[0], columnInfo.GetRuntimeName());
                        cataItem.ColumnInfo_ID = columnInfo.ID;
                        cataItem.SaveToDatabase();
                        married.Add(cataItem, columnInfo);
                    }
                }
                else if (generateCatalogues)
                {
                    new ForwardEngineerCatalogue(ti, cis).ExecuteForwardEngineering();
                }
            }

            if (married.Any() && YesNo("Found " + married.Count + " columns, make them all extractable?", "Make Extractable"))
            {
                foreach (var kvp in married)
                {
                    //yup thats how we roll, the database is main memory!
                    var ei = new ExtractionInformation(Activator.RepositoryLocator.CatalogueRepository, kvp.Key, kvp.Value, kvp.Value.Name);
                }
            }

            if (ignoredTables.Any())
            {
                WideMessageBox.Show("Ignored some tables", "Ignored " + ignoredTables.Count + " tables because they already existed as TableInfos:" + string.Join(Environment.NewLine, ignoredTables.Select(ti => ti.GetRuntimeName())));
            }

            if (anyNewTable != null)
            {
                Publish(anyNewTable);
                Emphasise(anyNewTable);
            }
        }
예제 #24
0
        private void olvComponents_CellRightClick(object sender, CellRightClickEventArgs e)
        {
            var model = (AdvertisedPipelineComponentTypeUnderContext)e.Model;

            ContextMenuStrip RightClickMenu = new ContextMenuStrip();

            if (model != null)
            {
                if (!model.IsCompatible())
                {
                    RightClickMenu.Items.Add("Component incompatible", null, (s, v) => WideMessageBox.Show(model.ToString(), model.GetReasonIncompatible(), WideMessageBoxTheme.Help));
                }
            }

            //show it
            if (RightClickMenu.Items.Count != 0)
            {
                RightClickMenu.Show(this, e.Location);
            }
        }
예제 #25
0
파일: ActivateItems.cs 프로젝트: rkm/RDMP
 public override void Show(string message)
 {
     WideMessageBox.Show("Message", message);
 }