Esempio n. 1
0
        private void FormDataBaseSync_Load(object sender, EventArgs e)
        {
            CTool.CheckPathExistOrCreate(m_SerializeConnectsPath);
            if (File.Exists(m_SerializeConnectsPath))
            {
                CSerialize ser = new CSerialize();
                ser.FileName = m_SerializeConnectsPath;
                m_db2Alias   = (List <SDB2Connection>)ser.DeSerialize();
            }
            else
            {
                CDB2ConnectInfo db2Info = new CDB2ConnectInfo();
                m_db2Alias = db2Info.m_conns;
            }

            /*初始化下拉框*/
            {
                this.comboBox_dDB.Items.Clear();
                this.comboBox_sDB.Items.Clear();
                foreach (SDB2Connection con in m_db2Alias)
                {
                    this.comboBox_sDB.Items.Add(con.alias);
                    this.comboBox_dDB.Items.Add(con.alias);
                }
            }
        }
Esempio n. 2
0
 public void createFilePath()
 {
     if (filePath.Length < 1)
     {
         return;
     }
     CTool.CheckPathExistOrCreate(filePath);
     if (isNode)
     {
         return;
     }
 }
Esempio n. 3
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. 4
0
        public void GenFile()
        {
            CTool.CheckPathExistOrCreate(m_ExportDataPath);

            StreamWriter sWriter = new StreamWriter(m_FileName, false, Encoding.Default);
            string       line    = "";

            sWriter.WriteLine("@echo off");

            line = String.Format("db2 connect to {0} user {1} using {2}  \r\n call :PrintErrMsg %errorlevel%  连接{3}数据库  ", m_sDB2Info.alias, m_sDB2Info.user, m_sDB2Info.passwd, m_sDB2Info.alias);
            sWriter.WriteLine(line);

            foreach (SDBTable tbl in m_tables)
            {
                line = String.Format("db2 \"export to {0}/{1}.ixf of ixf SELECT * FROM {2}.{3} WITH UR \"  ", m_ExportDataPath, tbl.name, tbl.schema, tbl.name);
                sWriter.WriteLine(line);
                line = String.Format("call :PrintErrMsg %errorlevel%  导出表{0}.{1}  \r\n", tbl.schema, tbl.name);
                sWriter.WriteLine(line);
            }

            sWriter.WriteLine("db2 connect reset\r\n");

            line = String.Format("db2 connect to {0} user {1} using {2}   \r\n call :PrintErrMsg %errorlevel%  连接{3}数据库  ", m_dDB2Info.alias, m_dDB2Info.user, m_dDB2Info.passwd, m_dDB2Info.alias);
            sWriter.WriteLine(line);

            foreach (SDBTable tbl in m_tables)
            {
                if (tbl.import_method == "replace")
                {
                    line = String.Format("db2 \"import from {0}/{1}.ixf of ixf modified by compound=100 commitcount 10000 replace into {2}.{3} \"  ", m_ExportDataPath, tbl.name, tbl.schema, tbl.name);
                }
                else if (tbl.import_method == "insert")
                {
                    line = String.Format("db2 \"import from {0}/{1}.ixf of ixf  commitcount 10000 insert into {2}.{3} \"  ", m_ExportDataPath, tbl.name, tbl.schema, tbl.name);
                }
                else if (tbl.import_method == "insert_update")
                {
                    line = String.Format("db2 \"import from {0}/{1}.ixf of ixf  commitcount 10000 insert_update into {2}.{3} \"  ", m_ExportDataPath, tbl.name, tbl.schema, tbl.name);
                }
                sWriter.WriteLine(line);
                line = String.Format("call :PrintErrMsg %errorlevel%  导入表{0}.{1}  \r\n", tbl.schema, tbl.name);
                sWriter.WriteLine(line);
            }
            sWriter.WriteLine("db2 connect reset\n");

            line = "echo 数据库同步成功完成! \r\n pause \r\n exit 0 \r\n:PrintErrMsg\r\n    if %1 equ 0 (goto SUCC) else (goto FAILD)\r\n\r\n    :FAILD\r\n        echo %2失败[%1]\r\n \r\n echo 数据库同步失败\r\n       pause\r\nexit %1\r\n    :SUCC\r\n        echo %2成功[%1]\r\nGOTO:EOF            ";
            sWriter.WriteLine(line);

            sWriter.Flush();
            sWriter.Close();
        }
Esempio n. 5
0
        private void button_SaveConfig_Click(object sender, EventArgs e)
        {
            SDB2Connection sConn, dConn;

            getSourceDBAndDestDBInfo(out sConn, out dConn);
            if (sConn != null)
            {
                sConn.user   = textBox_sDBUser.Text;
                sConn.passwd = textBox_sDBPwd.Text;
            }
            if (dConn != null)
            {
                dConn.user   = textBox_dDBUser.Text;
                dConn.passwd = textBox_dDBPwd.Text;
            }

            CTool.CheckPathExistOrCreate(m_SerializeConnectsPath);
            CSerialize ser = new CSerialize();

            ser.FileName = m_SerializeConnectsPath;
            ser.Serialize(m_db2Alias);
        }
Esempio n. 6
0
 private void FormKnowledgeBase_Load(object sender, EventArgs e)
 {
     CTool.CheckPathExistOrCreate(sTreeDir);
     deserializeTree();
     initTreeViewTable(this.treeView.Nodes, m_Tree);
 }