/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="bookmark"></param> /// <param name="obj"></param> protected override void OnBookmarkCallback(NativeActivityContext context, Bookmark bookmark, string obj) { var method = System.Reflection.MethodBase.GetCurrentMethod().Name; Debug.Assert(bookmark.Name == BookmarkName); context.GetExtension <CompositionContainer>().SatisfyImportsOnce(this); _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Finished Processing SRO UnitId: [{1}], Bookmark name: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name)); // get the Image IDs for the Verification and Planning images IList <int> verifImageIds = new List <int>(); _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)), VerificationImageSopInstanceUidValues.Get(context), ref verifImageIds); IList <int> planningImageIds = new List <int>(); _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)), PlanningImageSopInstanceUidValues.Get(context), ref planningImageIds); // (NB for an XVI 5x SRO we only expect a single Planning image & a single Verificationn image if (verifImageIds.Count != 1 || planningImageIds.Count != 1) { _logger.Log(EventSeverity.Error, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Verification and/or Planning Image Ids were not correctly found", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context))); ActivityStatus.Set(context, "FAILED"); } else { ActivityStatus.Set(context, "SUCCESS"); } foreach (int imageId in verifImageIds) { _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Found Verification Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), imageId.ToString())); } foreach (int imageId in planningImageIds) { _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Found Planning Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), imageId.ToString())); } PlanningImageIds.Set(context, planningImageIds); VerificationImageIds.Set(context, verifImageIds); OutUnitId.Set(context, UnitId.Get(context)); _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Finished Processing SRO UnitId: [{1}], Bookmark name: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), bookmark.Name)); }
/// <summary> /// /// </summary> /// <param name="context"></param> /// <param name="pCancelBookmarkCreation"></param> protected override void OnBeforeCreateBookmark(NativeActivityContext context, out bool pCancelBookmarkCreation) { var method = System.Reflection.MethodBase.GetCurrentMethod().Name; pCancelBookmarkCreation = false; _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Enter: Processing SRO UnitId: [{1}], Bookmark name: [{2}], Extension Recorded Id:[{3}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName, _processSpatialRegistrationObject.ConstructedBy)); var planningSopInstanceUids = PlanningImageSopInstanceUidValues.Get(context); var verificationSopInstanceUids = VerificationImageSopInstanceUidValues.Get(context); // we want to wait for both planning and verification instances //IList<string> instanceUidsToWaitFor = // planningSopInstanceUids.Concat(verificationSopInstanceUids).ToList(); string verForUid = string.Empty; if (!base._useQueryNotificationFor3DWorkflows) { verForUid = _processSpatialRegistrationObject.GetLocalizationFrameOfRefFromXVISRO(Int32.Parse(UnitId.Get(context))); } var metadata = _processSpatialRegistrationObject.BuildMonitorMetadataForXVI5xReferencedDicomData(verForUid, verificationSopInstanceUids); // // If the dataset we are planning to wait for is already available // skip the bookmark creation and proceed to next activity. // if (_waitSetDataWrapper.IsDataAvailable(metadata)) { pCancelBookmarkCreation = true; // get the Image IDs for the Verification and Planning images IList <int> verifImageIds = new List <int>(); _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)), VerificationImageSopInstanceUidValues.Get(context), ref verifImageIds); IList <int> planningImageIds = new List <int>(); _processSpatialRegistrationObject.GetReferencedImageIdsFromSOPInstanceUIDs(Int32.Parse(UnitId.Get(context)), PlanningImageSopInstanceUidValues.Get(context), ref planningImageIds); // (NB for an XVI 5x SRO we only expect a single Planning image & a single Verification image if (verifImageIds.Count != 1 || planningImageIds.Count != 1) { _logger.Log(EventSeverity.Error, method, string.Format("[{0}] Processing UnitId: [{1}], Verification and/or Planning Image Ids were not correctly found", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context))); ActivityStatus.Set(context, "FAILED"); } else { ActivityStatus.Set(context, "SUCCESS"); } foreach (int imageId in verifImageIds) { _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Found Verification Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), imageId.ToString())); } foreach (int imageId in planningImageIds) { _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Processing SRO UnitId: [{1}], Found Planning Image ID: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), imageId.ToString())); } PlanningImageIds.Set(context, planningImageIds); VerificationImageIds.Set(context, verifImageIds); OutUnitId.Set(context, UnitId.Get(context)); //if (!base._useQueryNotificationFor3DWorkflows) //{ // if (!String.IsNullOrEmpty(metadata.DataMonitoringEventId)) // { // WaitEventManager.TryRemoveEvent(metadata.DataMonitoringEventId); // } //} } else { BookmarkMetadata.Set(context, metadata.ToString()); if (base._useQueryNotificationFor3DWorkflows) { _waitSetDataWrapper.InitiateWaitForData(context.WorkflowInstanceId, BookmarkName, metadata, _waitHandlersRepository.Get("WorkQueueElement")); } else { _waitSetDataWrapper.InitiateWaitForDataEvent(context.WorkflowInstanceId, BookmarkName, metadata, _waitHandlersRepository.Get("WorkQueueElement")); } } _logger.Log(EventSeverity.Debug, method, string.Format("[{0}] Exit: Processing SRO UnitId: [{1}], Bookmark name: [{2}]", Thread.CurrentThread.ManagedThreadId, UnitId.Get(context), BookmarkName)); }