private void DBMS_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (sender == sourceDBMS)
            {
                IDBMSAssistant source = DBMSFactory.GetDBMSAssistantByName(sourceDBMS.Text);

                if (source != null)
                {
                    DBMSParams param = source.GetParams();

                    sourceServer.Enabled   = param.Server;
                    sourcePort.Enabled     = param.Port;
                    sourceDB.Enabled       = param.DB;
                    sourceUser.Enabled     = param.User;
                    sourceSchema.Enabled   = param.Schema;
                    sourcePwd.Enabled      = param.Pwd;
                    sourceCharSet.Enabled  = param.CharSet;
                    sourceTimeout.Enabled  = param.Timeout;
                    sourceEncrypt.Enabled  = param.Encrypt;
                    sourceCompress.Enabled = param.Compress;

                    sourcePort.Text    = param.DefaultPort;
                    sourceSchema.Text  = param.DefaultSchema;
                    sourceCharSet.Text = param.DefaultCharSet;
                    sourceTimeout.Text = param.DefaultTimeout;
                }
            }
            else if (sender == destDBMS)
            {
                IDBMSAssistant dest = DBMSFactory.GetDBMSAssistantByName(destDBMS.Text);

                if (dest != null)
                {
                    DBMSParams param = dest.GetParams();

                    destServer.Enabled   = param.Server;
                    destPort.Enabled     = param.Port;
                    destDB.Enabled       = param.DB;
                    destUser.Enabled     = param.User;
                    destSchema.Enabled   = param.Schema;
                    destPwd.Enabled      = param.Pwd;
                    destCharSet.Enabled  = param.CharSet;
                    destTimeout.Enabled  = param.Timeout;
                    destEncrypt.Enabled  = param.Encrypt;
                    destCompress.Enabled = param.Compress;

                    destPort.Text    = param.DefaultPort;
                    destSchema.Text  = param.DefaultSchema;
                    destCharSet.Text = param.DefaultCharSet;
                    destTimeout.Text = param.DefaultTimeout;
                }
            }
        }
        private bool InitDataSource(ref IDBMSAssistant source, ref IDBMSAssistant dest)
        {
            source = DBMSFactory.GetDBMSAssistantByName(sourceDBMS.Text);
            dest   = DBMSFactory.GetDBMSAssistantByName(destDBMS.Text);
            if (source != null && dest != null)
            {
                Database srcDB = new Database()
                {
                    DBMS     = sourceDBMS.Text,
                    Server   = sourceServer.Text,
                    Port     = uint.Parse(sourcePort.Text),
                    DB       = sourceDB.Text,
                    User     = sourceUser.Text,
                    Schema   = sourceSchema.Text,
                    Pwd      = sourcePwd.Text,
                    CharSet  = sourceCharSet.Text,
                    Compress = sourceCompress.Checked,
                    Encrypt  = sourceEncrypt.Checked,
                    Timeout  = uint.Parse(sourceTimeout.Text)
                };
                Database dstDB = new Database()
                {
                    DBMS     = destDBMS.Text,
                    Server   = destServer.Text,
                    Port     = uint.Parse(destPort.Text),
                    DB       = destDB.Text,
                    User     = destUser.Text,
                    Schema   = destSchema.Text,
                    Pwd      = destPwd.Text,
                    CharSet  = destCharSet.Text,
                    Compress = destCompress.Checked,
                    Encrypt  = destEncrypt.Checked,
                    Timeout  = uint.Parse(destTimeout.Text)
                };

                return(source.Connect(srcDB) && dest.Connect(dstDB));
            }

            return(false);
        }
        private void RetrieveTables()
        {
            progressLabel.Visible = true;
            progressBar.Value     = 0;
            progressBar.Maximum   = 100;
            progressBar.Visible   = true;
            Application.DoEvents();

            IDBMSAssistant source = null, dest = null;

            if (!InitDataSource(ref source, ref dest))
            {
                MessageBox.Show("数据源配置有误!", "配置助手", MessageBoxButtons.OK);
            }
            else
            {
                List <TableInfo> sourceInfo = new List <TableInfo>(), destInfo = new List <TableInfo>();

                source.GetTables(this, sourceInfo);
                dest.GetTables(this, destInfo);

                listView.Items.Clear();

                while (destInfo.Count > 0)
                {
                    TableInfo info = destInfo[0];

                    destInfo.RemoveAt(0);

                    Table table = new Table()
                    {
                        SourceName   = "<?>",
                        SourceSchema = "",
                        DestName     = info.Name,
                        DestSchema   = info.Schema,
                        Order        = info.Order,
                        PageSize     = 100,
                        OrderSQL     = info.KeyFields.Length == 0 ? "" : string.Join(" ASC, ", info.KeyFields) + " ASC",
                        WhereSQL     = "",
                        WriteMode    = WriteModes.Append,
                        KeyFields    = info.KeyFields,
                        SkipFields   = { },
                        Filter       = "",
                        References   = info.References
                    };
                    string sourceName = "";
                    bool   found      = false;

                    // 区分大小写匹配引入配置目标表
                    for (int i = 0; i < importedTables.Count; i++)
                    {
                        if (table.DestName.Equals(importedTables[i].DestName))
                        {
                            sourceName       = importedTables[i].SourceName;
                            table.PageSize   = importedTables[i].PageSize;
                            table.OrderSQL   = importedTables[i].OrderSQL;
                            table.WhereSQL   = importedTables[i].WhereSQL;
                            table.WriteMode  = importedTables[i].WriteMode;
                            table.SkipFields = importedTables[i].SkipFields;
                            table.Filter     = importedTables[i].Filter;
                            found            = true;

                            break;
                        }
                    }

                    // 不区分大小写匹配源数据表
                    if (found)
                    {
                        sourceName = sourceName.ToLower();
                    }
                    else
                    {
                        sourceName = table.DestName.ToLower();
                    }

                    for (int i = 0; i < sourceInfo.Count; i++)
                    {
                        if (sourceName.Equals(sourceInfo[i].Name.ToLower()))
                        {
                            table.SourceName = sourceInfo[i].Name;
                            sourceInfo.RemoveAt(i);
                            break;
                        }
                    }

                    ListViewItem item = listView.Items.Add(table.SourceFullName);

                    item.SubItems.Add(table.DestFullName);
                    item.SubItems.Add(table.Order.ToString());
                    item.Checked = found;
                    item.Tag     = table;
                }
            }
            progressLabel.Visible = false;
            progressBar.Visible   = false;
        }