private void ApplyChanges()
        {
            var groupFields = _originalContext.MetadataStructure.Options.GroupFieldsByTypes;

            _originalContext.Assign(_sqlContext);
            _originalContext.MetadataStructure.Options.GroupFieldsByTypes = groupFields;
            _originalContext.MetadataStructure.Refresh();
        }
Пример #2
0
        } // createQueryBuilder(...)

        //
        internal void buildBindingList(bool loadDefaultDatabaseOnly, bool loadSystemObjects, bool withFields)
        {
            this._colQnBindingList = new BindingList <ColumnQN>();
            using (SQLContext sqlContext = new SQLContext())
            {
                sqlContext.Assign(this._qb.SQLContext);
                sqlContext.MetadataContainer.LoadingOptions.LoadDefaultDatabaseOnly = loadDefaultDatabaseOnly;
                sqlContext.MetadataContainer.LoadingOptions.LoadSystemObjects       = loadSystemObjects;

                using (MetadataList xList = new MetadataList(sqlContext.MetadataContainer))
                {
                    xList.Load(MetadataType.Server, false);
                    foreach (MetadataItem srv in xList)
                    {
                    }
                    xList.Load(MetadataType.Database, false);
                    foreach (MetadataItem db in xList)
                    {
                        using (MetadataList schemasList = new MetadataList(db))
                        {
                            schemasList.Load(MetadataType.Schema, false);
                            foreach (MetadataItem sch in schemasList)
                            {
                                using (MetadataList tablesList = new MetadataList(sch))
                                {
                                    tablesList.Load(MetadataType.Table, false);
                                    foreach (MetadataItem tbl in tablesList)
                                    {
                                        using (MetadataList columnsList = new MetadataList(tbl))
                                        {
                                            columnsList.Load(MetadataType.Field, false);

                                            foreach (MetadataItem col in columnsList)
                                            {
                                                MetadataItem mdi = col;
                                                this.TreatField(mdi);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } // buildBindingList(...)
        public void ApplyChanges()
        {
            if (Modified)
            {
                _sqlContextCopy.LoadingOptions.OfflineMode = cbOfflineMode.IsChecked.HasValue &&
                                                             cbOfflineMode.IsChecked.Value;

                if (_sqlContextCopy.LoadingOptions.OfflineMode)
                {
                    _sqlContextCopy.MetadataProvider?.Disconnect();

                    _sqlContext.Assign(_sqlContextCopy);
                }
                else
                {
                    _sqlContext.MetadataContainer.Items.Clear();
                }
            }
        }
Пример #4
0
        public OfflineModePage(QueryBuilder queryBuilder, BaseSyntaxProvider syntaxProvider)
        {
            _queryBuilder   = queryBuilder;
            _syntaxProvider = syntaxProvider;

            _sqlContext = new SQLContext();
            _sqlContext.Assign(queryBuilder.SQLContext);

            InitializeComponent();

            cbOfflineMode.Checked = queryBuilder.MetadataLoadingOptions.OfflineMode;

            UpdateMode();

            cbOfflineMode.CheckedChanged += checkOfflineMode_CheckedChanged;
            bEditMetadata.Click          += buttonEditMetadata_Click;
            bSaveToXML.Click             += buttonSaveToXML_Click;
            bLoadFromXML.Click           += buttonLoadFromXML_Click;
        }
        public OfflineModePage(SQLContext context)
        {
            _sqlContext     = context;
            _sqlContextCopy = new SQLContext();
            _sqlContextCopy.Assign(context);

            _openDialog = new OpenFileDialog
            {
                Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*",
                Title  = "Select XML file to load metadata from"
            };

            _saveDialog = new SaveFileDialog
            {
                Filter = "XML files (*.xml)|*.xml|All files (*.*)|*.*",
                Title  = "Select XML file to save metadata to"
            };

            //Modified = false;
            //_queryBuilder = queryBuilder;
            //_syntaxProvider = syntaxProvider;

            //_metadataContainerCopy = new MetadataContainer(queryBuilder.SQLContext);
            //_metadataContainerCopy.Assign(_queryBuilder.MetadataContainer);

            InitializeComponent();

            cbOfflineMode.IsChecked = _sqlContextCopy.LoadingOptions.OfflineMode;

            UpdateMode();

            cbOfflineMode.Checked   += checkOfflineMode_CheckedChanged;
            cbOfflineMode.Unchecked += checkOfflineMode_CheckedChanged;
            bEditMetadata.Click     += buttonEditMetadata_Click;
            bSaveToXML.Click        += buttonSaveToXML_Click;
            bLoadFromXML.Click      += buttonLoadFromXML_Click;
        }
        public MetadataContainerLoadWindow(object owner, MetadataContainer metadataContainer, BaseConnectionDescriptor connection = null)
        {
            Debug.Assert(metadataContainer != null);

            _owner = owner;

            _pages = new List <WizardPageInfo>();

            // store reference to edited object
            EditedMetadataContainer = metadataContainer;

            _initialConnection = connection;
            Connection         = connection;

            // create new SQLContext for loading
            _temporarySqlContext = new SQLContext();
            _temporarySqlContext.Assign(EditedMetadataContainer.SQLContext);

            // create temporary MetadataContainer
            TemporaryMetadataContainer             = new MetadataContainer(_temporarySqlContext);
            _temporarySqlContext.MetadataContainer = TemporaryMetadataContainer;

            TemporaryMetadataContainer.Assign(EditedMetadataContainer);
            TemporaryMetadataContainer.LoadingOptions = new MetadataLoadingOptions();
            TemporaryMetadataContainer.LoadingOptions.Assign(EditedMetadataContainer.LoadingOptions);

            InitializeComponent();

            // set up pages

            _wizardPageWelcome = new WelcomeWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageWelcome);

            _wizardPageConnectionType = new ConnectionTypeWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageConnectionType);

            _wizardPageMetadataOpts = new MetadataOptsWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageMetadataOpts);

            _wizardPageLoadOpts = new LoadOptsWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageLoadOpts);

            _wizardPageFilter = new FilterWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageFilter);

            _wizardPageLoading = new LoadingWizardPage {
                Visibility = Visibility.Collapsed
            };
            GridRoot.Children.Add(_wizardPageLoading);

            _pages.Add(new WizardPageInfo(ShowWelcome));
            _pages.Add(new WizardPageInfo(ShowConnection, CheckConnectionSelected));
            _pages.Add(new WizardPageInfo(ShowMetadataOpts, CheckShowMetadataOpts, true, BeforeMetadataOpts));
            _pages.Add(new WizardPageInfo(ShowLoadOpts, CheckLoadOpts, (_temporarySqlContext.SyntaxProvider != null && _temporarySqlContext.SyntaxProvider.IsSupportDatabases()), BeforeLoadOpts));
            _pages.Add(new WizardPageInfo(ShowFilter, CheckFilter));
            _pages.Add(new WizardPageInfo(ShowLoading));

            _currentPage = 0;

            _pages[_currentPage].ShowProc();

            _wizardPageMetadataOpts.bConnectionTest.Click += buttonConnectionTest_Click;
            _wizardPageConnectionType.ComboBoxConnectionType.SelectionChanged += cbConnectionType_SelectedIndexChanged;
            _wizardPageConnectionType.ComboBoxSyntaxProvider.SelectionChanged += ComboBoxSyntaxProvider_SelectedIndexChanged;

            bBack.Click += buttonBack_Click;
            bNext.Click += buttonNext_Click;

            Loaded += MetadataContainerLoadForm_Load;

            Localize();

            Loaded += MetadataContainerLoadForm_Loaded;

            var propertyLanguage =
                DependencyPropertyDescriptor.FromProperty(LanguageProperty, typeof(MetadataContainerLoadWindow));

            propertyLanguage.AddValueChanged(this, LanguagePropertyChanged);
        }
        public MetadataEditor()
        {
            InitializeComponent();
            CreateAndBindCommands();

            foreach (Type type in ActiveQueryBuilder.Core.Helpers.SyntaxProviderList)
            {
                if (type == typeof(AutoSyntaxProvider))
                {
                    continue;
                }

                var syntax = Activator.CreateInstance(type) as BaseSyntaxProvider;
                if (syntax != null)
                {
                    cbSyntaxProvider.Items.Add(syntax);
                }
            }

            metadataEditorControl.OpenContainerLoadFormIfNotConnected = true;
            metadataEditorControl.LoadStart  += LoadStart;
            metadataEditorControl.LoadFinish += LoadFinish;
            metadataEditorControl.LoadStep   += LoadStep;

            cbSyntaxProvider.SelectedIndexChanged += CbSyntaxProvider_SelectedIndexChanged;
            tsmiLoadFromDatabase.Click            += loadFromDatabaseToolStripMenuItem_Click;

            _subscriptions.Add(ActiveQueryBuilder.View.Helpers.Localizer.Subscribe(LocalizerOnLanguageChanged));


            UpdateLocalization();

            _originalContext = new SQLContext()
            {
                SyntaxProvider = new MSSQLSyntaxProvider()
            };
            _originalContext.MetadataContainer.LoadingOptions.OfflineMode = true;
            _originalContext.MetadataContainer.ImportFromXML("Northwind.xml");
            _sqlContext = new SQLContext();
            _sqlContext.Assign(_originalContext);

            if (_sqlContext.SyntaxProvider == null)
            {
                _sqlContext.SyntaxProvider = new GenericSyntaxProvider();
            }

            _sqlContext.SyntaxProviderChanged += SqlContext_SyntaxProviderChanged;

            foreach (var item in cbSyntaxProvider.Items)
            {
                if (item.GetType() == _sqlContext.SyntaxProvider.GetType())
                {
                    cbSyntaxProvider.SelectedIndexChanged -= CbSyntaxProvider_SelectedIndexChanged;
                    try
                    {
                        cbSyntaxProvider.SelectedItem = item;
                        break;
                    }
                    finally
                    {
                        cbSyntaxProvider.SelectedIndexChanged += CbSyntaxProvider_SelectedIndexChanged;
                    }
                }
            }

            metadataEditorControl.Init(_sqlContext);
        }
        public MetadataContainerLoadForm(MetadataContainer metadataContainer, BaseConnectionDescriptor connection = null)
        {
            Debug.Assert(metadataContainer != null);

            _pages = new List <WizardPageInfo>();

            // store reference to edited object
            EditedMetadataContainer = metadataContainer;

            _initialConnection = connection;
            _connection        = connection;

            // create new SQLContext for loading
            _temporarySQLContext = new SQLContext();
            _temporarySQLContext.Assign(EditedMetadataContainer.SQLContext);

            // create temporary MetadataContainer
            TemporaryMetadataContainer             = new MetadataContainer(_temporarySQLContext);
            _temporarySQLContext.MetadataContainer = TemporaryMetadataContainer;

            TemporaryMetadataContainer.Assign(EditedMetadataContainer);
            TemporaryMetadataContainer.LoadingOptions = new MetadataLoadingOptions();
            TemporaryMetadataContainer.LoadingOptions.Assign(EditedMetadataContainer.LoadingOptions);

            InitializeComponent();

            // set up pages

            _wizardPageWelcome = new WelcomeWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageWelcome);

            _wizardPageConnectionType = new ConnectionTypeWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageConnectionType);

            _wizardPageMetadataOpts = new MetadataOptsWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageMetadataOpts);

            _wizardPageLoadOpts = new LoadOptsWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageLoadOpts);

            _wizardPageFilter = new FilterWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageFilter);

            _wizardPageLoading = new LoadingWizardPage
            {
                Dock    = DockStyle.Fill,
                Visible = false
            };
            Controls.Add(_wizardPageLoading);

            _pages.Add(new WizardPageInfo(ShowWelcome));
            _pages.Add(new WizardPageInfo(ShowConnection, CheckConnectionSelected));
            _pages.Add(new WizardPageInfo(ShowMetadataOpts, CheckShowMetadataOpts, true, BeforeMetadataOpts));
            _pages.Add(new WizardPageInfo(ShowLoadOpts, CheckLoadOpts, (_temporarySQLContext.SyntaxProvider != null && _temporarySQLContext.SyntaxProvider.IsSupportDatabases()), BeforeLoadOpts));
            _pages.Add(new WizardPageInfo(ShowFilter, CheckFilter));
            _pages.Add(new WizardPageInfo(ShowLoading));

            _currentPage = 0;

            _pages[_currentPage].showProc();

            _wizardPageMetadataOpts.bConnectionTest.Click += buttonConnectionTest_Click;
            _wizardPageConnectionType.cbConnectionType.SelectedIndexChanged += cbConnectionType_SelectedIndexChanged;
            _wizardPageConnectionType.cbSyntax.SelectedIndexChanged         += cbSyntax_SelectedIndexChanged;

            bBack.Click += buttonBack_Click;
            bNext.Click += buttonNext_Click;

            Load += MetadataContainerLoadForm_Load;
        }
        public MetadataEditorStandalone()
        {
            InitializeComponent();

            CreateAndBindCommands();

            foreach (Type type in ActiveQueryBuilder.Core.Helpers.SyntaxProviderList)
            {
                if (type == typeof(AutoSyntaxProvider))
                {
                    continue;
                }

                var syntax = Activator.CreateInstance(type) as BaseSyntaxProvider;

                if (syntax != null)
                {
                    cbSyntaxProvider.Items.Add(syntax);
                }
            }

            MetadataEditor.OpenContainerLoadFormIfNotConnected = true;
            MetadataEditor.LoadStart  += LoadStart;
            MetadataEditor.LoadFinish += LoadFinish;
            MetadataEditor.LoadStep   += LoadStep;

            cbSyntaxProvider.SelectionChanged += CbSyntaxProvider_SelectedIndexChanged;
            tsmiLoadFromDatabase.Click        += loadFromDatabaseToolStripMenuItem_Click;

            Title = "Metadata Editor - Active Query Builder 3 for .NET";
            AddAboutMenuItem();
            Icon = Properties.Resources.application_form.GetImageSource();

            UpdateLocalization();

            _originalContext = new SQLContext()
            {
                SyntaxProvider = new MSSQLSyntaxProvider()
            };
            _originalContext.MetadataContainer.LoadingOptions.OfflineMode = true;
            _originalContext.MetadataContainer.ImportFromXML("Northwind.xml");

            _sqlContext = new SQLContext();
            _sqlContext.Assign(_originalContext);

            if (_sqlContext.SyntaxProvider == null)
            {
                _sqlContext.SyntaxProvider = new GenericSyntaxProvider();
            }

            _sqlContext.SyntaxProviderChanged += SqlContext_SyntaxProviderChanged;

            foreach (var item in cbSyntaxProvider.Items)
            {
                if (item.GetType() != _sqlContext.SyntaxProvider.GetType())
                {
                    continue;
                }

                cbSyntaxProvider.SelectionChanged -= CbSyntaxProvider_SelectedIndexChanged;
                try
                {
                    cbSyntaxProvider.SelectedItem = item;
                    break;
                }
                finally
                {
                    cbSyntaxProvider.SelectionChanged += CbSyntaxProvider_SelectedIndexChanged;
                }
            }

            MetadataEditor.Init(_sqlContext);
        }