private void btnsavelocation_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(tbfilename.Text) || String.IsNullOrEmpty(tbsavename.Text)) { MessageBox.Show("Must provide fileName and SaveName to save"); return; } try { firedumpdbDataSetTableAdapters.backup_locationsTableAdapter backup_adapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); if (isEditor) { backup_adapter.Update(tbsavename.Text, "", "", path, tbfilename.Text, (int)ServiceType.Type.DropBox, 0, "", "", "", "", "", "", "", 0, 0, tbtoken.Text, "", 0, "", 0, row.id); } else { backup_adapter.Insert(tbsavename.Text, "", "", path, tbfilename.Text, (int)ServiceType.Type.DropBox, 0, "", "", "", "", "", "", "", 0, 0, tbtoken.Text, "", 0, "", 0); } locswitch.reloadDataset(); this.Close(); } catch (Exception ex) { MessageBox.Show("Could not save , error!"); } }
private void onJobSetDetails(JobDetail jobDetails) { Random rnd = new Random(); int sec = rnd.Next(10, 50); jobDetails.Second = sec; newJobs.Add(jobDetails); Console.WriteLine(jobDetails.DayOfWeek); firedumpdbDataSetTableAdapters.schedulesTableAdapter scheduleAdapter = new firedumpdbDataSetTableAdapters.schedulesTableAdapter(); scheduleAdapter.Insert((int)jobDetails.Server.id, jobDetails.Name, DateTime.Now, jobDetails.Activate, jobDetails.Hour, jobDetails.Database, "-", jobDetails.Minute, jobDetails.Second, jobDetails.DayOfWeek); firedumpdbDataSet.schedulesDataTable scheduleTable = new firedumpdbDataSet.schedulesDataTable(); scheduleAdapter.FillIdByName(scheduleTable, jobDetails.Name); int scheduleId = (int)scheduleTable[0].id; int locId = jobDetails.LocationId; firedumpdbDataSetTableAdapters.schedule_save_locationsTableAdapter savelocAdapter = new firedumpdbDataSetTableAdapters.schedule_save_locationsTableAdapter(); savelocAdapter.Insert(scheduleId, locId); firedumpdbDataSetTableAdapters.backup_locationsTableAdapter backAdapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); firedumpdbDataSet.backup_locationsDataTable backuptable = new firedumpdbDataSet.backup_locationsDataTable(); backuptable = backAdapter.GetDataByID(locId); dataGridViewlocs.DataSource = backuptable; scheduleAdapter.FillOrderByDate(scheduleTable); dataGridView1.DataSource = scheduleTable; }
private void loadlocationsCombobox() { firedumpdbDataSetTableAdapters.backup_locationsTableAdapter locAdapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); loctable = new firedumpdbDataSet.backup_locationsDataTable(); locAdapter.Fill(loctable); cblocation.DataSource = loctable; cblocation.DisplayMember = "name"; cblocation.ValueMember = "id"; if (cblocation.Items.Count > 0) { cblocation.SelectedIndex = 0; } }
private void bSave_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbName.Text)) { MessageBox.Show("Please enter a valid name for the enw file location", "New file system location", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { Path.IsPathRooted(tbPath.Text); } catch (ArgumentException ex) { MessageBox.Show("Please choose a valid path", "New file system location", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } adapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); if ((Int64)adapter.numberOfOccurances(tbName.Text) != 0) { MessageBox.Show("A save location with this name already exists", "New file system location", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { if (isEditor) { adapter.Update(tbName.Text, "", "", tbPath.Text, "", (int)ServiceType.Type.Local, 0, "", "", "", "", "", "", "", 0, 0, "", "", 0, "", 0, (Int64)locallocation["id"]); } else { adapter.Insert(tbName.Text, "", "", tbPath.Text, "", (int)ServiceType.Type.Local, 0, "", "", "", "", "", "", "", 0, 0, "", "", 0, "", 0); } locswitch.reloadDataset(); //callback stin klasi pou to kalese na kanei refresh to combobox this.Close(); } catch (Exception ex) { MessageBox.Show("Error occured trying to save to the database:\n" + ex.Message, "File system Location Save", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void bSave_Click(object sender, EventArgs e) { if (!performChecks(true)) { return; } if (!testConnectionSucceded) { DialogResult res = MessageBox.Show("Connection wasn't tested or the test wasn't successful. Save anyway?", "FTP Location Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (res != DialogResult.Yes) { return; } } firedumpdbDataSetTableAdapters.backup_locationsTableAdapter backup_adapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); int protocol = cmbProtocol.SelectedIndex; try { String passwd = EncryptionUtils.sEncrypt(tbPassword.Text); if (isEditor) { backup_adapter.Update(tbName.Text, tbUsername.Text, passwd, tbChooseAPath.Text, tbFilename.Text, (int)ServiceType.Type.Ftp, protocol, tbPrivateKey.Text, sshKeyFingerprint, "", "", "", "", "", 0, 0, "", "", Convert.ToInt64(tbPort.Text), tbHost.Text, protocol, (Int64)ftplocation["id"]); } else { backup_adapter.Insert(tbName.Text, tbUsername.Text, passwd, tbChooseAPath.Text, tbFilename.Text, (int)ServiceType.Type.Ftp, protocol, tbPrivateKey.Text, sshKeyFingerprint, "", "", "", "", "", 0, 0, "", "", Convert.ToInt64(tbPort.Text), tbHost.Text, protocol); } listener.reloadDataset(); this.Close(); }catch (Exception ex) { MessageBox.Show("Error occured trying to save:\n" + ex.Message, "FTP Location Save", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
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) { //File.AppendAllText(@"servicelog.txt", "Exception "+ex.ToString()); } } } } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1) { return; } if (e.ColumnIndex == 1) { int scheduleId = 0; if (int.TryParse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(), out scheduleId)) { if (scheduleId != -1) { DialogResult result = MessageBox.Show("Are you sure you want to delete this Job?", "Delete Schedule-Job", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { //delete from userinfo, schedule_save_location and logs first //userinfo firedumpdbDataSetTableAdapters.userinfoTableAdapter userAdapter = new firedumpdbDataSetTableAdapters.userinfoTableAdapter(); userAdapter.DeleteQueryByScheduleid(scheduleId); //logs firedumpdbDataSetTableAdapters.logsTableAdapter logAdapter = new firedumpdbDataSetTableAdapters.logsTableAdapter(); logAdapter.DeleteQueryByScheduleid(scheduleId); //save_locations firedumpdbDataSetTableAdapters.schedule_save_locationsTableAdapter saveLocAdapter = new firedumpdbDataSetTableAdapters.schedule_save_locationsTableAdapter(); saveLocAdapter.DeleteQueryByScheduleId(scheduleId); //last delete from schedule schedulesTableAdapter.DeleteQueryById(scheduleId); firedumpdbDataSet.schedulesDataTable scheduleTable = new firedumpdbDataSet.schedulesDataTable(); schedulesTableAdapter.FillOrderByDate(scheduleTable); dataGridView1.DataSource = scheduleTable; } } } } else { int scheduleId = 0; if (int.TryParse(dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString(), out scheduleId)) { if (scheduleId != -1) { firedumpdbDataSetTableAdapters.schedule_save_locationsTableAdapter savelocAdapter = new firedumpdbDataSetTableAdapters.schedule_save_locationsTableAdapter(); firedumpdbDataSetTableAdapters.backup_locationsTableAdapter backAdapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); firedumpdbDataSet.schedule_save_locationsDataTable saveloctable = new firedumpdbDataSet.schedule_save_locationsDataTable(); savelocAdapter.FillByScheduleId(saveloctable, scheduleId); firedumpdbDataSet.backup_locationsDataTable backuptable = new firedumpdbDataSet.backup_locationsDataTable(); if (saveloctable.Count > 0) { backuptable = backAdapter.GetDataByID(saveloctable[0].backup_location_id); dataGridViewlocs.DataSource = backuptable; } //MessageBox.Show(scheduleId+" "+saveloctable.Count.ToString()); } } } }
private void saveFingerprint(string fingerprint) { firedumpdbDataSetTableAdapters.backup_locationsTableAdapter adapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); adapter.UpdateFingerprint(fingerprint, config.id); }
/// <summary> /// /// </summary> /// <param name="bpType">0 = Full Backup 1 = Incremental Backup 2 = Incremental Delta</param> /// <returns></returns> public string[] calculatePrefix(int bpType) { string prefix = ""; //<filename_prefix> firedumpdbDataSetTableAdapters.backup_locationsTableAdapter adapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); List <firedumpdbDataSet.backup_locationsRow> locations = new List <firedumpdbDataSet.backup_locationsRow>(); foreach (int id in locationIds) { locations.Add(adapter.GetDataByID(id)[0]); } int index = -1; int j = 0; while (index == -1 && j < locations.Count()) { if (locations[j].service_type == 0) { index = j; } j++; } List <string[]> splitBpFnames = new List <string[]>(); if (index == -1) { //periptwsi p den iparxei save location local fix argotera string path = locations[0].path; //dialegw tixea to prwto location string[] splitpath = StringUtils.splitPath(path); List <string> fnames = new List <string>(); switch (locations[0].service_type) { case 1: //FTP fnames = getFtpDirectoryListing(locations[0], splitpath[0]); break; case 2: //dropbox break; case 3: //google drive break; default: break; } splitBpFnames = getSplitBpFnames(fnames, splitpath[1].Split('_')[0]); } else { string path = locations[index].path; string[] splitpath = StringUtils.splitPath(path); List <string> fnames = new List <string>(); foreach (string fname in Directory.GetFiles(splitpath[0])) { fnames.Add(fname.Replace(splitpath[0], "")); } splitBpFnames = getSplitBpFnames(fnames, splitpath[1].Split('_')[0]); //Console.WriteLine("path "+splitpath[0]); //Console.WriteLine("filename " + splitpath[1]); } string[] res = new string[2]; if (splitBpFnames.Count() > 0) { res = findNext(splitBpFnames, bpType); prefix += res[1]; } else { prefix += "FB_0.0.0"; } //calculate datetime and add it to prefix in binlog required format if (ConfigurationManager.getInstance().binlogConfigInstance.useServerTime) { MySQLCredentialsConfig myconfig = new MySQLCredentialsConfig(); myconfig.host = config.host; myconfig.port = config.port; myconfig.username = config.username; myconfig.password = config.password; myconfig.database = config.database; DbConnection dbcon = new DbConnection(myconfig); prefix += "_" + dbcon.getCurrentDatetime().Replace(':', ','); } else { prefix += "_" + DateTime.Now.ToString("yyyy-M-d HH:mm:ss").Replace(':', ','); } //</filename_prefix> res[1] = prefix; return(res); }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="locid">-1 for local path or the id of the save location</param> /// <returns>List of full paths for all files in the import chain in order</returns> public List <string> calculateChain(string path, int locid) { List <string> filesChain = new List <string>(); try { string[] tmp = StringUtils.splitPath(path); string initpath = tmp[0]; string initfname = tmp[1]; if (initfname.Contains("_FB_")) //is full backup { filesChain.Add(path); return(filesChain); } if (!initfname.Contains("_FB_") && !initfname.Contains("_IB_") && !initfname.Contains("_IDB_")) // file has no incremental format { filesChain.Add(path); return(filesChain); } string initfnamecut = tmp[1].Split('_')[0]; string[] filesindir = new string[1]; if (locid != -1) { firedumpdbDataSetTableAdapters.backup_locationsTableAdapter adapter = new firedumpdbDataSetTableAdapters.backup_locationsTableAdapter(); firedumpdbDataSet.backup_locationsRow location = adapter.GetDataByID(locid)[0]; switch (location.service_type) { case 0: //Local filesindir = Directory.GetFiles(initpath); break; case 1: //FTP filesindir = getFtpDirectoryListing(location, initpath).ToArray(); break; case 2: //dropbox break; case 3: //google drive break; default: break; } } else { filesindir = Directory.GetFiles(initpath); } List <string> fnames = new List <string>(); foreach (string fpath in filesindir) { fnames.Add(fpath.Replace(initpath, "")); } List <string> bpFnames = new List <string>(); foreach (string fname in fnames) { if (fname.Contains(initfnamecut) && fname.Contains("_")) { bpFnames.Add(fname); } } if (bpFnames.Count() < 2) { filesChain.Add("Error:No previous files in chain for incremental backup."); return(filesChain); } string[] splitinitbpindexes = initfname.Split('_')[2].Split('.'); //0.0.0 int indexC = Convert.ToInt32(splitinitbpindexes[2]); List <int> chainedIndexes = new List <int>(); int idx = StringUtils.indexOfContained(bpFnames, splitinitbpindexes[0] + "." + "0.0"); if (idx != -1) { filesChain.Add(initpath + bpFnames[idx]); } else { filesChain = new List <string>(); filesChain.Add("Error:Missing file with version: " + splitinitbpindexes[0] + ".0.0" + " from the incremental chain"); return(filesChain); } if (indexC > 0) { for (int i = 0; i <= indexC; i++) { idx = StringUtils.indexOfContained(bpFnames, splitinitbpindexes[0] + "." + splitinitbpindexes[1] + "." + i); if (idx != -1) { filesChain.Add(initpath + bpFnames[idx]); } else { filesChain = new List <string>(); filesChain.Add("Error:Missing file with version: " + splitinitbpindexes[0] + "." + splitinitbpindexes[1] + "." + i + " from the incremental chain"); return(filesChain); } } } else { filesChain.Add(path); } } catch (Exception ex) { filesChain.Add("Error"); filesChain.Add("Excption calculating file chain: " + ex.Message); Console.WriteLine(ex.StackTrace); } return(filesChain); }