locked
Can you track a FlowDecision RRS feed

  • Question

  • I would like to track what decisions a FlowDecision is making.  ANy way to do this?
    Friday, October 1, 2010 10:49 PM

Answers

  • Hi,

    You can write a code activity that can track custom data:
        public sealed class TrackingActivity : CodeActivity {
            protected override void Execute(CodeActivityContext context) {
                CustomTrackingRecord myRecord = new CustomTrackingRecord("MyCustomTrackingRecord");
                myRecord.Data["MyTrackingData"] = "in the middle of workflow";
                context.Track(myRecord);
            }
        }

    then put this activity right before the FlowDecision activity.

    Hope this helps
    Regards


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com "Microsoft Windows Workflow Foundation 4.0 Cookbook"
    • Marked as answer by Andrew_Zhu Friday, October 8, 2010 9:14 AM
    Wednesday, October 6, 2010 8:22 AM
  • As a different workaround, you could develop a custom Expression activity (inheriting from CodeActivity<bool>) that includes tracking functionality, and assign that as the Condition property of the FlowDecision. This would solve the problem of not needing superfluous tracking activities, but would mean that you'd have to build your flowchart in code rather than using the designer, which would probably be much uglier than just using a tracking activity.

    public class TrackResult<T> : CodeActivity<T>

    {

        public InArgument<T> Expression { get; set; }

     

        protected override T Execute(CodeActivityContext context)

        {

            T result = context.Get(Expression);

            // Either explicitly call context.Track here, or just set up a tracking profile on TrackResult.Expression

           return result;

        }
    }

     

     

    • Marked as answer by Andrew_Zhu Friday, October 8, 2010 9:14 AM
    Wednesday, October 6, 2010 7:03 PM

All replies

  • Has anyone tried to do this?
    Tuesday, October 5, 2010 10:15 PM
  • Hi,

    You can write a code activity that can track custom data:
        public sealed class TrackingActivity : CodeActivity {
            protected override void Execute(CodeActivityContext context) {
                CustomTrackingRecord myRecord = new CustomTrackingRecord("MyCustomTrackingRecord");
                myRecord.Data["MyTrackingData"] = "in the middle of workflow";
                context.Track(myRecord);
            }
        }

    then put this activity right before the FlowDecision activity.

    Hope this helps
    Regards


    This posting is provided "AS IS" with no warranties, and confers no rights. Microsoft Online Community Support. My Blog:http://xhinker.com "Microsoft Windows Workflow Foundation 4.0 Cookbook"
    • Marked as answer by Andrew_Zhu Friday, October 8, 2010 9:14 AM
    Wednesday, October 6, 2010 8:22 AM
  • That is what I am currently doing on each branch of the flow decision. And its ugly.

     

    Wednesday, October 6, 2010 5:36 PM
  • Unfortunately, the various flowchart nodes (FlowDecision, FlowStep, FlowSwitch) are simple data nodes and not full-fledged activities, so they don't have access to the infrastructure (like tracking) that activities do.
    Wednesday, October 6, 2010 5:42 PM
  • This seems like a real issue that I hope is address in later releases of the framework. As well as not being able to inherit from flow node.

    Wednesday, October 6, 2010 5:45 PM
  • As a different workaround, you could develop a custom Expression activity (inheriting from CodeActivity<bool>) that includes tracking functionality, and assign that as the Condition property of the FlowDecision. This would solve the problem of not needing superfluous tracking activities, but would mean that you'd have to build your flowchart in code rather than using the designer, which would probably be much uglier than just using a tracking activity.

    public class TrackResult<T> : CodeActivity<T>

    {

        public InArgument<T> Expression { get; set; }

     

        protected override T Execute(CodeActivityContext context)

        {

            T result = context.Get(Expression);

            // Either explicitly call context.Track here, or just set up a tracking profile on TrackResult.Expression

           return result;

        }
    }

     

     

    • Marked as answer by Andrew_Zhu Friday, October 8, 2010 9:14 AM
    Wednesday, October 6, 2010 7:03 PM