Esempio n. 1
0
        /// <inheritdoc />
        public async Task <StoreResponse> Handle(
            StoreRequest message,
            CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(message, nameof(message));

            if (await AuthorizationService.CheckAccess(DataActions.Write, cancellationToken) != DataActions.Write)
            {
                throw new UnauthorizedDicomActionException(DataActions.Write);
            }

            StoreRequestValidator.ValidateRequest(message);

            // Find a reader that can parse the request body.
            IDicomInstanceEntryReader dicomInstanceEntryReader = _dicomInstanceEntryReaderManager.FindReader(message.RequestContentType);

            if (dicomInstanceEntryReader == null)
            {
                throw new UnsupportedMediaTypeException(
                          string.Format(CultureInfo.InvariantCulture, DicomCoreResource.UnsupportedContentType, message.RequestContentType));
            }

            // Read list of entries.
            IReadOnlyList <IDicomInstanceEntry> instanceEntries = await dicomInstanceEntryReader.ReadAsync(
                message.RequestContentType,
                message.RequestBody,
                cancellationToken);

            // Process list of entries.
            return(await _storeService.ProcessAsync(instanceEntries, message.StudyInstanceUid, cancellationToken));
        }
Esempio n. 2
0
        public LoggingDicomInstanceEntryReader(
            IDicomInstanceEntryReader dicomInstanceEntryReader,
            ILogger <LoggingDicomInstanceEntryReader> logger)
        {
            EnsureArg.IsNotNull(dicomInstanceEntryReader, nameof(dicomInstanceEntryReader));
            EnsureArg.IsNotNull(logger, nameof(logger));

            _dicomInstanceEntryReader = dicomInstanceEntryReader;
            _logger = logger;

            _readerType = _dicomInstanceEntryReader.GetType().Name;
        }
Esempio n. 3
0
        /// <inheritdoc />
        public IDicomInstanceEntryReader FindReader(string contentType)
        {
            LogFindingReaderDelegate(_logger, contentType, null);

            IDicomInstanceEntryReader dicomInstanceEntryReader = _dicomInstanceEntryReaderManager.FindReader(contentType);

            if (dicomInstanceEntryReader == null)
            {
                LogNoReaderFoundDelegate(_logger, null);
            }
            else
            {
                LogReaderFoundDelegate(_logger, dicomInstanceEntryReader.GetType().Name, null);
            }

            return(dicomInstanceEntryReader);
        }