Esempio n. 1
0
        public void StartRestore(StartRestoreRequest request)
        {
            if ((BackupStorageType)request.StorageType == BackupStorageType.Local)
            {
                if (string.IsNullOrEmpty(request.FilePathOrId) || !File.Exists(request.FilePathOrId))
                {
                    throw new FileNotFoundException();
                }
            }

            if (!request.BackupId.Equals(Guid.Empty))
            {
                var backupRecord = BackupRepository.GetBackupRecord(request.BackupId);
                if (backupRecord == null)
                {
                    throw new FileNotFoundException();
                }

                request.FilePathOrId  = backupRecord.StoragePath;
                request.StorageType   = backupRecord.StorageType;
                request.StorageParams = JsonConvert.DeserializeObject <Dictionary <string, string> >(backupRecord.StorageParams);
            }

            var progress = BackupWorker.StartRestore(request);

            if (!string.IsNullOrEmpty(progress.Error))
            {
                throw new FaultException();
            }
        }
Esempio n. 2
0
        public void DeleteBackup(Guid id)
        {
            var backupRecord = BackupRepository.GetBackupRecord(id);

            BackupRepository.DeleteBackupRecord(backupRecord.Id);

            var storage = BackupStorageFactory.GetBackupStorage(backupRecord);

            if (storage == null)
            {
                return;
            }
            storage.Delete(backupRecord.StoragePath);
        }