protected override void ProcessFtp(ISourceFactory factory) { using (var hostManager = AutoDiscover == true ? new DynamicHostManager(Config, new NetworkScanner(TaskPoolScheduler.Default), TaskPoolScheduler.Default) : (IHostManager) new StaticHostManager(Config.Known)) { CancellationToken token = CancellationToken.None; if (Config.TimeOut.HasValue) { CancellationTokenSource tokenSource = new CancellationTokenSource(TimeSpan.FromMinutes(Config.TimeOut.Value)); token = tokenSource.Token; } var downloaders = factory.GetSources(hostManager); var tasks = downloaders.Select(ftpDownloader => ftpDownloader.Download(token)); var archiving = new DeleteArchiving(); if (Archive.HasValue) { log.Info("Archiving..."); archiving.Archive(Out, TimeSpan.FromDays(Archive.Value)); } Task.WhenAll(tasks).Wait(token); } }
public override async Task <JobResult> InternalExecute(IJobExecutionContext context) { var archivingJob = new DeleteArchiving(Logger); var result = await archivingJob.Archive(Config.Cameras, TimeSpan.FromDays(Config.RetentionPeriodDays.Value), Config.FilesToDelete); return(result); }