示例#1
0
        public void Start()
        {
            var config = BackupConfigurationSection.GetSection();

            BackupWorker.Start(config);
            host = new ServiceHost(typeof(BackupService));
            host.Open();

            if (config.Cleaner.ElementInformation.IsPresent)
            {
                cleanerService = new BackupCleanerService {
                    Period = config.Cleaner.Period
                };
                cleanerService.Start();
            }
            if (config.Scheduler.ElementInformation.IsPresent)
            {
                schedulerService = new BackupSchedulerService {
                    Period = config.Scheduler.Period
                };
                schedulerService.Start();
            }
            deleterTempService = new BackupCleanerTempFileService();
            deleterTempService.Start();
        }
        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);
                }
            }
        }
 public BackupServiceLauncher(
     BackupCleanerService cleanerService,
     BackupSchedulerService schedulerService,
     BackupWorker backupWorker,
     ConfigurationExtension configuration,
     BackupListener backupListener,
     NotifyConfiguration notifyConfiguration)
 {
     CleanerService      = cleanerService;
     SchedulerService    = schedulerService;
     BackupWorker        = backupWorker;
     Configuration       = configuration;
     BackupListener      = backupListener;
     NotifyConfiguration = notifyConfiguration;
 }
示例#4
0
 public BackupServiceLauncher(
     IServiceProvider serviceProvider,
     BackupCleanerService cleanerService,
     BackupSchedulerService schedulerService,
     BackupWorker backupWorker,
     IConfiguration configuration,
     BackupListener backupListener)
 {
     ServiceProvider  = serviceProvider;
     CleanerService   = cleanerService;
     SchedulerService = schedulerService;
     BackupWorker     = backupWorker;
     Configuration    = configuration;
     BackupListener   = backupListener;
 }
 public void Stop()
 {
     BackupWorker.Stop();
     if (host != null)
     {
         host.Close();
         host = null;
     }
     if (cleanerService != null)
     {
         cleanerService.Stop();
         cleanerService = null;
     }
     if (schedulerService != null)
     {
         schedulerService.Stop();
         schedulerService = null;
     }
 }