public int UpdateBackupPlan(BackupPlan backupPlan) { lock (DatabaseConnection.connection) { return(DatabaseConnection.connection.Update(backupPlan)); } }
public ManageBackupPlanWindow(int backupPlanId) { InitializeComponent(); isNewBackupPlan = false; databaseService = new DatabaseService(); backupPlanToEdit = databaseService.GetBackupPlan(backupPlanId); }
public int InsertBackupPlan(BackupPlan backupPlan) { lock (DatabaseConnection.connection) { return(DatabaseConnection.connection.Insert(backupPlan)); } }
public void InsertBackup(Backup backup) { lock (DatabaseConnection.connection) { DatabaseConnection.connection.Insert(backup); BackupPlan backupPlan = GetBackupPlan(backup.backupPlanId); backupPlan.lastExecution = backup.date; backupPlan.currentStatus = "Updated"; backupPlan.lastResult = true; backupPlan.lastBackupDuration = backup.runTime; DatabaseConnection.connection.Update(backupPlan); } }
private void buttonComplete_Click(object sender, EventArgs e) { if (ValidatePlanCreation()) { string dialogMessage; if (isNewBackupPlan) { BackupPlan plan = new BackupPlan(); plan.name = textBoxPlanName.Text; plan.path = textBoxFolderPath.Text; plan.creationDate = DateTime.Now; plan.scheduleType = comboBoxScheduleType.Text; plan.scheduleTime = dateTimePickerScheduleTime.Value; if (comboBoxScheduleType.Text.Equals("Weekly") || comboBoxScheduleType.Text.Equals("Monthly")) { plan.scheduleDay = comboBoxMonthOrWeekDay.SelectedIndex + 1; } plan.currentStatus = "No backup"; plan.cloudName = comboBoxClouds.Text; plan.cloudId = ((ListItem)comboBoxClouds.SelectedItem).Value; plan.overrideBackup = radioButtonYes.Checked ? true : false; if (!plan.scheduleType.Equals("Manual")) { plan.nextExecution = MyUtils.GetNextExecution(plan); } databaseService.InsertBackupPlan(plan); dialogMessage = "Plan created succesfully!"; Logger.Log(string.Format("Plan {0} created succesfully!", plan.name)); } else { backupPlanToEdit.name = textBoxPlanName.Text; backupPlanToEdit.path = textBoxFolderPath.Text; backupPlanToEdit.creationDate = DateTime.Now; backupPlanToEdit.scheduleType = comboBoxScheduleType.Text; backupPlanToEdit.scheduleTime = dateTimePickerScheduleTime.Value; if (comboBoxScheduleType.Text.Equals("Weekly") || comboBoxScheduleType.Text.Equals("Monthly")) { backupPlanToEdit.scheduleDay = comboBoxMonthOrWeekDay.SelectedIndex + 1; } backupPlanToEdit.cloudName = comboBoxClouds.Text; backupPlanToEdit.cloudId = ((ListItem)comboBoxClouds.SelectedItem).Value; backupPlanToEdit.overrideBackup = radioButtonYes.Checked ? true : false; if (!backupPlanToEdit.scheduleType.Equals("Manual")) { backupPlanToEdit.nextExecution = MyUtils.GetNextExecution(backupPlanToEdit); } databaseService.UpdateBackupPlan(backupPlanToEdit); dialogMessage = "Plan updated succesfully"; } this.DialogResult = DialogResult.OK; DialogResult dialog = MessageBox.Show(dialogMessage); if (dialog == DialogResult.OK) { MainWindow.instance.backupPlansTabController.LoadPlans(); this.Close(); } } else { DialogResult dialog = MessageBox.Show("Please complete all fields."); } }