Esempio n. 1
0
        public void ScanWork()
        {
            do
            {
                _logger.LogInfo("Scanning... ");
                if (workStop.WaitOne(TimeSpan.Zero))
                {
                    return;
                }

                var files     = _scanner.GetFiles();
                var scanChunk = _scanner.ScanFiles(files);



                if (scanChunk.ChunkFiles.Any())
                {
                    if (!string.IsNullOrEmpty(scanChunk.Name))
                    {
                        _pdfAggregatorFilesHandler.Handle(scanChunk.ChunkFiles, _storageService, $"{scanChunk.Name ?? "out"}_{DateTime.UtcNow.ToFileTimeUtc()}.pdf");

                        foreach (var includedFile in scanChunk.ChunkFiles)
                        {
                            _logger.LogInfo(" File.Delete " + includedFile);
                            File.Delete(includedFile);
                        }
                    }
                    else
                    {
                        _logger.LogInfo($"   [{scanChunk.ChunkFiles.Count}] files in a chunk. Waiting for barcode.");
                    }
                }
                else
                {
                    _logger.LogInfo("no files in a chunk");
                }
            }while (WaitHandle.WaitAny(new WaitHandle[] { workStop, newFile }, _props.ScanInterval) != 0);
        }