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

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

                request.FilePathOrId  = backupRecord.StoragePath;
                request.StorageType   = backupRecord.StorageType;
                request.StorageParams = backupRecord.StorageParams;
            }

            var progress = BackupWorker.StartRestore(request);

            if (!string.IsNullOrEmpty(progress.Error))
            {
                throw new FaultException(progress.Error);
            }
            return(progress);
        }
Exemple #2
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();
            }
        }
Exemple #3
0
        public BackupProgress StartRestore(StartRestoreRequest request)
        {
            if (!request.BackupId.Equals(Guid.Empty))
            {
                var backupRepository = BackupStorageFactory.GetBackupRepository();
                var backupRecord     = backupRepository.GetBackupRecord(request.BackupId);
                if (backupRecord == null)
                {
                    throw new FileNotFoundException();
                }

                request.FilePathOrId = backupRecord.StoragePath;
                request.StorageType  = backupRecord.StorageType;
            }

            var progress = BackupWorker.StartRestore(request.TenantId, request.StorageType, request.FilePathOrId, request.NotifyAfterCompletion);

            if (!string.IsNullOrEmpty(progress.Error))
            {
                throw new FaultException(progress.Error);
            }
            return(progress);
        }