Exemple #1
0
        private void deleteBackup()
        {
            string       backupName = this.loadSelectedBackup();
            DialogResult result     = MessageBox.Show("Are you sure you want to delete the backup " + backupName + "?", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.No)
            {
                return;
            }
            string filepath = this.loadSelectedBackup();

            if (filepath == null)
            {
                return;
            }
            Database database = new Database(filepath);
            Settings settings = new Settings(database);
            string   name     = settings.Name;

            database.Close();
            try {
                File.Delete(filepath);
            }
            catch (IOException e) {
                this.showError("Could not delete " + filepath + ": " + e.Message);
            }
            Scheduler.Delete(name);
            this.populateBackupsList();
        }
        private void setupTask()
        {
            DateTime start = DateTime.Today + new TimeSpan(this.dateTimePickerScheduleTime.Value.Hour, this.dateTimePickerScheduleTime.Value.Minute, 0);

            // If we're starting in the past, move to tomorrow
            if (start < DateTime.Now)
            {
                start += new TimeSpan(1, 0, 0, 0);
            }

            DaysOfTheWeek dow = 0;

            if (this.checkBoxScheduleMon.Checked)
            {
                dow |= DaysOfTheWeek.Monday;
            }
            if (this.checkBoxScheduleTues.Checked)
            {
                dow |= DaysOfTheWeek.Tuesday;
            }
            if (this.checkBoxScheduleWeds.Checked)
            {
                dow |= DaysOfTheWeek.Wednesday;
            }
            if (this.checkBoxScheduleThurs.Checked)
            {
                dow |= DaysOfTheWeek.Thursday;
            }
            if (this.checkBoxScheduleFri.Checked)
            {
                dow |= DaysOfTheWeek.Friday;
            }
            if (this.checkBoxScheduleSat.Checked)
            {
                dow |= DaysOfTheWeek.Saturday;
            }
            if (this.checkBoxScheduleSun.Checked)
            {
                dow |= DaysOfTheWeek.Sunday;
            }

            if (this.initialBackupName != null && this.initialBackupName != this.settings.Name)
            {
                Scheduler.Delete(this.initialBackupName);
            }
            Scheduler scheduler = new Scheduler(this.checkBoxUseScheduler.Checked, start, dow, this.checkBoxSchedulerWhenAvailable.Checked, this.checkBoxSchedulerOnBatteries.Checked);

            scheduler.Save(this.settings.Name);
        }