Example #1
0
        private void bStartDump_Click(object sender, EventArgs e)
        {
            if (!performChecks())
            {
                return;
            }
            if (adapter.isDumpRunning())
            {
                MessageBox.Show("dump is running...");
                return;
            }
            if (logadapter.isDumpRunning())
            {
                MessageBox.Show("dump is running...");
                return;
            }


            List <string> databases      = new List <string>();
            List <string> excludedTables = new List <string>();

            tableList = new List <string>();
            foreach (TreeNode node in tvDatabases.Nodes)
            {
                if (node.Checked)
                {
                    databases.Add(node.Text);
                    string tables = "";
                    foreach (TreeNode childNode in node.Nodes)
                    {
                        if (!childNode.Checked)
                        {
                            tables += childNode.Text + ",";
                        }
                        else
                        {
                            tableList.Add(childNode.Text);
                        }
                    }
                    if (tables != "")
                    {
                        tables = tables.Substring(0, tables.Length - 1); //vgazei to teleutaio comma
                    }
                    excludedTables.Add(tables);
                }
            }

            //testing

            /*
             * IncrementalUtils testutils = new IncrementalUtils();
             * List<string> chain = testutils.calculateChain("D:\\MyStuff\\Backups\\dumps\\test\\testdumpinc_IDB_0.2.2_2019-10-30 17,50,46", -1);
             * foreach (string chainfname in chain)
             * {
             *  Console.WriteLine("chain: "+chainfname);
             * }
             * bool b = true; //gia na mi vgazei unreachable code apo katw
             * if (b) return;*/
            /*
             * BinlogDumpCredentialsConfig configtest1 = new BinlogDumpCredentialsConfig();
             * configtest1.host = (string)serverData.Rows[cmbServers.SelectedIndex]["host"];
             * configtest1.port = unchecked((int)(long)serverData.Rows[cmbServers.SelectedIndex]["port"]);
             * configtest1.username = (string)serverData.Rows[cmbServers.SelectedIndex]["username"];
             * configtest1.password = (string)serverData.Rows[cmbServers.SelectedIndex]["password"];
             *
             * backuplocations = new List<firedumpdbDataSet.backup_locationsRow>();
             * List<int> locationIds1 = new List<int>();
             * foreach (ListViewItem item in lbSaveLocations.Items)
             * {
             *  Object loc = item.Tag;
             *  backuplocations.Add((firedumpdbDataSet.backup_locationsRow)loc);
             *  locationIds1.Add((int)((firedumpdbDataSet.backup_locationsRow)loc).id);
             * }
             * configtest1.locationIds = locationIds1.ToArray();
             * configtest1.isIncrementalDelta = true;
             * IncrementalUtils iutils = new IncrementalUtils(configtest1);
             * configtest1 = iutils.calculateDumpConfig();
             *
             * foreach (string logfile in configtest1.logfiles)
             * {
             *  Console.WriteLine(logfile);
             * }
             * Console.WriteLine("Next prefix: " + configtest1.prefix);
             * Console.WriteLine("StartDateTime: " + configtest1.startDateTime);
             * bool a = true; //gia na mi vgazei unreachable code apo katw
             * if (a) return;
             * // /testing*/

            if (cIncrementalFormat.Checked && databases.Count() > 1)
            {
                MessageBox.Show("Only one database may be selected with incremental format enabled.", "MySQL dump", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (databases.Count == 0)
            {
                MessageBox.Show("No database selected", "MySQL Dump", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!cIncrementalFormat.Checked || rbFull.Checked)
            {
                adapter = new MySqlDumpAdapter();
                DumpCredentialsConfig config = new DumpCredentialsConfig();
                config.host     = (string)serverData.Rows[cmbServers.SelectedIndex]["host"];
                config.port     = unchecked ((int)(long)serverData.Rows[cmbServers.SelectedIndex]["port"]);
                config.username = (string)serverData.Rows[cmbServers.SelectedIndex]["username"];
                config.password = (string)serverData.Rows[cmbServers.SelectedIndex]["password"];


                if (databases.Count == 1)
                {
                    config.database = databases[0];
                    if (excludedTables[0] != "")
                    {
                        config.excludeTablesSingleDatabase = excludedTables[0];
                    }
                }
                else
                {
                    databaseList         = databases;
                    config.database      = databases[0];
                    config.databases     = databases.ToArray();
                    config.excludeTables = excludedTables.ToArray();
                }

                pbDumpExec.Value = 0;

                bStartDump.Enabled = false;
                adapter.setTableList(tableList);

                adapter.Cancelled        += onCancelledHandler;
                adapter.Completed        += onCompletedHandler;
                adapter.CompressProgress += compressProgressHandler;
                adapter.CompressStart    += onCompressStartHandler;
                adapter.Error            += onErrorHandler;
                adapter.InitDumpTables   += initDumpTablesHandler;
                adapter.Progress         += onProgressHandler;
                adapter.TableRowCount    += tableRowCountHandler;
                adapter.TableStartDump   += onTableDumpStartHandler;

                this.UseWaitCursor = true;
                adapter.startDump(config);
            }
            else
            {
                logadapter = new BinlogDumpAdapter();
                BinlogDumpCredentialsConfig config = new BinlogDumpCredentialsConfig();
                config.host               = (string)serverData.Rows[cmbServers.SelectedIndex]["host"];
                config.port               = unchecked ((int)(long)serverData.Rows[cmbServers.SelectedIndex]["port"]);
                config.username           = (string)serverData.Rows[cmbServers.SelectedIndex]["username"];
                config.password           = (string)serverData.Rows[cmbServers.SelectedIndex]["password"];
                config.database           = databases[0]; //if here only one database is selected due to above checks
                config.isIncrementalDelta = rbIncDelta.Checked;

                backuplocations = new List <firedumpdbDataSet.backup_locationsRow>();
                List <int> locationIds = new List <int>();
                foreach (ListViewItem item in lbSaveLocations.Items)
                {
                    Object loc = item.Tag;
                    backuplocations.Add((firedumpdbDataSet.backup_locationsRow)loc);
                    locationIds.Add((int)((firedumpdbDataSet.backup_locationsRow)loc).id);
                }
                config.locationIds = locationIds.ToArray();

                pbDumpExec.Value   = 0;
                bStartDump.Enabled = false;

                logadapter.config = config;

                //handlers
                logadapter.Cancelled        += onCancelledHandler;
                logadapter.Completed        += onCompletedHandlerBinlog;
                logadapter.CompressProgress += compressProgressHandler;
                logadapter.CompressStart    += onCompressStartHandler;
                logadapter.Progress         += onProgressHandler;
                logadapter.Error            += onErrorHandler;
                //handlers

                this.UseWaitCursor = true;
                logadapter.startDump();
            }
        }
Example #2
0
        private void bStartDump_Click(object sender, EventArgs e)
        {
            if (!performChecks())
            {
                return;
            }
            if (adapter.isDumpRunning())
            {
                MessageBox.Show("dump is running...");
                return;
            }
            adapter = new MySqlDumpAdapter();

            List <string> databases      = new List <string>();
            List <string> excludedTables = new List <string>();

            tableList = new List <string>();
            foreach (TreeNode node in tvDatabases.Nodes)
            {
                if (node.Checked)
                {
                    databases.Add(node.Text);
                    string tables = "";
                    foreach (TreeNode childNode in node.Nodes)
                    {
                        if (!childNode.Checked)
                        {
                            tables += childNode.Text + ",";
                        }
                        else
                        {
                            tableList.Add(childNode.Text);
                        }
                    }
                    if (tables != "")
                    {
                        tables = tables.Substring(0, tables.Length - 1); //vgazei to teleutaio comma
                    }
                    excludedTables.Add(tables);
                }
            }

            DumpCredentialsConfig config = new DumpCredentialsConfig();

            config.host     = (string)serverData.Rows[cmbServers.SelectedIndex]["host"];
            config.port     = unchecked ((int)(long)serverData.Rows[cmbServers.SelectedIndex]["port"]);
            config.username = (string)serverData.Rows[cmbServers.SelectedIndex]["username"];
            config.password = (string)serverData.Rows[cmbServers.SelectedIndex]["password"];

            if (databases.Count == 0)
            {
                MessageBox.Show("No database selected", "MySQL Dump", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (databases.Count == 1)
            {
                config.database = databases[0];
                if (excludedTables[0] != "")
                {
                    config.excludeTablesSingleDatabase = excludedTables[0];
                }
            }
            else
            {
                databaseList         = databases;
                config.database      = databases[0];
                config.databases     = databases.ToArray();
                config.excludeTables = excludedTables.ToArray();
            }

            pbDumpExec.Value = 0;

            bStartDump.Enabled = false;
            adapter.setTableList(tableList);

            adapter.Cancelled        += onCancelledHandler;
            adapter.Completed        += onCompletedHandler;
            adapter.CompressProgress += compressProgressHandler;
            adapter.CompressStart    += onCompressStartHandler;
            adapter.Error            += onErrorHandler;
            adapter.InitDumpTables   += initDumpTablesHandler;
            adapter.Progress         += onProgressHandler;
            adapter.TableRowCount    += tableRowCountHandler;
            adapter.TableStartDump   += onTableDumpStartHandler;
            adapter.startDump(config);
        }