protected override void OnStart(StartApplicationRequest request) { //NOOP IsRunning = true; }
public StartApplicationRequestResponse StartApplication(StartApplicationRequest request) { CheckNumberOfApplications(); CheckMemoryAvailable(); try { OperationContext operationContext = OperationContext.Current; // 5 minute timeout, mostly for debugging. operationContext.Channel.OperationTimeout = TimeSpan.FromMinutes(5); Application application = Application.Start(request); //TODO: when we start allowing application recovery, remove these lines. // NOTE: These events are fired only if the underlying connection is permanent (eg, duplex http or net tcp). // Commented out per CR 3/22/2011, don't want the contenxt to reference the application //operationContext.Channel.Closed += delegate { application.Stop(); }; //operationContext.Channel.Faulted += delegate { application.Stop(); }; return new StartApplicationRequestResponse { AppIdentifier = application.Identifier }; } catch (Enterprise.Common.InvalidUserSessionException ex) { throw new FaultException<SessionValidationFault>(new SessionValidationFault { ErrorMessage = ExceptionTranslator.Translate(ex) }); } catch (Enterprise.Common.PasswordExpiredException ex) { throw new FaultException<SessionValidationFault>(new SessionValidationFault { ErrorMessage = ExceptionTranslator.Translate(ex) }); } catch (Enterprise.Common.UserAccessDeniedException ex) { throw new FaultException<SessionValidationFault>(new SessionValidationFault { ErrorMessage = ExceptionTranslator.Translate(ex) }); } catch (Enterprise.Common.RequestValidationException ex) { throw new FaultException<SessionValidationFault>(new SessionValidationFault { ErrorMessage = ExceptionTranslator.Translate(ex) }); } catch (Exception ex) { throw new FaultException(ExceptionTranslator.Translate(ex)); } }
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); }