Exemple #1
0
 private void SetInitialConnectionStatus(ConnectionEventArgs e)
 {
     this.con    = e.con;
     this.server = e.server;
     SetAutoCommit(con);
     this.setConnectionAndServerToUserControls();
     this.setHomeConnectionStatus();
 }
Exemple #2
0
        private void fillTreeView()
        {
            if (cmbServers.Items.Count == 0)
            {
                return;
            }                                            //ama den iparxei kanenas server den to kanei
            sqlservers server = null;

            this.Invoke((MethodInvoker) delegate()
            {
                server = sqlservers.CreateSqlServerFromDataTable(serverData, cmbServers);
            });
            ConnectionResultSet result = DB.TestConnection(server);

            if (result.wasSuccessful)
            {
                DbConnection  con       = DB.connect(server);
                List <string> databases = null;
                if (Utils._convert(server.db_type) == sqlbox.commons.DbType.SQLITE)
                {
                    databases = new List <string>()
                    {
                        "main"
                    };
                }
                else
                {
                    databases = new SqlBuilderFactory(server)
                                .Create(null).removeSystemDatabases(DbDataHelper.getDatabases(server, con), !hideSystemDatabases);
                }
                foreach (string database in databases)
                {
                    this.Invoke((MethodInvoker) delegate()
                    {
                        TreeNode node        = new TreeNode(database);
                        node.ImageIndex      = 0;
                        List <string> tables = DbDataHelper.getTables(server, database, con);
                        foreach (string table in tables)
                        {
                            TreeNode tablenode   = new TreeNode(table);
                            tablenode.ImageIndex = 1;
                            node.Nodes.Add(tablenode);
                        }
                        tvDatabases.Nodes.Add(node);
                    });
                }
                DB.close(con);
            }
            else
            {
                this.Invoke((MethodInvoker) delegate()
                {
                    MessageBox.Show("Connection failed: \n" + result.errorMessage, "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                });
            }
        }
Exemple #3
0
        private void fillTreeView()
        {
            if (cmbServers.Items.Count == 0)
            {
                return;
            }                                            //ama den iparxei kanenas server den to kanei
            sqlservers server = null;

            this.Invoke((MethodInvoker) delegate()
            {
                server = DbUtils.getSqlServerFromTable(serverData, cmbServers);
            });

            //edw prepei na bei to database kai mia if then else apo katw analoga ama kanei OldMySqlConnect se server i se database
            ConnectionResultSet result = DB.TestConnection(server);

            if (result.wasSuccessful)
            {
                MySqlConnection con       = (MySqlConnection)DB.connect(server);
                List <string>   databases = DbUtils.getDatabases(server, con);//con.getDatabases();
                if (hideSystemDatabases)
                {
                    databases = DbUtils.removeSystemDatabases(databases);
                }
                foreach (string database in databases)
                {
                    this.Invoke((MethodInvoker) delegate() {
                        TreeNode node        = new TreeNode(database);
                        node.ImageIndex      = 0;
                        List <string> tables = DbUtils.getTables(server, database, con);
                        foreach (string table in tables)
                        {
                            TreeNode tablenode   = new TreeNode(table);
                            tablenode.ImageIndex = 1;
                            node.Nodes.Add(tablenode);
                        }
                        tvDatabases.Nodes.Add(node);
                    });
                }
                DB.close(con);
            }
            else
            {
                this.Invoke((MethodInvoker) delegate() {
                    MessageBox.Show("Connection failed: \n" + result.errorMessage, "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                });
            }
        }
Exemple #4
0
        private void openDatabaseWindow()
        {
            var databaseConnector = new DatabaseConnect();

            databaseConnector.TopMost = true;
            databaseConnector.Show();
            this.EnableDisable(false);
            databaseConnector.onConnect += (sender, e) =>
            {
                this.con = e.con;
                SetAutoCommit(con);
                this.server = e.server;
                this.setConnectionAndServerToUserControls();
                this.setHomeConnectionStatus();
            };
            databaseConnector.FormClosed += (sender, e) => this.EnableDisable(true);
        }
Exemple #5
0
        private void menuClick(object sender, EventArgs e)
        {
            sqlservers server = DbUtils.getSqlServerFromTable(serverData, cmbServers);

            if (tvDatabases.SelectedNode != null && tvDatabases.SelectedNode.Parent == null)
            {
                string database = tvDatabases.SelectedNode.Text;
                if (sender.ToString() == "browse data")
                {
                    SqlDbViewerForm sqlform = new SqlDbViewerForm(server, database);
                    sqlform.Show();
                }
                else if (sender.ToString() == "inspect database")
                {
                    AnalyzeDbForm adbf = new AnalyzeDbForm(server, database);
                    adbf.Show();
                }
            }
            else
            {
                if (tvDatabases.SelectedNode != null && tvDatabases.SelectedNode.Parent != null)
                {
                    string database = tvDatabases.SelectedNode.Parent.Text;
                    if (sender.ToString() == "browse data")
                    {
                        SqlDbViewerForm sqlform = new SqlDbViewerForm(server, database);
                        sqlform.Show();
                    }
                    else if (sender.ToString() == "inspect database")
                    {
                        AnalyzeDbForm adbf = new AnalyzeDbForm(server, database);
                        adbf.Show();
                    }
                }
            }
        }
Exemple #6
0
        private void fillTreeView()
        {
            if (cmbServers.Items.Count == 0)
            {
                return;
            }                                            //ama den iparxei kanenas server den to kanei
            sqlservers server = null;

            this.Invoke((MethodInvoker) delegate()
            {
                server = DbUtils.getSqlServerFromTable(serverData, cmbServers);
            });

            //edw prepei na bei to database kai mia if then else apo katw analoga ama kanei OldMySqlConnect se server i se database
            ConnectionResultSet result = DB.TestConnection(server);

            if (result.wasSuccessful)
            {
                MySqlConnection con       = (MySqlConnection)DB.connect(server);
                List <string>   databases = DbUtils.getDatabases(server, con);//con.getDatabases();
                if (hideSystemDatabases)
                {
                    databases = DbUtils.removeSystemDatabases(databases);
                }
                foreach (string database in databases)
                {
                    this.Invoke((MethodInvoker) delegate() {
                        TreeNode node        = new TreeNode(database);
                        node.ImageIndex      = 0;
                        List <string> tables = DbUtils.getTables(server, database, con);
                        foreach (string table in tables)
                        {
                            TreeNode tablenode   = new TreeNode(table);
                            tablenode.ImageIndex = 1;
                            node.Nodes.Add(tablenode);
                        }
                        tvDatabases.Nodes.Add(node);
                    });
                }

                this.Invoke((MethodInvoker) delegate() {
                    ToolStripMenuItem opendb    = new ToolStripMenuItem();
                    ToolStripMenuItem analyzedb = new ToolStripMenuItem();
                    opendb.Text           = "browse data";
                    opendb.Tag            = "sql";
                    opendb.Click         += new EventHandler(menuClick);
                    analyzedb.Text        = "inspect database";
                    analyzedb.Click      += new EventHandler(menuClick);
                    ContextMenuStrip menu = new ContextMenuStrip();
                    menu.Items.AddRange(new ToolStripMenuItem[] { opendb, analyzedb });
                    tvDatabases.ContextMenuStrip = menu;
                });
                DB.close(con);
            }
            else
            {
                this.Invoke((MethodInvoker) delegate() {
                    MessageBox.Show("Connection failed: \n" + result.errorMessage, "Test Connection", MessageBoxButtons.OK, MessageBoxIcon.Error);
                });
            }
        }