示例#1
0
        private void btExport_Click(object sender, EventArgs e)
        {
            DumpData Dump = new DumpData();

            try
            {
                string[] dbs = tbDatabases.Text.Replace("\r", "").Split('\n').Select(db => db.Trim()).Where(db => db != "").ToArray();

                Dump.databases = dbs;
                Dump.path = tbOutputPath.Text;
                Dump.exportempty = cbExportEmpty.Checked;

                Dump.maxrows = cbMaxrows.Checked ? int.Parse(tbMaxrows.Text) : -1;
                Dump.binaryhex = cbBinaryhex.Checked;
                Dump.binaryfile = cbBinaryfile.Checked;

                Dump.excludeTables = tbExcludeTables.Text.Replace("\r", "").Split('\n').Select(table => table.Trim()).Where(table => table != "").ToArray();
                if (Dump.excludeTables.Length == 1 && string.IsNullOrEmpty(Dump.excludeTables[0]))
                {
                    Dump.excludeTables = new string[] { };
                }
                Dump.useRegexpTables = cbUseRegexpTables.Checked;

                Dump.excludeColumns = tbExcludeColumns.Text.Replace("\r", "").Split('\n').Select(col => col.Trim()).Where(col => col != "").ToArray();
                if (Dump.excludeColumns.Length == 1 && string.IsNullOrEmpty(Dump.excludeColumns[0]))
                {
                    Dump.excludeColumns = new string[] { };
                }
                Dump.useRegexpColumns = cbUseRegexpColumns.Checked;

                Dump.sortColumns = cbSortColumns.Checked;
                Dump.sortRows = cbSortRows.Checked;

                switch (cbSeparator.Text)
                {
                    case "Comma":
                        Dump.separator = ",";
                        break;
                    case "Tab":
                        Dump.separator = "\t";
                        break;
                    default:
                        System.Windows.Forms.MessageBox.Show("No separator selected!");
                        return;
                }

                Dump.overwrite = cbOverwrite.Checked;
                Dump.header = cbHeader.Checked;
                Dump.escapecharacters = cbEscapecharacters.Checked;
                Dump.extension = cbExtension.Text;

                Dump.dbprovider = cbProvider.SelectedValue.ToString();
                Dump.dbserver = cbServer.Text;

                if (cbSQLLogin.Checked)
                {
                    Dump.dbusername = tbUsername.Text;
                    Dump.dbpassword = tbPassword.Text;
                }
                else
                {
                    Dump.dbusername = null;
                    Dump.dbpassword = null;
                }

                Dump.Dump();

                this.Text = Dump._result;
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(
                                "DB: " + Dump._dbname + "\n" +
                                "Table: " + Dump._tablename + "\n" +
                                "SQL: " + Dump._sql + "\n" +
                                ex.ToString());
            }
        }
示例#2
0
        private void btExport_Click(object sender, EventArgs e)
        {
            DumpData Dump = new DumpData();

            try
            {
                string[] dbs = tbDatabases.Text.Replace("\r", "").Split('\n').Select(db => db.Trim()).Where(db => db != "").ToArray();

                Dump.databases   = dbs;
                Dump.path        = tbOutputPath.Text;
                Dump.exportempty = cbExportEmpty.Checked;

                Dump.maxrows    = cbMaxrows.Checked ? int.Parse(tbMaxrows.Text) : -1;
                Dump.binaryhex  = cbBinaryhex.Checked;
                Dump.binaryfile = cbBinaryfile.Checked;

                Dump.excludeTables = tbExcludeTables.Text.Replace("\r", "").Split('\n').Select(table => table.Trim()).Where(table => table != "").ToArray();
                if (Dump.excludeTables.Length == 1 && string.IsNullOrEmpty(Dump.excludeTables[0]))
                {
                    Dump.excludeTables = new string[] { };
                }
                Dump.useRegexpTables = cbUseRegexpTables.Checked;

                Dump.excludeColumns = tbExcludeColumns.Text.Replace("\r", "").Split('\n').Select(col => col.Trim()).Where(col => col != "").ToArray();
                if (Dump.excludeColumns.Length == 1 && string.IsNullOrEmpty(Dump.excludeColumns[0]))
                {
                    Dump.excludeColumns = new string[] { };
                }
                Dump.useRegexpColumns = cbUseRegexpColumns.Checked;

                Dump.sortColumns = cbSortColumns.Checked;
                Dump.sortRows    = cbSortRows.Checked;

                switch (cbSeparator.Text)
                {
                case "Comma":
                    Dump.separator = ",";
                    break;

                case "Tab":
                    Dump.separator = "\t";
                    break;

                default:
                    System.Windows.Forms.MessageBox.Show("No separator selected!");
                    return;
                }

                Dump.overwrite        = cbOverwrite.Checked;
                Dump.header           = cbHeader.Checked;
                Dump.escapecharacters = cbEscapecharacters.Checked;
                Dump.extension        = cbExtension.Text;

                Dump.dbprovider = cbProvider.SelectedValue.ToString();
                Dump.dbserver   = cbServer.Text;

                if (cbSQLLogin.Checked)
                {
                    Dump.dbusername = tbUsername.Text;
                    Dump.dbpassword = tbPassword.Text;
                }
                else
                {
                    Dump.dbusername = null;
                    Dump.dbpassword = null;
                }

                Dump.Dump();

                this.Text = Dump._result;
            }
            catch (System.Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(
                    "DB: " + Dump._dbname + "\n" +
                    "Table: " + Dump._tablename + "\n" +
                    "SQL: " + Dump._sql + "\n" +
                    ex.ToString());
            }
        }