Ejemplo n.º 1
0
 public void DeleteBackup()
 {
     FileIOHelper.DeleteSingleFile(SelectedBackup.FullName);
     BackupList.Remove(SelectedBackup);
     SelectedBackup = null;
     NotifyOfPropertyChange(() => BackupList);
     NotifyOfPropertyChange(() => SelectedBackup);
 }
Ejemplo n.º 2
0
        public void DeleteActiveDatabase()
        {
            // Make a safety backup for the active database
            string source = Settings.DatabasePath;
            string guid   = Guid.NewGuid().ToString();
            string target = $"{Settings.BackupPath}Delete backup {guid}.db";

            if (CopyDatabase(source, target))
            {
                FileInfo targetFile = new FileInfo(target);
                BackupList.Add(targetFile);
                FileIOHelper.DeleteSingleFile(source);
                NotifyOfPropertyChange(() => CanDeleteActiveDatabase);
                NotifyOfPropertyChange(() => CanCreateDatabase);
            }
        }
Ejemplo n.º 3
0
        public void RestoreBackup()
        {
            // Make a safetybackup for the active database
            string source = Settings.DatabasePath;
            string guid   = Guid.NewGuid().ToString();
            string target = $"{Settings.BackupPath}Restore backup {guid}.db";

            if (File.Exists(source))
            {
                if (CopyDatabase(source, target))
                {
                    FileInfo targetFile = new FileInfo(target);
                    BackupList.Add(targetFile);
                    FileIOHelper.DeleteSingleFile(source);
                    CopyDatabase(SelectedBackup.FullName, source);
                }
            }
            else
            {
                // no active database for any reason ..
                CopyDatabase(SelectedBackup.FullName, source);
                NotifyOfPropertyChange(() => CanDeleteActiveDatabase);
            }
        }