Пример #1
0
        /// <summary>
        /// Registers a number of <see cref="ISopDataSource"/>s with the <see cref="UnitTestStudyLoader"/>.
        /// </summary>
        /// <remarks>
        /// <para>Dispose the returned context to unregister the data sources.</para>
        /// <para>This method is thread safe.</para>
        /// </remarks>
        /// <param name="server">Specifies the "server" on which these data sources "reside."</param>
        /// <param name="sopDataSources">The <see cref="ISopDataSource"/>s to be registered.</param>
        /// <returns>A context object that should be disposed in order to unregister the data sources.</returns>
        public static UnitTestStudyProviderContext RegisterStudies(IDicomServiceNode server, IEnumerable <ISopDataSource> sopDataSources)
        {
            var unitTestStudyProvider = new UnitTestStudyProviderContext(server, sopDataSources);

            RegisterStudyProvider(unitTestStudyProvider);
            return(unitTestStudyProvider);
        }
Пример #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="studyInstanceUid"></param>
        /// <param name="server"></param>
		public LoadStudyArgs(string studyInstanceUid, IDicomServiceNode server)
		{
			Platform.CheckForNullReference(studyInstanceUid, "studyInstanceUids");
            Platform.CheckForNullReference(server, "server");
            StudyInstanceUid = studyInstanceUid;
			Server = server;
		}
Пример #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="studyInstanceUid"></param>
 /// <param name="server"></param>
 /// <param name="studyLoaderOptions"> </param>
 public LoadStudyArgs(string studyInstanceUid, IDicomServiceNode server, StudyLoaderOptions studyLoaderOptions)
 {
     Platform.CheckForNullReference(studyInstanceUid, "studyInstanceUids");
     Platform.CheckForNullReference(server, "server");
     StudyInstanceUid   = studyInstanceUid;
     Server             = server;
     StudyLoaderOptions = studyLoaderOptions ?? new StudyLoaderOptions();
 }
Пример #4
0
	    /// <summary>
	    /// Constructor.
	    /// </summary>
	    /// <param name="studyInstanceUid"></param>
	    /// <param name="server"></param>
        /// <param name="studyLoaderOptions"> </param>
        public LoadStudyArgs(string studyInstanceUid, IDicomServiceNode server, StudyLoaderOptions studyLoaderOptions)
        {
            Platform.CheckForNullReference(studyInstanceUid, "studyInstanceUids");
            Platform.CheckForNullReference(server, "server");
            StudyInstanceUid = studyInstanceUid;
            Server = server;
            StudyLoaderOptions = studyLoaderOptions ?? StudyLoaderOptions.Default;
        }
Пример #5
0
        private static int GetSortKey(IDicomServiceNode serviceNode)
        {
            if (serviceNode.IsLocal)
                return 0; //local first.

            // TODO (CR Jun 2012): !!!!! This should be IsSupported<IStudyLoader>(), but it's in the wrong assembly !!!!!! Need to move IStudyLoader to Common.
            //Ones that can load, followed by those that can't.
            return serviceNode.StreamingParameters != null ? 1 : 2;
        }
Пример #6
0
	    /// <summary>
        /// Constructor.
        /// </summary>
        public DicomImageSetDescriptor(IStudyRootStudyIdentifier sourceStudy, IDicomServiceNode server, Exception loadStudyError)
		{
            Platform.CheckForNullReference(sourceStudy, "sourceStudy");
            SourceStudy = sourceStudy;
            Server = server ?? sourceStudy.FindServer(true);

	        LoadStudyError = loadStudyError;
            IsOffline = loadStudyError is OfflineLoadStudyException;
            IsNearline = loadStudyError is NearlineLoadStudyException;
            IsInUse = loadStudyError is InUseLoadStudyException;
            IsNotLoadable = loadStudyError is StudyLoaderNotFoundException;
		}
Пример #7
0
		/// <summary>
		/// Constructs a new <see cref="OpenStudyArgs"/> using the specified parameters.
		/// </summary>
		/// <param name="studyInstanceUids">The Study Instance UIDs of the studies to be opened.</param>
		/// <param name="server">The server from which the study should be loaded.</param>
		/// <param name="windowBehaviour">The window launch options.</param>
		public OpenStudyArgs(string[] studyInstanceUids, IDicomServiceNode server, WindowBehaviour windowBehaviour)
		{
			Platform.CheckForNullReference(studyInstanceUids, "studyInstanceUids");
            Platform.CheckForNullReference(server, "server");

			if (studyInstanceUids.Length == 0)
				throw new ArgumentException("studyInstanceUids array cannot be empty.");

			_studyInstanceUids = studyInstanceUids;
			_server = server;
			_windowBehaviour = windowBehaviour;
		}
Пример #8
0
        public ImageViewerMoveScu(string localAETitle, IDicomServiceNode remoteAEInfo, IPatientRootData patient, IStudyIdentifier studiesToRetrieve)
            : base(localAETitle, remoteAEInfo.AETitle, remoteAEInfo.ScpParameters.HostName, remoteAEInfo.ScpParameters.Port, localAETitle)
        {
            Platform.CheckForEmptyString(localAETitle, "localAETitle");
            Platform.CheckForEmptyString(remoteAEInfo.AETitle, "AETitle");
            Platform.CheckForEmptyString(remoteAEInfo.ScpParameters.HostName, "HostName");
            Platform.CheckForNullReference(studiesToRetrieve, "studiesToRetrieve");

            _studyToRetrieve = studiesToRetrieve;
            _patientToRetrieve = patient;
            _errorDescriptionDetails = string.Empty;
        }
Пример #9
0
        internal static int GetSortKey(IDicomServiceNode serviceNode)
        {
			if (serviceNode == null)
				return 3; //We basically know nothing ... sort below even non-streaming servers.

            if (serviceNode.IsLocal)
                return 0; //Local first.

            // TODO (CR Jun 2012): !!!!! This should be IsSupported<IStudyLoader>(), but it's in the wrong assembly !!!!!! Need to move IStudyLoader to Common.
            //Ones that can load, followed by those that can't.
            return serviceNode.StreamingParameters != null ? 1 : 2;
        }
Пример #10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sourceAE">The AE title of the remote application sending the SOP Instances.</param>
        /// <param name="configuration">Storage configuration. </param>
        /// <param name="hostname">The IP Address the remote app is connecting with.</param>
        /// <param name="auditSource">The source of the request for auditing purposes </param>
        public DicomReceiveImportContext(string sourceAE, string hostname, StorageConfiguration configuration, EventSource auditSource) : base(sourceAE, configuration, auditSource)
        {
            // TODO (CR Jun 2012 - Med): This object is disposable and should be cleaned up.

            _monitor = WorkItemActivityMonitor.Create(false);
            _monitor.WorkItemsChanged += WorkItemsChanged;

            var serverList = ServerDirectory.GetRemoteServersByAETitle(sourceAE);
            if (serverList.Count == 1)
                _dicomServerNode = CollectionUtils.FirstElement(serverList);

            _hostname = hostname;
        }
Пример #11
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sourceAE">The AE title of the remote application sending the SOP Instances.</param>
        /// <param name="configuration">Storage configuration. </param>
        /// <param name="hostname">The IP Address the remote app is connecting with.</param>
        /// <param name="auditSource">The source of the request for auditing purposes </param>
        public DicomReceiveImportContext(string sourceAE, string hostname, StorageConfiguration configuration, EventSource auditSource) : base(sourceAE, configuration, auditSource)
        {
            _monitor = WorkItemActivityMonitor.Create(false);
            _monitor.WorkItemsChanged += WorkItemsChanged;

            var serverList = ServerDirectory.GetRemoteServersByAETitle(sourceAE);

            if (serverList.Count == 1)
            {
                _dicomServerNode = CollectionUtils.FirstElement(serverList);
            }

            _hostname = hostname;
        }
Пример #12
0
 internal static int GetSortKey(IDicomServiceNode serviceNode)
 {
     if (serviceNode == null)
     {
         return(3);                //We basically know nothing ... sort below even non-streaming servers.
     }
     if (serviceNode.IsLocal)
     {
         return(0); //Local first.
     }
     // TODO (CR Jun 2012): !!!!! This should be IsSupported<IStudyLoader>(), but it's in the wrong assembly !!!!!! Need to move IStudyLoader to Common.
     //Ones that can load, followed by those that can't.
     return(serviceNode.StreamingParameters != null ? 1 : 2);
 }
Пример #13
0
        public void RetrieveStudy(IDicomServiceNode remoteAEInfo, IStudyRootData study)
        {
            EventResult result = EventResult.Success;

            try
            {
                var request = new DicomRetrieveStudyRequest
                {
                    ServerName     = remoteAEInfo.Name,
                    ServerAETitle  = remoteAEInfo.AETitle,
                    ServerHostname = remoteAEInfo.ScpParameters != null ? remoteAEInfo.ScpParameters.HostName : null,
                    ServerPort     = remoteAEInfo.ScpParameters != null ? remoteAEInfo.ScpParameters.Port : 0,
                    Study          = new WorkItemStudy(study),
                    Patient        = new WorkItemPatient(study)
                };

                // TODO (CR Jul 2012): The service itself has logic like this already, so this should probably be there, too.
                // Then, we could also get rid of this GetMatching... method.
                var data = GetMatchingActiveWorkItem(request);
                if (data != null)
                {
                    var existingRequest = data.Request as DicomRetrieveStudyRequest;
                    if (existingRequest != null && remoteAEInfo.Name == existingRequest.ServerName)
                    {
                        Request = data.Request;
                        return;
                    }
                }

                InsertRequest(request, new DicomRetrieveProgress());
            }
            catch (Exception ex)
            {
                result    = EventResult.MajorFailure;
                Exception = ex;
                Platform.Log(LogLevel.Error, ex, Common.SR.MessageFailedToSendStudy);
                throw;
            }
            finally
            {
                var instances = new AuditedInstances();
                instances.AddInstance(study.PatientId, study.PatientsName, study.StudyInstanceUid);

                AuditHelper.LogBeginReceiveInstances(remoteAEInfo.AETitle, remoteAEInfo.ScpParameters.HostName,
                                                     instances, string.IsNullOrEmpty(Request.UserName)
                                                                                        ? EventSource.CurrentProcess
                                                                                        : EventSource.CurrentUser, result);
            }
        }
Пример #14
0
		/// <summary>
		/// Starts the enumeration of images that match the specified
		/// Study Instance UID.
		/// </summary>
		/// <param name="studyLoaderArgs"></param>
		/// <returns>Number of images in study.</returns>
		public int Start(StudyLoaderArgs studyLoaderArgs)
		{
            if (studyLoaderArgs.Server != null)
			    _currentServer = studyLoaderArgs.Server.ToServiceNode();

			try
			{
				return OnStart(studyLoaderArgs);
			}
			catch(LoadStudyException)
			{
				throw;
			}
			catch(Exception e)
			{
				throw new LoadStudyException(studyLoaderArgs.StudyInstanceUid, e);
			}
		}
Пример #15
0
        protected override int OnStart(StudyLoaderArgs studyLoaderArgs)
        {
            var ae = studyLoaderArgs.Server as IDicomServiceNode;

            _ae = ae;

            EventResult      result          = EventResult.Success;
            AuditedInstances loadedInstances = new AuditedInstances();

            try
            {
                ServerPartition partition = ServerPartitionMonitor.Instance.GetPartition(_ae.AETitle);
                if (!partition.Enabled)
                {
                    throw new OfflineLoadStudyException(studyLoaderArgs.StudyInstanceUid);
                }

                FilesystemMonitor.Instance.GetReadableStudyStorageLocation(partition.Key,
                                                                           studyLoaderArgs.StudyInstanceUid,
                                                                           StudyRestore.False,
                                                                           StudyCache.True,
                                                                           out _location);

                StudyXml studyXml = _location.LoadStudyXml();

                _instances = GetInstances(studyXml).GetEnumerator();

                loadedInstances.AddInstance(studyXml.PatientId, studyXml.PatientsName, studyXml.StudyInstanceUid);

                return(studyXml.NumberOfStudyRelatedInstances);
            }
            catch (StudyIsNearlineException e)
            {
                throw new NearlineLoadStudyException(studyLoaderArgs.StudyInstanceUid, e);
            }
            finally
            {
                AuditHelper.LogOpenStudies(new[] { ae.AETitle }, loadedInstances, EventSource.CurrentUser, result);
            }
        }
Пример #16
0
        public void PublishFiles(IDicomServiceNode remoteAEInfo, IStudyRootData study, DeletionBehaviour behaviour, List <string> files)
        {
            EventResult result = EventResult.Success;

            try
            {
                var request = new PublishFilesRequest
                {
                    DestinationServerName     = remoteAEInfo.Name,
                    DestinationServerAETitle  = remoteAEInfo.AETitle,
                    DestinationServerHostname = remoteAEInfo.ScpParameters != null ? remoteAEInfo.ScpParameters.HostName : null,
                    DestinationServerPort     = remoteAEInfo.ScpParameters != null ? remoteAEInfo.ScpParameters.Port : 0,
                    Priority          = WorkItemPriorityEnum.High,
                    DeletionBehaviour = behaviour,
                    Study             = new WorkItemStudy(study),
                    Patient           = new WorkItemPatient(study),
                    FilePaths         = files
                };
                InsertRequest(request, new DicomSendProgress());
            }
            catch (Exception ex)
            {
                result    = EventResult.MajorFailure;
                Exception = ex;
                Platform.Log(LogLevel.Error, ex, Common.SR.MessageFailedToSendSops);
                throw;
            }
            finally
            {
                var instances = new AuditedInstances();
                instances.AddInstance(study.PatientId, study.PatientsName, study.StudyInstanceUid);

                AuditHelper.LogBeginSendInstances(remoteAEInfo.AETitle, remoteAEInfo.ScpParameters.HostName,
                                                  instances,
                                                  string.IsNullOrEmpty(Request.UserName)
                                                                        ? EventSource.CurrentProcess
                                                                        : EventSource.CurrentUser, result);
            }
        }
Пример #17
0
        protected override int OnStart(StudyLoaderArgs studyLoaderArgs)
        {
            var ae = studyLoaderArgs.Server as IDicomServiceNode;
            _ae = ae;

            EventResult result = EventResult.Success;
            AuditedInstances loadedInstances = new AuditedInstances();
            try
            {
                ServerPartition partition = ServerPartitionMonitor.Instance.GetPartition(_ae.AETitle);
                if (!partition.Enabled)
                    throw new OfflineLoadStudyException(studyLoaderArgs.StudyInstanceUid);    

                FilesystemMonitor.Instance.GetReadableStudyStorageLocation(partition.Key,
                                                                           studyLoaderArgs.StudyInstanceUid,
                                                                           StudyRestore.False,
                                                                           StudyCache.True,
                                                                           out _location);

                StudyXml studyXml = _location.LoadStudyXml();

                _instances = GetInstances(studyXml).GetEnumerator();

                loadedInstances.AddInstance(studyXml.PatientId, studyXml.PatientsName, studyXml.StudyInstanceUid);

                return studyXml.NumberOfStudyRelatedInstances;

            }
            catch (StudyIsNearlineException e)
            {
                throw new NearlineLoadStudyException(studyLoaderArgs.StudyInstanceUid, e);
            }
            finally
            {
                AuditHelper.LogOpenStudies(new[] {ae.AETitle}, loadedInstances, EventSource.CurrentUser, result);
            }
        }
Пример #18
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="studyInstanceUid"></param>
        /// <param name="server"></param>
		public LoadStudyArgs(string studyInstanceUid, IDicomServiceNode server)
            : this(studyInstanceUid, server, StudyLoaderCheckOptions.Default)
        {}
Пример #19
0
        private static bool PublishFilesToRemote(IDicomServiceNode destination, ICollection<DicomFile> files)
		{
			try
			{
                Platform.GetService((IPublishFiles service) => service.PublishRemote(files,destination));
				return true;
			}
            catch (Exception ex)
			{
				Platform.Log(LogLevel.Error, ex, "An error occurred while attempting to publish files to server {0}.", destination.AETitle);
			}
			return false;
		}
Пример #20
0
        private static bool StudyExistsOnRemote(IDicomServiceNode server, string studyInstanceUid)
		{
            IList<StudyRootStudyIdentifier> result = null;
            server.GetService<IStudyRootQuery>(s => result = 
                s.StudyQuery(new StudyRootStudyIdentifier {StudyInstanceUid = studyInstanceUid}));
			return result.Count > 0;
		}
Пример #21
0
        private static bool ContainsServer(IEnumerable<IDicomServiceNode> servers, IDicomServiceNode server)
		{
			return server != null && servers.Any(s => s.Name == server.Name);
		}
Пример #22
0
        public void RetrieveSeries(IDicomServiceNode remoteAEInfo, IStudyRootData study, string[] seriesInstanceUids)
        {
            EventResult result = EventResult.Success;
            try
            {
                var request = new DicomRetrieveSeriesRequest
                {
                    ServerName = remoteAEInfo.Name,
                    SeriesInstanceUids = new List<string>(),
                    Study = new WorkItemStudy(study),
                    Patient = new WorkItemPatient(study)
                };

                request.SeriesInstanceUids.AddRange(seriesInstanceUids);
                InsertRequest(request, new DicomRetrieveProgress());
            }
            catch (Exception ex)
            {
                result = EventResult.MajorFailure;
                Exception = ex;
                throw;
            }
            finally
            {
                var instances = new AuditedInstances();
                instances.AddInstance(study.PatientId, study.PatientsName, study.StudyInstanceUid);

                AuditHelper.LogBeginReceiveInstances(remoteAEInfo.AETitle, remoteAEInfo.ScpParameters.HostName,
                                       instances, string.IsNullOrEmpty(Request.UserName)
                                                      ? EventSource.CurrentProcess
                                                      : EventSource.CurrentUser, result);
            }
        }
Пример #23
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="localAETitle">The local AE Title.</param>
 /// <param name="request">The <see cref="WorkItemRequest"/> for the association.</param>
 public ImageViewerStorageScu(string localAETitle, IDicomServiceNode request)
     : base(localAETitle, request.AETitle, request.ScpParameters.HostName, request.ScpParameters.Port)
 {
 }
Пример #24
0
			internal UnitTestStudyProviderContext(IDicomServiceNode server, IEnumerable<ISopDataSource> sopDataSources)
			{
				Platform.CheckForNullReference(server, "server");
				Platform.CheckForNullReference(sopDataSources, "sopDataSources");

				Server = server;
				SopDataSources = sopDataSources;
			}
Пример #25
0
        public void SendSops(IDicomServiceNode remoteAEInfo, IStudyRootData study, string seriesInstanceUid, string[] sopInstanceUids, WorkItemPriorityEnum priority)
        {
            EventResult result = EventResult.Success;
            try
            {
                var request = new DicomSendSopRequest
                                  {
                                      DestinationServerName = remoteAEInfo.Name,
                                      SeriesInstanceUid = seriesInstanceUid,
                                      SopInstanceUids = new List<string>(),
                                      Priority = priority,
                                      Study = new WorkItemStudy(study),
                                      Patient = new WorkItemPatient(study)
                                  };
                request.SopInstanceUids.AddRange(sopInstanceUids);
                InsertRequest(request, new DicomSendProgress());
            }
            catch (Exception ex)
            {
                result = EventResult.MajorFailure;
                Exception = ex;
                Platform.Log(LogLevel.Error, ex, Common.SR.MessageFailedToSendSops);
                throw;
            }
            finally
            {
                var instances = new AuditedInstances();
                instances.AddInstance(study.PatientId, study.PatientsName, study.StudyInstanceUid);

                AuditHelper.LogBeginSendInstances(remoteAEInfo.AETitle, remoteAEInfo.ScpParameters.HostName,
                                                  instances,
                                                  string.IsNullOrEmpty(Request.UserName)
                                                      ? EventSource.CurrentProcess
                                                      : EventSource.CurrentUser, result);
            }
        }
Пример #26
0
		public void PublishRemote(ICollection<DicomFile> files, IDicomServiceNode destinationServer)
		{
			if (files == null || files.Count == 0)
				return;

			// cache files to temporary storage
			string tempFileDirectory;
			List<string> savedFiles;
			SaveFiles(files, destinationServer.AETitle, out tempFileDirectory, out savedFiles);

			try
			{
				var client = new DicomSendBridge();
				client.PublishFiles(destinationServer, new StudyRootStudyIdentifier(CollectionUtils.FirstElement(files).DataSet),
				                    DeletionBehaviour.DeleteOnSuccess, savedFiles);
			}
			catch (Exception ex)
			{
				var message = string.Format("Failed to connect to the dicom send service to send files.  The files must be published manually (location: {0})", tempFileDirectory);
				throw new DicomFilePublishingException(message, ex);
			}
		}
Пример #27
0
		/// <summary>
		/// Loads the next <see cref="Sop"/>.
		/// </summary>
		/// <returns>The next <see cref="Sop"/> or <b>null</b> if there are none remaining.</returns>
		/// <remarks>
		/// Implementers of <see cref="IStudyLoader"/> should avoid loading pixel data
		/// in this method for performance reasons.
		/// </remarks>
        public Sop LoadNextSop()
		{
		    SopDataSource dataSource = LoadNextSopDataSource();
		    if (dataSource == null)
		    {
		        _currentServer = null;
		        return null;
		    }

		    dataSource.Server = _currentServer;
		    return CreateSop(dataSource);
		}
			public StudyInfo(IImageSopProvider provider, NextSeriesNumberDelegate nextSeriesNumberDelegate = null)
			{
				_provider = provider;
				_nextSeriesNumberDelegate = nextSeriesNumberDelegate ?? new DefaultNextSeriesNumberGetter().GetNextSeriesNumber;
				_studyInstanceUid = provider.Sop.StudyInstanceUid;
				_originServer = ServerDirectory.GetRemoteServersByAETitle(provider.Sop[DicomTags.SourceApplicationEntityTitle].ToString()).FirstOrDefault();
				_sourceServer = provider.Sop.DataSource.Server;

				KeyObjectSeriesUid = DicomUid.GenerateUid().UID;
				KeyObjectSeriesDateTime = Platform.Time;
				PresentationSeriesUid = DicomUid.GenerateUid().UID;
				PresentationSeriesDateTime = Platform.Time;
			}
Пример #29
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="studyInstanceUid"></param>
        /// <param name="server"></param>
		public LoadStudyArgs(string studyInstanceUid, IDicomServiceNode server)
            : this(studyInstanceUid, server, null)
        {}
Пример #30
0
        private void OnReceiveMoveSeriesRequest(ClearCanvas.Dicom.Network.DicomServer server, byte presentationID, DicomMessage message, IDicomServiceNode remoteAEInfo)
		{
			string studyInstanceUid = message.DataSet[DicomTags.StudyInstanceUid].GetString(0, "");
			var seriesUids = (string[])message.DataSet[DicomTags.SeriesInstanceUid].Values;

            lock (_syncLock)
            {

                int subOperations = 0;
                using (var context = new DataAccessContext())
                {
                    var results = context.GetStudyStoreQuery().SeriesQuery(new SeriesIdentifier
                                                                               {
                                                                                   StudyInstanceUid =
                                                                                       studyInstanceUid,
                                                                               });
                    foreach (SeriesIdentifier series in results)
                    {
                        foreach (string seriesUid in seriesUids)
                            if (series.SeriesInstanceUid.Equals(seriesUid) &&
                                series.NumberOfSeriesRelatedInstances.HasValue)
                            {
                                subOperations += series.NumberOfSeriesRelatedInstances.Value;
                                break;
                            }
                    }

                    var s =
                        context.GetStudyStoreQuery().StudyQuery(new StudyRootStudyIdentifier
                                                                    {StudyInstanceUid = studyInstanceUid});
                    var identifier = CollectionUtils.FirstElement(s);
                    var client = new DicomSendBridge();

                    client.SendSeries(remoteAEInfo, identifier, seriesUids, WorkItemPriorityEnum.High);
                    _sendOperations.Add(new SendOperationInfo(client.WorkItem, message.MessageId, presentationID,
                                                              server)
                                            {
                                                SubOperations = subOperations
                                            });
                }
            }
		}
Пример #31
0
 public ImageViewerMoveScu(string localAETitle, IDicomServiceNode remoteAEInfo, IPatientRootData patient, IStudyIdentifier studyInformation, IEnumerable<string> seriesInstanceUids)
     : this(localAETitle, remoteAEInfo, patient, studyInformation)
 {
     _seriesInstanceUids = seriesInstanceUids;
 }
Пример #32
0
        public void PublishFiles(IDicomServiceNode remoteAEInfo, IStudyRootData study, DeletionBehaviour behaviour, List<string> files)
        {
            EventResult result = EventResult.Success;
            try
            {
                var request = new PublishFilesRequest
                                  {
                                      DestinationServerName = remoteAEInfo.Name,
                                      Priority = WorkItemPriorityEnum.High,
                                      DeletionBehaviour = behaviour,
                                      Study = new WorkItemStudy(study),
                                      Patient = new WorkItemPatient(study),
                                      FilePaths = files
                                  };
                InsertRequest(request, new DicomSendProgress());
            }
            catch (Exception ex)
            {
                result = EventResult.MajorFailure;
                Exception = ex;
                Platform.Log(LogLevel.Error, ex, Common.SR.MessageFailedToSendSops);
                throw;
            }
            finally
            {
                var instances = new AuditedInstances();
                instances.AddInstance(study.PatientId, study.PatientsName, study.StudyInstanceUid);

                AuditHelper.LogBeginSendInstances(remoteAEInfo.AETitle, remoteAEInfo.ScpParameters.HostName,
                                                  instances,
                                                  string.IsNullOrEmpty(Request.UserName)
                                                      ? EventSource.CurrentProcess
                                                      : EventSource.CurrentUser, result);
            }
        }
Пример #33
0
		/// <summary>
		/// Registers a number of <see cref="ISopDataSource"/>s with the <see cref="UnitTestStudyLoader"/>.
		/// </summary>
		/// <remarks>
		/// <para>Dispose the returned context to unregister the data sources.</para>
		/// <para>This method is thread safe.</para>
		/// </remarks>
		/// <param name="server">Specifies the "server" on which these data sources "reside."</param>
		/// <param name="sopDataSources">The <see cref="ISopDataSource"/>s to be registered.</param>
		/// <returns>A context object that should be disposed in order to unregister the data sources.</returns>
		public static UnitTestStudyProviderContext RegisterStudies(IDicomServiceNode server, IEnumerable<ISopDataSource> sopDataSources)
		{
			var unitTestStudyProvider = new UnitTestStudyProviderContext(server, sopDataSources);
			RegisterStudyProvider(unitTestStudyProvider);
			return unitTestStudyProvider;
		}
Пример #34
0
        public void RetrieveStudy(IDicomServiceNode remoteAEInfo, IStudyRootData study)
        {
            EventResult result = EventResult.Success;
            try
            {
                var request = new DicomRetrieveStudyRequest
                {
                    ServerName = remoteAEInfo.Name,
                    Study = new WorkItemStudy(study),
                    Patient = new WorkItemPatient(study)

                };

                // TODO (CR Jul 2012): The service itself has logic like this already, so this should probably be there, too.
                // Then, we could also get rid of this GetMatching... method.
                var data = GetMatchingActiveWorkItem(request);
                if (data != null)
                {
                    var existingRequest = data.Request as DicomRetrieveStudyRequest;
                    if (existingRequest != null && remoteAEInfo.Name == existingRequest.ServerName)
                    {
                        Request = data.Request;
                        return;
                    }
                }

                InsertRequest(request, new DicomRetrieveProgress());
            }
            catch (Exception ex)
            {
                result = EventResult.MajorFailure;
                Exception = ex;
                Platform.Log(LogLevel.Error, ex, Common.SR.MessageFailedToSendStudy);
                throw;
            }
            finally
            {
                var instances = new AuditedInstances();
                instances.AddInstance(study.PatientId, study.PatientsName, study.StudyInstanceUid);

                AuditHelper.LogBeginReceiveInstances(remoteAEInfo.AETitle, remoteAEInfo.ScpParameters.HostName,
                                                     instances, string.IsNullOrEmpty(Request.UserName)
                                                                    ? EventSource.CurrentProcess
                                                                    : EventSource.CurrentUser, result);
            }
        }
Пример #35
0
	    private void OnReceiveMoveStudiesRequest(ClearCanvas.Dicom.Network.DicomServer server, byte presentationID, DicomMessage message, IDicomServiceNode remoteAEInfo)
		{
			IEnumerable<string> studyUids = (string[])message.DataSet[DicomTags.StudyInstanceUid].Values;

            foreach (string studyUid in studyUids)
            {
                lock (_syncLock)
                {
                    int subOperations = 0;
                    using (var context = new DataAccessContext())
                    {
                        var s =
                            context.GetStudyStoreQuery().StudyQuery(new StudyRootStudyIdentifier
                                                                        {StudyInstanceUid = studyUid});
                        var identifier = CollectionUtils.FirstElement(s);
                        if (identifier.NumberOfStudyRelatedInstances.HasValue)
                            subOperations = identifier.NumberOfStudyRelatedInstances.Value;

                        var client = new DicomSendBridge();
                        client.SendStudy(remoteAEInfo, identifier, WorkItemPriorityEnum.High);
                        _sendOperations.Add(new SendOperationInfo(client.WorkItem, message.MessageId,
                                                                  presentationID,
                                                                  server)
                                                {
                                                    SubOperations = subOperations
                                                });
                    }
                }
            }
		}
Пример #36
0
		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="sourceAE">The AE title of the remote application sending the SOP Instances.</param>
		/// <param name="configuration">Storage configuration. </param>
		/// <param name="hostname">The IP Address the remote app is connecting with.</param>
		/// <param name="auditSource">The source of the request for auditing purposes </param>
		public DicomReceiveImportContext(string sourceAE, string hostname, StorageConfiguration configuration, EventSource auditSource) : base(sourceAE, configuration, auditSource)
		{
			_monitor = WorkItemActivityMonitor.Create(false);
			_monitor.WorkItemsChanged += WorkItemsChanged;

			var serverList = ServerDirectory.GetRemoteServersByAETitle(sourceAE);
			if (serverList.Count == 1)
				_dicomServerNode = CollectionUtils.FirstElement(serverList);

			_hostname = hostname;
		}
Пример #37
0
        private void OnReceiveMoveImageRequest(ClearCanvas.Dicom.Network.DicomServer server, byte presentationID, DicomMessage message, IDicomServiceNode remoteAEInfo)
		{
			string studyInstanceUid = message.DataSet[DicomTags.StudyInstanceUid].GetString(0, string.Empty);
			string seriesInstanceUid = message.DataSet[DicomTags.SeriesInstanceUid].GetString(0, string.Empty);
			var sopInstanceUids = (string[])message.DataSet[DicomTags.SopInstanceUid].Values;

            lock (_syncLock)
            {

                using (var context = new DataAccessContext())
                {
                    var s = context.GetStudyStoreQuery().StudyQuery(new StudyRootStudyIdentifier
                                                                    {StudyInstanceUid = studyInstanceUid});
                    var identifier = CollectionUtils.FirstElement(s);

                    var client = new DicomSendBridge();
                    client.SendSops(remoteAEInfo, identifier, seriesInstanceUid, sopInstanceUids, WorkItemPriorityEnum.High);
                    _sendOperations.Add(new SendOperationInfo(client.WorkItem, message.MessageId, presentationID, server)
                                            {
                                                SubOperations = sopInstanceUids.Length
                                            });
                }
            }
		}
Пример #38
0
		/// <summary>
		/// Adds a study to the list of studies to be opened.
		/// </summary>
		public void AddStudy(string studyInstanceUid, IDicomServiceNode server)
		{
            _studiesToOpen.Add(new LoadStudyArgs(studyInstanceUid, server, StudyLoaderOptions));
		}