Beispiel #1
0
        /// <summary>
        /// Opens the given study.
        /// </summary>
        public Viewer OpenStudies(List <OpenStudyInfo> studiesToOpen)
        {
            var request = new OpenStudiesRequest
            {
                ActivateIfAlreadyOpen = _openStudiesBehaviour.ActivateExistingViewer,
                ReportFaultToUser     = _openStudiesBehaviour.ReportFaultToUser,
                StudiesToOpen         = studiesToOpen
            };

            return(_viewerAutomationClient.OpenStudies(request).Viewer);
        }
		/// <summary>
		/// Opens the given study.
		/// </summary>
		public Viewer OpenStudies(List<OpenStudyInfo> studiesToOpen)
		{
		    var request = new OpenStudiesRequest
		                      {
		                          ActivateIfAlreadyOpen = _openStudiesBehaviour.ActivateExistingViewer,
		                          ReportFaultToUser = _openStudiesBehaviour.ReportFaultToUser,
		                          StudiesToOpen = studiesToOpen
		                      };

		    return _viewerAutomationClient.OpenStudies(request).Viewer;
		}
Beispiel #3
0
		private static IImageViewer LaunchViewer(OpenStudiesRequest request, string primaryStudyInstanceUid)
		{
			try
			{
				CompleteOpenStudyInfo(request.StudiesToOpen);
			}
			catch (Exception ex)
			{
				if (request.ReportFaultToUser) SynchronizationContext.Current.Post(ReportLoadFailures, ex);
				throw;
			}
		    
            ImageViewerComponent viewer;
            if (!request.LoadPriors.HasValue || request.LoadPriors.Value)
                viewer = new ImageViewerComponent(LayoutManagerCreationParameters.Extended);
            else
                viewer = new ImageViewerComponent(LayoutManagerCreationParameters.Extended, PriorStudyFinder.Null);

			var loadStudyArgs = (from info in request.StudiesToOpen 
                                 let server = ServerDirectory.GetRemoteServersByAETitle(info.SourceAETitle).FirstOrDefault() ?? ServerDirectory.GetLocalServer()
                                 select new LoadStudyArgs(info.StudyInstanceUid, server)).ToList();

		    try
			{
				viewer.LoadStudies(loadStudyArgs);
			}
			catch (Exception e)
			{
				bool faultThrown = false;
				try
				{
					HandleLoadStudiesException(e, primaryStudyInstanceUid, viewer);
				}
				catch
				{
					faultThrown = true;
					viewer.Dispose();
					throw;
				}
				finally
				{
					if (!faultThrown || request.ReportFaultToUser)
						SynchronizationContext.Current.Post(ReportLoadFailures, e);
				}
			}

			ImageViewerComponent.Launch(viewer, new LaunchImageViewerArgs(ViewerLaunchSettings.WindowBehaviour));
			return viewer;
		}
Beispiel #4
0
	    public OpenStudiesResult OpenStudies(OpenStudiesRequest request)
		{
			if (request == null)
			{
				string message = "The open studies request cannot be null.";
				Platform.Log(LogLevel.Debug, message);
				throw new FaultException(message);
			}

			if (request.StudiesToOpen == null || request.StudiesToOpen.Count == 0)
			{
				string message = "At least one study must be specified.";
				Platform.Log(LogLevel.Debug, message);
				throw new FaultException(message);
			}

			OpenStudiesResult result = new OpenStudiesResult();
			bool activateIfOpen = request.ActivateIfAlreadyOpen ?? true;

			try
			{
				string primaryStudyInstanceUid = request.StudiesToOpen[0].StudyInstanceUid;
				IImageViewer viewer = null;
				if (activateIfOpen)
				{
					Workspace workspace = GetViewerWorkspace(primaryStudyInstanceUid);
					if (workspace != null)
					{
						viewer = ImageViewerComponent.GetAsImageViewer(workspace);
						workspace.Activate();
					}
				}
				
				if (viewer == null)
					viewer = LaunchViewer(request, primaryStudyInstanceUid);

				Guid? viewerId = ViewerAutomationTool.GetViewerId(viewer);
				if (viewerId == null)
					throw new FaultException("Failed to retrieve the id of the specified viewer.");

				result.Viewer = new Viewer(viewerId.Value, GetPrimaryStudyIdentifier(viewer));
				return result;
			}
			catch(FaultException)
			{
				throw;
			}
			catch(Exception e)
			{
				string message = "An unexpected error has occurred while attempting to open the study(s).";
				Platform.Log(LogLevel.Error, e, message);
				throw new FaultException(message);
			}
		}
		public OpenStudiesResult OpenStudies(OpenStudiesRequest request)
		{
			// Done for reasons of speed, as well as the fact that a call to the service from the same thread
			// that the service is hosted on (the main UI thread) will cause a deadlock.
			if (SynchronizationContext.Current == ViewerAutomationServiceHostTool.HostSynchronizationContext)
			{
				return new ViewerAutomation().OpenStudies(request);
			}
			else
			{
				using (ViewerAutomationServiceClient client = new ViewerAutomationServiceClient())
				{
					return client.OpenStudies(request);
				}
			} 
		}
			public Viewer OpenViewer(IList<StudyRootStudyIdentifier> studyRootStudyIdentifiers)
			{
				try
				{
					var request = new OpenStudiesRequest
					{
						ActivateIfAlreadyOpen = false,	// we want to control this manually
						ReportFaultToUser = true,
						StudiesToOpen = studyRootStudyIdentifiers.Select(i => new OpenStudyInfo(i)).ToList()
					};

					var result = _viewerAutomation.OpenStudies(request);
					return result.Viewer;
				}
				catch (FaultException<StudyNotFoundFault> e) { throw new OpenStudyException(studyRootStudyIdentifiers, e); }
				catch (FaultException<StudyOfflineFault> e) { throw new OpenStudyException(studyRootStudyIdentifiers, e); }
				catch (FaultException<StudyNearlineFault> e) { throw new OpenStudyException(studyRootStudyIdentifiers, e); }
				catch (FaultException<StudyInUseFault> e) { throw new OpenStudyException(studyRootStudyIdentifiers, e); }
				catch (FaultException<OpenStudiesFault> e) { throw new OpenStudyException(studyRootStudyIdentifiers, e); }
			}
 public OpenStudiesResult OpenStudies(OpenStudiesRequest request)
 {
     return(base.Channel.OpenStudies(request));
 }