Пример #1
0
        private void work()
        {
            //获取源数据
            String host             = txtSourceIP.Text.Trim();
            String portStr          = txtSourcePort.Text.Trim();
            String userName         = txtSourceUserName.Text.Trim();
            String passWord         = txtSourcePassWord.Text.Trim();
            String dataBase         = cboSourceDataBase.Text;
            String connectionString = MySqlUtil.getConnectionStr(host, portStr, userName, passWord, dataBase);

            connection = MySqlUtil.getConn(connectionString);
            Dictionary <String, DataTable> source        = new Dictionary <string, DataTable>();
            Dictionary <String, DataTable> sourceSetting = btnConnSource.Tag as Dictionary <String, DataTable>;
            Dictionary <String, DataTable> targetSetting = btnConnSource.Tag as Dictionary <String, DataTable>;
            DataTable sourceColumns = sourceSetting["columns"] as DataTable;
            DataTable targetColumns = targetSetting["columns"] as DataTable;

            lbState.Text = "开始获取源数据";
            List <Dictionary <String, Dictionary <String, Object> > > sqlList = new List <Dictionary <String, Dictionary <String, Object> > >();

            foreach (String tableName in clbTableInfo.CheckedItems)
            {
                bool createTable = radCreate.Checked && !radSkip.Checked;

                bool tableIsExist = checkTableExist(tableName, sourceColumns);

                if (createTable && tableIsExist)
                {
                    String insertSql = getCreateSql(sourceColumns, tableName);
                }

                String    sql    = "select * from " + tableName;
                DataTable tempDT = MySqlUtil.getDateTable(connection, sql);

                DataTable tableInfo = sourceSetting[tableName];

                StringBuilder fields = new StringBuilder();

                var rows = sourceColumns.Select("TABLE_NAME = '" + tableName + "' and COLUMN_KEY <> 'PRI'").Distinct(row => row["COLUMN_NAME"]);



                foreach (var row in rows)
                {
                    String colName = row["COLUMN_NAME"].ToString();
                    fields.Append(colName).Append(",");
                }
            }
        }