Beispiel #1
0
        private void setupFormComponents()
        {
            setupTooltips();

            BinlogConfig configInstance = ConfigurationManager.getInstance().binlogConfigInstance;

            //General
            tbCharacterSetsDir.Text = configInstance.characterSetsDir;
            tbExcludeGtids.Text     = configInstance.excludeGtids;
            tbBindAdress.Text       = configInstance.bindAdress;

            cmbBase64.DataSource = new string[] { "", "uncompressed", "auto", "decode-rows" };
            if (string.IsNullOrWhiteSpace(configInstance.base64output))
            {
                cmbBase64.SelectedIndex = 0;
            }
            else
            {
                cmbBase64.SelectedIndex = cmbBase64.Items.IndexOf(configInstance.base64output);
                if (cmbBase64.SelectedIndex == -1)
                {
                    cmbBase64.SelectedIndex = 0;
                }
            }
            cmbCharset.DataSource = new string[] { "utf8", "armscii8", "ascii", "cp850", "cp852", "cp866", "cp1250", "cp1251", "cp1256", "cp1257", "dec8", "geostd8", "greek", "hebrew", "hp8", "Index",
                                                   "keybcs2", "koi8r", "koi8u", "latin1", "latin2", "latin5", "latin7", "macce", "macroman", "swe7" };
            if (string.IsNullOrWhiteSpace(configInstance.charsetName))
            {
                cmbCharset.SelectedIndex = 0;
            }
            else
            {
                cmbCharset.SelectedIndex = cmbCharset.Items.IndexOf(configInstance.charsetName);
                if (cmbCharset.SelectedIndex == -1)
                {
                    cmbCharset.SelectedIndex = 0;
                }
            }
            cmbCompressionAlgorithm.DataSource = new string[] { "", "uncompressed", "zlib", "zstd" };
            if (string.IsNullOrWhiteSpace(configInstance.compressionAlgorithms))
            {
                cmbCompressionAlgorithm.SelectedIndex = 0;
            }
            else
            {
                cmbCompressionAlgorithm.SelectedIndex = cmbCompressionAlgorithm.Items.IndexOf(configInstance.compressionAlgorithms);
                if (cmbCompressionAlgorithm.SelectedIndex == -1)
                {
                    cmbCompressionAlgorithm.SelectedIndex = 0;
                }
            }
            cmbProtocol.DataSource = new string[] { "tcp", "socket", "pipe", "memory" };
            if (string.IsNullOrWhiteSpace(configInstance.protocol))
            {
                cmbProtocol.SelectedIndex = 0;
            }
            else
            {
                cmbProtocol.SelectedIndex = cmbProtocol.Items.IndexOf(configInstance.protocol);
                if (cmbProtocol.SelectedIndex == -1)
                {
                    cmbProtocol.SelectedIndex = 0;
                }
            }

            if (!string.IsNullOrWhiteSpace(configInstance.rewriteDb) && configInstance.rewriteDb.Contains("->"))
            {
                string[] splitRewritedb = configInstance.rewriteDb.Split(new string[] { "->" }, StringSplitOptions.None);
                if (splitRewritedb.Length == 2)
                {
                    tbRewriteFrom.Text = splitRewritedb[0];
                    tbRewriteTo.Text   = splitRewritedb[1];
                }
            }

            if (configInstance.conServerId != 0)
            {
                tbConServerId.Text = configInstance.conServerId.ToString();
            }
            if (configInstance.serverId != -1)
            {
                tbServerId.Text = configInstance.serverId.ToString();
            }
            if (configInstance.rowEventMaxSize != 0)
            {
                tbRowEventMaxSize.Text = configInstance.rowEventMaxSize.ToString();
            }

            cbDisableBinaryLogging.Checked = configInstance.disableLogBin;
            cbForceIfOpen.Checked          = configInstance.forceIfOpen;
            cbForceRead.Checked            = configInstance.forceRead;
            cbGetServerPublicKey.Checked   = configInstance.getServerPublicKey;
            cbIdempotent.Checked           = configInstance.idempotent;
            cbRaw.Checked        = configInstance.raw;
            cbSkipGtids.Checked  = configInstance.skipGtids;
            cbServerTime.Checked = configInstance.useServerTime;

            //Debug
            tbDebugOptions.Text = configInstance.debugOptions;

            cbDebugCheck.Checked         = configInstance.debugCheck;
            cbDebugInfo.Checked          = configInstance.debugInfo;
            cbHexdump.Checked            = configInstance.hexdump;
            cbPrintDefaults.Checked      = configInstance.printDefaults;
            cbPrintTableMetadata.Checked = configInstance.printTableMetadata;
            cbVerbose.Checked            = configInstance.verbose;
        }
Beispiel #2
0
        private StringBuilder calculateArguments()
        {
            StringBuilder arguments = new StringBuilder();

            performChecks();
            if (!result.wasSuccessful)
            {
                return(arguments);
            }
            //-R -h localhost -u root -p --skip-gtids -d "anime" DESKTOP-5TEPA4J-bin.000003
            arguments.Append("-R ");
            arguments.Append(" -h " + config.host);
            arguments.Append(" -u " + config.username);
            arguments.Append(" -p" + config.password);
            arguments.Append(" -d " + config.database);
            arguments.Append(" --start-datetime=\"" + config.startDateTime + "\"");

            BinlogConfig binlogConfigInstance = ConfigurationManager.getInstance().binlogConfigInstance;

            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.base64output))
            {
                arguments.Append(" --base64-output=" + binlogConfigInstance.base64output);
            }
            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.bindAdress))
            {
                arguments.Append(" --bind-address=" + binlogConfigInstance.bindAdress);
            }
            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.characterSetsDir))
            {
                arguments.Append(" --character-sets-dir=" + binlogConfigInstance.characterSetsDir);
            }
            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.charsetName))
            {
                arguments.Append(" --set-charset=" + binlogConfigInstance.charsetName);
            }
            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.compressionAlgorithms) && binlogConfigInstance.compressionAlgorithms != "uncompressed")
            {
                arguments.Append(" --compress"); //below version not working for current binlog.exe
                //arguments.Append(" --compression-algorithms=" + binlogConfigInstance.compressionAlgorithms);
            }
            if (binlogConfigInstance.conServerId != 0)
            {
                arguments.Append(" --connection-server-id=" + binlogConfigInstance.conServerId);
            }
            if (binlogConfigInstance.debugCheck)
            {
                arguments.Append(" --debug-check");
            }
            if (binlogConfigInstance.debugInfo)
            {
                arguments.Append(" --debug-info");
            }
            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.debugOptions))
            {
                arguments.Append(" --debug=" + binlogConfigInstance.debugOptions);
            }
            if (binlogConfigInstance.disableLogBin)
            {
                arguments.Append(" -D");
            }
            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.excludeGtids))
            {
                arguments.Append(" --exclude-gtids=" + binlogConfigInstance.excludeGtids);
            }
            if (binlogConfigInstance.forceIfOpen)
            {
                arguments.Append(" -F");
            }
            if (binlogConfigInstance.forceRead)
            {
                arguments.Append(" -f");
            }
            if (binlogConfigInstance.getServerPublicKey)
            {
                arguments.Append(" --get-server-public-key");
            }
            if (binlogConfigInstance.hexdump)
            {
                arguments.Append(" -H");
            }
            if (binlogConfigInstance.idempotent)
            {
                arguments.Append(" -idempotent");
            }
            if (binlogConfigInstance.printDefaults)
            {
                arguments.Append(" --print-defaults");
            }
            if (binlogConfigInstance.printTableMetadata)
            {
                arguments.Append(" --print-table-metadata");
            }
            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.protocol))
            {
                arguments.Append(" --protocol=" + binlogConfigInstance.protocol);
            }
            if (binlogConfigInstance.raw)
            {
                arguments.Append(" --raw");
            }
            if (!string.IsNullOrWhiteSpace(binlogConfigInstance.rewriteDb))
            {
                arguments.Append(" --rewrite-db=" + binlogConfigInstance.rewriteDb);
            }
            if (binlogConfigInstance.rowEventMaxSize != 0)
            {
                arguments.Append(" --binlog-row-event-max-size=" + binlogConfigInstance.rowEventMaxSize);
            }
            if (binlogConfigInstance.serverId != -1)
            {
                arguments.Append(" --server-id=" + binlogConfigInstance.serverId);
            }
            if (binlogConfigInstance.skipGtids)
            {
                arguments.Append(" --skip-gtids=true");
            }
            if (binlogConfigInstance.verbose)
            {
                arguments.Append(" -v");
            }


            //last
            arguments.Append(" ");
            foreach (string fname in config.logfiles)
            {
                arguments.Append(fname + " ");
            }
            Console.WriteLine(arguments.ToString());

            return(arguments);
        }
Beispiel #3
0
        private void bSave_Click(object sender, EventArgs e)
        {
            BinlogConfig configInstance = ConfigurationManager.getInstance().binlogConfigInstance;
            //add some extra checks in here later

            /*
             * MessageBox.Show("Header encryption only works with .7z file format. Switch to .7z format or disable header encryption.",
             *          "Header Encryption", MessageBoxButtons.OK, MessageBoxIcon.Error);*/

            //checks
            int  conServerId     = 0;
            int  serverId        = -1;
            long rowEventMaxSize = 0;

            if ((!string.IsNullOrWhiteSpace(tbRewriteFrom.Text) && string.IsNullOrWhiteSpace(tbRewriteTo.Text)) || (string.IsNullOrWhiteSpace(tbRewriteFrom.Text) && !string.IsNullOrWhiteSpace(tbRewriteTo.Text)))
            {
                MessageBox.Show("To rewrite database name both from and to fields must be set.",
                                "Save Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!string.IsNullOrWhiteSpace(tbConServerId.Text))
            {
                try
                {
                    conServerId = Convert.ToInt32(tbConServerId.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("The conncetion server id must be an integer.",
                                    "Save Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (!string.IsNullOrWhiteSpace(tbServerId.Text))
            {
                try
                {
                    serverId = Convert.ToInt32(tbServerId.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("The server id must be an integer.",
                                    "Save Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            if (!string.IsNullOrWhiteSpace(tbRowEventMaxSize.Text))
            {
                try
                {
                    rowEventMaxSize = Convert.ToInt64(tbRowEventMaxSize.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("The row event max size must be a long number.",
                                    "Save Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            //checks

            configInstance.characterSetsDir      = tbCharacterSetsDir.Text;
            configInstance.excludeGtids          = tbExcludeGtids.Text;
            configInstance.bindAdress            = tbBindAdress.Text;
            configInstance.base64output          = cmbBase64.SelectedValue.ToString();
            configInstance.charsetName           = cmbCharset.SelectedValue.ToString();
            configInstance.compressionAlgorithms = cmbCompressionAlgorithm.SelectedValue.ToString();
            configInstance.protocol = cmbProtocol.SelectedValue.ToString();
            if (!string.IsNullOrWhiteSpace(tbRewriteFrom.Text) && !string.IsNullOrWhiteSpace(tbRewriteTo.Text))
            {
                configInstance.rewriteDb = tbRewriteFrom.Text + "->" + tbRewriteTo.Text;
            }
            configInstance.conServerId        = conServerId;
            configInstance.serverId           = serverId;
            configInstance.rowEventMaxSize    = rowEventMaxSize;
            configInstance.disableLogBin      = cbDisableBinaryLogging.Checked;
            configInstance.forceIfOpen        = cbForceIfOpen.Checked;
            configInstance.forceRead          = cbForceRead.Checked;
            configInstance.getServerPublicKey = cbGetServerPublicKey.Checked;
            configInstance.idempotent         = cbIdempotent.Checked;
            configInstance.raw           = cbRaw.Checked;
            configInstance.skipGtids     = cbSkipGtids.Checked;
            configInstance.useServerTime = cbServerTime.Checked;
            //debug
            configInstance.debugCheck         = cbDebugCheck.Checked;
            configInstance.debugInfo          = cbDebugInfo.Checked;
            configInstance.hexdump            = cbHexdump.Checked;
            configInstance.printDefaults      = cbPrintDefaults.Checked;
            configInstance.printTableMetadata = cbPrintTableMetadata.Checked;
            configInstance.verbose            = cbVerbose.Checked;
            configInstance.debugOptions       = tbDebugOptions.Text;

            configInstance.saveConfig();
            this.Close();
        }