Exemplo n.º 1
0
        public static async Task<BackupResultHelper> StartBackup(List<Game> games, BackupType backupType, bool backupEnabled, BackupSyncOptions backupSyncOptions, int intervalMinute = 0, int intervalHour = 0) {
            //Check for problems with parameters
            if (!games.Any() && backupType == BackupType.Autobackup && backupEnabled) {
                _resultHelper = new BackupResultHelper {Message = @"Auto-backup disabled", AutobackupEnabled = false};
                return _resultHelper;
            }
            if (!games.Any()) {
                ErrorResultHelper.Message = @"No games selected";
                return ErrorResultHelper;
            }

            var gamesToBackup= new List<Game>();
            if (!backupEnabled) {
                if (!GetDirectoryOrFile(backupType)) return ErrorResultHelper;
                gamesToBackup = ModifyGamePaths(games);
            }

            switch (backupType) {                  
                case BackupType.ToZip:
                   return await BackupToZip.BackupAndZip(gamesToBackup, _specifiedFile);
                case BackupType.ToFolder:
                    return BackupToFolder.BackupSaves(gamesToBackup, _specifiedFolder);
                case BackupType.Autobackup:
                    return BackupAuto.ToggleAutoBackup(gamesToBackup, backupEnabled, backupSyncOptions, intervalMinute, intervalHour, _specifiedFolder);
            }

            return ErrorResultHelper;
        }
Exemplo n.º 2
0
 public static BackupResultHelper ToggleAutoBackup(List<Game> gamesToBackup, bool backupEnabled, BackupSyncOptions backupSyncOptions, int intervalMinute, int intervalHour, DirectoryInfo autobackupDi) {
     if (backupEnabled) return ShutdownAutobackup();
     GamesToBackup = gamesToBackup;
     _backupEnabled = false;
     _backupSyncOptions = backupSyncOptions;
     _autoBackupDirectoryInfo = autobackupDi;
     _progress = new ProgressHelper(){ FilesComplete = 0, TotalFiles = 0};
     return InitializeAutobackup(intervalMinute, intervalHour);
 }
Exemplo n.º 3
0
 public MainViewModel() {
     GamesDbApi = SingletonHelper.GamesDBAPI;
     BackupSyncOptions = new BackupSyncOptions();
     PercentComplete = 0;
     NumberOfBackups = 0;
     IntervalMinute = 5;
     Span = new TimeSpan(0,0,IntervalMinute,0); //Must always be initialized after Interval
     BackupEnabledVisibility = Visibility.Hidden;
     GamesList = DirectoryFinder.GetGamesList();
     GamesToBackup = new ObservableCollection<Game>();
     BackupTypes = new ObservableCollection<BackupType>() {
         BackupType.Autobackup,
         BackupType.ToFolder,
         BackupType.ToZip
     };
     BackupType = BackupType.ToFolder;
     DirectoryFinder.CreateSbtDirectories();
     SetUpInterface();
     RegisterAll();
     
 }