コード例 #1
0
        public FolderWatcherManager(IFolderWatcher watcher, FileFollowerManager manager, CancellationToken token)
        {
            wait = () => {
                const int _5_seconds = 5000;
                Task      taskDelay  = null;
                try     { taskDelay = Task.Delay(_5_seconds, token); taskDelay.Wait(); return(true); }
                catch   { return(false); }
                finally { if (taskDelay != null)
                          {
                              taskDelay.Dispose();
                          }
                }
            };

            act = () => {
                foreach (var path in watcher.FilteredFiles)
                {
                    manager.Watch(path);
                    if (token.IsCancellationRequested)
                    {
                        return(false);
                    }
                }
                return(true);
            };
        }
コード例 #2
0
ファイル: FolderWatcherTest.cs プロジェクト: Jamedjo/Raticon
 void AssertWatchTriggeredBy(Action action)
 {
     bool called = false;
     watcher = new FolderWatcher(path => called = true);
     WatchAction(action);
     Assert.IsTrue(called);
 }
コード例 #3
0
 public void Release(IFolderWatcher folderWatcher)
 {
     var disposableInstance = folderWatcher as IDisposable;
     if (disposableInstance != null)
     {
         disposableInstance.Dispose();
     }
 }
コード例 #4
0
        void AssertWatchTriggeredBy(Action action)
        {
            bool called = false;

            watcher = new FolderWatcher(path => called = true);
            WatchAction(action);
            Assert.IsTrue(called);
        }
コード例 #5
0
        private void InitializeService()
        {
            var configuration = new Configuration();

            configuration.Load();

            var fileSender = new FileSender(configuration);

            _folderWatcher = new FolderWatcher(configuration, fileSender);
        }
コード例 #6
0
 public ExampleService(ILogger logger, KxClient client, IFolderWatcher folderWatcher, IOptions <DocumentTypeConfiguration> documentTypeConfiguration, IVirtualUserConnector virtualUserConnector, IBaseMongoRepository repository, IOptions <ProcessDocumentConfiguration> timerconfig)
 {
     this.logger               = logger;
     this.client               = client;
     this.folderWatcher        = folderWatcher;
     this.virtualUserConnector = virtualUserConnector;
     this.repository           = repository;
     this.timerconfig          = timerconfig.Value;
     this.documentTypeConfig   = documentTypeConfiguration.Value;
     typesToArchive            = documentTypeConfig.ToArchive;
     typesToSendToVu           = documentTypeConfig.ToSendToVirtualUser;
 }
コード例 #7
0
        private void Initialize(string folder, Func <string, IRepository> repositoryFactory,
                                Func <string, IFolderWatcher> folderWatcherFactory)
        {
            _repository = repositoryFactory(folder);

            _folderWatcher         = folderWatcherFactory(folder);
            _folderWatcher.OnNext += UpdateStatus;

            // _repository.Info.Path returns a path ending with '\'
            GitDir = _repository.Info.Path.Substring(0, _repository.Info.Path.Length - 1);
            CurrentWorkingDirectory = Path.GetFullPath(Path.Combine(GitDir, ".."));

            UpdateStatus(CurrentWorkingDirectory);
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HomeWindowViewModel"/> class.
 /// </summary>
 public HomeWindowViewModel(IUpdateMessagesListTask updateMessagesListTask, IMessageMediator mediator, IPleaseWaitService pleaseWaitService, IFolderWatcher folderWatcher, ITryFindParent tryFindParent, IOpenEmailFile openEmailFile)
 {
     this.updateMessagesListTask = updateMessagesListTask;
     this.mediator          = mediator;
     this.pleaseWaitService = pleaseWaitService;
     this.folderWatcher     = folderWatcher;
     this.tryFindParent     = tryFindParent;
     this.openEmailFile     = openEmailFile;
     RowDoubleClick         = new Command <MouseButtonEventArgs>(OnRowDoubleClickExecute, OnRowDoubleClickCanExecute);
     CheckMessagesCommand   = new AsynchronousCommand(OnCheckMessagesCommandExecute, () => !CheckMessagesCommand.IsExecuting);
     MarkAsReadCommand      = new Command <MessageModel>(OnMarkAsReadCommandExecute);
     ImageSingleClick       = new Command <MessageModel>(OnImageSingleClickExecute);
     Messages = new InitialLoadCommand().Load();
     CheckMessagesWithWaiting();
 }
コード例 #9
0
        public FileSystemMonitorService(
            FileSystemMonitorServiceConfiguration configuration,
            IFolderWatcherFactory folderWatcherFactory,
            FileServiceFactory jobManagerFactory,
            SynchronizationServiceFactory synchronizationServiceFactory,
            ILogger logger)
        {
            _logger = logger;
            _folderWatcherFactory = folderWatcherFactory;
            _folderWatcher = folderWatcherFactory.Create(configuration.FolderToMonitor);
            _jobManagerFactory = jobManagerFactory;
            _synchronizationServiceFactory = synchronizationServiceFactory;
            _configuration = configuration;

            _serviceShutdownEvent = new ManualResetEventSlim(false);
            _fileProcessingRoutine = new Task(this.RunServiceOperation, TaskCreationOptions.LongRunning);
            _operationQueue = new Queue<FileSystemWatcherEventArgs>();

            this.SubscribeToEvents();
            this.InitializeServiceState(configuration);
        }
コード例 #10
0
 public MainViewModel(IFolderWatcher folderWatcher)
 {
     Files = new ObservableCollection<StockFile>();
     _folderWatcher = folderWatcher;
     _folderWatcher.FileFound += (e, args) => _dispatcher.Invoke(() => Files.Add(args.File));
 }
コード例 #11
0
        public void Release(IFolderWatcher folderWatcher)
        {
            _logger.Log(LogLevel.Trace, "Releasing folder watcher.");

            _folderWatcherFactory.Release(folderWatcher);
        }
コード例 #12
0
 public MainViewModel(IFolderWatcher folderWatcher)
 {
     Files                     = new ObservableCollection <StockFile>();
     _folderWatcher            = folderWatcher;
     _folderWatcher.FileFound += (e, args) => _dispatcher.Invoke(() => Files.Add(args.File));
 }
コード例 #13
0
 public FilmProcessingWatcher(Func <Action <string>, IFolderWatcher> watcherFactory, IFilmProcessor filmProcessor)
 {
     Watcher = watcherFactory(path => OnChangeAction(path, filmProcessor));
 }