BackupsContext - async

This commit is contained in:
Anton Suhorukov 2023-03-13 19:29:42 +03:00
parent 34b3fe715c
commit 9a1404a401
16 changed files with 111 additions and 119 deletions

View File

@ -127,7 +127,7 @@ public class BackupAjaxHandler
{
DemandPermissionsBackup();
await _backupService.DeleteAllBackups(GetCurrentTenantId());
await _backupService.DeleteAllBackupsAsync(GetCurrentTenantId());
}
public async Task<List<BackupHistoryRecord>> GetBackupHistory()
@ -173,16 +173,16 @@ public class BackupAjaxHandler
break;
}
_backupService.CreateSchedule(scheduleRequest);
_backupService.CreateScheduleAsync(scheduleRequest);
}
public Schedule GetSchedule()
public async Task<Schedule> GetScheduleAsync()
{
DemandPermissionsBackup();
ScheduleResponse response;
response = _backupService.GetSchedule(GetCurrentTenantId());
response = await _backupService.GetScheduleAsync(GetCurrentTenantId());
if (response == null)
{
return null;
@ -224,7 +224,7 @@ public class BackupAjaxHandler
StorageParams = schedule.StorageParams
};
_backupService.CreateSchedule(Schedule);
_backupService.CreateScheduleAsync(Schedule);
}
else if (response.StorageType != BackupStorageType.ThirdPartyConsumer)
@ -235,12 +235,11 @@ public class BackupAjaxHandler
return schedule;
}
public void DeleteSchedule()
public Task DeleteScheduleAsync()
{
DemandPermissionsBackup();
_backupService.DeleteSchedule(GetCurrentTenantId());
return _backupService.DeleteScheduleAsync(GetCurrentTenantId());
}
private void DemandPermissionsBackup()
@ -257,7 +256,7 @@ public class BackupAjaxHandler
#region restore
public void StartRestore(string backupId, BackupStorageType storageType, Dictionary<string, string> storageParams, bool notify)
public Task StartRestoreAsync(string backupId, BackupStorageType storageType, Dictionary<string, string> storageParams, bool notify)
{
DemandPermissionsRestore();
@ -283,7 +282,7 @@ public class BackupAjaxHandler
}
}
_backupService.StartRestore(restoreRequest);
return _backupService.StartRestoreAsync(restoreRequest);
}
public BackupProgress GetRestoreProgress()

View File

@ -33,13 +33,13 @@ public interface IBackupService
BackupProgress GetRestoreProgress(int tenantId);
BackupProgress GetTransferProgress(int tenantId);
Task<List<BackupHistoryRecord>> GetBackupHistory(int tenantId);
ScheduleResponse GetSchedule(int tenantId);
Task<ScheduleResponse> GetScheduleAsync(int tenantId);
string GetTmpFolder();
void CreateSchedule(CreateScheduleRequest request);
Task DeleteAllBackups(int tenantId);
Task CreateScheduleAsync(CreateScheduleRequest request);
Task DeleteAllBackupsAsync(int tenantId);
Task DeleteBackup(Guid backupId);
void DeleteSchedule(int tenantId);
Task DeleteScheduleAsync(int tenantId);
void StartBackup(StartBackupRequest request);
void StartRestore(StartRestoreRequest request);
Task StartRestoreAsync(StartRestoreRequest request);
void StartTransfer(StartTransferRequest request);
}

View File

@ -60,8 +60,8 @@ public class BackupService : IBackupService
public async Task DeleteBackup(Guid id)
{
var backupRecord = _backupRepository.GetBackupRecord(id);
_backupRepository.DeleteBackupRecord(backupRecord.Id);
var backupRecord = await _backupRepository.GetBackupRecordAsync(id);
await _backupRepository.DeleteBackupRecordAsync(backupRecord.Id);
var storage = _backupStorageFactory.GetBackupStorage(backupRecord);
if (storage == null)
@ -72,13 +72,13 @@ public class BackupService : IBackupService
await storage.Delete(backupRecord.StoragePath);
}
public async Task DeleteAllBackups(int tenantId)
public async Task DeleteAllBackupsAsync(int tenantId)
{
foreach (var backupRecord in _backupRepository.GetBackupRecordsByTenantId(tenantId))
foreach (var backupRecord in await _backupRepository.GetBackupRecordsByTenantIdAsync(tenantId))
{
try
{
_backupRepository.DeleteBackupRecord(backupRecord.Id);
await _backupRepository.DeleteBackupRecordAsync(backupRecord.Id);
var storage = _backupStorageFactory.GetBackupStorage(backupRecord);
if (storage == null)
{
@ -97,7 +97,7 @@ public class BackupService : IBackupService
public async Task<List<BackupHistoryRecord>> GetBackupHistory(int tenantId)
{
var backupHistory = new List<BackupHistoryRecord>();
foreach (var record in _backupRepository.GetBackupRecordsByTenantId(tenantId))
foreach (var record in await _backupRepository.GetBackupRecordsByTenantIdAsync(tenantId))
{
var storage = _backupStorageFactory.GetBackupStorage(record);
if (storage == null)
@ -118,7 +118,7 @@ public class BackupService : IBackupService
}
else
{
_backupRepository.DeleteBackupRecord(record.Id);
await _backupRepository.DeleteBackupRecordAsync(record.Id);
}
}
return backupHistory;
@ -133,7 +133,7 @@ public class BackupService : IBackupService
}
}
public void StartRestore(StartRestoreRequest request)
public async Task StartRestoreAsync(StartRestoreRequest request)
{
if (request.StorageType == BackupStorageType.Local)
{
@ -145,7 +145,7 @@ public class BackupService : IBackupService
if (!request.BackupId.Equals(Guid.Empty))
{
var backupRecord = _backupRepository.GetBackupRecord(request.BackupId);
var backupRecord = await _backupRepository.GetBackupRecordAsync(request.BackupId);
if (backupRecord == null)
{
throw new FileNotFoundException();
@ -183,9 +183,9 @@ public class BackupService : IBackupService
return _backupWorker.TempFolder;
}
public void CreateSchedule(CreateScheduleRequest request)
public Task CreateScheduleAsync(CreateScheduleRequest request)
{
_backupRepository.SaveBackupSchedule(
return _backupRepository.SaveBackupScheduleAsync(
new BackupSchedule()
{
TenantId = request.TenantId,
@ -197,14 +197,14 @@ public class BackupService : IBackupService
});
}
public void DeleteSchedule(int tenantId)
public Task DeleteScheduleAsync(int tenantId)
{
_backupRepository.DeleteBackupSchedule(tenantId);
return _backupRepository.DeleteBackupScheduleAsync(tenantId);
}
public ScheduleResponse GetSchedule(int tenantId)
public async Task<ScheduleResponse> GetScheduleAsync(int tenantId)
{
var schedule = _backupRepository.GetBackupSchedule(tenantId);
var schedule = await _backupRepository.GetBackupScheduleAsync(tenantId);
if (schedule != null)
{
var tmp = new ScheduleResponse

View File

@ -137,7 +137,7 @@ public class BackupProgressItem : BaseBackupProgressItem
var repo = _backupRepository;
repo.SaveBackupRecord(
await repo.SaveBackupRecordAsync(
new BackupRecord
{
Id = Guid.Parse(Id),

View File

@ -132,7 +132,7 @@ public class RestoreProgressItem : BaseBackupProgressItem
if (!_coreBaseSettings.Standalone)
{
var backupHash = BackupWorker.GetBackupHash(tempFile);
var record = _backupRepository.GetBackupRecord(backupHash, TenantId);
var record = await _backupRepository.GetBackupRecordAsync(backupHash, TenantId);
if (record == null)
{

View File

@ -38,48 +38,48 @@ public class BackupRepository : IBackupRepository
_creatorDbContext = creatorDbContext;
}
public void SaveBackupRecord(BackupRecord backup)
public async Task SaveBackupRecordAsync(BackupRecord backup)
{
using var backupContext = _dbContextFactory.CreateDbContext();
backupContext.AddOrUpdate(backupContext.Backups, backup);
backupContext.SaveChanges();
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
await backupContext.AddOrUpdateAsync(b => b.Backups, backup);
await backupContext.SaveChangesAsync();
}
public BackupRecord GetBackupRecord(Guid id)
public async Task<BackupRecord> GetBackupRecordAsync(Guid id)
{
using var backupContext = _dbContextFactory.CreateDbContext();
return backupContext.Backups.Find(id);
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
return await backupContext.Backups.FindAsync(id);
}
public BackupRecord GetBackupRecord(string hash, int tenant)
public async Task<BackupRecord> GetBackupRecordAsync(string hash, int tenant)
{
using var backupContext = _dbContextFactory.CreateDbContext();
return backupContext.Backups.AsNoTracking().AsQueryable().SingleOrDefault(b => b.Hash == hash && b.TenantId == tenant);
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
return await backupContext.Backups.AsNoTracking().SingleOrDefaultAsync(b => b.Hash == hash && b.TenantId == tenant);
}
public List<BackupRecord> GetExpiredBackupRecords()
public async Task<List<BackupRecord>> GetExpiredBackupRecordsAsync()
{
using var backupContext = _dbContextFactory.CreateDbContext();
return backupContext.Backups.AsNoTracking().Where(b => b.ExpiresOn != DateTime.MinValue && b.ExpiresOn <= DateTime.UtcNow).ToList();
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
return await backupContext.Backups.AsNoTracking().Where(b => b.ExpiresOn != DateTime.MinValue && b.ExpiresOn <= DateTime.UtcNow).ToListAsync();
}
public List<BackupRecord> GetScheduledBackupRecords()
public async Task<List<BackupRecord>> GetScheduledBackupRecordsAsync()
{
using var backupContext = _dbContextFactory.CreateDbContext();
return backupContext.Backups.AsNoTracking().AsQueryable().Where(b => b.IsScheduled == true && b.Removed == false).ToList();
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
return await backupContext.Backups.AsNoTracking().Where(b => b.IsScheduled == true && b.Removed == false).ToListAsync();
}
public List<BackupRecord> GetBackupRecordsByTenantId(int tenantId)
public async Task<List<BackupRecord>> GetBackupRecordsByTenantIdAsync(int tenantId)
{
using var backupContext = _dbContextFactory.CreateDbContext();
return backupContext.Backups.AsNoTracking().AsQueryable().Where(b => b.TenantId == tenantId && b.Removed == false).ToList();
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
return await backupContext.Backups.AsNoTracking().Where(b => b.TenantId == tenantId && b.Removed == false).ToListAsync();
}
public void MigrationBackupRecords(int tenantId, int newTenantId, string region)
public async Task MigrationBackupRecordsAsync(int tenantId, int newTenantId, string region)
{
using var backupContext = _dbContextFactory.CreateDbContext();
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
var backups = backupContext.Backups.AsNoTracking().AsQueryable().Where(b => b.TenantId == tenantId).ToList();
var backups = await backupContext.Backups.AsNoTracking().Where(b => b.TenantId == tenantId).ToListAsync();
backups.ForEach(backup =>
{
@ -88,52 +88,47 @@ public class BackupRepository : IBackupRepository
});
var backupContextByNewTenant = _creatorDbContext.CreateDbContext<BackupsContext>(region);
backupContextByNewTenant.Backups.AddRange(backups);
backupContextByNewTenant.SaveChanges();
await backupContextByNewTenant.Backups.AddRangeAsync(backups);
await backupContextByNewTenant.SaveChangesAsync();
}
public void DeleteBackupRecord(Guid id)
public async Task DeleteBackupRecordAsync(Guid id)
{
using var backupContext = _dbContextFactory.CreateDbContext();
var backup = backupContext.Backups.Find(id);
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
if (backup != null)
{
backup.Removed = true;
backupContext.Backups.Update(backup);
backupContext.SaveChanges();
}
await backupContext.Backups.Where(q => q.Id == id)
.ExecuteUpdateAsync(q => q.SetProperty(b => b.Removed, b => true));
}
public void SaveBackupSchedule(BackupSchedule schedule)
public async Task SaveBackupScheduleAsync(BackupSchedule schedule)
{
using var backupContext = _dbContextFactory.CreateDbContext();
backupContext.AddOrUpdate(backupContext.Schedules, schedule);
backupContext.SaveChanges();
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
await backupContext.AddOrUpdateAsync(q => q.Schedules, schedule);
await backupContext.SaveChangesAsync();
}
public void DeleteBackupSchedule(int tenantId)
public async Task DeleteBackupScheduleAsync(int tenantId)
{
using var backupContext = _dbContextFactory.CreateDbContext();
backupContext.Schedules.Where(s => s.TenantId == tenantId).ExecuteDelete();
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
await backupContext.Schedules.Where(s => s.TenantId == tenantId).ExecuteDeleteAsync();
}
public List<BackupSchedule> GetBackupSchedules()
public async Task<List<BackupSchedule>> GetBackupSchedulesAsync()
{
using var backupContext = _dbContextFactory.CreateDbContext();
var query = backupContext.Schedules.AsQueryable().Join(backupContext.Tenants,
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
var query = backupContext.Schedules.Join(backupContext.Tenants,
s => s.TenantId,
t => t.Id,
(s, t) => new { schedule = s, tenant = t })
.Where(q => q.tenant.Status == TenantStatus.Active)
.Select(q => q.schedule);
return query.ToList();
return await query.ToListAsync();
}
public BackupSchedule GetBackupSchedule(int tenantId)
public async Task<BackupSchedule> GetBackupScheduleAsync(int tenantId)
{
using var backupContext = _dbContextFactory.CreateDbContext();
return backupContext.Schedules.AsNoTracking().SingleOrDefault(s => s.TenantId == tenantId);
using var backupContext = await _dbContextFactory.CreateDbContextAsync();
return await backupContext.Schedules.AsNoTracking().SingleOrDefaultAsync(s => s.TenantId == tenantId);
}
}

View File

@ -28,15 +28,15 @@ namespace ASC.Data.Backup.Storage;
public interface IBackupRepository
{
BackupRecord GetBackupRecord(Guid id);
BackupRecord GetBackupRecord(string hash, int tenant);
BackupSchedule GetBackupSchedule(int tenantId);
List<BackupRecord> GetBackupRecordsByTenantId(int tenantId);
List<BackupRecord> GetExpiredBackupRecords();
List<BackupRecord> GetScheduledBackupRecords();
List<BackupSchedule> GetBackupSchedules();
void DeleteBackupRecord(Guid id);
void DeleteBackupSchedule(int tenantId);
void SaveBackupRecord(BackupRecord backupRecord);
void SaveBackupSchedule(BackupSchedule schedule);
Task<BackupRecord> GetBackupRecordAsync(Guid id);
Task<BackupRecord> GetBackupRecordAsync(string hash, int tenant);
Task<BackupSchedule> GetBackupScheduleAsync(int tenantId);
Task<List<BackupRecord>> GetBackupRecordsByTenantIdAsync(int tenantId);
Task<List<BackupRecord>> GetExpiredBackupRecordsAsync();
Task<List<BackupRecord>> GetScheduledBackupRecordsAsync();
Task<List<BackupSchedule>> GetBackupSchedulesAsync();
Task DeleteBackupRecordAsync(Guid id);
Task DeleteBackupScheduleAsync(int tenantId);
Task SaveBackupRecordAsync(BackupRecord backupRecord);
Task SaveBackupScheduleAsync(BackupSchedule schedule);
}

View File

@ -261,8 +261,8 @@ public class BackupPortalTask : PortalTaskBase
private async Task<IEnumerable<BackupFileInfo>> GetFiles(int tenantId)
{
var files = (await GetFilesToProcess(tenantId)).ToList();
using var backupRecordContext = _dbContextFactory.CreateDbContext();
var exclude = backupRecordContext.Backups.AsQueryable().Where(b => b.TenantId == tenantId && b.StorageType == 0 && b.StoragePath != null).ToList();
using var backupRecordContext = await _dbContextFactory.CreateDbContextAsync();
var exclude = await backupRecordContext.Backups.Where(b => b.TenantId == tenantId && b.StorageType == 0 && b.StoragePath != null).ToListAsync();
files = files.Where(f => !exclude.Any(e => f.Path.Replace('\\', '/').Contains($"/file_{e.StoragePath}/"))).ToList();
return files;
@ -625,8 +625,8 @@ public class BackupPortalTask : PortalTaskBase
{
var files = (await GetFilesToProcess(TenantId)).ToList();
using var backupRecordContext = _dbContextFactory.CreateDbContext();
var exclude = backupRecordContext.Backups.AsQueryable().Where(b => b.TenantId == TenantId && b.StorageType == 0 && b.StoragePath != null).ToList();
using var backupRecordContext = await _dbContextFactory.CreateDbContextAsync();
var exclude = await backupRecordContext.Backups.Where(b => b.TenantId == TenantId && b.StorageType == 0 && b.StoragePath != null).ToListAsync();
files = files.Where(f => !exclude.Any(e => f.Path.Replace('\\', '/').Contains($"/file_{e.StoragePath}/"))).ToList();

View File

@ -118,7 +118,7 @@ public class RestorePortalTask : PortalTaskBase
await restoreTask.RunJob();
}
_backupRepository.MigrationBackupRecords(TenantId, _columnMapper.GetTenantMapping(), _region);
await _backupRepository.MigrationBackupRecordsAsync(TenantId, _columnMapper.GetTenantMapping(), _region);
}
_options.DebugEndRestoreData();

View File

@ -46,9 +46,7 @@ public class BackupDeleteScheldureRequestedIntegrationEventHandler : IIntegratio
{
_logger.InformationHandlingIntegrationEvent(@event.Id, Program.AppName, @event);
_backupService.DeleteSchedule(@event.TenantId);
await Task.CompletedTask;
await _backupService.DeleteScheduleAsync(@event.TenantId);
}
}
}

View File

@ -69,7 +69,7 @@ public class BackupRestoreRequestedIntegrationEventHandler : IIntegrationEventHa
_tenantManager.SetCurrentTenant(@event.TenantId);
_securityContext.AuthenticateMeWithoutCookie(_authManager.GetAccountByID(@event.TenantId, @event.CreateBy));
_backupAjaxHandler.StartRestore(@event.BackupId,
await _backupAjaxHandler.StartRestoreAsync(@event.BackupId,
@event.StorageType,
@event.StorageParams,
@event.Notify);

View File

@ -66,7 +66,7 @@ internal sealed class BackupCleanerService : BackgroundService
continue;
}
await ExecuteBackupCleaner(stoppingToken);
await ExecuteBackupCleanerAsync(stoppingToken);
await Task.Delay(_backupCleanerPeriod, stoppingToken);
}
@ -74,7 +74,7 @@ internal sealed class BackupCleanerService : BackgroundService
_logger.DebugBackupCleanerServiceStopping();
}
private async Task ExecuteBackupCleaner(CancellationToken stoppingToken)
private async Task ExecuteBackupCleanerAsync(CancellationToken stoppingToken)
{
await using var serviceScope = _scopeFactory.CreateAsyncScope();
@ -83,18 +83,18 @@ internal sealed class BackupCleanerService : BackgroundService
_logger.DebugStartedClean();
var backupsToRemove = backupRepository.GetExpiredBackupRecords();
var backupsToRemove = await backupRepository.GetExpiredBackupRecordsAsync();
_logger.DebugFoundBackups(backupsToRemove.Count);
foreach (var scheduledBackups in backupRepository.GetScheduledBackupRecords().GroupBy(r => r.TenantId))
foreach (var scheduledBackups in (await backupRepository.GetScheduledBackupRecordsAsync()).GroupBy(r => r.TenantId))
{
if (stoppingToken.IsCancellationRequested)
{
return;
}
var schedule = backupRepository.GetBackupSchedule(scheduledBackups.Key);
var schedule = await backupRepository.GetBackupScheduleAsync(scheduledBackups.Key);
if (schedule != null)
{
@ -128,7 +128,7 @@ internal sealed class BackupCleanerService : BackgroundService
await backupStorage.Delete(backupRecord.StoragePath);
backupRepository.DeleteBackupRecord(backupRecord.Id);
await backupRepository.DeleteBackupRecordAsync(backupRecord.Id);
}
catch (ProviderInfoArgumentException error)
{
@ -136,7 +136,7 @@ internal sealed class BackupCleanerService : BackgroundService
if (DateTime.UtcNow > backupRecord.CreatedOn.AddMonths(6))
{
backupRepository.DeleteBackupRecord(backupRecord.Id);
await backupRepository.DeleteBackupRecordAsync(backupRecord.Id);
}
}
catch (Exception error)

View File

@ -39,19 +39,19 @@ internal sealed class BackupListenerService : IHostedService
_scopeFactory = scopeFactory;
}
public void DeleteScheldure(DeleteSchedule deleteSchedule)
public async Task DeleteScheldureAsync(DeleteSchedule deleteSchedule)
{
using (var scope = _scopeFactory.CreateScope())
{
var backupService = scope.ServiceProvider.GetService<BackupService>();
backupService.DeleteSchedule(deleteSchedule.TenantId);
await backupService.DeleteScheduleAsync(deleteSchedule.TenantId);
}
}
public Task StartAsync(CancellationToken cancellationToken)
{
_cacheDeleteSchedule.Subscribe((n) => DeleteScheldure(n), CacheNotifyAction.Insert);
_cacheDeleteSchedule.Subscribe((n) => DeleteScheldureAsync(n), CacheNotifyAction.Insert);
return Task.CompletedTask;
}

View File

@ -73,7 +73,7 @@ public sealed class BackupSchedulerService : BackgroundService
_logger.DebugBackupSchedulerServiceDoingWork();
ExecuteBackupScheduler(stoppingToken);
await ExecuteBackupSchedulerAsync(stoppingToken);
await Task.Delay(_backupSchedulerPeriod, stoppingToken);
}
@ -81,7 +81,7 @@ public sealed class BackupSchedulerService : BackgroundService
_logger.DebugBackupSchedulerServiceStopping();
}
private void ExecuteBackupScheduler(CancellationToken stoppingToken)
private async Task ExecuteBackupSchedulerAsync(CancellationToken stoppingToken)
{
using var serviceScope = _scopeFactory.CreateScope();
@ -92,7 +92,7 @@ public sealed class BackupSchedulerService : BackgroundService
_logger.DebugStartedToSchedule();
var backupsToSchedule = backupRepository.GetBackupSchedules().Where(schedule => backupSchedule.IsToBeProcessed(schedule)).ToList();
var backupsToSchedule = (await backupRepository.GetBackupSchedulesAsync()).Where(schedule => backupSchedule.IsToBeProcessed(schedule)).ToList();
_logger.DebugBackupsSchedule(backupsToSchedule.Count);
@ -113,7 +113,7 @@ public sealed class BackupSchedulerService : BackgroundService
{
schedule.LastBackupTime = DateTime.UtcNow;
backupRepository.SaveBackupSchedule(schedule);
await backupRepository.SaveBackupScheduleAsync(schedule);
_logger.DebugStartScheduledBackup(schedule.TenantId, schedule.StorageType, schedule.StorageBasePath);

View File

@ -53,9 +53,9 @@ public class BackupController : ControllerBase
/// <category>Backup</category>
/// <returns>Backup Schedule</returns>
[HttpGet("getbackupschedule")]
public BackupAjaxHandler.Schedule GetBackupSchedule()
public Task<BackupAjaxHandler.Schedule> GetBackupSchedule()
{
return _backupHandler.GetSchedule();
return _backupHandler.GetScheduleAsync();
}
/// <summary>
@ -87,9 +87,9 @@ public class BackupController : ControllerBase
/// </summary>
/// <category>Backup</category>
[HttpDelete("deletebackupschedule")]
public bool DeleteBackupSchedule()
public async Task<bool> DeleteBackupSchedule()
{
_backupHandler.DeleteSchedule();
await _backupHandler.DeleteScheduleAsync();
return true;
}

View File

@ -438,11 +438,11 @@ public class StorageController : BaseSettingsController
}
[HttpGet("storage/backup")]
public List<StorageDto> GetAllBackupStorages()
public async Task<List<StorageDto>> GetAllBackupStorages()
{
_permissionContext.DemandPermissions(SecutiryConstants.EditPortalSettings);
var schedule = _backupAjaxHandler.GetSchedule();
var schedule = await _backupAjaxHandler.GetScheduleAsync();
var current = new StorageSettings();
if (schedule != null && schedule.StorageType == BackupStorageType.ThirdPartyConsumer)