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()); } } } } }
private void saveToLocations(string fileAbsPath, string prefix) { //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() { progressContainer = new ProgressFormContainer(); //progressContainer.Show(); 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, fileAbsPath, prefix); //fix auto na mpei to prefix adapterLocation.SaveInit += onSaveInitHandler; adapterLocation.InnerSaveInit += onInnerSaveInitHandler; adapterLocation.LocationProgress += onLocationProgressHandler; adapterLocation.SaveProgress += setSaveProgressHandler; adapterLocation.SaveComplete += onSaveCompleteHandler; adapterLocation.SaveError += onSaveErrorHandler; adapterLocation.setProgress(); adapterLocation.startSave(); }
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; } }