コード例 #1
0
        public MergePagesService(string inputFolderPath, IDocumentFactory documentFactory)
        {
            MergePagesQueueManager.PrepareQueues();

            logger = HostLogger.Get <MergePagesService>();

            this.documentFactory = documentFactory;
            directoryService     = new DirectoryService();
            directoryService.SetInputDirectory(inputFolderPath);

            newFileEvent  = new AutoResetEvent(false);
            stopWorkEvent = new ManualResetEvent(false);

            directoryWatcher = new FileSystemWatcher {
                Path = inputFolderPath, NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite
            };
            directoryWatcher.Created += (sender, fileSystemEventArgs) => newFileEvent.Set();

            tokenSource           = new CancellationTokenSource();
            mergeTask             = new Task(() => WorkProcedure(tokenSource.Token));
            monitoreTask          = new Task(() => messageService.MonitoreClient(tokenSource.Token, stopWorkEvent));
            sendQueueSettingsTask = new Task(() => messageService.SendSettings(tokenSource.Token));

            messageService = new MessageService();
        }
コード例 #2
0
        public MergePagesClient(string outputPath)
        {
            MergePagesQueueManager.PrepareQueues();
            logger = HostLogger.Get <MergePagesClient>();

            directoryService = new DirectoryService();
            directoryService.SetOutputDirectory(outputPath);

            watcher = new FileSystemWatcher(outputPath)
            {
                Filter = "*.xml"
            };
            watcher.Changed += QueueSettingsChanged;

            stopWaitEvent = new ManualResetEvent(false);
            tokenSource   = new CancellationTokenSource();

            processFilesTask = new Task(() => WorkProcedure(tokenSource.Token));
            monitoringTask   = new Task(() => MonitorServer(tokenSource.Token));
        }