/// <summary>
		/// Method called when stopping the DICOM SCP.
		/// </summary>
		protected override void Stop()
		{
			lock (_syncLock)
			{
                ServerPartitionMonitor.Instance.Changed -= _changedEvent;

				foreach (DicomScp<DicomScpContext> scp in _listenerList)
				{
					scp.Stop();
					var helper = new ApplicationActivityAuditHelper(
								ServerPlatform.AuditSource,
								EventIdentificationContentsEventOutcomeIndicator.Success,
								ApplicationActivityType.ApplicationStopped,
								new AuditProcessActiveParticipant(scp.AeTitle));
                    ServerAuditHelper.LogAuditMessage(helper);
				}

                foreach (DicomScp<DicomScpContext> scp in _alternateAeListenerList)
                {
                    scp.Stop();
                    var helper = new ApplicationActivityAuditHelper(
                                ServerPlatform.AuditSource,
                                EventIdentificationContentsEventOutcomeIndicator.Success,
                                ApplicationActivityType.ApplicationStopped,
                                new AuditProcessActiveParticipant(scp.AeTitle));
                    ServerAuditHelper.LogAuditMessage(helper);
                }		
			}
		}
	    private void StartScp(DicomScp<DicomScpContext> listener, List<DicomScp<DicomScpContext>> list)
        {
            if (listener.Start())
            {
                list.Add(listener);
                var helper = new ApplicationActivityAuditHelper(
                                        ServerPlatform.AuditSource,
                                        EventIdentificationContentsEventOutcomeIndicator.Success,
                                        ApplicationActivityType.ApplicationStarted,
                                        new AuditProcessActiveParticipant(listener.AeTitle));
                ServerAuditHelper.LogAuditMessage(helper);
            }
            else
            {
                var helper = new ApplicationActivityAuditHelper(
                    ServerPlatform.AuditSource,
                    EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable,
                    ApplicationActivityType.ApplicationStarted,
                    new AuditProcessActiveParticipant(listener.AeTitle));
                ServerAuditHelper.LogAuditMessage(helper);

                Platform.Log(LogLevel.Error, "Unable to add {1} SCP handler for server partition {0}",
                             listener.Context.Partition.Description,
                             listener.ListenAddress.AddressFamily == AddressFamily.InterNetworkV6
                                 ? "IPv6"
                                 : "IPv4");
                Platform.Log(LogLevel.Error,
                             "Partition {0} will not accept IPv6 incoming DICOM associations.",
                             listener.Context.Partition.Description);

                ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener",
                                     AlertTypeCodes.UnableToStart, null, TimeSpan.Zero,
                                     "Unable to start {2} DICOM listener on {0} : {1}",
                                     listener.AeTitle, listener.ListenPort,
                                     listener.ListenAddress.AddressFamily == AddressFamily.InterNetworkV6
                                         ? "IPv6"
                                         : "IPv4");
            }
        }
Exemple #3
0
		private void CheckPartitions()
		{
    	
			lock (_syncLock)
			{
				_partitions = new List<ServerPartition>(ServerPartitionMonitor.Instance);
				IList<DicomScp<DicomScpContext>> scpsToDelete = new List<DicomScp<DicomScpContext>>();

				foreach (DicomScp<DicomScpContext> scp in _listenerList)
				{
					bool bFound = false;
					foreach (ServerPartition part in _partitions)
					{
						if (part.Port == scp.ListenPort && part.AeTitle.Equals(scp.AeTitle) && part.Enabled)
						{
							bFound = true;
							break;
						}
					}

					if (!bFound)
					{
						Platform.Log(LogLevel.Info, "Partition was deleted, shutting down listener {0}:{1}", scp.AeTitle, scp.ListenPort);
						scp.Stop();
						scpsToDelete.Add(scp);
						ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
												ServerPlatform.AuditSource,
												EventIdentificationContentsEventOutcomeIndicator.Success,
												ApplicationActivityType.ApplicationStopped,
												new AuditProcessActiveParticipant(scp.AeTitle));
						ServerPlatform.LogAuditMessage(helper);
					}
				}

				foreach (DicomScp<DicomScpContext> scp in scpsToDelete)
					_listenerList.Remove(scp);

				foreach (ServerPartition part in _partitions)
				{
					if (!part.Enabled)
						continue;

					bool bFound = false;
					foreach (DicomScp<DicomScpContext> scp in _listenerList)
					{
						if (part.Port != scp.ListenPort || !part.AeTitle.Equals(scp.AeTitle))
							continue;

						// Reset the context partition, incase its changed.
						scp.Context.Partition = part;

						bFound = true;
						break;
					}

					if (!bFound)
					{
						Platform.Log(LogLevel.Info, "Detected partition was added, starting listener {0}:{1}", part.AeTitle, part.Port);
						StartListeners(part);
					}
				}
			}
		}
Exemple #4
0
		private void StartListeners(ServerPartition part)
		{
			DicomScpContext parms =
				new DicomScpContext(part);

			if (DicomSettings.Default.ListenIPV4)
			{
				DicomScp<DicomScpContext> ipV4Scp = new DicomScp<DicomScpContext>(parms, AssociationVerifier.Verify, AssociationAuditLogger.InstancesTransferredAuditLogger);

				ipV4Scp.ListenPort = part.Port;
				ipV4Scp.AeTitle = part.AeTitle;

				if (ipV4Scp.Start(IPAddress.Any))
				{
					_listenerList.Add(ipV4Scp);
					ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
											ServerPlatform.AuditSource, 
											EventIdentificationContentsEventOutcomeIndicator.Success, 
											ApplicationActivityType.ApplicationStarted, 
											new AuditProcessActiveParticipant(ipV4Scp.AeTitle));
					ServerPlatform.LogAuditMessage(helper);
				}
				else
				{
					ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
											ServerPlatform.AuditSource,
											EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable,
											ApplicationActivityType.ApplicationStarted,
											new AuditProcessActiveParticipant(ipV4Scp.AeTitle));
					ServerPlatform.LogAuditMessage(helper);
					Platform.Log(LogLevel.Error, "Unable to add IPv4 SCP handler for server partition {0}",
								 part.Description);
					Platform.Log(LogLevel.Error,
								 "Partition {0} will not accept IPv4 incoming DICOM associations.",
								 part.Description);
					ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener",
                                         AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, "Unable to start IPv4 DICOM listener on {0} : {1}",
					                     ipV4Scp.AeTitle, ipV4Scp.ListenPort);
				}
			}

			if (DicomSettings.Default.ListenIPV6)
			{
				DicomScp<DicomScpContext> ipV6Scp = new DicomScp<DicomScpContext>(parms, AssociationVerifier.Verify, AssociationAuditLogger.InstancesTransferredAuditLogger);

				ipV6Scp.ListenPort = part.Port;
				ipV6Scp.AeTitle = part.AeTitle;

				if (ipV6Scp.Start(IPAddress.IPv6Any))
				{
					_listenerList.Add(ipV6Scp);
					ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
											ServerPlatform.AuditSource,
											EventIdentificationContentsEventOutcomeIndicator.Success,
											ApplicationActivityType.ApplicationStarted,
											new AuditProcessActiveParticipant(ipV6Scp.AeTitle));
					ServerPlatform.LogAuditMessage(helper);
				}
				else
				{
					ApplicationActivityAuditHelper helper = new ApplicationActivityAuditHelper(
						ServerPlatform.AuditSource,
						EventIdentificationContentsEventOutcomeIndicator.MajorFailureActionMadeUnavailable,
						ApplicationActivityType.ApplicationStarted,
						new AuditProcessActiveParticipant(ipV6Scp.AeTitle));
					ServerPlatform.LogAuditMessage(helper);

					Platform.Log(LogLevel.Error, "Unable to add IPv6 SCP handler for server partition {0}",
								 part.Description);
					Platform.Log(LogLevel.Error,
								 "Partition {0} will not accept IPv6 incoming DICOM associations.",
								 part.Description);
					ServerPlatform.Alert(AlertCategory.Application, AlertLevel.Critical, "DICOM Listener",
                                         AlertTypeCodes.UnableToStart, null, TimeSpan.Zero, "Unable to start IPv6 DICOM listener on {0} : {1}",
										 ipV6Scp.AeTitle, ipV6Scp.ListenPort);
				}
			}
		}
	    /// <summary>
		/// Method called when stopping the DICOM SCP.
		/// </summary>
		protected override void Stop()
		{
			//TODO CR (Jan 2014): Move this into the base if it applies to all subclasses?
			PersistentStoreRegistry.GetDefaultStore().ShutdownRequested = true;

			lock (_syncLock)
			{
				if (_changedEvent == null)
					return;

                ServerPartitionMonitor.Instance.Changed -= _changedEvent;

				foreach (DicomScp<DicomScpContext> scp in _listenerList)
				{
					scp.Stop();
					var helper = new ApplicationActivityAuditHelper(
								ServerPlatform.AuditSource,
								EventIdentificationContentsEventOutcomeIndicator.Success,
								ApplicationActivityType.ApplicationStopped,
								new AuditProcessActiveParticipant(scp.AeTitle));
                    ServerAuditHelper.LogAuditMessage(helper);
				}

                foreach (DicomScp<DicomScpContext> scp in _alternateAeListenerList)
                {
                    scp.Stop();
                    var helper = new ApplicationActivityAuditHelper(
                                ServerPlatform.AuditSource,
                                EventIdentificationContentsEventOutcomeIndicator.Success,
                                ApplicationActivityType.ApplicationStopped,
                                new AuditProcessActiveParticipant(scp.AeTitle));
                    ServerAuditHelper.LogAuditMessage(helper);
                }		
			}
		}