Пример #1
0
        public AeTitleJobProcessor(
            ClaraApplicationEntity configuration,
            IInstanceStoredNotificationService instanceStoredNotificationService,
            ILoggerFactory loggerFactory,
            IJobRepository jobStore,
            IInstanceCleanupQueue cleanupQueue,
            IDicomToolkit dicomToolkit,
            CancellationToken cancellationToken) : base(instanceStoredNotificationService, loggerFactory, jobStore, cleanupQueue, cancellationToken)
        {
            if (loggerFactory is null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
            _dicomToolkit  = dicomToolkit ?? throw new ArgumentNullException(nameof(dicomToolkit));
            _collections   = new Dictionary <string, InstanceCollection>();
            _pipelines     = new Dictionary <string, string>();

            _logger = loggerFactory.CreateLogger <AeTitleJobProcessor>();

            _timer           = new System.Timers.Timer(1000);
            _timer.AutoReset = false;
            _timer.Elapsed  += OnTimedEvent;
            _timer.Enabled   = true;

            _jobs = new BlockingCollection <InstanceCollection>();

            InitializeSettings();
            _jobProcessingTask = ProcessJobs();
        }
Пример #2
0
 public MockBadJobProcessorValidationFailure(
     ClaraApplicationEntity configuration,
     IInstanceStoredNotificationService instanceStoredNotificationService,
     ILoggerFactory loggerFactory,
     IJobRepository jobStore,
     IInstanceCleanupQueue cleanupQueue,
     CancellationToken cancellationToken) : base(instanceStoredNotificationService, loggerFactory, jobStore, cleanupQueue, cancellationToken)
 {
 }
Пример #3
0
 public MockJobProcessor(
     ClaraApplicationEntity configuration,
     IInstanceStoredNotificationService instanceStoredNotificationService,
     ILoggerFactory loggerFactory,
     IJobRepository jobStore,
     IInstanceCleanupQueue cleanupQueue,
     CancellationToken cancellationToken) : base(instanceStoredNotificationService, loggerFactory, jobStore, cleanupQueue, cancellationToken)
 {
     _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
 }
Пример #4
0
        public AeTitleJobProcessorTest()
        {
            _cancellationTokenSource   = new CancellationTokenSource();
            _configuration             = new ClaraApplicationEntity();
            _loggerNotificationService = new Mock <ILogger <InstanceStoredNotificationService> >();
            _loggerJobProcessorBase    = new Mock <ILogger <JobProcessorBase> >();
            _logger              = new Mock <ILogger <AeTitleJobProcessor> >();
            _cleanupQueue        = new Mock <IInstanceCleanupQueue>();
            _notificationService = new InstanceStoredNotificationService(_loggerNotificationService.Object, _cleanupQueue.Object);
            _loggerFactory       = new Mock <ILoggerFactory>();
            _jobsApi             = new Mock <IJobs>();
            _payloadsApi         = new Mock <IPayloads>();
            _instances           = new List <InstanceStorageInfo>();
            _dicomToolkit        = new Mock <IDicomToolkit>();
            _fileSystem          = new MockFileSystem();

            _cleanupQueue.Setup(p => p.QueueInstance(It.IsAny <InstanceStorageInfo>()));

            _loggerFactory.Setup(p => p.CreateLogger(It.IsAny <string>())).Returns((string type) =>
            {
                return(_logger.Object);
            });
            string expectedValue = string.Empty;

            _dicomToolkit.Setup(p => p.TryGetString(It.IsAny <string>(), It.IsAny <DicomTag>(), out expectedValue))
            .Callback(new AeTitleJobProcessorTest.OutAction((string path, DicomTag tag, out string value) =>
            {
                var instance = _instances.First(p => p.InstanceStorageFullPath == path);
                value        = tag == DicomTag.PatientID ? instance.PatientId :
                               tag == DicomTag.StudyInstanceUID ? instance.StudyInstanceUid :
                               instance.SeriesInstanceUid;
            })).Returns(true);

            _patient1 = "PATIENT1";
            _patient2 = "PATIENT2";
            _study1   = DicomUIDGenerator.GenerateDerivedFromUUID();
            _study2   = DicomUIDGenerator.GenerateDerivedFromUUID();
            _study3   = DicomUIDGenerator.GenerateDerivedFromUUID();
            _series1  = DicomUIDGenerator.GenerateDerivedFromUUID();
            _series2  = DicomUIDGenerator.GenerateDerivedFromUUID();
            _series3  = DicomUIDGenerator.GenerateDerivedFromUUID();
            _series4  = DicomUIDGenerator.GenerateDerivedFromUUID();
            _aeTitle  = "AET1";

            GenerateInstances();
        }
Пример #5
0
        public JobProcessorBase(
            IInstanceStoredNotificationService instanceStoredNotificationService,
            ILoggerFactory loggerFactory,
            IJobRepository jobStore,
            IInstanceCleanupQueue cleanupQueue,
            CancellationToken cancellationToken)
        {
            if (loggerFactory is null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _instanceStoredNotificationService = instanceStoredNotificationService ?? throw new ArgumentNullException(nameof(instanceStoredNotificationService));
            _logger             = loggerFactory.CreateLogger <JobProcessorBase>();
            _jobStore           = jobStore ?? throw new ArgumentNullException(nameof(jobStore));
            _cleanupQueue       = cleanupQueue ?? throw new ArgumentNullException(nameof(cleanupQueue));
            CancellationToken   = cancellationToken;
            _cancelSubscription = _instanceStoredNotificationService.Subscribe(this);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="serviceProvider">Instance of IServiceProvide for dependency injection.</param>
        /// <param name="applicationEntity">ClaraApplicationEntity configuration to be used.</param>
        /// <param name="storageRootFullPath">Temporary storage path location</param>
        /// <param name="iFileSystem">instance of IFileSystem</param>
        public ApplicationEntityHandler(IServiceProvider serviceProvider, ClaraApplicationEntity applicationEntity, string storageRootFullPath, CancellationToken cancellationToken, IFileSystem iFileSystem)
        {
            Guard.Against.NullOrWhiteSpace(storageRootFullPath, nameof(storageRootFullPath));

            _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            Configuration    = applicationEntity ?? throw new ArgumentNullException(nameof(applicationEntity));
            _loggerFactory   = _serviceProvider.GetService <ILoggerFactory>();

            _logger               = _loggerFactory.CreateLogger <ApplicationEntityHandler>();
            _dicomToolkit         = _serviceProvider.GetService <IDicomToolkit>();
            _cancellationToken    = cancellationToken;
            _fileSystem           = iFileSystem ?? throw new ArgumentNullException(nameof(iFileSystem));
            AeStorageRootFullPath = _fileSystem.Path.Combine(storageRootFullPath, applicationEntity.AeTitle.RemoveInvalidPathChars());

            _instanceStoredNotificationService = (IInstanceStoredNotificationService)serviceProvider.GetService(typeof(IInstanceStoredNotificationService)) ?? throw new ArgumentNullException("IInstanceStoredNotificationService service not configured");

            _jobProcessor = typeof(JobProcessorBase).CreateInstance <JobProcessorBase>(serviceProvider, Configuration.Processor, Configuration, _cancellationToken);
            _logger.Log(LogLevel.Information, "Clara AE Title {0} configured with temporary storage location {1}", applicationEntity.AeTitle, AeStorageRootFullPath);

            CleanRootPath();
        }