private static void ManageActivityMonitorConnection() { if (KeyImageInformation.Count == 0 && _activityMonitor != null) { try { _activityMonitor.IsConnectedChanged -= DummyEventHandler; _activityMonitor.Dispose(); } catch (Exception e) { Platform.Log(LogLevel.Warn, e, "Failed to unsubscribe from activity monitor events."); } finally { _activityMonitor = null; } } else if (KeyImageInformation.Count > 0 && _activityMonitor == null && WorkItemActivityMonitor.IsSupported) { try { _activityMonitor = WorkItemActivityMonitor.Create(); //we subscribe to something to keep the connection open. _activityMonitor.IsConnectedChanged += DummyEventHandler; } catch (Exception e) { _activityMonitor = null; Platform.Log(LogLevel.Warn, e, "Failed to subscribe to activity monitor events."); } } }
public override void Initialize() { base.Initialize(); KeyImageClipboard.OnViewerOpened(base.Context.Viewer); UpdateEnabled(); if (WorkItemActivityMonitor.IsSupported) { _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; } if (!KeyImageClipboard.HasViewPlugin) { foreach (var a in Actions) { // TODO (CR Phoenix5 - High): use the ID, which doesn't change; this will change with language. if (a.Path.LocalizedPath == "global-toolbars/ToolbarStandard/Show Key Images") { var buttonAction = a as ButtonAction; if (buttonAction != null) { buttonAction.Visible = false; } } } } }
public MoveScpExtension() : base(GetSupportedSops()) { _sendOperations = new List <SendOperationInfo>(); // TODO (CR Jun 2012 - Med): This item is disposable and should ideally be cleaned up. _activityMonitor = WorkItemActivityMonitor.Create(false); _activityMonitor.WorkItemsChanged += UpdateProgress; }
public MoveScpExtension() : base(GetSupportedSops()) { _sendOperations = new List<SendOperationInfo>(); // TODO (CR Jun 2012 - Med): This item is disposable and should ideally be cleaned up. _activityMonitor = WorkItemActivityMonitor.Create(false); _activityMonitor.WorkItemsChanged += UpdateProgress; }
public override void Initialize() { base.Initialize(); this.Context.SelectionChanged += OnSelectedStudyChanged; _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; }
public override void Initialize() { base.Initialize(); _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.IsConnectedChanged += OnConnectionChanged; this.Enabled = _workItemActivityMonitor.IsConnected; }
public override void Initialize() { base.Initialize(); KeyImageClipboard.OnViewerOpened(base.Context.Viewer); UpdateEnabled(); _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; }
protected override void Dispose(bool disposing) { if (disposing) { _workItemActivityMonitor.IsConnectedChanged -= OnConnectionChanged; _workItemActivityMonitor.Dispose(); _workItemActivityMonitor = null; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { this.Context.SelectionChanged -= OnSelectedStudyChanged; _workItemActivityMonitor.IsConnectedChanged -= OnIsConnectedChanged; _workItemActivityMonitor.Dispose(); _workItemActivityMonitor = null; } base.Dispose(disposing); }
/// <summary> /// Constructor. /// </summary> /// <param name="sourceAE">The AE title of the remote application sending the SOP Instances.</param> /// <param name="configuration">Storage configuration. </param> /// <param name="hostname">The IP Address the remote app is connecting with.</param> /// <param name="auditSource">The source of the request for auditing purposes </param> public DicomReceiveImportContext(string sourceAE, string hostname, StorageConfiguration configuration, EventSource auditSource) : base(sourceAE, configuration, auditSource) { // TODO (CR Jun 2012 - Med): This object is disposable and should be cleaned up. _monitor = WorkItemActivityMonitor.Create(false); _monitor.WorkItemsChanged += WorkItemsChanged; var serverList = ServerDirectory.GetRemoteServersByAETitle(sourceAE); if (serverList.Count == 1) _dicomServerNode = CollectionUtils.FirstElement(serverList); _hostname = hostname; }
/// <summary> /// Called by the framework to initialize this tool. /// </summary> public override void Initialize() { base.Initialize(); ImageViewer.EventBroker.DisplaySetChanged += OnDisplaySetChanged; ImageViewer.EventBroker.LayoutCompleted += OnLayoutComplete; if (WorkItemActivityMonitor.IsSupported) { _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.WorkItemsChanged += OnWorkItemsChanged; } }
/// <summary> /// Constructor. /// </summary> /// <param name="sourceAE">The AE title of the remote application sending the SOP Instances.</param> /// <param name="configuration">Storage configuration. </param> /// <param name="hostname">The IP Address the remote app is connecting with.</param> /// <param name="auditSource">The source of the request for auditing purposes </param> public DicomReceiveImportContext(string sourceAE, string hostname, StorageConfiguration configuration, EventSource auditSource) : base(sourceAE, configuration, auditSource) { _monitor = WorkItemActivityMonitor.Create(false); _monitor.WorkItemsChanged += WorkItemsChanged; var serverList = ServerDirectory.GetRemoteServersByAETitle(sourceAE); if (serverList.Count == 1) { _dicomServerNode = CollectionUtils.FirstElement(serverList); } _hostname = hostname; }
private void TestActivityMonitorSubscriptions(IWorkItemActivityMonitor monitor, IWorkItemActivityCallback callback) { ResetCallbackFields(); var item = new WorkItemData { Type = DicomRetrieveRequest.WorkItemTypeString }; var items = new List <WorkItemData> { item }; var eventType = WorkItemsChangedEventType.Update; SubscribeAndPause(monitor, WorkItemChanged1); WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 1); Assert.AreEqual(1, WorkItemChanged1Count); Assert.AreEqual(0, WorkItemChanged2Count); Assert.AreEqual(0, WorkItemChanged3Count); SubscribeAndPause(monitor, WorkItemChanged2); WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 2); Assert.AreEqual(2, WorkItemChanged1Count); Assert.AreEqual(1, WorkItemChanged2Count); Assert.AreEqual(0, WorkItemChanged3Count); item.Type = DicomSendRequest.WorkItemTypeString; callback.WorkItemsChanged(eventType, items); Thread.Sleep(100); Assert.AreEqual(3, WorkItemChanged1Count); Assert.AreEqual(2, WorkItemChanged2Count); Assert.AreEqual(0, WorkItemChanged3Count); UnsubscribeAndPause(monitor, WorkItemChanged1); callback.WorkItemsChanged(eventType, items); Thread.Sleep(100); Assert.AreEqual(3, WorkItemChanged1Count); Assert.AreEqual(3, WorkItemChanged2Count); Assert.AreEqual(0, WorkItemChanged3Count); SubscribeAndPause(monitor, WorkItemChanged1); UnsubscribeAndPause(monitor, WorkItemChanged2); SubscribeAndPause(monitor, WorkItemChanged3); WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 2); Assert.AreEqual(4, WorkItemChanged1Count); Assert.AreEqual(3, WorkItemChanged2Count); Assert.AreEqual(1, WorkItemChanged3Count); //TODO (Marmot): Expand to include multiple filters, etc. }
protected override void Dispose(bool disposing) { if (_workItemActivityMonitor != null) { _workItemActivityMonitor.IsConnectedChanged -= OnIsConnectedChanged; _workItemActivityMonitor.Dispose(); _workItemActivityMonitor = null; } if (Context != null) { KeyImageClipboard.OnViewerClosed(Context.Viewer); } base.Dispose(disposing); }
public override void Start() { _delaySetFileStoreDirectory = new DelayedEventPublisher(RealSetFileStoreDirectory); _activityMonitor = WorkItemActivityMonitor.Create(); _activityMonitor.IsConnectedChanged += ActivityMonitorOnIsConnectedChanged; _configuration = StudyStore.GetConfiguration(); _fileStoreDirectory = _currentFileStoreDirectory = _configuration.FileStoreDirectory; UpdateFileStoreDriveName(); MaximumUsedSpaceChanged(); _currentDeletionRule = _configuration.DefaultDeletionRule.Clone(); base.Start(); }
public override void Initialize() { base.Initialize(); _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.IsConnectedChanged += IsConnectedChanged; _workItemActivityMonitor.WorkItemsChanged += WorkItemsChanged; Enabled = _workItemActivityMonitor.IsConnected; _asyncOperation = AsyncOperationManager.CreateOperation(null); if (XnatSettings.Default.DownloadCheckInterval > 0) { StartDownloadCheckingThread(); } }
private void Connect() { if (_workItemActivityMonitor != null) { return; } Platform.Log(LogLevel.Debug, "Attempting to connect to ActivityMonitorService."); _workItemActivityMonitor = WorkItemActivityMonitor.Create(false); _workItemActivityMonitor.WorkItemsChanged += OnWorkItemsChanged; _workItemActivityMonitor.StudiesCleared += OnStudiesCleared; _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; _updatedIdleStudies = new HashSet <long>(); FireIsConnectedChanged(); }
private void StartMonitoringStudies() { if (_activityMonitor != null) { return; } _synchronizationContext = SynchronizationContext.Current; //Don't use the sync context when monitoring work item activity, since we'll be processing //the changed studies asynchronously anyway. _activityMonitor = WorkItemActivityMonitor.Create(false); _activityMonitor.IsConnectedChanged += OnIsConnectedChangedAsync; _activityMonitor.WorkItemsChanged += OnWorkItemsChangedAsync; _activityMonitor.StudiesCleared += OnStudiesClearedAsync; UpdateReindexing(); _processChangedStudiesTimer = new System.Threading.Timer(ProcessChangedStudiesAsync, null, 100, 100); }
/// <summary> /// Called when the tool is disposed. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { // TODO - Auto-save new annotations here? ImageViewer.EventBroker.DisplaySetChanged -= OnDisplaySetChanged; ImageViewer.EventBroker.LayoutCompleted -= OnLayoutComplete; if (_workItemActivityMonitor != null) { _workItemActivityMonitor.WorkItemsChanged -= OnWorkItemsChanged; _workItemActivityMonitor.Dispose(); _workItemActivityMonitor = null; } } base.Dispose(disposing); }
private void StopMonitoringStudies() { _synchronizationContext = null; if (_activityMonitor != null) { _activityMonitor.IsConnectedChanged -= OnIsConnectedChangedAsync; _activityMonitor.WorkItemsChanged -= OnWorkItemsChangedAsync; _activityMonitor.StudiesCleared -= OnStudiesClearedAsync; _activityMonitor.Dispose(); _activityMonitor = null; } if (_processChangedStudiesTimer != null) { _processChangedStudiesTimer.Dispose(); _processChangedStudiesTimer = null; } UpdateReindexing(); }
protected override void Dispose(bool disposing) { if (disposing) { _workItemActivityMonitor.IsConnectedChanged -= IsConnectedChanged; _workItemActivityMonitor.WorkItemsChanged -= WorkItemsChanged; _workItemActivityMonitor.Dispose(); _workItemActivityMonitor = null; ImportStatus = ImportStatus.Standby; _checkingForDownloads = false; // Attempt to clean up temp files foreach (var studyUidFolder in _studyUidsTempFolders) { Directory.Delete(_studyUidsTempFolders[studyUidFolder.Key], true); } } base.Dispose(disposing); }
public override void Initialize() { base.Initialize(); KeyImageClipboard.OnViewerOpened(Context.Viewer); UpdateEnabled(); if (WorkItemActivityMonitor.IsSupported) { _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; } if (!KeyImageClipboardComponent.HasViewPlugin) { foreach (var buttonAction in Actions.Where(a => a.ActionID == "show").OfType <ClickAction>()) { buttonAction.Visible = false; } } }
public void RunApplication(string[] args) { Console.WriteLine("Starting WorkItemActivityMonitor test application ..."); _workItemActivityMonitor = WorkItemActivityMonitor.Create(false); _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; _workItemActivityMonitor.WorkItemsChanged += OnWorkItemsChanged; Console.WriteLine("Press <Enter> to terminate."); Console.WriteLine(); Console.WriteLine(); string message = String.Format("IsConnected={0}", _workItemActivityMonitor.IsConnected); Console.WriteLine(message); Console.ReadLine(); _workItemActivityMonitor.IsConnectedChanged -= OnIsConnectedChanged; _workItemActivityMonitor.WorkItemsChanged -= OnWorkItemsChanged; _workItemActivityMonitor.Dispose(); }
private void DropConnection() { if (_workItemActivityMonitor == null) { return; } Platform.Log(LogLevel.Debug, "Attempting to disconnect from ActivityMonitorService."); _workItemActivityMonitor.WorkItemsChanged -= OnWorkItemsChanged; _workItemActivityMonitor.StudiesCleared -= OnStudiesCleared; _workItemActivityMonitor.IsConnectedChanged -= OnIsConnectedChanged; _workItemActivityMonitor.Dispose(); _workItemActivityMonitor = null; _updatedIdleStudies.Clear(); _updatedIdleStudies = null; AimCache.Instance.ClearCache(); FireIsConnectedChanged(); }
private void TestActivityMonitorConnection(IWorkItemActivityMonitor monitor) { ResetCallbackFields(); Assert.AreEqual(CommunicationState.Opened, TestServiceProvider.ServiceInstance.State); Assert.IsTrue(monitor.IsConnected); monitor.IsConnectedChanged += OnIsConnectedChanged; WaitForEvent(() => TestServiceProvider.ServiceInstance.Close()); Assert.AreEqual(1, IsConnectedChangedCount); Assert.IsFalse(monitor.IsConnected); WaitForEvent(() => TestServiceProvider.ServiceInstance.Open()); Assert.AreEqual(2, IsConnectedChangedCount); Assert.IsTrue(monitor.IsConnected); monitor.IsConnectedChanged -= OnIsConnectedChanged; TestServiceProvider.ServiceInstance.Close(); Thread.Sleep(1000); //should be more than enough time; we unsubscribed from the event, so there's nothing to wait for. Assert.AreEqual(2, IsConnectedChangedCount); Assert.IsFalse(monitor.IsConnected); }
public override void Initialize() { base.Initialize(); KeyImageClipboard.OnViewerOpened(base.Context.Viewer); UpdateEnabled(); if (WorkItemActivityMonitor.IsSupported) { _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; } if (!KeyImageClipboard.HasViewPlugin) { foreach (var a in Actions) { // TODO (CR Phoenix5 - High): use the ID, which doesn't change; this will change with language. if (a.Path.LocalizedPath == "global-toolbars/ToolbarStandard/Show Key Images") { var buttonAction = a as ButtonAction; if (buttonAction != null) buttonAction.Visible = false; } } } }
private void UnsubscribeAndPause(IWorkItemActivityMonitor monitor, EventHandler <WorkItemsChangedEventArgs> eventHandler) { monitor.WorkItemsChanged -= eventHandler; //It may take a sec for the monitor to unsubscribe via the actual service. Thread.Sleep(100); }
private void DropConnection() { if (_workItemActivityMonitor == null) return; Platform.Log(LogLevel.Debug, "Attempting to disconnect from ActivityMonitorService."); _workItemActivityMonitor.WorkItemsChanged -= OnWorkItemsChanged; _workItemActivityMonitor.StudiesCleared -= OnStudiesCleared; _workItemActivityMonitor.IsConnectedChanged -= OnIsConnectedChanged; _workItemActivityMonitor.Dispose(); _workItemActivityMonitor = null; _updatedIdleStudies.Clear(); _updatedIdleStudies = null; AimCache.Instance.ClearCache(); FireIsConnectedChanged(); }
private void TestActivityMonitorSubscriptions(IWorkItemActivityMonitor monitor, IWorkItemActivityCallback callback) { ResetCallbackFields(); var item = new WorkItemData { Type = DicomRetrieveRequest.WorkItemTypeString }; var items = new List<WorkItemData> { item }; var eventType = WorkItemsChangedEventType.Update; SubscribeAndPause(monitor, WorkItemChanged1); WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 1); Assert.AreEqual(1, WorkItemChanged1Count); Assert.AreEqual(0, WorkItemChanged2Count); Assert.AreEqual(0, WorkItemChanged3Count); SubscribeAndPause(monitor, WorkItemChanged2); WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 2); Assert.AreEqual(2, WorkItemChanged1Count); Assert.AreEqual(1, WorkItemChanged2Count); Assert.AreEqual(0, WorkItemChanged3Count); item.Type = DicomSendRequest.WorkItemTypeString; callback.WorkItemsChanged(eventType, items); Thread.Sleep(100); Assert.AreEqual(3, WorkItemChanged1Count); Assert.AreEqual(2, WorkItemChanged2Count); Assert.AreEqual(0, WorkItemChanged3Count); UnsubscribeAndPause(monitor, WorkItemChanged1); callback.WorkItemsChanged(eventType, items); Thread.Sleep(100); Assert.AreEqual(3, WorkItemChanged1Count); Assert.AreEqual(3, WorkItemChanged2Count); Assert.AreEqual(0, WorkItemChanged3Count); SubscribeAndPause(monitor, WorkItemChanged1); UnsubscribeAndPause(monitor, WorkItemChanged2); SubscribeAndPause(monitor, WorkItemChanged3); WaitForEvents(() => callback.WorkItemsChanged(eventType, items), 2); Assert.AreEqual(4, WorkItemChanged1Count); Assert.AreEqual(3, WorkItemChanged2Count); Assert.AreEqual(1, WorkItemChanged3Count); //TODO (Marmot): Expand to include multiple filters, etc. }
internal WorkItemActivityMonitorProxy(IWorkItemActivityMonitor real, SynchronizationContext synchronizationContext) { _real = real; _synchronizationContext = synchronizationContext; }
private void StartMonitoringStudies() { if (_activityMonitor != null) return; _synchronizationContext = SynchronizationContext.Current; //Don't use the sync context when monitoring work item activity, since we'll be processing //the changed studies asynchronously anyway. _activityMonitor = WorkItemActivityMonitor.Create(false); _activityMonitor.IsConnectedChanged += OnIsConnectedChangedAsync; _activityMonitor.WorkItemsChanged += OnWorkItemsChangedAsync; _activityMonitor.StudiesCleared += OnStudiesClearedAsync; UpdateReindexing(); _processChangedStudiesTimer = new System.Threading.Timer(ProcessChangedStudiesAsync, null, 100, 100); }
public override void Initialize() { base.Initialize(); KeyImageClipboard.OnViewerOpened(Context.Viewer); UpdateEnabled(); if (WorkItemActivityMonitor.IsSupported) { _workItemActivityMonitor = WorkItemActivityMonitor.Create(); _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; } if (!KeyImageClipboardComponent.HasViewPlugin) { foreach (var buttonAction in Actions.Where(a => a.ActionID == "show").OfType<ClickAction>()) buttonAction.Visible = false; } }
private static void ManageActivityMonitorConnection() { if (_keyImageInformation.Count == 0 && _activityMonitor != null) { try { _activityMonitor.IsConnectedChanged -= DummyEventHandler; _activityMonitor.Dispose(); } catch (Exception e) { Platform.Log(LogLevel.Warn, e, "Failed to unsubscribe from activity monitor events."); } finally { _activityMonitor = null; } } else if (_keyImageInformation.Count > 0 && _activityMonitor == null && WorkItemActivityMonitor.IsSupported) { try { _activityMonitor = WorkItemActivityMonitor.Create(); //we subscribe to something to keep the connection open. _activityMonitor.IsConnectedChanged += DummyEventHandler; } catch (Exception e) { _activityMonitor = null; Platform.Log(LogLevel.Warn, e, "Failed to subscribe to activity monitor events."); } } }
private void UnsubscribeAndPause(IWorkItemActivityMonitor monitor, EventHandler<WorkItemsChangedEventArgs> eventHandler) { monitor.WorkItemsChanged -= eventHandler; //It may take a sec for the monitor to unsubscribe via the actual service. Thread.Sleep(100); }
private void Connect() { if (_workItemActivityMonitor != null) return; Platform.Log(LogLevel.Debug, "Attempting to connect to ActivityMonitorService."); _workItemActivityMonitor = WorkItemActivityMonitor.Create(false); _workItemActivityMonitor.WorkItemsChanged += OnWorkItemsChanged; _workItemActivityMonitor.StudiesCleared += OnStudiesCleared; _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged; _updatedIdleStudies = new HashSet<long>(); FireIsConnectedChanged(); }
/// <summary> /// Constructor. /// </summary> /// <param name="sourceAE">The AE title of the remote application sending the SOP Instances.</param> /// <param name="configuration">Storage configuration. </param> /// <param name="hostname">The IP Address the remote app is connecting with.</param> /// <param name="auditSource">The source of the request for auditing purposes </param> public DicomReceiveImportContext(string sourceAE, string hostname, StorageConfiguration configuration, EventSource auditSource) : base(sourceAE, configuration, auditSource) { _monitor = WorkItemActivityMonitor.Create(false); _monitor.WorkItemsChanged += WorkItemsChanged; var serverList = ServerDirectory.GetRemoteServersByAETitle(sourceAE); if (serverList.Count == 1) _dicomServerNode = CollectionUtils.FirstElement(serverList); _hostname = hostname; }