Exemplo n.º 1
0
        public Scanner(ScanProperties props)
        {
            _props       = props;
            _serviceName = $"Scanner_{Guid.NewGuid()}";

            if (!Directory.Exists(props.InDir))
            {
                Directory.CreateDirectory(props.InDir);
            }

            if (!Directory.Exists(props.ErrorDir))
            {
                Directory.CreateDirectory(props.ErrorDir);
            }

            _watcher          = new FileSystemWatcher(props.InDir);
            _watcher.Changed += Watcher_Changed;

            _workThread   = new Thread(WorkingMethod);
            _stopEvent    = new ManualResetEvent(false);
            _newFileEvent = new AutoResetEvent(false);

            _sbClient = new ServerSbClient(string.Empty, props.CnString, props.InfoQueueName);
            _sbClient.InitTopics();

            _imagesAggregator = new ImagesAggregator(props, FilePattern, _sbClient);
        }
Exemplo n.º 2
0
        public ImagesAggregator(ScanProperties props, string filePattern, ServerSbClient serviceBusClient)
        {
            _props         = props;
            _patternPrefix = filePattern.Split('*')[0];

            _logger             = Logger.Logger.Current;
            _usedFiles          = new List <string>();
            _saveTimer          = new Timer(props.ScanTimeout);
            _saveTimer.Elapsed += (sender, args) => SendDocument();
            _lockObj            = new object();
            InitDocAndSection();

            _serviceBusClient = serviceBusClient;
        }
Exemplo n.º 3
0
        public CentralService(string output, string cnString, string infoQueueName, string stateQueueName)
        {
            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            _stopEvent = new ManualResetEvent(false);

            _sbClient = new ServerSbClient(output, cnString, infoQueueName);
            _sbClient.CreateInfoListener(infoQueueName);
            _sbClient.InitTopics();

            _watcher          = new FileSystemWatcher(AppDomain.CurrentDomain.BaseDirectory);
            _watcher.Changed += Watcher_Changed;
            _watcher.Filter   = "*.exe.config";
        }