Example #1
0
        public override IMapsDirectlyToDatabaseTable[] SelectMany(string prompt, Type arrayElementType,
                                                                  IMapsDirectlyToDatabaseTable[] availableObjects, string initialSearchText)
        {
            if (!availableObjects.Any())
            {
                MessageBox.Show("There are no '" + arrayElementType.Name + "' objects in your RMDP");
                return(null);
            }

            SelectIMapsDirectlyToDatabaseTableDialog selectDialog = new SelectIMapsDirectlyToDatabaseTableDialog(this, availableObjects, false, false);

            selectDialog.Text = prompt;
            selectDialog.SetInitialFilter(initialSearchText);
            selectDialog.AllowMultiSelect = true;

            if (selectDialog.ShowDialog() == DialogResult.OK)
            {
                var ms       = selectDialog.MultiSelected.ToList();
                var toReturn = Array.CreateInstance(arrayElementType, ms.Count);

                for (int i = 0; i < ms.Count; i++)
                {
                    toReturn.SetValue(ms[i], i);
                }

                return((IMapsDirectlyToDatabaseTable[])toReturn);
            }

            return(null);
        }
Example #2
0
        private void btnAddExtractableDatasetPackage_Click(object sender, EventArgs e)
        {
            var dataExportChildProvider = _activator.CoreChildProvider as DataExportChildProvider;

            if (dataExportChildProvider == null)
            {
                return;
            }

            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(Activator, dataExportChildProvider.AllPackages, false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var packageToAdd = (ExtractableDataSetPackage)dialog.Selected;

                var contents = _activator.RepositoryLocator.DataExportRepository.PackageManager.GetAllDataSets(packageToAdd, dataExportChildProvider.ExtractableDataSets);

                foreach (var cata in contents.Select(ds => ds.Catalogue))
                {
                    if (!_collection.GetCatalogues().Contains(cata))
                    {
                        AddCatalogue((Catalogue)cata);
                    }
                }

                SaveCollectionChanges();
                GenerateChart();
            }
        }
Example #3
0
        private object PickMany(ParameterInfo parameterInfo, Type arrayElementType, IMapsDirectlyToDatabaseTable[] availableObjects)
        {
            if (!availableObjects.Any())
            {
                MessageBox.Show("There are no '" + arrayElementType.Name + "' objects in your RMDP");
                return(null);
            }

            SelectIMapsDirectlyToDatabaseTableDialog selectDialog = new SelectIMapsDirectlyToDatabaseTableDialog(availableObjects, false, false);

            selectDialog.Text             = parameterInfo.Name;
            selectDialog.AllowMultiSelect = true;


            if (selectDialog.ShowDialog() == DialogResult.OK)
            {
                var ms       = selectDialog.MultiSelected.ToList();
                var toReturn = Array.CreateInstance(arrayElementType, ms.Count);

                for (int i = 0; i < ms.Count; i++)
                {
                    toReturn.SetValue(ms[i], i);
                }

                return(toReturn);
            }


            return(null);
        }
Example #4
0
        /// <summary>
        /// Prompts user to select 1 of the objects of type T in the list you provide, returns true if they made a non null selection
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="availableObjects"></param>
        /// <param name="selected"></param>
        /// <param name="initialSearchText"></param>
        /// <param name="allowAutoSelect">True to silently auto select the object if there are only 1 <paramref name="availableObjects"/></param>
        /// <returns></returns>
        protected bool SelectOne <T>(IList <T> availableObjects, out T selected, string initialSearchText = null, bool allowAutoSelect = false) where T : DatabaseEntity
        {
            //if theres only one object available to select
            if (availableObjects.Count == 1)
            {
                if (allowAutoSelect || YesNo("You only have one compatible object, use '" + availableObjects[0] + "'", "Select '" + availableObjects[0] + "'?"))
                {
                    selected = availableObjects[0];
                    return(true);
                }
                else
                {
                    selected = null;
                    return(false);
                }
            }


            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(availableObjects, false, false);

            dialog.SetInitialFilter(initialSearchText);

            selected = dialog.ShowDialog() == DialogResult.OK? (T)dialog.Selected:null;

            return(selected != null);
        }
Example #5
0
        public override IMapsDirectlyToDatabaseTable SelectOne(string prompt, IMapsDirectlyToDatabaseTable[] availableObjects,
                                                               string initialSearchText = null, bool allowAutoSelect = false)
        {
            if (!availableObjects.Any())
            {
                MessageBox.Show("There are no compatible objects in your RMDP for '" + prompt + "''");
                return(null);
            }

            //if there is only one object available to select
            if (availableObjects.Length == 1)
            {
                if (allowAutoSelect || YesNo("You only have one compatible object, use '" + availableObjects[0] + "'", "Select '" + availableObjects[0] + "'?"))
                {
                    return(availableObjects[0]);
                }
                else
                {
                    return(null);
                }
            }

            SelectIMapsDirectlyToDatabaseTableDialog selectDialog = new SelectIMapsDirectlyToDatabaseTableDialog(this, availableObjects, false, false);

            selectDialog.Text = prompt;
            selectDialog.SetInitialFilter(initialSearchText);


            if (selectDialog.ShowDialog() == DialogResult.OK)
            {
                return(selectDialog.Selected);
            }

            return(null); //user didn't select one of the IMapsDirectlyToDatabaseTable objects shown in the dialog
        }
Example #6
0
        private void ChooseHijacker()
        {
            var others
                =
                    //get all configurations
                    _aggregate.Repository.GetAllObjects <AggregateConfiguration>().Where(a =>
                                                                                         //which are not themselves already shortcuts!
                                                                                         a.OverrideFiltersByUsingParentAggregateConfigurationInstead_ID == null
                                                                                         &&
                                                                                         //and which have a filter set!
                                                                                         a.RootFilterContainer_ID != null)
                    //and are not ourself!
                    .Except(new[] { _aggregate }).ToArray();

            SelectIMapsDirectlyToDatabaseTableDialog dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_activator, others, true, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.Selected == null)
                {
                    _aggregate.OverrideFiltersByUsingParentAggregateConfigurationInstead_ID = null;
                }
                else
                {
                    _aggregate.OverrideFiltersByUsingParentAggregateConfigurationInstead_ID =
                        ((AggregateConfiguration)dialog.Selected).ID;
                }

                _aggregate.SaveToDatabase();
                Publish(_aggregate);
            }
        }
Example #7
0
        private void btnPickDatabaseEntities_Click(object sender, EventArgs e)
        {
            var type        = _args.Type;
            var elementType = type.GetElementType();

            if (elementType == null)
            {
                throw new NotSupportedException("No array element existed for DemandsInitialization Type " + type);
            }

            if (!_args.CatalogueRepository.SupportsObjectType(elementType))
            {
                throw new NotSupportedException("CatalogueRepository does not support element " + elementType + " for DemandsInitialization Type " + type);
            }

            var objects = _args.CatalogueRepository.GetAllObjects(elementType);
            var dialog  = new SelectIMapsDirectlyToDatabaseTableDialog(objects, true, false);

            dialog.AllowMultiSelect = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var result = dialog.MultiSelected == null ? null : dialog.MultiSelected.ToArray();
                _args.Setter(result);
                SetUp(result);
            }
        }
Example #8
0
        private void btnImportCatalogues_Click(object sender, EventArgs e)
        {
            GovernancePeriod[] toImportFrom = Activator.RepositoryLocator.CatalogueRepository.GetAllObjects <GovernancePeriod>()
                                              .Where(gov => gov.ID != _governancePeriod.ID)
                                              .ToArray();

            if (!toImportFrom.Any())
            {
                MessageBox.Show("You do not have any other GovernancePeriods in your Catalogue");
                return;
            }

            SelectIMapsDirectlyToDatabaseTableDialog dialog = new SelectIMapsDirectlyToDatabaseTableDialog(toImportFrom, false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                ICatalogue[] toAdd = ((GovernancePeriod)dialog.Selected).GovernedCatalogues.ToArray();

                //do not add any we already have
                toAdd = toAdd.Except(olvCatalogues.Objects.Cast <Catalogue>()).ToArray();

                if (!toAdd.Any())
                {
                    MessageBox.Show("Selected GovernancePeriod '" + dialog.Selected +
                                    "' does not govern any novel Catalogues (Catalogues already in your configuration are not repeat imported)");
                }
                else
                {
                    AddCatalogues(toAdd);

                    Publish(_governancePeriod);
                }
            }
        }
Example #9
0
        private void btnExisting_Click(object sender, EventArgs e)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(Activator.RepositoryLocator.DataExportRepository.GetAllObjects <Project>(), false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                SetProject((Project)dialog.Selected);
            }
        }
Example #10
0
        private void lPick_Click(object sender, System.EventArgs e)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_available.Cast <IMapsDirectlyToDatabaseTable>(), false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                suggestComboBox1.SelectedItem = dialog.Selected;
            }
        }
Example #11
0
        private void btnChooseRightTableInfo_Click(object sender, EventArgs e)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(Activator, _leftTableInfo.Repository.GetAllObjects <TableInfo>().Where(t => t.ID != _leftTableInfo.ID), false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                SetRightTableInfo((TableInfo)dialog.Selected);
            }
        }
Example #12
0
        private void btnPick_Click(object sender, EventArgs e)
        {
            var available = cbxCatalogues.Items.OfType <Catalogue>();
            var dialog    = new SelectIMapsDirectlyToDatabaseTableDialog(available, false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                cbxCatalogues.SelectedItem = dialog.Selected;
            }
        }
Example #13
0
        private void lblPickPivotColumn_Click(object sender, EventArgs e)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_catalogue.GetAllExtractionInformation(ExtractionCategory.Any), true, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var ei = dialog.Selected as ExtractionInformation;
                cbxPivotColumn.SelectedItem = ei;
                SetPivot(ei);
            }
        }
        private void AddDatasetsToConfiguration()
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_importableDataSets, false, false);

            dialog.AllowMultiSelect = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                new ExecuteCommandAddDatasetsToConfiguration(_activator, new ExtractableDataSetCommand(dialog.MultiSelected.Cast <ExtractableDataSet>().ToArray()), _extractionConfiguration).Execute();
            }
        }
Example #15
0
        private IFilter ImportOneFromSelection(IContainer containerToImportOneInto, IFilter[] filtersThatCouldBeImported, ISqlParameter[] globalParameters, IFilter[] otherFiltersInScope)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(filtersThatCouldBeImported, false, false);

            if (dialog.ShowDialog() == DialogResult.OK && dialog.Selected != null)
            {
                var chosenFilter = (IFilter)dialog.Selected;
                return(Import(containerToImportOneInto, chosenFilter, globalParameters, otherFiltersInScope));
            }

            return(null);//user chose not to import anything
        }
Example #16
0
        private void btnPick_Click(object sender, EventArgs e)
        {
            var available = cbxCatalogues.Items.OfType <Catalogue>();
            var dialog    = new SelectIMapsDirectlyToDatabaseTableDialog(Activator, available, false, false);

            dialog.AllowMultiSelect = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                SetCatalogueSelection(dialog.MultiSelected.OfType <ICatalogue>().ToArray());
            }
        }
        public override void Execute()
        {
            base.Execute();

            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_compatibleCohorts.Where(c => c.ID != _extractionConfiguration.Cohort_ID), false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                //clear current one
                _extractionConfiguration.Cohort_ID = ((ExtractableCohort)dialog.Selected).ID;
                _extractionConfiguration.SaveToDatabase();
                Publish(_extractionConfiguration);
            }
        }
Example #18
0
        private void btnViewDataTable_Click(object sender, EventArgs e)
        {
            var navigateTo = new SelectIMapsDirectlyToDatabaseTableDialog(Activator, GetCatalogueItems().Where(ci => string.IsNullOrWhiteSpace(ci.Description)), false, false);

            navigateTo.Show();

            navigateTo.Closed += (o, args) =>
            {
                if (navigateTo.DialogResult == DialogResult.OK)
                {
                    var cmd = new ExecuteCommandShow(Activator, navigateTo.Selected, 1);
                    cmd.Execute();
                }
            };
        }
Example #19
0
        private void btnSingleCatalogue_Click(object sender, EventArgs e)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_activator.RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>(), false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var c = (Catalogue)dialog.Selected;
                _collection.SetSingleCatalogueMode(c);

                btnAllCatalogues.Checked   = false;
                btnSingleCatalogue.Checked = true;

                SaveCollectionChanges();
                GenerateChart();
            }
        }
Example #20
0
        private void btnPick_Click(object sender, EventArgs e)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_activator, _objectsForComboBox.Cast <IMapsDirectlyToDatabaseTable>(), true, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (dialog.Selected == null)
                {
                    cbxValue.Text = ClearSelection;
                }
                else
                {
                    cbxValue.SelectedItem = dialog.Selected;
                }
            }
        }
Example #21
0
        private void btnPickProject_Click(object sender, EventArgs e)
        {
            if (_projectSpecific != null)
            {
                SelectProject(null);
            }
            else
            {
                var all    = Activator.RepositoryLocator.DataExportRepository.GetAllObjects <Project>();
                var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(all, false, false);

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    SelectProject((Project)dialog.Selected);
                }
            }
        }
Example #22
0
        private void UseExisting(object sender, EventArgs e)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_availableServers, false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var selected = (ExternalDatabaseServer)dialog.Selected;

                if (selected != null)
                {
                    _tableInfo.IdentifierDumpServer_ID = selected.ID;
                    _tableInfo.SaveToDatabase();

                    _activator.RefreshBus.Publish(this, new RefreshObjectEventArgs((TableInfo)_tableInfo));
                }
            }
        }
Example #23
0
        protected bool SelectMany <T>(T[] available, out T[] selected, string initialSearchText = null) where T : DatabaseEntity
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(available, false, false);

            dialog.AllowMultiSelect = true;
            dialog.SetInitialFilter(initialSearchText);
            dialog.ShowDialog();

            if (dialog.DialogResult != DialogResult.OK)
            {
                selected = null;
                return(false);
            }

            selected = dialog.MultiSelected.Cast <T>().ToArray();
            return(true);
        }
Example #24
0
        private void AddCredentialPermission(TableInfo tableInfo)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_availableCredentials, false, false);

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var cmd     = new DataAccessCredentialsCommand((DataAccessCredentials)dialog.Selected);
                var execute = new ExecuteCommandUseCredentialsToAccessTableInfoData(_activator, cmd, tableInfo);

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

                execute.Execute();
            }
        }
Example #25
0
        private void btnAddCatalogue_Click(object sender, EventArgs e)
        {
            var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_activator, _activator.RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>().Except(_collection.GetCatalogues()), false, false);

            dialog.AllowMultiSelect = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                var selectedCatalogues = dialog.MultiSelected;
                foreach (var catalogue in selectedCatalogues)
                {
                    AddCatalogue((Catalogue)catalogue);
                }

                SaveCollectionChanges();
                GenerateChart();
            }
        }
Example #26
0
        private void btnPick_Click(object sender, EventArgs e)
        {
            var dlg = new SelectIMapsDirectlyToDatabaseTableDialog(Activator,
                                                                   cbxDatasets.Items.Cast <ExtractableDataSet>().ToArray(), false, false);

            foreach (var eds in this._selectedDatasets)
            {
                dlg.MultiSelected.Add(eds);
            }

            dlg.AllowMultiSelect = true;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                _selectedDatasets = dlg.MultiSelected.Cast <ExtractableDataSet>().ToArray();
            }

            UpdateDatasetControlVisibility();
        }
Example #27
0
        private object PickOne(ParameterInfo parameterInfo, Type paramType, IMapsDirectlyToDatabaseTable[] availableObjects)
        {
            if (!availableObjects.Any())
            {
                MessageBox.Show("There are no '" + paramType.Name + "' objects in your RMDP");
                return(null);
            }

            SelectIMapsDirectlyToDatabaseTableDialog selectDialog = new SelectIMapsDirectlyToDatabaseTableDialog(availableObjects, false, false);

            selectDialog.Text = parameterInfo.Name;

            if (selectDialog.ShowDialog() == DialogResult.OK)
            {
                return(selectDialog.Selected);
            }

            return(null); //user didn't select one of the IMapsDirectlyToDatabaseTable objects shown in the dialog
        }
Example #28
0
        private void AddAggregates(AggregateConfiguration[] userCanPickFrom)
        {
            SelectIMapsDirectlyToDatabaseTableDialog dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_activator, userCanPickFrom, false, false);

            dialog.AllowMultiSelect = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (!dialog.MultiSelected.Any())
                {
                    return;
                }

                PopupChecksUI checks = new PopupChecksUI("Adding Aggregate(s)", true);


                foreach (AggregateConfiguration aggregateConfiguration in dialog.MultiSelected)
                {
                    try
                    {
                        var cmd          = new AggregateConfigurationCombineable(aggregateConfiguration);
                        var cmdExecution = new ExecuteCommandAddAggregateConfigurationToCohortIdentificationSetContainer(_activator, cmd, _container);
                        if (cmdExecution.IsImpossible)
                        {
                            checks.OnCheckPerformed(
                                new CheckEventArgs(
                                    "Could not add AggregateConfiguration " + aggregateConfiguration + " because of Reason:" +
                                    cmdExecution.ReasonCommandImpossible, CheckResult.Fail));
                        }
                        else
                        {
                            cmdExecution.Execute();
                            checks.OnCheckPerformed(new CheckEventArgs("Successfully added AggregateConfiguration " + aggregateConfiguration, CheckResult.Success));
                        }
                    }
                    catch (Exception e)
                    {
                        checks.OnCheckPerformed(new CheckEventArgs("Failed to add AggregateConfiguration " + aggregateConfiguration + "(see Exception for details)", CheckResult.Fail, e));
                    }
                }
            }
        }
Example #29
0
        private void AddCatalogues()
        {
            SelectIMapsDirectlyToDatabaseTableDialog dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_activator, RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>(), false, false);

            dialog.AllowMultiSelect = true;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                if (!dialog.MultiSelected.Any())
                {
                    return;
                }

                PopupChecksUI checks = new PopupChecksUI("Adding Catalogues", true);


                foreach (Catalogue catalogue in dialog.MultiSelected)
                {
                    try
                    {
                        var cmd          = new CatalogueCombineable(catalogue);
                        var cmdExecution = new ExecuteCommandAddCatalogueToCohortIdentificationSetContainer(_activator, cmd, _container);
                        if (cmdExecution.IsImpossible)
                        {
                            checks.OnCheckPerformed(
                                new CheckEventArgs(
                                    "Could not add Catalogue " + catalogue + " because of Reason:" +
                                    cmdExecution.ReasonCommandImpossible, CheckResult.Fail));
                        }
                        else
                        {
                            cmdExecution.Execute();
                            checks.OnCheckPerformed(new CheckEventArgs("Successfully added Catalogue " + catalogue, CheckResult.Success));
                        }
                    }
                    catch (Exception e)
                    {
                        checks.OnCheckPerformed(new CheckEventArgs("Failed to add Catalogue " + catalogue + "(see Exception for details)", CheckResult.Fail, e));
                    }
                }
            }
        }
Example #30
0
        private void btnPackage_Click(object sender, EventArgs e)
        {
            var dlg = new SelectIMapsDirectlyToDatabaseTableDialog(Activator,
                                                                   Activator.RepositoryLocator.DataExportRepository.GetAllObjects <ExtractableDataSetPackage>(), false, false);

            dlg.AllowMultiSelect = true;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                _selectedDatasets = dlg.MultiSelected
                                    .Cast <ExtractableDataSetPackage>()
                                    .SelectMany(p =>
                                                Activator.RepositoryLocator.DataExportRepository.PackageManager.GetAllDataSets(p,
                                                                                                                               cbxDatasets.Items.Cast <ExtractableDataSet>().ToArray()))
                                    .Distinct()
                                    .ToArray();
            }

            UpdateDatasetControlVisibility();
        }