public EtlOptions(DirectoryOptions directoryOptions, EncryptionOptions encryptionOptions, ArchiveOptions archiveOptions, LoggingOptions loggingOptions) { DirectoryOptions = directoryOptions; EncryptionOptions = encryptionOptions; ArchiveOptions = archiveOptions; LoggingOptions = loggingOptions; }
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); }
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); }
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); }
public ETLOptions(WatcherOptions watcherOptions, MovingOptions movingOptions, ArchiveOptions archiveOptions) { WatcherOptions = watcherOptions; MovingOptions = movingOptions; ArchiveOptions = archiveOptions; }