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); } } }