Пример #1
0
        protected override int OnStart(StudyLoaderArgs studyLoaderArgs)
        {
            var serverAe = studyLoaderArgs.Server;
            Platform.CheckForNullReference(serverAe, "Server");
            Platform.CheckMemberIsSet(serverAe.StreamingParameters, "StreamingParameters");
            _serverAe = serverAe;

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

                StudyXml studyXml = RetrieveStudyXml(studyLoaderArgs);
                _instances = GetInstances(studyXml).GetEnumerator();

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

                return studyXml.NumberOfStudyRelatedInstances;

            }
            finally
            {
                AuditHelper.LogOpenStudies(new string[] { _serverAe.AETitle }, loadedInstances, EventSource.CurrentUser, result);
            }
        }
Пример #2
0
        protected override int OnStart(StudyLoaderArgs studyLoaderArgs)
        {
            _sops = null;

            EventResult result = EventResult.Success;
            var loadedInstances = new AuditedInstances();
            try
            {
                using (var context = new DataAccessContext())
                {
                    IStudy study = context.GetStudyBroker().GetStudy(studyLoaderArgs.StudyInstanceUid);
                    if (study == null)
                    {
                        result = EventResult.MajorFailure;
                        loadedInstances.AddInstance(studyLoaderArgs.StudyInstanceUid);
                        throw new NotFoundLoadStudyException(studyLoaderArgs.StudyInstanceUid);
                    }
                    loadedInstances.AddInstance(study.PatientId, study.PatientsName, study.StudyInstanceUid);

                    _sops = study.GetSopInstances().GetEnumerator();
                    return study.NumberOfStudyRelatedInstances;
                }
            }
            finally
            {
                AuditHelper.LogOpenStudies(new[] { AuditHelper.LocalAETitle }, loadedInstances, EventSource.CurrentUser, result);
            }
        }
        protected override int OnStart(StudyLoaderArgs studyLoaderArgs)
        {
            _sops = null;

            EventResult result = EventResult.Success;
            var loadedInstances = new AuditedInstances();
            try
            {
                using (var context = new DataAccessContext())
                {
                    if (!studyLoaderArgs.Options.IgnoreInUse)
                    {
                        var workItemStatusFilter = WorkItemStatusFilter.StatusIn(
                            WorkItemStatusEnum.Pending,
                            WorkItemStatusEnum.InProgress,
                            WorkItemStatusEnum.Idle,
                            WorkItemStatusEnum.Failed);

                        var updateItems = context.GetWorkItemBroker().GetWorkItems(
                            WorkItemConcurrency.StudyUpdate,
                            workItemStatusFilter,
                            studyLoaderArgs.StudyInstanceUid);

                        var deleteItems = context.GetWorkItemBroker().GetWorkItems(
                            WorkItemConcurrency.StudyDelete,
                            workItemStatusFilter,
                            studyLoaderArgs.StudyInstanceUid);

                        var updateTriggerItems = context.GetWorkItemBroker().GetWorkItems(
                            WorkItemConcurrency.StudyUpdateTrigger,
                            workItemStatusFilter,
                            studyLoaderArgs.StudyInstanceUid);

                        if (updateItems.Any() || deleteItems.Any() || updateTriggerItems.Any())
                        {
                            var message = string.Format("There are work items actively modifying the study with UID '{0}'.", studyLoaderArgs.StudyInstanceUid);
                            throw new InUseLoadStudyException(studyLoaderArgs.StudyInstanceUid, message);
                        }
                    }

                    IStudy study = context.GetStudyBroker().GetStudy(studyLoaderArgs.StudyInstanceUid);
                    if (study == null)
                    {
                        result = EventResult.MajorFailure;
                        loadedInstances.AddInstance(studyLoaderArgs.StudyInstanceUid);
                        throw new NotFoundLoadStudyException(studyLoaderArgs.StudyInstanceUid);
                    }
                    loadedInstances.AddInstance(study.PatientId, study.PatientsName, study.StudyInstanceUid);

                    _sops = study.GetSopInstances().GetEnumerator();
                    return study.NumberOfStudyRelatedInstances;
                }
            }
            finally
            {
                AuditHelper.LogOpenStudies(new[] { AuditHelper.LocalAETitle }, loadedInstances, EventSource.CurrentUser, result);
            }
        }
Пример #4
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);
			}
		}
Пример #5
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);
            }
        }
Пример #6
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);
            }
        }
Пример #7
0
			private List<Sop> LoadSops()
			{
			    IStudyLoader studyLoader;
			    try
			    {
                    studyLoader = Server.GetService<IStudyLoader>();
                    _studyLoaderName = studyLoader.Name;
                }
			    catch (Exception e)
			    {
                    //For legacy reasons, so code expecting one of these exceptions will still get one.
                    throw new StudyLoaderNotFoundException(e);
			    }

                var args = new StudyLoaderArgs(StudyInstanceUid, Server, _args != null ? _args.StudyLoaderCheckOptions : StudyLoaderCheckOptions.Default);
				int total;
				var sops = new List<Sop>();
				
				try
				{
					if (LoadOnlineOnly && StudyItem != null)
					{
					    // TODO (CR Apr 2012): try to get rid of this.
						//This stinks, but we pre-emptively throw the offline/nearline exception
						//to avoid trying to load a prior when we know it's not online.
						switch (StudyItem.InstanceAvailability)
						{
							case "OFFLINE":
								throw new OfflineLoadStudyException(StudyInstanceUid);
							case "NEARLINE":
								throw new NearlineLoadStudyException(StudyInstanceUid);
							default:
								break;
						}
					}

                    total = studyLoader.Start(args);
					if (total <= 0)
						throw new NotFoundLoadStudyException(args.StudyInstanceUid);
				}
				catch (LoadStudyException)
				{
					throw;
				}
				catch (Exception e)
				{
					throw new LoadStudyException(args.StudyInstanceUid, e);
				}

				try
				{
					while (true)
					{
                        Sop sop = studyLoader.LoadNextSop();
						if (sop == null)
							break;

						sops.Add(sop);
					}

					if (sops.Count == 0)
						throw new LoadStudyException(args.StudyInstanceUid, total, total);

					return sops;
				}
				catch (Exception e)
				{
					DisposeSops(sops);
					throw new LoadStudyException(args.StudyInstanceUid, total, total, e);
				}
			}
Пример #8
0
 /// <summary>
 /// Called by <see cref="Start"/> to begin prefetching.
 /// </summary>
 protected abstract int OnStart(StudyLoaderArgs studyLoaderArgs);
Пример #9
0
	    /// <summary>
		/// Called by <see cref="Start"/> to begin prefetching.
		/// </summary>
		protected abstract int OnStart(StudyLoaderArgs studyLoaderArgs);
Пример #10
0
        private StudyXml RetrieveStudyXml(StudyLoaderArgs studyLoaderArgs)
        {
            var headerParams = new HeaderStreamingParameters
                                   {
                                       StudyInstanceUID = studyLoaderArgs.StudyInstanceUid,
                                       ServerAETitle = _serverAe.AETitle,
                                       ReferenceID = Guid.NewGuid().ToString()
                                   };

            HeaderStreamingServiceClient client = null;
            try
            {

                string uri = String.Format(StreamingSettings.Default.FormatHeaderServiceUri,
                                            _serverAe.ScpParameters.HostName, _serverAe.StreamingParameters.HeaderServicePort);

                client = new HeaderStreamingServiceClient(new Uri(uri));
                client.Open();
                var studyXml = client.GetStudyXml(ServerDirectory.GetLocalServer().AETitle, headerParams);
                client.Close();
                return studyXml;
            }
            catch (FaultException<StudyIsInUseFault> e)
            {
                throw new InUseLoadStudyException(studyLoaderArgs.StudyInstanceUid, e);
            }
            catch (FaultException<StudyIsNearlineFault> e)
            {
				throw new NearlineLoadStudyException(studyLoaderArgs.StudyInstanceUid, e)
					{ IsStudyBeingRestored = e.Detail.IsStudyBeingRestored };
            }
            catch (FaultException<StudyNotFoundFault> e)
            {
                throw new NotFoundLoadStudyException(studyLoaderArgs.StudyInstanceUid, e);
            }
            catch (FaultException e)
            {
                //TODO: Some versions (pre-Team) of the ImageServer
				//throw a generic fault when a study is nearline, instead of the more specialized one.
                string message = e.Message.ToLower();
                if (message.Contains("nearline"))
					throw new NearlineLoadStudyException(studyLoaderArgs.StudyInstanceUid, e)
						{ IsStudyBeingRestored = true }; //assume true in legacy case.

                throw new LoadStudyException(studyLoaderArgs.StudyInstanceUid, e);
            }
            catch (Exception e)
            {
                if (client != null)
                    client.Abort();

                throw new LoadStudyException(studyLoaderArgs.StudyInstanceUid, e);
            }
        }