0
votes

I am creating a custom native activity using workflow foundation 4.5. I want to set a bookmark for the activity and do some custom handling in the WorkflowApplication's PersistableIdle callback. Within that callback I want to read the data that was provided into the activity's InArgument<> and/or Properties before the workflow instance is persisted away. So essentially, I want to read these values from outside the context of the activity that executed and outside the run time as a pre-step before completing the persistence process.

I thought I might be able to do this with the WorkflowInspectionServices helper class but it's unclear if that works given I have to context to read from that activity instance's InArgument<>.

Is there another helper class that can make this happen with wf4.5 that I haven't discovered yet? Thanks.

 wfApp.PersistableIdle += args =>
        {
            using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
            {
                wfApp.Unload();
                args.Bookmarks.ForEach(bookmark =>
                {
                    var activityId = bookmark.BookmarkName;

                    //Doesn't seem this will really work?
                    var activityInfo = WorkflowInspectionServices.Resolve(activity, activityId) as MyCustomActivity;


                    var recipientId = activityInfo.RecipientId.Get(<I have no context>);
                   workflowSuspendedCallback.Invoke(activityId, recipientId));
                });
                scope.Complete();
            }
            return PersistableIdleAction.None;
        };
1
Simply create your own workflow extension to get this information from your activity. - user1228
Awesome. Nice hook into the run time. I was also looking at the Workflow Tracker but that seemed overkill since I only care about certain activities. - Fratt

1 Answers

0
votes

The use of activity extensions did the trick. Thanks Will.