public void StartListening() { _safeExecuteManager.ExecuteWithExceptionLogging(() => { _subscriber.Receive(LogServiceState); }); }
public void StartListening() { _safeExecuteManager.ExecuteWithExceptionLogging(() => { _subscriber.Receive(ProcessReceivedFileBatchMessage); }); }
public void StartNotify() { _safeExecuteManager.ExecuteWithExceptionLogging(() => { _observingTimer.Start(); _subscriber.Receive(SetReceivedSettings); }); }
public int CreateUser(User user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } return(_safeExecuteManager.ExecuteWithExceptionLogging(user, (u) => { return _userRepository.Create(u); })); }
/// <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); } }); }
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); }); }
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(); }); }
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); }); }
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); } }); }