示例#1
0
 public void StartListening()
 {
     _safeExecuteManager.ExecuteWithExceptionLogging(() =>
     {
         _subscriber.Receive(LogServiceState);
     });
 }
示例#2
0
 public void StartListening()
 {
     _safeExecuteManager.ExecuteWithExceptionLogging(() =>
     {
         _subscriber.Receive(ProcessReceivedFileBatchMessage);
     });
 }
示例#3
0
 public void StartNotify()
 {
     _safeExecuteManager.ExecuteWithExceptionLogging(() =>
     {
         _observingTimer.Start();
         _subscriber.Receive(SetReceivedSettings);
     });
 }
示例#4
0
        public int CreateUser(User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            return(_safeExecuteManager.ExecuteWithExceptionLogging(user, (u) =>
            {
                return _userRepository.Create(u);
            }));
        }
示例#5
0
        /// <summary>
        /// Initializes FileSystemWatchers with paths enumerated in App.config file in observableFolders section
        /// </summary>
        private void InitFileSystemWatchersDictionary()
        {
            ServiceStateInfo.Instance.UpdateState(ServiceState.IsWaitingForNewFiles);

            _fileSystemWatchers = new List <FileSystemWatcher>();

            _safeExecuteManager.ExecuteWithExceptionLogging(() =>
            {
                foreach (var path in _appConfigHelper.ObservableFolders)
                {
                    if (!_fileSystemHelper.DirectoryHelper.IsValidDirectoryPath(path))
                    {
                        throw new ArgumentException($"Invalid directory path: {path}");
                    }

                    _fileSystemHelper.DirectoryHelper.CreateDirectoryIfNotExists(path);

                    var watcher = new FileSystemWatcher(path);
                    watcher.EnableRaisingEvents = true;
                    watcher.Created            += OnFileAdded;

                    _fileSystemWatchers.Add(watcher);
                }
            });
        }
示例#6
0
        public virtual void HandlePreviousStepResult(object sender, FileStoragePipelineEventArgs args)
        {
            if (args.BatchFilePaths == null)
            {
                throw new ArgumentNullException(nameof(args.BatchFilePaths));
            }

            if (!args.BatchFilePaths.Any())
            {
                throw new ArgumentException(nameof(args.BatchFilePaths), "The pathed batch contains no files.");
            }

            ServiceStateInfo.Instance.UpdateState(ServiceState.IsHandlingBatch);

            _safeExecuteManager.ExecuteWithExceptionLogging(() =>
            {
                foreach (var file in args.BatchFilePaths)
                {
                    _pdfGenerator.AddImageToDocument(file);
                }

                var outputFilePath = GetOutputPath(args.BatchFilePaths.First());
                _pdfGenerator.SavePdf(outputFilePath);

                args.FilePath = outputFilePath;

                OnStepExecuted(this, args);
            });
        }
示例#7
0
        public void HandlePreviousStepResult(object sender, FileStoragePipelineEventArgs args)
        {
            ServiceStateInfo.Instance.UpdateState(ServiceState.IsProvidingBatch);

            _safeExecuteManager.ExecuteWithExceptionLogging(() =>
            {
                if (IsFileFromNewPatch(args.FilePath))
                {
                    ProvideNewBatch();
                }
            });

            _documentParts.Add(args.FilePath);
        }
        public void StartProcessing(IEnumerable <WorkflowStepChain> procceedChains)
        {
            _safeExecuteManager.ExecuteWithExceptionLogging(() =>
            {
                _fileStorageObserver.FileAdded += _imagesBatchProvider.HandlePreviousStepResult;

                foreach (var chain in procceedChains)
                {
                    _imagesBatchProvider.StepExecuted            += chain.ExecutorsChain.First.Value.HandlePreviousStepResult;
                    chain.ExecutorsChain.Last.Value.StepExecuted += _imagesBatchFilesCleaner.HandlePreviousStepResult;
                }

                _fileStorageObserver.ObserverAndProceedExistingFiles();
            });
        }
示例#9
0
        public void HandlePreviousStepResult(object sender, FileStoragePipelineEventArgs args)
        {
            ServiceStateInfo.Instance.UpdateState(ServiceState.IsPublishungBatch);

            _safeExecuteManager.ExecuteWithExceptionLogging(() =>
            {
                if (_fileSystemHelper.FileAccessMonitor.IsFileIsReadyForAccess(args.FilePath))
                {
                    foreach (var fileMessage in _filePatchMessageFactory.GetFilePatchMessages(args.FilePath))
                    {
                        _publisher.Publish(fileMessage);
                    }

                    _fileSystemHelper.FileHelper.DeleteFile(args.FilePath);
                }

                OnStepExecuted(this, args);
            });
        }
示例#10
0
        public void HandlePreviousStepResult(object sender, FileStoragePipelineEventArgs args)
        {
            if (args.BatchFilePaths == null)
            {
                throw new ArgumentNullException(nameof(args.BatchFilePaths));
            }

            if (!args.BatchFilePaths.Any())
            {
                throw new ArgumentException(nameof(args.BatchFilePaths), "The pathed batch contains no files.");
            }

            ServiceStateInfo.Instance.UpdateState(ServiceState.IsCleaningBatchFiles);

            _safeExecuteManager.ExecuteWithExceptionLogging(() =>
            {
                foreach (var file in args.BatchFilePaths)
                {
                    _fileSystemHelper.FileHelper.DeleteFile(file);
                }
            });
        }