public bool Start(HostControl hostControl)
        {
            _logger.Info("The file handler service is starting.");

            var sourceFolderPaths = _settingsProvider.GetSourceFolderPaths();
            var timeout           = _settingsProvider.GetPageTimeout() * 1000;

            try
            {
                _fileHandlers = sourceFolderPaths.Select(sourceFolderPath =>
                {
                    var handler = _fileHandlerFactory.GetHandler();
                    handler.Start(sourceFolderPath, timeout);
                    return(handler);
                }).ToList();
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                throw;
            }

            _logger.Info("The file handler service has started.");

            return(true);
        }
Esempio n. 2
0
        public bool Start(HostControl hostControl)
        {
            _logger.Info("The file handler service is starting.");

            var queueName = _settingsProvider.GetMessageQueueName();
            var queuePath = MessageQueueHelper.GetQueuePath(queueName);

            InitializeCentralQueueSender(queuePath);
            InitializeQueueListener(queuePath);

            var sourceFolderPaths = _settingsProvider.GetSourceFolderPaths();

            _pageTimeout = _settingsProvider.GetPageTimeout();

            try
            {
                _fileHandlers = sourceFolderPaths.Select(sourceFolderPath =>
                {
                    var handler            = _fileHandlerFactory.GetHandler();
                    handler.DocumentSaved += OnDocumentSaved;
                    handler.Start(sourceFolderPath, _pageTimeout);
                    return(handler);
                }).ToList();
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                throw;
            }

            var reportingTimeout = _settingsProvider.GetReportingTimeout() * 1000;

            _reportingTimer.Change(reportingTimeout, reportingTimeout);

            _logger.Info("The file handler service has started.");

            return(true);
        }