Ejemplo n.º 1
0
        public void SourceLocationShouldScanExample14()
        {
            var loc = new LocalSourceLocation();

            loc.LastCompletedScan = DateTime.Now.AddHours(-1250);
            loc.Priority          = ArchivialLibrary.Files.FileBackupPriority.Low;

            var options = new ArchivialLibrary.Folders.ScanFrequencies();

            options.LowPriorityScanFrequencyInHours = 72;

            Assert.IsTrue(loc.ShouldScan(options));
        }
Ejemplo n.º 2
0
        public void SourceLocationShouldScanExample5()
        {
            var loc = new LocalSourceLocation();

            loc.LastCompletedScan = DateTime.Now.AddMinutes(-61);
            loc.Priority          = ArchivialLibrary.Files.FileBackupPriority.High;

            var options = new ArchivialLibrary.Folders.ScanFrequencies();

            options.HighPriorityScanFrequencyInHours = 1;

            Assert.IsTrue(loc.ShouldScan(options));
        }
Ejemplo n.º 3
0
        public void SourceLocationShouldScanExample8()
        {
            var loc = new LocalSourceLocation();

            loc.LastCompletedScan = DateTime.Now.AddHours(-23);
            loc.Priority          = ArchivialLibrary.Files.FileBackupPriority.Medium;

            var options = new ArchivialLibrary.Folders.ScanFrequencies();

            options.MedPriorityScanFrequencyInHours = 24;

            Assert.IsFalse(loc.ShouldScan(options));
        }
Ejemplo n.º 4
0
        public void SourceLocationShouldScanExample1()
        {
            var loc = new LocalSourceLocation();

            loc.LastCompletedScan = null;

            var options = new ArchivialLibrary.Folders.ScanFrequencies();

            options.LowPriorityScanFrequencyInHours  = 72;
            options.MedPriorityScanFrequencyInHours  = 24;
            options.HighPriorityScanFrequencyInHours = 1;

            Assert.IsTrue(loc.ShouldScan(options));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Checks to see if a source location is ready to scan again.
        /// </summary>
        /// <remarks>
        /// The source location is ready to scan again once enough time has elapsed since the previous scan.
        /// </remarks>
        /// <returns></returns>
        public bool ShouldScan(ScanFrequencies options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }
            if (LastCompletedScan == null)
            {
                // no scan has completed before
                return(true);
            }

            DateTime lastAcceptableScanPoint;

            if (Priority == FileBackupPriority.Low)
            {
                lastAcceptableScanPoint = DateTime.Now.AddHours(-options.LowPriorityScanFrequencyInHours);
            }
            else if (Priority == FileBackupPriority.Medium)
            {
                lastAcceptableScanPoint = DateTime.Now.AddHours(-options.MedPriorityScanFrequencyInHours);
            }
            else if (Priority == FileBackupPriority.High)
            {
                lastAcceptableScanPoint = DateTime.Now.AddHours(-options.HighPriorityScanFrequencyInHours);
            }
            else if (Priority == FileBackupPriority.Meta)
            {
                lastAcceptableScanPoint = DateTime.Now.AddHours(-options.HighPriorityScanFrequencyInHours);
            }
            else
            {
                throw new InvalidOperationException("Unexpected backup priority specified: " + Priority);
            }

            if (LastCompletedScan.Value < lastAcceptableScanPoint)
            {
                // a scan hasn't been completed recently.
                return(true);
            }
            else
            {
                // scan already completed recently.
                return(false);
            }
        }