Esempio n. 1
0
        private void button_sync_Click(object sender, EventArgs e)
        {
            if (m_Schema.Length < 1)
            {
                MessageBox.Show("请选择Schema!");
                return;
            }

            CGenDB2ExpImpBat batFile = new CGenDB2ExpImpBat();

            getSourceDBAndDestDBInfo(out batFile.m_sDB2Info, out batFile.m_dDB2Info);
            batFile.m_sDB2Info.user   = textBox_sDBUser.Text;
            batFile.m_sDB2Info.passwd = textBox_sDBPwd.Text;

            batFile.m_dDB2Info.user   = textBox_dDBUser.Text;
            batFile.m_dDB2Info.passwd = textBox_dDBPwd.Text;

            {
                SDB2Connection sConn, dConn;
                getSourceDBAndDestDBInfo(out sConn, out dConn);

                CDB2Option opt = new CDB2Option(dConn);
                //opt.TableSchema = m_Schema;

                foreach (KeyValuePair <string, SDBTable> kv in m_SelTables)
                {
                    batFile.m_tables.Add(kv.Value);
                    SDBTable stbl = kv.Value;
                    opt.TableSchema = stbl.schema;
                    if (stbl.delete_method == "delete")
                    {
                        opt.delete(stbl.name);
                    }
                    else if (stbl.delete_method == "truncate")
                    {
                        opt.truncate(stbl.name);
                    }
                }
            }

            CTool.CheckPathExistOrCreate("./export_data/");
            CTool.DeleteDirAllFiles("./export_data/");

            batFile.m_TableSchema = m_Schema;
            batFile.m_FileName    = "./export_data/NJFKDJHSJFLSJFLS.bat";

            batFile.GenFile();

            CCmd cmd = new CCmd();

            cmd.cmd("db2cmd " + batFile.m_FileName);
        }
Esempio n. 2
0
        private void button_LoadSchema_Click(object sender, EventArgs e)
        {
            SDB2Connection sConn, dConn;

            getSourceDBAndDestDBInfo(out sConn, out dConn);
            sConn.user   = textBox_sDBUser.Text;
            sConn.passwd = textBox_sDBPwd.Text;
            dConn.user   = textBox_dDBUser.Text;
            dConn.passwd = textBox_dDBPwd.Text;

            CDB2Option    dbOpt   = new CDB2Option(sConn);
            List <string> schemas = dbOpt.getAllSchemas();

            comboBox_Schemas.Items.Clear();
            foreach (string schema in schemas)
            {
                comboBox_Schemas.Items.Add(schema);
            }
        }
Esempio n. 3
0
        private void button_TestDBConnect_Click(object sender, EventArgs e)
        {
            string         ErrMsg1, ErrMsg2;
            SDB2Connection sConn, dConn;

            getSourceDBAndDestDBInfo(out sConn, out dConn);
            sConn.user   = textBox_sDBUser.Text;
            sConn.passwd = textBox_sDBPwd.Text;
            dConn.user   = textBox_dDBUser.Text;
            dConn.passwd = textBox_dDBPwd.Text;

            CDB2Option dbOpt = new CDB2Option(sConn);

            dbOpt.testConnect(out ErrMsg1);

            dbOpt = new CDB2Option(dConn);
            dbOpt.testConnect(out ErrMsg2);

            if ((ErrMsg1.Length < 1) && (ErrMsg2.Length < 1))
            {
                MessageBox.Show("源数据库连接成功!\r\n目标数据库连接成功!", "测试结果", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if ((ErrMsg1.Length < 1) && (ErrMsg2.Length > 0))
            {
                string str = "源数据库连接成功!\r\n目标数据库连接失败:\r\n";
                str += ErrMsg2;
                MessageBox.Show(str, "测试结果", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if ((ErrMsg1.Length > 0) && (ErrMsg2.Length < 1))
            {
                string str = "目标数据库连接成功!\r\n源数据库连接失败:\r\n";
                str += ErrMsg1;
                MessageBox.Show(str, "测试结果", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string str = "源数据库连接失败:\r\n";
                str += ErrMsg1;
                str += "\r\n目标数据库连接失败:\r\n";
                str += ErrMsg2;
                MessageBox.Show(str, "测试结果", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
        private void button_uptTable_Click(object sender, EventArgs e)
        {
            if (m_Schema.Length < 1)
            {
                MessageBox.Show("请选择Schema!");
                return;
            }
            List <string[]> sTables = null;
            List <string[]> dTables = null;

            /*源数据库*/
            string         salias = this.comboBox_sDB.Text;
            SDB2Connection conn   = null;

            foreach (SDB2Connection dn in m_db2Alias)
            {
                if (dn.alias == salias)
                {
                    conn = dn;
                    break;
                }
            }
            conn.user   = this.textBox_sDBUser.Text;
            conn.passwd = this.textBox_sDBPwd.Text;

            {
                CDB2Option opt = new CDB2Option(conn);
                opt.TableSchema = m_Schema;
                sTables         = opt.getAllTables();
            }

            /*目标数据库*/
            salias = this.comboBox_dDB.Text;
            foreach (SDB2Connection dn in m_db2Alias)
            {
                if (dn.alias == salias)
                {
                    conn = dn;
                    break;
                }
            }
            conn.user   = this.textBox_dDBUser.Text;
            conn.passwd = this.textBox_dDBPwd.Text;

            {
                CDB2Option opt = new CDB2Option(conn);
                opt.TableSchema = m_Schema;
                dTables         = opt.getAllTables();
            }

            int i = 0;

            this.listView_table.Items.Clear();
            foreach (string[] em in sTables)
            {
                bool bMatch = false;
                for (i = 0; i < dTables.Count(); i++)
                {
                    if (em[0] == dTables[i][0])
                    {
                        bMatch = true;
                        dTables.Remove(dTables[i]);
                        break;
                    }
                }
                ListViewItem item = this.listView_table.Items.Add(em[0]);
                if (bMatch)
                {
                    foreach (ListViewItem item1 in this.listView_TblSel.Items)
                    {
                        if (item1.Text == em[0])
                        {
                            item.ForeColor = Color.Red;
                        }
                    }
                    item.SubItems.Add(em[0]);
                    item.SubItems.Add(em[1]);
                }
                else
                {
                    item.SubItems.Add("");
                    item.SubItems.Add(em[1]);
                }
            }
        }