public void TestExecuteDump() { ConfigurationManager.getInstance().initializeConfig(); MysqlDump mysqldump = new MysqlDump(); DumpCredentialsConfig creconfig = new DumpCredentialsConfig(); creconfig.host = Const.host; creconfig.port = 3306; creconfig.username = Const.username; creconfig.password = Const.password; creconfig.database = Const.database; mysqldump.credentialsConfigInstance = creconfig; DumpResultSet dumpresult = mysqldump.executeDump(); Console.WriteLine(dumpresult.ToString()); Assert.IsTrue(dumpresult.wasSuccessful); Assert.AreEqual(0, dumpresult.errorNumber); string absfilepath = dumpresult.fileAbsPath; Assert.AreEqual(true, File.Exists(absfilepath)); File.Delete(absfilepath); Assert.AreEqual(false, File.Exists(absfilepath)); }
public void startDump(DumpCredentialsConfig credentialsConfigInstance) { SqlDump mysqldump = new SqlDump(credentialsConfigInstance); mysqldump.IsTest = true; DumpResultSet dumpresult = mysqldump.executeDump(); }
public void startDump(DumpCredentialsConfig credentialsConfigInstance) { MysqlDump mysqldump = new MysqlDump(); mysqldump.credentialsConfigInstance = credentialsConfigInstance; DumpResultSet dumpresult = mysqldump.executeDump(); }
public void onCompleted(DumpResultSet status) { Assert.IsTrue(status.wasSuccessful); Assert.IsTrue(File.Exists(status.fileAbsPath)); File.Delete(status.fileAbsPath); Assert.IsFalse(File.Exists(status.fileAbsPath)); Console.WriteLine(progressCallCount); }
private void OnCompleted(DumpResultSet resultSet) { if (resultSet != null) { if (resultSet.wasSuccessful) { List <int> locations = new List <int>(); //get schedule_save_location data table by schedule ID firedumpdbDataSetTableAdapters.schedule_save_locationsTableAdapter savelocAdapter = new firedumpdbDataSetTableAdapters.schedule_save_locationsTableAdapter(); firedumpdbDataSet.schedule_save_locationsDataTable saveloctable = new firedumpdbDataSet.schedule_save_locationsDataTable(); savelocAdapter.FillByScheduleId(saveloctable, schedulesRow.id); if (saveloctable.Count > 0) { //File.AppendAllText(@"servicelog.txt", "saveloctable.Count > 0"); //now get backuplocations by backuplocationID try { firedumpdbDataSetTableAdapters.backup_locationsTableAdapter backupAdapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); firedumpdbDataSet.backup_locationsDataTable backuptable = new firedumpdbDataSet.backup_locationsDataTable(); for (int i = 0; i < saveloctable.Count; i++) { firedumpdbDataSet.backup_locationsDataTable temp = backupAdapter.GetDataByID(saveloctable[i].backup_location_id); locations.Add((int)temp[0].id); //File.AppendAllText(@"servicelog.txt", "Addbackup_locationsRow " + temp[0].id + temp[0].name); } locationAdapterManager = new LocationAdapterManager(locations, resultSet.fileAbsPath); locationAdapterManager.SaveInit += onSaveInitHandler; locationAdapterManager.InnerSaveInit += onInnerSaveInitHandler; locationAdapterManager.LocationProgress += onLocationProgressHandler; locationAdapterManager.SaveProgress += setSaveProgressHandler; locationAdapterManager.SaveComplete += onSaveCompleteHandler; locationAdapterManager.SaveError += onSaveErrorHandler; locationAdapterManager.setProgress(); //File.AppendAllText(@"servicelog.txt", "locationAdapterManager.startSave"); locationAdapterManager.startSave(); }catch (Exception ex) { Console.WriteLine(ex.ToString()); //File.AppendAllText(@"servicelog.txt", "Exception "+ex.ToString()); } } } } }
public void TestExecuteDump() { ConfigurationManager.getInstance(); SqlDump mysqldump = new SqlDump(new DumpCredentialsConfig(Const.host, 3306, Const.username, Const.password, Const.database)); mysqldump.IsTest = true; DumpResultSet dumpresult = mysqldump.executeDump(); Console.WriteLine(dumpresult.ToString()); Assert.IsTrue(dumpresult.wasSuccessful); Assert.AreEqual(0, dumpresult.errorNumber); string absfilepath = dumpresult.fileAbsPath; Assert.AreEqual(true, File.Exists(absfilepath)); File.Delete(absfilepath); Assert.AreEqual(false, File.Exists(absfilepath)); }
public void TestExecuteDumpPhaseTwo() { DumpCredentialsConfig creconfig = new DumpCredentialsConfig(); creconfig.host = Const.host; creconfig.port = 3306; creconfig.username = Const.username; creconfig.password = Const.password; creconfig.database = Const.database; ConfigurationManager.getInstance().initializeConfig(); ConfigurationManager.getInstance().mysqlDumpConfigInstance.includeCreateSchema = false; ConfigurationManager.getInstance().compressConfigInstance.enableCompression = true; DbConnection connection = DbConnection.Instance(); connection.Host = Const.host; connection.password = Const.password; connection.username = Const.username; List <string> tables = connection.getTables(Const.database); int actualNumOfTables = tables.Count; MysqlDump mysqldump = new MysqlDump(); mysqldump.IsTest = true; mysqldump.credentialsConfigInstance = creconfig; mysqldump.CompressProgress += compressProgress; mysqldump.CompressStart += onCompressStart; mysqldump.TableRowCount += tableRowCount; mysqldump.TableStartDump += onTableStartDump; DumpResultSet dumpresult = mysqldump.executeDump(); Assert.IsTrue(dumpresult.wasSuccessful); Assert.IsTrue(File.Exists(dumpresult.fileAbsPath)); File.Delete(dumpresult.fileAbsPath); Assert.AreEqual(false, File.Exists(dumpresult.fileAbsPath)); validateOnTableStartDump(actualNumOfTables); }
private void onCompletedHandler(DumpResultSet status) { if (status != null) { lStatus.Invoke((MethodInvoker) delegate() { lStatus.Text = "Completed"; }); pbDumpExec.Invoke((MethodInvoker) delegate() { pbDumpExec.Value = pbDumpExec.Maximum; }); if (status.wasSuccessful) { string prefix = null; if (cIncrementalFormat.Checked) { this.Invoke((MethodInvoker) delegate() { List <int> locations = new List <int>(); foreach (ListViewItem item in lbSaveLocations.Items) { Object loc = item.Tag; locations.Add(Convert.ToInt32(((firedumpdbDataSet.backup_locationsRow)loc).id)); } 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"]; 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); } } config.database = databases[0]; config.locationIds = locations.ToArray(); IncrementalUtils iutils = new IncrementalUtils(config); prefix = iutils.calculatePrefix(0)[1]; }); } saveToLocations(status.fileAbsPath, prefix); } else { this.UseWaitCursor = false; string errorMessage = ""; switch (status.errorNumber) { case -1: errorMessage = "Connection credentials not set correctly:\n" + status.errorMessage; Console.WriteLine(errorMessage); break; case -2: errorMessage = "MySQL dump failed:\n" + status.mysqldumpexeStandardError; Console.WriteLine(errorMessage); break; case -3: errorMessage = "Compression failed:\n" + status.mysqldumpexeStandardError; Console.WriteLine(errorMessage); break; default: break; } MessageBox.Show(errorMessage, "Dump failed", MessageBoxButtons.OK, MessageBoxIcon.Error); bStartDump.Invoke((MethodInvoker) delegate() { bStartDump.Enabled = true; }); } //kiala pramata na kanei edo, afta pou meleges // //gia ui components xriazete Invoke } else { this.UseWaitCursor = false; } }
private void onCompletedHandler(DumpResultSet status) { if (status != null) { lStatus.Invoke((MethodInvoker) delegate() { lStatus.Text = "Completed"; }); pbDumpExec.Invoke((MethodInvoker) delegate() { pbDumpExec.Value = pbDumpExec.Maximum; }); if (status.wasSuccessful) { //EDW KALEITAI TO SAVE STA LOCATIONS List <int> locations = new List <int>(); backuplocations = new List <firedumpdbDataSet.backup_locationsRow>(); dataGridView1.Invoke((MethodInvoker) delegate() { dataGridView1.Rows.Clear(); dataGridView1.Refresh(); }); this.Invoke((MethodInvoker) delegate() { foreach (ListViewItem item in lbSaveLocations.Items) { Object loc = item.Tag; locations.Add(Convert.ToInt32(((firedumpdbDataSet.backup_locationsRow)loc).id)); backuplocations.Add((firedumpdbDataSet.backup_locationsRow)loc); addToGridView(loc); } }); adapterLocation = new LocationAdapterManager(locations, status.fileAbsPath); adapterLocation.SaveInit += onSaveInitHandler; adapterLocation.InnerSaveInit += onInnerSaveInitHandler; adapterLocation.LocationProgress += onLocationProgressHandler; adapterLocation.SaveProgress += setSaveProgressHandler; adapterLocation.SaveComplete += onSaveCompleteHandler; adapterLocation.SaveError += onSaveErrorHandler; adapterLocation.setProgress(); adapterLocation.startSave(); } else { this.UseWaitCursor = false; string errorMessage = ""; switch (status.errorNumber) { case 1: errorMessage = "Connection credentials not set correctly:\n" + status.errorMessage; Console.WriteLine(errorMessage); break; case 2: errorMessage = "MySQL dump failed:\n" + status.mysqldumpexeStandardError; Console.WriteLine(errorMessage); break; case 3: errorMessage = "Compression failed:\n" + status.mysqldumpexeStandardError; Console.WriteLine(errorMessage); break; default: break; } MessageBox.Show(errorMessage, "Dump failed", MessageBoxButtons.OK, MessageBoxIcon.Error); bStartDump.Invoke((MethodInvoker) delegate() { bStartDump.Enabled = true; }); } } else { this.UseWaitCursor = false; } }