コード例 #1
0
ファイル: FormDataBaseSync.cs プロジェクト: HUHANK/Tool
        private bool getSourceDBAndDestDBInfo(out SDB2Connection sDB, out SDB2Connection dDB)
        {
            sDB = null;
            dDB = null;

            string salias = this.comboBox_sDB.Text;

            foreach (SDB2Connection dn in m_db2Alias)
            {
                if (dn.alias == salias)
                {
                    sDB = dn;
                    break;
                }
            }

            salias = this.comboBox_dDB.Text;
            foreach (SDB2Connection dn in m_db2Alias)
            {
                if (dn.alias == salias)
                {
                    dDB = dn;
                    break;
                }
            }

            return(true);
        }
コード例 #2
0
ファイル: FormDataBaseSync.cs プロジェクト: HUHANK/Tool
        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]);
                }
            }
        }
コード例 #3
0
 public CDB2Option(SDB2Connection con)
 {
     m_db2Alias    = con;
     m_isConnected = false;
     connect();
 }
コード例 #4
0
        private void GetDBDirectorys()
        {
            if (!File.Exists(TempDBFileName))
            {
                string cmdstr = " \"db2 list db directory > " + TempDBFileName + " && exit \"";
                CCmd   cmd    = new CCmd();
                cmd.db2cmd(cmdstr);
            }

            int            LNUM          = 0;
            int            TotalEntryNum = 0;
            SDB2Connection db2           = new SDB2Connection();

            StreamReader sRead = new StreamReader(TempDBFileName, GetFileEncodeType(TempDBFileName));
            string       line;

            sRead.ReadLine();
            while ((line = sRead.ReadLine()) != null)
            {
                if (line.Trim().Length < 1)
                {
                    continue;
                }
                LNUM++;
                if (LNUM == 1)
                {
                    continue;
                }
                if (LNUM == 2)
                {
                    TotalEntryNum = int.Parse(line.Split('=')[1].Trim());
                    continue;
                }
                if ((LNUM - 3) % 10 == 0)
                {
                    if (3 != LNUM)
                    {
                        m_conns.Add(db2);
                        db2 = new SDB2Connection();
                    }
                    continue;
                }

                if (line.Contains("数据库别名"))
                {
                    db2.alias = line.Split('=')[1].Trim();
                    continue;
                }
                if (line.Contains("数据库名称"))
                {
                    db2.database = line.Split('=')[1].Trim();
                    continue;
                }
                if (line.Contains("节点名"))
                {
                    db2.node = line.Split('=')[1].Trim();
                    continue;
                }
                if (line.Contains("注释"))
                {
                    db2.note = line.Split('=')[1].Trim();
                    continue;
                }
            }
            m_conns.Add(db2);
            sRead.Close();
            //if ((LNUM-3)/10 != TotalEntryNum)
            //{
            //    Console.WriteLine("生成的系统数据库目录文件不完整!");
            //}
        }