/// <summary> /// Handle the situation where at least one of the study being loaded is in use. User can decide to continue loading or cancel the operation. /// In former case, all studies will be reloaded. Caller should check the value returned by this method. /// </summary> /// <param name="viewer"></param> /// <returns>False if the operation should be aborted. Caller is responsible for releasing any resource used by the <see cref="ImageViewerComponent"/>.</returns> private bool HandleStudyInUseError(ImageViewerComponent viewer) { var desktopWindow = DesktopWindow ?? Application.ActiveDesktopWindow; var action = PromptUser(); switch (action) { case StudyInUseUserDecision.Continue: try { SetStudyLoadOption(true); viewer.LoadStudies(_studiesToOpen); return(true); } catch (Exception e) { ExceptionHandler.Report(e, SR.MessageFailedToOpenStudy, desktopWindow); } return(false); case StudyInUseUserDecision.Cancel: return(false); default: throw new NotImplementedException("Implement this action based on user's decision"); } }
/// <summary> /// Handle the situation where at least one of the study being loaded is in use. User can decide to continue loading or cancel the operation. /// In former case, all studies will be reloaded. Caller should check the value returned by this method. /// </summary> /// <param name="viewer"></param> /// <returns>False if the operation should be aborted. Caller is responsible for releasing any resource used by the <see cref="ImageViewerComponent"/>.</returns> private bool HandleStudyInUseError(ImageViewerComponent viewer) { var desktopWindow = DesktopWindow ?? Application.ActiveDesktopWindow; var action = PromptUser(); switch (action) { case StudyInUseUserDecision.Continue: try { SetStudyLoadOption(true); viewer.LoadStudies(_studiesToOpen); return true; } catch (Exception e) { ExceptionHandler.Report(e, SR.MessageFailedToOpenStudy, desktopWindow); } return false; case StudyInUseUserDecision.Cancel: return false; default: throw new NotImplementedException("Implement this action based on user's decision"); } }
protected override void OnStart(StartApplicationRequest request) { lock (_syncLock) { Platform.Log(LogLevel.Info, "Viewer Application is starting..."); if (Application.Instance == null) { Platform.StartApp("ClearCanvas.Desktop.Application", new string[] { "-r" }); } } if (Platform.IsLogLevelEnabled(LogLevel.Debug)) { Platform.Log(LogLevel.Debug, "Finding studies..."); } var startRequest = (StartViewerApplicationRequest)request; IList <StudyRootStudyIdentifier> studies = FindStudies(startRequest); List <LoadStudyArgs> loadArgs = CollectionUtils.Map(studies, (StudyRootStudyIdentifier identifier) => CreateLoadStudyArgs(identifier)); DesktopWindowCreationArgs args = new DesktopWindowCreationArgs("", Identifier.ToString()); WebDesktopWindow window = new WebDesktopWindow(args, Application.Instance); window.Open(); _viewer = CreateViewerComponent(startRequest); try { if (Platform.IsLogLevelEnabled(LogLevel.Debug)) { Platform.Log(LogLevel.Debug, "Loading study..."); } _viewer.LoadStudies(loadArgs); } catch (Exception e) { if (!AnySopsLoaded(_viewer)) //end the app. { throw; } //Show an error and continue. ExceptionHandler.Report(e, window); } if (Platform.IsLogLevelEnabled(LogLevel.Debug)) { Platform.Log(LogLevel.Info, "Launching viewer..."); } ImageViewerComponent.Launch(_viewer, window, ""); _viewerHandler = EntityHandler.Create <ViewerEntityHandler>(); _viewerHandler.SetModelObject(_viewer); _app = new Common.ViewerApplication { Identifier = Identifier, Viewer = (Viewer)_viewerHandler.GetEntity(), VersionString = GetProductVersionString() }; // Push the ViewerApplication object to the client Event @event = new PropertyChangedEvent { PropertyName = "Application", Value = _app, Identifier = Guid.NewGuid(), SenderId = request.Identifier }; ApplicationContext.Current.FireEvent(@event); }
protected override void OnStart(StartApplicationRequest request) { lock (_syncLock) { Platform.Log(LogLevel.Info, "Viewer Application is starting..."); if (Application.Instance == null) Platform.StartApp("ClearCanvas.Desktop.Application",new string[] {"-r"}); } if (Platform.IsLogLevelEnabled(LogLevel.Debug)) Platform.Log(LogLevel.Debug, "Finding studies..."); var startRequest = (StartViewerApplicationRequest)request; IList<StudyRootStudyIdentifier> studies = FindStudies(startRequest); List<LoadStudyArgs> loadArgs = CollectionUtils.Map(studies, (StudyRootStudyIdentifier identifier) => CreateLoadStudyArgs(identifier)); DesktopWindowCreationArgs args = new DesktopWindowCreationArgs("", Identifier.ToString()); WebDesktopWindow window = new WebDesktopWindow(args, Application.Instance); window.Open(); _viewer = CreateViewerComponent(startRequest); try { if (Platform.IsLogLevelEnabled(LogLevel.Debug)) Platform.Log(LogLevel.Debug, "Loading study..."); _viewer.LoadStudies(loadArgs); } catch (Exception e) { if (!AnySopsLoaded(_viewer)) //end the app. throw; //Show an error and continue. ExceptionHandler.Report(e, window); } if (Platform.IsLogLevelEnabled(LogLevel.Debug)) Platform.Log(LogLevel.Info, "Launching viewer..."); ImageViewerComponent.Launch(_viewer, window, ""); _viewerHandler = EntityHandler.Create<ViewerEntityHandler>(); _viewerHandler.SetModelObject(_viewer); _app = new Common.ViewerApplication { Identifier = Identifier, Viewer = (Viewer) _viewerHandler.GetEntity(), VersionString = GetProductVersionString() }; // Push the ViewerApplication object to the client Event @event = new PropertyChangedEvent { PropertyName = "Application", Value = _app, Identifier = Guid.NewGuid(), SenderId = request.Identifier }; ApplicationContext.Current.FireEvent(@event); }