示例#1
0
 void Config()
 {
     options        = optionsManager.GetOptions <ETLOptions>() as ETLOptions;
     movingOptions  = optionsManager.GetOptions <MovingOptions>() as MovingOptions;
     archiveOptions = optionsManager.GetOptions <ArchiveOptions>() as ArchiveOptions;
     watcherOptions = optionsManager.GetOptions <WatcherOptions>() as WatcherOptions;
     logger         = new Logger(movingOptions.TargetDirectory);
 }
示例#2
0
        public Watcher(MovingOptions movingOptions, WatcherOptions watcherOptions, ArchiveOptions archiveOptions, string report)
        {
            this.sourceDir = movingOptions.SourceDirectory;
            this.targetDir = movingOptions.TargetDirectory;

            Directory.CreateDirectory(sourceDir);
            Directory.CreateDirectory(targetDir);

            fileSystemWatcher          = new FileSystemWatcher(sourceDir);
            fileSystemWatcher.Filter   = watcherOptions.Filter;
            fileSystemWatcher.Created += OnCreated;

            enableLogging          = movingOptions.EnableLogging;
            enableArchiveDirectory = movingOptions.EnableArchiveDirectory;
            compressionLevel       = archiveOptions.CompressionLevel;
            this.report            = report;
            logger = new Logger(targetDir);
        }
示例#3
0
        public static string Validate(ETLOptions options)
        {
            string report = "";

            #region Moving Validation
            MovingOptions moving = options.MovingOptions;
            if (!CreateDirectoryIfNotExist(moving.SourceDirectory))
            {
                report += "Cannot open source directory, using default. ";
                moving.SourceDirectory = @"C:\Users\Public\Desktop\SourceFolder";
                CreateDirectoryIfNotExist(moving.SourceDirectory);
            }
            if (!CreateDirectoryIfNotExist(moving.TargetDirectory))
            {
                report += "Cannot open target directory, using default. ";
                moving.TargetDirectory = @"C:\Users\Public\Desktop\TargetFolder";
                CreateDirectoryIfNotExist(moving.TargetDirectory);
            }
            #endregion
            #region Archive Validation
            ArchiveOptions archive = options.ArchiveOptions;
            if ((int)archive.CompressionLevel < 0 || (int)archive.CompressionLevel > 2)
            {
                report += "Compression level value can't be below 0 or above 2, using default value. ";
                archive.CompressionLevel = System.IO.Compression.CompressionLevel.Optimal;
            }
            #endregion
            #region Watcher Validation
            WatcherOptions watcher = options.WatcherOptions;
            if (watcher.Filter != "*.txt")
            {
                report        += "Filter can be only \"*.txt\", using default value. ";
                watcher.Filter = "*.txt";
            }
            #endregion
            return(report);
        }
示例#4
0
 public ETLOptions(WatcherOptions watcherOptions, MovingOptions movingOptions, ArchiveOptions archiveOptions)
 {
     WatcherOptions = watcherOptions;
     MovingOptions  = movingOptions;
     ArchiveOptions = archiveOptions;
 }