Example #1
0
        /// <summary>The exec load database details.</summary>
        /// <returns>The exec load database details.</returns>
        private bool ExecLoadDatabaseDetails()
        {
            bool   populate   = false;
            string connection = string.Empty;
            bool   success    = false;

            try
            {
                _hostWindow.SetPointerState(Cursors.WaitCursor);
                if (_metaDataService == null)
                {
                    _metaDataService = DatabaseMetaDataService.Create(_services.Settings.ConnectionDefinition.ProviderName);
                }

                connection = _metaDataService.GetDescription();
                populate   = true;
            }
            catch (Exception exp)
            {
                string msg = string.Format(
                    "{0}\r\n\r\nCheck the connection and select 'Reset Database Connection'.",
                    exp.Message);
                _hostWindow.DisplaySimpleMessageBox(_hostWindow.Instance, msg, "DB Connection Error");
                _hostWindow.SetStatus(this, exp.Message);
            }
            finally
            {
                _hostWindow.SetPointerState(Cursors.Default);
            }

            if (populate)
            {
                try
                {
                    _hostWindow.SetPointerState(Cursors.WaitCursor);
                    _model = _metaDataService.GetDbObjectModel(_services.Settings.ConnectionDefinition.ConnectionString);
                }
                finally
                {
                    _hostWindow.SetPointerState(Cursors.Default);
                }

                BuildTreeFromDbModel(connection);
                _hostWindow.SetStatus(this, string.Empty);
                success = true;
            }
            else
            {
                _populated = false;
                DatabaseTreeView.CollapseAll();
            }

            return(success);
        }
Example #2
0
        /// <summary>The get tables and views.</summary>
        private void GetTablesAndViews()
        {
            if (_metaDataService == null)
            {
                _metaDataService = DatabaseMetaDataService.Create(_services.Settings.ConnectionDefinition.ProviderName);

                DbModelInstance model      = _metaDataService.GetDbObjectModel(_services.Settings.ConnectionDefinition.ConnectionString);
                List <string>   tableNames = new List <string>();
                foreach (DbModelTable table in model.Tables)
                {
                    tableNames.Add(Utility.MakeSqlFriendly(table.FullName));
                }

                foreach (DbModelView view in model.Views)
                {
                    tableNames.Add(Utility.MakeSqlFriendly(view.FullName));
                }

                cboTableName.Items.AddRange(tableNames.ToArray());
            }
        }
Example #3
0
 /// <summary>The settings_ database connection reset.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 private void Settings_DatabaseConnectionReset(object sender, EventArgs e)
 {
     _metaDataService = null;
     _sqlWriter       = null;
     ExecLoadDatabaseDetails();
 }
        /// <summary>The get tables and views.</summary>
        private void GetTablesAndViews()
        {
            if (_metaDataService == null)
            {
                _metaDataService = DatabaseMetaDataService.Create(_services.Settings.ConnectionDefinition.ProviderName);

                DbModelInstance model = _metaDataService.GetDbObjectModel(_services.Settings.ConnectionDefinition.ConnectionString);
                List<string> tableNames = new List<string>();
                foreach (DbModelTable table in model.Tables)
                {
                    tableNames.Add(Utility.MakeSqlFriendly(table.FullName));
                }

                foreach (DbModelView view in model.Views)
                {
                    tableNames.Add(Utility.MakeSqlFriendly(view.FullName));
                }

                cboTableName.Items.AddRange(tableNames.ToArray());
            }
        }
 /// <summary>The settings_ database connection reset.</summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The e.</param>
 private void Settings_DatabaseConnectionReset(object sender, EventArgs e)
 {
     _metaDataService = null;
     _sqlWriter = null;
     ExecLoadDatabaseDetails();
 }
        /// <summary>The exec load database details.</summary>
        /// <returns>The exec load database details.</returns>
        private bool ExecLoadDatabaseDetails()
        {
            bool populate = false;
            string connection = string.Empty;
            bool success = false;

            try
            {
                _hostWindow.SetPointerState(Cursors.WaitCursor);
                if (_metaDataService == null)
                {
                    _metaDataService = DatabaseMetaDataService.Create(_services.Settings.ConnectionDefinition.ProviderName);
                }

                connection = _metaDataService.GetDescription();
                populate = true;
            }
            catch (Exception exp)
            {
                string msg = string.Format(
                    "{0}\r\n\r\nCheck the connection and select 'Reset Database Connection'.",
                    exp.Message);
                _hostWindow.DisplaySimpleMessageBox(_hostWindow.Instance, msg, "DB Connection Error");
                _hostWindow.SetStatus(this, exp.Message);
            }
            finally
            {
                _hostWindow.SetPointerState(Cursors.Default);
            }

            if (populate)
            {
                try
                {
                    _hostWindow.SetPointerState(Cursors.WaitCursor);
                    _model = _metaDataService.GetDbObjectModel(_services.Settings.ConnectionDefinition.ConnectionString);
                }
                finally
                {
                    _hostWindow.SetPointerState(Cursors.Default);
                }

                BuildTreeFromDbModel(connection);
                _hostWindow.SetStatus(this, string.Empty);
                success = true;
            }
            else
            {
                _populated = false;
                DatabaseTreeView.CollapseAll();
            }

            return success;
        }