public void ScheduleBackupTasks(BackupSchedulerService backupSchedulerService) { Log.DebugFormat("started to schedule backups"); var backupsToSchedule = BackupRepository.GetBackupSchedules().Where(schedule => Schedule.IsToBeProcessed(schedule)).ToList(); Log.DebugFormat("{0} backups are to schedule", backupsToSchedule.Count); foreach (var schedule in backupsToSchedule) { if (!backupSchedulerService.IsStarted) { return; } try { var tariff = PaymentManager.GetTariff(schedule.TenantId); if (tariff.State < TariffState.Delay) { schedule.LastBackupTime = DateTime.UtcNow; BackupRepository.SaveBackupSchedule(schedule); Log.DebugFormat("Start scheduled backup: {0}, {1}, {2}, {3}", schedule.TenantId, schedule.BackupMail, schedule.StorageType, schedule.StorageBasePath); BackupWorker.StartScheduledBackup(schedule); } else { Log.DebugFormat("Skip portal {0} not paid", schedule.TenantId); } } catch (Exception error) { Log.Error("error while scheduling backups: {0}", error); } } }