Example #1
0
        private void OnActivateViewer(object sender, EventArgs e)
        {
            StudyItem study = GetSelectedStudy();

            if (study == null)
            {
                MessageBox.Show("Select a single study item in the list.");
                return;
            }

            Guid?viewerId = GetSelectedViewer();

            if (viewerId == null)
            {
                MessageBox.Show("An active viewer must be selected.");
                return;
            }

            using (AutomationClient client = new AutomationClient())
            {
                try
                {
                    ActivateViewerRequest request = new ActivateViewerRequest();
                    request.Viewer            = new Viewer();
                    request.Viewer.Identifier = GetIdentifier(viewerId.Value);
                    client.ActivateViewer(request);
                }
                catch (Exception ex)
                {
                    study.RemoveViewer(viewerId.Value);
                    MessageBox.Show(ex.Message);
                }
            }
        }
Example #2
0
        public void ActivateViewer(ActivateViewerRequest request)
        {
            if (request == null)
            {
                string message = "The activate viewer request cannot be null.";
                Platform.Log(LogLevel.Debug, message);
                throw new FaultException(message);
            }

            if (request.Viewer == null || request.Viewer.Identifier.Equals(Guid.Empty))
            {
                string message = "A valid viewer id must be specified.";
                Platform.Log(LogLevel.Debug, message);
                throw new FaultException(message);
            }

            IImageViewer viewer = ViewerAutomationTool.GetViewer(request.Viewer.Identifier);

            if (viewer == null)
            {
                string message = String.Format("The specified viewer ({0}) was not found, " +
                                               "likely because it has already been closed by the user.", request.Viewer.Identifier);
                Platform.Log(LogLevel.Debug, message);

                throw new FaultException <ViewerNotFoundFault>(new ViewerNotFoundFault(message), _viewerNotFoundReason);
            }

            IWorkspace workspace = GetViewerWorkspace(viewer);

            if (workspace == null)
            {
                string message = String.Format("The specified viewer ({0}) was found, " +
                                               "but does not appear to be hosted in one of the active workspaces.", request.Viewer.Identifier);
                Platform.Log(LogLevel.Error, message);

                throw new FaultException <ViewerNotFoundFault>(new ViewerNotFoundFault(message), _viewerNotFoundReason);
            }

            try
            {
                workspace.Activate();
            }
            catch (Exception e)
            {
                string message = String.Format("An unexpected error has occurred while attempting " +
                                               "to activate the specified viewer ({0}).", request.Viewer.Identifier);
                Platform.Log(LogLevel.Error, e, message);
                throw new FaultException(message);
            }
        }
Example #3
0
 public void ActivateViewer(ActivateViewerRequest 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)
     {
         new ViewerAutomation().ActivateViewer(request);
     }
     else
     {
         using (ViewerAutomationServiceClient client = new ViewerAutomationServiceClient())
         {
             client.ActivateViewer(request);
         }
     }
 }
Example #4
0
 public void ActivateViewer(ActivateViewerRequest request)
 {
     Execute(a => a.ActivateViewer(request));
 }