Пример #1
0
        public Logger()
        {
            OptionsManager optionsManager = new OptionsManager(AppDomain.CurrentDomain.BaseDirectory);

            configOptions        = optionsManager.GetOptions <Options>();
            sourcePath           = configOptions.PathToDirectory.SourceDirectory;
            targetPath           = configOptions.PathToDirectory.TargetDirectory;
            watcher              = new FileSystemWatcher(sourcePath);
            watcher.NotifyFilter = NotifyFilters.LastAccess
                                   | NotifyFilters.LastWrite
                                   | NotifyFilters.FileName
                                   | NotifyFilters.DirectoryName;
            watcher.Filter   = "*.txt";
            watcher.Created += Watcher_Created;
        }
Пример #2
0
        public Watcher()
        {
            string appDirectory = AppDomain.CurrentDomain.BaseDirectory;

            optionsManager = new OptionsManager(appDirectory);
            ETLOptions options = optionsManager.GetOptions <ETLOptions>() as ETLOptions;

            source               = options.WorkFoldersOptions.SourceDir;
            target               = options.WorkFoldersOptions.TargetDir;
            saveArchive          = options.ArchivationOptions.ArchiveDir;
            Logger.loggerOptions = options.LoggerOptions;
            Logger.loaded        = true;

            watcher          = new FileSystemWatcher(source);
            watcher.Created += Created;
        }
Пример #3
0
        public Watcher()
        {
            manager  = new OptionsManager();
            crypter  = new Crypter(manager.GetOptions <CrypterOptions>() as CrypterOptions);
            archiver = new Archiver(manager.GetOptions <ArchiverOptions>() as ArchiverOptions);
            watcher  = new FileSystemWatcher(manager.Options.SourcePath, "*.*");

            watcher.Created += OnChanged;
            watcher.Changed += OnChanged;
            watcher.Renamed += OnChanged;
            watcher.Deleted += OnDeleted;

            watcher.EnableRaisingEvents   = true;
            watcher.IncludeSubdirectories = true;

            Logger = manager.Logger;
            archiver.Options.TargetLogger = Logger;
            crypter.Options.TargetLogger  = Logger;

            jsonWatcher                     = new FileSystemWatcher(manager.Options.Path, "appsettings.json");
            jsonWatcher.Created            += OnOptionsFileChanged;
            jsonWatcher.Changed            += OnOptionsFileChanged;
            jsonWatcher.Deleted            += OnOptionsFileChanged;
            jsonWatcher.EnableRaisingEvents = true;

            xmlWatcher          = new FileSystemWatcher(manager.Options.Path, "config.xml");
            xmlWatcher.Created += OnOptionsFileChanged;
            xmlWatcher.Changed += OnOptionsFileChanged;
            xmlWatcher.Deleted += OnOptionsFileChanged;
            if (manager.Options != manager.JSONOptions)
            {
                xmlWatcher.EnableRaisingEvents = true;
            }
            else
            {
                xmlWatcher.EnableRaisingEvents = false;
            }
        }