Esempio n. 1
0
        internal void Start()
        {
            List <string> tables   = utils.StringUtils.extractTableListFromString(schedulesRow.tables);
            string        database = schedulesRow.database;

            firedumpdbDataSetTableAdapters.sql_serversTableAdapter serveradapter = new firedumpdbDataSetTableAdapters.sql_serversTableAdapter();
            firedumpdbDataSet.sql_serversDataTable servertable = new firedumpdbDataSet.sql_serversDataTable();
            serveradapter.FillById(servertable, schedulesRow.server_id);

            if (servertable?.Count > 0)
            {
                //File.AppendAllText(@"servicelog.txt", "COUNT:"+servertable.Count+",");
                server = servertable[0];
            }
            else
            {
                //File.AppendAllText(@"servicelog.txt", "COUNT:" + "EMPTY" + ",");
                return;
            }
            DumpCredentialsConfig dumpConfig = new DumpCredentialsConfig(server.host, (int)server.port, server.username, server.password, database);

            if (tables.Count > 0)
            {
                dumpConfig.excludeTables = tables.ToArray();
            }

            mysqldumpAdapter                   = new SqlDumpAdapter();
            mysqldumpAdapter.Cancelled        += OnCancelled;
            mysqldumpAdapter.Completed        += OnCompleted;
            mysqldumpAdapter.CompressProgress += oncompressprogress;
            mysqldumpAdapter.CompressStart    += oncompstart;
            mysqldumpAdapter.Error            += onerror;
            mysqldumpAdapter.InitDumpTables   += oninitdumptables;
            mysqldumpAdapter.Progress         += onprogress;
            mysqldumpAdapter.TableRowCount    += ontablerowcount;
            mysqldumpAdapter.TableStartDump   += ontablestartdump;

            //File.AppendAllText(@"servicelog.txt", "STARTDUMP");
            mysqldumpAdapter.startDump(dumpConfig);
        }
Esempio n. 2
0
        private void bStartDump_Click(object sender, EventArgs e)
        {
            //new ProgressFormContainer().Show();
            if (!performChecks())
            {
                return;
            }
            if (adapter.isDumpRunning())
            {
                MessageBox.Show("dump is running...");
                return;
            }
            adapter = new SqlDumpAdapter();

            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(DbUtils.getSqlServerFromTable(serverData, cmbServers));

            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
            {
                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);
        }