Exemplo n.º 1
0
        private void oracleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DbTableListForm form = new DbTableListForm();

            using (OracleConnection cnn = new OracleConnection(this.ConnectionStringOracle))
            {
                cnn.Open();
                OracleDataAdapter da = new OracleDataAdapter("Select table_name from user_tables where table_name like '%_GEO_%' order by table_name", cnn);
                DataTable         dt = new DataTable();
                da.Fill(dt);
                List <DbTableModel> lst = new List <DbTableModel>();
                foreach (DataRow row in dt.Rows)
                {
                    lst.Add(new DbTableModel()
                    {
                        TableName = row[0].ToString(),
                        Db        = new DbModel()
                        {
                            ConnectionString = this.ConnectionStringPostgis,
                            DbType           = DbModelType.Oracle,
                            Guid             = Guid.NewGuid().ToString()
                        }
                    });
                }

                foreach (var item in lst)
                {
                    if (!this.DbTableModels.Any(a => a.TableName == item.TableName && a.Db.ConnectionString == item.Db.ConnectionString))
                    {
                        this.DbTableModels.Add(item);
                    }
                }
            }

            form.checkedListBoxTables.Items.Clear();
            foreach (var item in this.DbTableModels.Where(a => a.Db.DbType == DbModelType.Oracle).ToList())
            {
                form.checkedListBoxTables.Items.Add(item.TableName, item.IsOpen);
            }
            form.TableList = this.DbTableModels.Where(a => a.Db.DbType == DbModelType.Oracle).ToList();

            form.Owner = this;
            form.Show();
        }
Exemplo n.º 2
0
        private void postgresqlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DbTableListForm form = new DbTableListForm();

            using (NpgsqlConnection cnn = new NpgsqlConnection(this.ConnectionStringPostgis))
            {
                cnn.Open();
                NpgsqlDataAdapter da = new NpgsqlDataAdapter("SELECT f_table_name FROM geometry_columns where f_table_name like '%_geo_%'", cnn);
                DataTable         dt = new DataTable();
                da.Fill(dt);
                List <DbTableModel> lst = new List <DbTableModel>();
                foreach (DataRow row in dt.Rows)
                {
                    lst.Add(new DbTableModel()
                    {
                        TableName = row[0].ToString(),
                        Db        = new DbModel()
                        {
                            ConnectionString = this.ConnectionStringPostgis,
                            DbType           = DbModelType.Postgresql,
                            Guid             = Guid.NewGuid().ToString()
                        }
                    });
                }

                foreach (var item in lst)
                {
                    if (!this.DbTableModels.Any(a => a.TableName == item.TableName && a.Db.ConnectionString == item.Db.ConnectionString))
                    {
                        this.DbTableModels.Add(item);
                    }
                }
            }

            form.checkedListBoxTables.Items.Clear();
            foreach (var item in this.DbTableModels.Where(a => a.Db.DbType == DbModelType.Postgresql).ToList())
            {
                form.checkedListBoxTables.Items.Add(item.TableName, item.IsOpen);
            }
            form.TableList = this.DbTableModels.Where(a => a.Db.DbType == DbModelType.Postgresql).ToList();

            form.Owner = this;
            form.Show();
        }