public void Validate(object obj) { string report = ""; ETLOptions options = obj as ETLOptions; #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 Report = report; }
public Watcher(ETLOptions options, Logger.ILogger logger, string report) { MovingOptions movingOptions = options.MovingOptions; WatcherOptions watcherOptions = options.WatcherOptions; ArchiveOptions archiveOptions = options.ArchiveOptions; 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; dbLogger = logger; }
public ETLOptions(WatcherOptions watcherOptions, MovingOptions movingOptions, ArchiveOptions archiveOptions) { WatcherOptions = watcherOptions; MovingOptions = movingOptions; ArchiveOptions = archiveOptions; }