Ejemplo n.º 1
0
 private void FireWorkItemsChanged(WorkItemsChangedEventArgs e)
 {
     if (!_disposed)
     {
         EventsHelper.Fire(_workItemsChanged, this, e);
     }
 }
Ejemplo n.º 2
0
 private void OnWorkItemsChanged(object sender, WorkItemsChangedEventArgs e)
 {
     if (_synchronizationContext != null)
     {
         _synchronizationContext.Post(ignore => FireWorkItemsChanged(e), null);
     }
     else
     {
         FireWorkItemsChanged(e);
     }
 }
        private void OnWorkItemsChanged(WorkItemsChangedEventType eventType, List <WorkItemData> workItems)
        {
            IList <Delegate> delegates;

            lock (_syncLock)
            {
                if (_disposed)
                {
                    return;
                }

                delegates = _workItemsChanged != null?_workItemsChanged.GetInvocationList() : new Delegate[0];
            }

            if (delegates.Count <= 0)
            {
                return;
            }

            var args = new WorkItemsChangedEventArgs(eventType, workItems);

            CallDelegates(delegates, args);
        }
		private void OnWorkItemsChanged(WorkItemsChangedEventType eventType, List<WorkItemData> workItems)
        {
            IList<Delegate> delegates;
            lock (_syncLock)
            {
                if (_disposed)
                    return;

                delegates = _workItemsChanged != null ? _workItemsChanged.GetInvocationList() : new Delegate[0];
            }

            if (delegates.Count <= 0)
                return;

			var args = new WorkItemsChangedEventArgs(eventType, workItems);
            CallDelegates(delegates, args);
        }
Ejemplo n.º 5
0
 private void UpdateProgress(object sender, WorkItemsChangedEventArgs workItemsChangedEventArgs)
 {
 	foreach (var item in workItemsChangedEventArgs.ChangedItems)
 	{
 		UpdateProgress(item);
 	}	
 }
Ejemplo n.º 6
0
		private void ActivityMonitorWorkItemsChanged(object sender, WorkItemsChangedEventArgs e)
		{
			foreach (var item in e.ChangedItems)
			{
				// check for a new failure, and raise an alert if necessary
				if (!_failedWorkItems.Contains(item.Identifier) && item.Status == WorkItemStatusEnum.Failed)
				{
					_failedWorkItems.Add(item.Identifier);

                    if (item.Patient != null && item.Study != null)
                    {
                        var studyDate = DateParser.Parse(item.Study.StudyDate);
                        var message = string.Format(SR.MessageWorkItemFailed,
                                                    item.Request.ActivityTypeString,
                                                    item.Patient.PatientsName,
                                                    studyDate.HasValue ? Format.Date(studyDate.Value) : string.Empty,
                                                    item.Study.AccessionNumber);
                        _window.ShowAlert(AlertLevel.Error, message, SR.LinkOpenActivityMonitor,
                                          window => _showActivityMonitor(), true);
                    }
                    else
                    {
                        var message = string.Format(SR.MessageNonStudyWorkItemFailed,
                                                item.Request.ActivityTypeString);
                        _window.ShowAlert(AlertLevel.Error, message, SR.LinkOpenActivityMonitor,
                                          window => _showActivityMonitor(), true);
                    }
				}

				// if a previously failed item is re-tried, remove it from the set of failed items
				if (_failedWorkItems.Contains(item.Identifier) && item.Status != WorkItemStatusEnum.Failed)
				{
					_failedWorkItems.Remove(item.Identifier);
				}
			}
		}
Ejemplo n.º 7
0
        /// <summary>
        /// Work Items Changed event handler.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnWorkItemsChangedAsync(object sender, WorkItemsChangedEventArgs args)
        {
			// ignore refresh events
            if (args.EventType == WorkItemsChangedEventType.Refresh || args.ChangedItems == null)
                return;

            var syncContext = _synchronizationContext;
            if (syncContext == null)
                return;

            lock (_syncLock)
            {
                var previousChangedStudiesCount = _setChangedStudies.Count;
                foreach (var item in args.ChangedItems)
                {
                    var theItem = item;
                    if (theItem.Type.Equals(ReindexRequest.WorkItemTypeString))
                        syncContext.Post(ignore => UpdateReindexing(theItem.Status == WorkItemStatusEnum.InProgress), false);
                    
                    if (item.Request.ConcurrencyType == WorkItemConcurrency.StudyRead)
                        continue; //If it's a "read" operation, don't update anything.

                    if (item.Request.ConcurrencyType == WorkItemConcurrency.StudyDelete)
                        _hastenUpdateQuery = true; //We want deleted studies to disappear quickly, so make a hasty update query.

                    //If it's not a read operation, but it has a Study UID, then it's probably updating studies.
                    //(e.g. re-index, re-apply rules, import, process study).
                    if (!String.IsNullOrEmpty(item.StudyInstanceUid))
                    {
                        if (Platform.IsLogLevelEnabled(LogLevel.Debug))
                            Platform.Log(LogLevel.Debug, "Study '{0}' has changed (Work Item: {1}, {2})", item.StudyInstanceUid, item.Identifier, item.Type);

                        _setChangedStudies[item.StudyInstanceUid] = item.StudyInstanceUid;
                    }
                }

                if (_setChangedStudies.Count > previousChangedStudiesCount)
                {
                    Platform.Log(LogLevel.Debug, "{0} studies changed since the last update.", _setChangedStudies.Count);

                    //Only update this if we've received a message for a study not already in the set.
                    //We're only interested in the unique set of studies that has changed (or is changing)
                    //since the last time we updated the studies in the study list.
                    _lastStudyChangeTime = DateTime.Now;
                }
            }
        }
Ejemplo n.º 8
0
 private void FireWorkItemsChanged(WorkItemsChangedEventArgs e)
 {
     if (!_disposed)
         EventsHelper.Fire(_workItemsChanged, this, e);
 }
Ejemplo n.º 9
0
 private void OnWorkItemsChanged(object sender, WorkItemsChangedEventArgs e)
 {
     if (_synchronizationContext != null)
         _synchronizationContext.Post(ignore => FireWorkItemsChanged(e), null);
     else
         FireWorkItemsChanged(e);
 }
Ejemplo n.º 10
0
		private void WorkItemsChanged(object sender, WorkItemsChangedEventArgs e)
		{
			foreach (var item in e.ChangedItems)
			{
				if (item.Request is DicomReceiveRequest)
				{
					lock (StudyWorkItemsSyncLock)
					{
						WorkItem workItem;
						if (StudyWorkItems.TryGetValue(item.StudyInstanceUid, out workItem))
						{
							if (workItem.Oid == item.Identifier)
							{
								workItem.Status = item.Status;
								workItem.Progress = item.Progress;
							}
						}
					}
				}
			}
		}
        private void OnWorkItemsChanged(object sender, WorkItemsChangedEventArgs eventArgs)
        {
            if (eventArgs.EventType != WorkItemsChangedEventType.Update || eventArgs.ChangedItems.IsNullOrEmpty())
                return; // We are only interested in Update events

            foreach (var workItemData in eventArgs.ChangedItems)
            {
                // Fire event when import ends or an item is removed
                if (workItemData.Type == "ProcessStudy")
                {
                    if (workItemData.Status == WorkItemStatusEnum.Idle || workItemData.Status == WorkItemStatusEnum.Complete || workItemData.Status == WorkItemStatusEnum.Deleted)
                    {
                        // HACK: To minimize number of readings of annotation documents, we remember studies that were already updated when their Status == Idle
                        long idleKey = 0x3B3402E0 ^ workItemData.Identifier ^ workItemData.StudyInstanceUid.GetHashCode();
                        if (workItemData.Status == WorkItemStatusEnum.Idle)
                        {
                            // NOTE: we cannot skip updating on any Idle status because there could be new SOPs processed just before the Idle status kicked in

                            if (!_updatedIdleStudies.Contains(idleKey))
                                _updatedIdleStudies.Add(idleKey);
                        }
                        else
                        {
                            if (_updatedIdleStudies.Contains(idleKey))
                            {
                                _updatedIdleStudies.Remove(idleKey);
                                continue; // update event was sent already
                            }
                        }

                        DoStudyUpdate(workItemData.StudyInstanceUid);
                    }
                }
                else if (workItemData.Type == "DeleteSeries")
                {
                    if (workItemData.Status == WorkItemStatusEnum.Complete)
                    {
                        DoStudyUpdate(workItemData.StudyInstanceUid);
                    }
                }
                else if (workItemData.Type == "DeleteStudy")
                {
                    if (workItemData.Status == WorkItemStatusEnum.Complete)
                    {
                        DoStudyUpdate(workItemData.StudyInstanceUid);
                    }
                }
            }
        }
        private void OnWorkItemsChanged(object sender, WorkItemsChangedEventArgs e)
        {
            if (e.EventType != WorkItemsChangedEventType.Update || e.ChangedItems == null || !e.ChangedItems.Any())
                return; // We are only interested in Update events

            var studiesWithAddedInstances = new HashSet<string>();
            foreach (WorkItemData workItemData in e.ChangedItems)
            {
                if (workItemData.Type == "ProcessStudy")
                {
                    if (workItemData.Status == WorkItemStatusEnum.Idle ||
                        workItemData.Status == WorkItemStatusEnum.Complete ||
                        workItemData.Status == WorkItemStatusEnum.Deleted)
                    {
                        if (workItemData.Status == WorkItemStatusEnum.Idle)
                        {
                            // NOTE: new SOPs are already available when Idle status kicked in

                            if (!string.IsNullOrEmpty(workItemData.StudyInstanceUid))
                                studiesWithAddedInstances.Add(workItemData.StudyInstanceUid);
                        }
                    }
                }
                else if (workItemData.Type == "DeleteSeries")
                {
                    // TODO: remove graphics if the Segmentation instance is deleted?
                    //if (workItemData.Status == WorkItemStatusEnum.Complete)
                    //{
                    //}
                }
            }

            if (studiesWithAddedInstances.Any())
            {
                // Load new segmentations asynchronously
                SynchronizationContext.Current.Post((state => LoadNewSeries(studiesWithAddedInstances.ToList())), null);
            }
        }