private void ButtonImport_Click(object sender, EventArgs e)
        {
            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                Profile profile = new Profile();
                try
                {
                    profile.Load(openDialog.FileName);

                    IRunnerAssistant assist = RunnerFactory.GetRunnerAssistantByName(profile.Runner);

                    if (assist == null)
                    {
                        throw new Exception($"执行器 {profile.Runner} 不支持!");
                    }

                    Database source = new Database(), dest = new Database();

                    importedTables.Clear();

                    // 暂时只支持第一个实例
                    assist.LoadSample(profile.Instances[0], source, dest, importedTables, out importedParam);

                    runner.Text = profile.Runner;

                    sourceDBMS.Text        = source.DBMS;
                    sourceServer.Text      = source.Server;
                    sourcePort.Text        = source.Port.ToString();
                    sourceDB.Text          = source.DB;
                    sourceUser.Text        = source.User;
                    sourceSchema.Text      = source.Schema;
                    sourcePwd.Text         = source.Pwd;
                    sourceCharSet.Text     = source.CharSet;
                    sourceTimeout.Text     = source.Timeout.ToString();
                    sourceCompress.Checked = source.Compress;
                    sourceEncrypt.Checked  = source.Encrypt;

                    destDBMS.Text        = dest.DBMS;
                    destServer.Text      = dest.Server;
                    destPort.Text        = dest.Port.ToString();
                    destDB.Text          = dest.DB;
                    destUser.Text        = dest.User;
                    destSchema.Text      = dest.Schema;
                    destPwd.Text         = dest.Pwd;
                    destCharSet.Text     = dest.CharSet;
                    destTimeout.Text     = dest.Timeout.ToString();
                    destCompress.Checked = dest.Compress;
                    destEncrypt.Checked  = dest.Encrypt;

                    RetrieveTables();
                }
                catch (Exception ex)
                {
                    MessageBox.Show($"配置文件有误!{ex.Message}", "加载配置", MessageBoxButtons.OK);
                }
            }
        }
        private void ButtonSave_Click(object sender, EventArgs e)
        {
            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                IRunnerAssistant assist = RunnerFactory.GetRunnerAssistantByName(runner.Text);
                string           path   = Path.GetDirectoryName(saveDialog.FileName) + "\\";
                string           file   = Path.GetFileName(saveDialog.FileName);
                Database         source = new Database()
                {
                    DBMS     = sourceDBMS.Text,
                    Server   = sourceServer.Text,
                    Port     = uint.Parse(sourcePort.Text),
                    DB       = sourceDB.Text,
                    User     = sourceUser.Text,
                    Pwd      = sourcePwd.Text,
                    CharSet  = sourceCharSet.Text,
                    Compress = sourceCompress.Checked,
                    Encrypt  = sourceEncrypt.Checked,
                    Timeout  = uint.Parse(sourceTimeout.Text)
                };
                Database dest = new Database()
                {
                    DBMS     = destDBMS.Text,
                    Server   = destServer.Text,
                    Port     = uint.Parse(destPort.Text),
                    DB       = destDB.Text,
                    User     = destUser.Text,
                    Pwd      = destPwd.Text,
                    CharSet  = destCharSet.Text,
                    Compress = destCompress.Checked,
                    Encrypt  = destEncrypt.Checked,
                    Timeout  = uint.Parse(destTimeout.Text)
                };
                List <Table> tables = new List <Table>();

                for (int i = 0; i < listView.Items.Count; i++)
                {
                    ListViewItem item = listView.Items[i];

                    if (item.Checked && item.Tag is Table table)
                    {
                        tables.Add(table);
                    }
                }

                assist.SaveSample(source, dest, tables, importedParam, path, file);
            }
        }