Beispiel #1
0
		public DicomServer(DicomServerConfiguration serverConfiguration)
		{
			_aeTitle = serverConfiguration.AETitle;
            _host = serverConfiguration.HostName;
			_port = serverConfiguration.Port;

			_context = new DicomServerContext(this);
			_scp = new DicomScp<IDicomServerContext>(_context, AssociationVerifier.VerifyAssociation);
		}
Beispiel #2
0
        public DicomServer(DicomServerConfiguration serverConfiguration)
        {
            _aeTitle = serverConfiguration.AETitle;
            _host    = serverConfiguration.HostName;
            _port    = serverConfiguration.Port;

            _context = new DicomServerContext(this);
            _scp     = new DicomScp <IDicomServerContext>(_context, AssociationVerifier.VerifyAssociation);
        }
        /// <summary>
        /// Adds services for enabling a DICOM server.
        /// </summary>
        /// <param name="services">The services collection.</param>
        /// <param name="configurationRoot">An optional configuration root object. This method uses the "DicomServer" section.</param>
        /// <param name="configureAction">An optional delegate to set <see cref="DicomServerConfiguration"/> properties after values have been loaded from configuration.</param>
        /// <returns>A <see cref="IDicomServerBuilder"/> object.</returns>
        public static IDicomServerBuilder AddDicomServer(
            this IServiceCollection services,
            IConfiguration configurationRoot,
            Action <DicomServerConfiguration> configureAction = null)
        {
            EnsureArg.IsNotNull(services, nameof(services));

            var dicomServerConfiguration = new DicomServerConfiguration();

            configurationRoot?.GetSection(DicomServerConfigurationSectionName).Bind(dicomServerConfiguration);
            configureAction?.Invoke(dicomServerConfiguration);

            services.AddSingleton(Options.Create(dicomServerConfiguration));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Security));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Features));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Services.DeletedInstanceCleanup));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Services.StoreServiceSettings));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Audit));

            services.RegisterAssemblyModules(Assembly.GetExecutingAssembly(), dicomServerConfiguration);
            services.RegisterAssemblyModules(typeof(InitializationModule).Assembly, dicomServerConfiguration);

            services.AddOptions();

            services.AddMvc(options =>
            {
                options.EnableEndpointRouting      = false;
                options.RespectBrowserAcceptHeader = true;
                options.OutputFormatters.Insert(0, new DicomJsonOutputFormatter());
            }).AddJsonOptions(jsonOptions =>
            {
                jsonOptions.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
            });

            services.AddSingleton <IUrlResolver, UrlResolver>();

            services.RegisterAssemblyModules(typeof(DicomMediatorExtensions).Assembly, dicomServerConfiguration.Features);
            services.AddTransient <IStartupFilter, DicomServerStartupFilter>();

            // Register the Json Serializer to use
            var jsonSerializer = new JsonSerializer();

            jsonSerializer.Converters.Add(new JsonDicomConverter());
            services.AddSingleton(jsonSerializer);

            services.TryAddSingleton <RecyclableMemoryStreamManager>();

            // Disable fo-dicom data item validation. Disabling at global level
            // Opt-in validation instead of opt-out
            // De-serializing to Dataset while read has no Dataset level option to disable validation
#pragma warning disable CS0618 // Type or member is obsolete
            DicomValidation.AutoValidation = false;
#pragma warning restore CS0618 // Type or member is obsolete

            return(new DicomServerBuilder(services));
        }
        private void NotifyDicomServerConfigurationChanged(DicomServerConfiguration dicomServerConfiguration)
        {
            if (_refreshTimer == null)
            {
                return;
            }

            _dicomServerConfiguration = dicomServerConfiguration;
            EventsHelper.Fire(DicomServerConfigurationChanged, this, EventArgs.Empty);
        }
        public DicomServiceNode(DicomServerConfiguration localConfiguration)
        {
            Server = new ApplicationEntity
            {
                Name          = SR.LocalServerName,
                AETitle       = localConfiguration.AETitle,
                ScpParameters = new ScpParameters(localConfiguration.HostName, localConfiguration.Port)
            };

            IsLocal        = true;
            IsPriorsServer = true;
            ExtensionData  = new Dictionary <string, object>();
        }
        public void GivenASecurityConfigurationWithNoAudienceSpecified_WhenGettingValidAudiences_ThenNullShouldBeReturned()
        {
            var dicomServerConfiguration = new DicomServerConfiguration
            {
                Security =
                {
                    Authentication = new AuthenticationConfiguration(),
                },
            };

            var securityModule = new SecurityModule(dicomServerConfiguration);

            Assert.Null(securityModule.GetValidAudiences());
        }
        public void GivenASecurityConfigurationWithAudiences_WhenGettingValidAudiences_ThenCorrectAudienceShouldBeReturned()
        {
            var dicomServerConfiguration = new DicomServerConfiguration
            {
                Security =
                {
                    Authentication = new AuthenticationConfiguration
                    {
                        Audiences  = new[]{ "audience1", "audience2" },
                    },
                },
            };

            var securityModule = new SecurityModule(dicomServerConfiguration);

            Assert.Equal(new[] { "audience1", "audience2" }, securityModule.GetValidAudiences());
        }
        public override void Process()
        {
            EnsureMaxUsedSpaceNotExceeded();

            DicomServerConfiguration configuration = GetServerConfiguration();
            var remoteAE = ServerDirectory.GetRemoteServerByName(Request.ServerName);

            if (remoteAE == null)
            {
                Proxy.Fail(string.Format("Unknown destination: {0}", Request.ServerName), WorkItemFailureType.Fatal);
                return;
            }

            if (RetrieveStudy != null)
            {
                _scu = new ImageViewerMoveScu(configuration.AETitle, remoteAE, RetrieveStudy.Patient, RetrieveStudy.Study);
            }
            else if (RetrieveSeries != null)
            {
                _scu = new ImageViewerMoveScu(configuration.AETitle, remoteAE, RetrieveSeries.Patient, RetrieveSeries.Study, RetrieveSeries.SeriesInstanceUids);
            }
            else
            {
                Proxy.Fail("Invalid request type.", WorkItemFailureType.Fatal);
                return;
            }

            Progress.ImagesToRetrieve     = _scu.TotalSubOperations;
            Progress.FailureSubOperations = 0;
            Progress.WarningSubOperations = 0;
            Progress.SuccessSubOperations = 0;
            Progress.IsCancelable         = false;
            Proxy.UpdateProgress();

            _scu.ImageMoveCompleted += OnMoveImage;

            _scu.Retrieve();

            Progress.ImagesToRetrieve     = _scu.TotalSubOperations;
            Progress.SuccessSubOperations = _scu.SuccessSubOperations;
            Progress.FailureSubOperations = _scu.FailureSubOperations;
            Progress.WarningSubOperations = _scu.WarningSubOperations;
            Progress.StatusDetails        = !string.IsNullOrEmpty(_scu.ErrorDescriptionDetails) ? _scu.ErrorDescriptionDetails : _scu.FailureDescription;

            if (_scu.Canceled)
            {
                if (_cancelDueToDiskSpace)
                {
                    var study = RetrieveStudy.Study ?? RetrieveSeries.Study;

                    Platform.Log(LogLevel.Info, "Dicom Retrieve for {0} from {1} was cancelled because disk space has been exceeded", study, remoteAE.AETitle);
                    Progress.IsCancelable = true;
                    throw new NotEnoughStorageException(); // item will be failed
                }
                else if (StopPending)
                {
                    Progress.IsCancelable = true;
                    Proxy.Postpone();
                }
                else
                {
                    Proxy.Cancel();
                }
            }
            else if (_scu.FailureSubOperations > 0 || _scu.Failed)
            {
                Progress.IsCancelable = true;
                Proxy.Fail(!string.IsNullOrEmpty(_scu.ErrorDescriptionDetails) ? _scu.ErrorDescriptionDetails : _scu.FailureDescription, WorkItemFailureType.NonFatal);
            }
            else
            {
                Proxy.Complete();
            }
        }
        public override void Process()
        {
            DicomServerConfiguration configuration = GetServerConfiguration();
            var remoteAE = ServerDirectory.GetRemoteServerByName(Request.DestinationServerName);

            if (remoteAE == null)
            {
                Proxy.Fail(string.Format("Unknown destination: {0}", Request.DestinationServerName), WorkItemFailureType.Fatal);
                return;
            }

            if (AutoRoute != null && Proxy.Item.Priority != WorkItemPriorityEnum.Stat)
            {
                DateTime now           = Platform.Time;
                DateTime scheduledTime = AutoRoute.GetScheduledTime(now, 0);
                if (now != scheduledTime)
                {
                    Proxy.Postpone();
                    Platform.Log(LogLevel.Info, "Rescheduling AutoRoute WorkItem {0} back into the scheduled time window: {1}", Proxy.Item.Oid, Proxy.Item.ProcessTime);
                    return;
                }
            }

            _scu = new ImageViewerStorageScu(configuration.AETitle, remoteAE);

            LoadImagesToSend();

            if (Request.CompressionType != CompressionType.None)
            {
                _scu.LoadPreferredSyntaxes(Request);
            }

            Progress.TotalImagesToSend    = _scu.TotalSubOperations;
            Progress.FailureSubOperations = 0;
            Progress.WarningSubOperations = 0;
            Progress.SuccessSubOperations = 0;
            Progress.IsCancelable         = true;
            Proxy.UpdateProgress();

            _scu.ImageStoreCompleted += OnImageSent;

            _scu.DoSend();

            if (_scu.Canceled)
            {
                if (StopPending)
                {
                    Proxy.Postpone();
                }
                else
                {
                    Proxy.Cancel();
                }
            }
            else if (_scu.Failed || _scu.FailureSubOperations > 0)
            {
                var      settings = new DicomSendSettings();
                TimeSpan delay    = settings.RetryDelayUnits == RetryDelayTimeUnit.Seconds
                                     ? TimeSpan.FromSeconds(settings.RetryDelay)
                                     : TimeSpan.FromMinutes(settings.RetryDelay);

                Proxy.Fail(_scu.FailureDescription, WorkItemFailureType.NonFatal,
                           AutoRoute != null
                               ? AutoRoute.GetScheduledTime(Platform.Time, (int)delay.TotalSeconds)
                               : Platform.Time.Add(delay), settings.RetryCount);
            }
            else
            {
                Proxy.Complete();
            }
        }
Beispiel #10
0
 public SecurityModule(DicomServerConfiguration dicomServerConfiguration)
 {
     EnsureArg.IsNotNull(dicomServerConfiguration, nameof(dicomServerConfiguration));
     _securityConfiguration = dicomServerConfiguration.Security;
 }
Beispiel #11
0
 public static void UpdateConfiguration(DicomServerConfiguration configuration)
 {
     Platform.GetService<IDicomServerConfiguration>(
         s => s.UpdateConfiguration(new UpdateDicomServerConfigurationRequest{Configuration = configuration}));
 }
Beispiel #12
0
		private void NotifyDicomServerConfigurationChanged(DicomServerConfiguration dicomServerConfiguration)
		{
			if (_refreshTimer == null)
				return;

			_dicomServerConfiguration = dicomServerConfiguration;
			EventsHelper.Fire(DicomServerConfigurationChanged, this, EventArgs.Empty);
		}
Beispiel #13
0
 public static IDicomServiceNode ToServiceNode(this DicomServerConfiguration serverConfiguration)
 {
     Platform.CheckForNullReference(serverConfiguration, "serverConfiguration");
     return(new DicomServiceNode(serverConfiguration));
 }
Beispiel #14
0
 public void Refresh()
 {
     _dicomServerConfiguration = DicomServer.GetConfiguration();
     _storageConfiguration = StudyStore.GetConfiguration();
 }
Beispiel #15
0
 public void Refresh()
 {
     _dicomServerConfiguration = DicomServer.GetConfiguration();
     _storageConfiguration     = StudyStore.GetConfiguration();
 }
Beispiel #16
0
        /// <summary>
        /// Adds services for enabling a DICOM server.
        /// </summary>
        /// <param name="services">The services collection.</param>
        /// <param name="configurationRoot">An optional configuration root object. This method uses the "DicomServer" section.</param>
        /// <param name="configureAction">An optional delegate to set <see cref="DicomServerConfiguration"/> properties after values have been loaded from configuration.</param>
        /// <returns>A <see cref="IDicomServerBuilder"/> object.</returns>
        public static IDicomServerBuilder AddDicomServer(
            this IServiceCollection services,
            IConfiguration configurationRoot,
            Action <DicomServerConfiguration> configureAction = null)
        {
            EnsureArg.IsNotNull(services, nameof(services));

            var dicomServerConfiguration = new DicomServerConfiguration();

            configurationRoot?.GetSection(DicomServerConfigurationSectionName).Bind(dicomServerConfiguration);
            configureAction?.Invoke(dicomServerConfiguration);

            services.AddSingleton(Options.Create(dicomServerConfiguration));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Security));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Features));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Services.DeletedInstanceCleanup));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Services.StoreServiceSettings));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Services.ExtendedQueryTag));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Services.DataPartition));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Audit));
            services.AddSingleton(Options.Create(dicomServerConfiguration.Swagger));

            services.RegisterAssemblyModules(Assembly.GetExecutingAssembly(), dicomServerConfiguration);
            services.RegisterAssemblyModules(typeof(InitializationModule).Assembly, dicomServerConfiguration);
            services.AddApplicationInsightsTelemetry();

            services.AddOptions();

            services
            .AddMvc(options =>
            {
                options.EnableEndpointRouting      = false;
                options.RespectBrowserAcceptHeader = true;
            })
            .AddJsonSerializerOptions(o => o.ConfigureDefaultDicomSettings());

            services.AddApiVersioning(c =>
            {
                c.ApiVersionReader = new UrlSegmentApiVersionReader();
                c.AssumeDefaultVersionWhenUnspecified = true;
                c.DefaultApiVersion = new ApiVersion(1, 0, "prerelease");
                c.ReportApiVersions = true;
                c.UseApiBehavior    = false;
            });

            services.AddVersionedApiExplorer(options =>
            {
                // The format for this is 'v'major[.minor][-status] ex. v1.0-prerelease
                options.GroupNameFormat           = "'v'VVV";
                options.SubstituteApiVersionInUrl = true;
            });

            services.AddTransient <IConfigureOptions <SwaggerGenOptions>, ConfigureSwaggerOptions>();
            services.AddSwaggerGen(options =>
            {
                options.OperationFilter <SwaggerDefaultValues>();
                options.OperationFilter <ErrorCodeOperationFilter>();
                options.OperationFilter <RetrieveOperationFilter>();
                options.DocumentFilter <ReflectionTypeFilter>();
            });

            services.AddSingleton <IUrlResolver, UrlResolver>();

            services.RegisterAssemblyModules(typeof(DicomMediatorExtensions).Assembly, dicomServerConfiguration.Features, dicomServerConfiguration.Services);
            services.AddTransient <IStartupFilter, DicomServerStartupFilter>();

            services.TryAddSingleton <RecyclableMemoryStreamManager>();

            return(new DicomServerBuilder(services));
        }