Esempio n. 1
0
 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.");
         }
     }
 }
Esempio n. 2
0
        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;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
        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;
        }
Esempio n. 6
0
        public override void Initialize()
        {
            base.Initialize();

            _workItemActivityMonitor = WorkItemActivityMonitor.Create();
            _workItemActivityMonitor.IsConnectedChanged += OnConnectionChanged;

            this.Enabled = _workItemActivityMonitor.IsConnected;
        }
Esempio n. 7
0
        public override void Initialize()
        {
            base.Initialize();
            KeyImageClipboard.OnViewerOpened(base.Context.Viewer);

            UpdateEnabled();

            _workItemActivityMonitor = WorkItemActivityMonitor.Create();
            _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged;
        }
Esempio n. 8
0
		public override void Initialize()
		{
			base.Initialize();
			KeyImageClipboard.OnViewerOpened(base.Context.Viewer);

			UpdateEnabled();

		    _workItemActivityMonitor = WorkItemActivityMonitor.Create();
            _workItemActivityMonitor.IsConnectedChanged += OnIsConnectedChanged;
		}
Esempio n. 9
0
        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);
        }
Esempio n. 11
0
        /// <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;
            }
        }
Esempio n. 13
0
        /// <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;
        }
Esempio n. 14
0
        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.
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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();
        }
Esempio n. 17
0
        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();
        }
Esempio n. 19
0
        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);
        }
Esempio n. 21
0
        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();
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        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();
        }
Esempio n. 26
0
        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();
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
0
		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);
		}
Esempio n. 29
0
		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;
                    }
                }
            }
		}
Esempio n. 30
0
 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);
 }
Esempio n. 31
0
        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();
        }
        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();
        }
Esempio n. 33
0
        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.
        }
Esempio n. 34
0
        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);
        }
        /// <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);
        }
Esempio n. 36
0
 internal WorkItemActivityMonitorProxy(IWorkItemActivityMonitor real, SynchronizationContext synchronizationContext)
 {
     _real = real;
     _synchronizationContext = synchronizationContext;
 }
Esempio n. 37
0
        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);
        }
Esempio n. 38
0
		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;
			}
		}
Esempio n. 39
0
		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.");
				}
			}
		}
Esempio n. 40
0
 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();
        }
Esempio n. 42
0
		/// <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;
		}
        /// <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;
            }
        }
Esempio n. 44
0
 internal WorkItemActivityMonitorProxy(IWorkItemActivityMonitor real, SynchronizationContext synchronizationContext)
 {
     _real = real;
     _synchronizationContext = synchronizationContext;
 }