locked
Return Values from Composite Activity RRS feed

  • Question

  • Hi there,

    I have a composite activity which has 2 simple activities to add individual records to the database, each of these activities need to return the id's of the newly added row in the db to the workflow. How can i capture the return values from these individual activites and return them back to the calling application? Any thoughts?

    Thanks

     

    Wednesday, December 6, 2006 7:05 PM

Answers

  • Use the same approach. Declare dependency properties in A and bind them to properties in B and C. Later when you use A in workflow, bind the properties in A to that in the workflow. Does this help?

    Wednesday, December 6, 2006 9:53 PM
  • You can declare the dependency property in  activity A whose type is a business entity which wraps multiple values. You can assign value to this property in Onclosed method of the A so as to ensure that all child activities are executed and values for all the dependency properties are set. In this case you can use the entity directly in your workflow instead of creating multiple dependency properties.

    So you activity A might have something like this:

        public static DependencyProperty MyDataProperty = System.Workflow.ComponentModel.DependencyProperty.Register("MyData", typeof(DataClass), typeof(CustomActivity));

     

            [Description("Description")]

            [Category("This is the category which will be displayed in the Property Browser")]

            [Browsable(true)]

            [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]

            public DataClass MyData

            {

                get

                {

                    return ((DataClass)(base.GetValue(CustomActivity.MyDataProperty)));

                }

                set

                {

                    base.SetValue(CustomActivity.MyDataProperty, value);

                }

            }

    protected override void OnClosed(IServiceProvider provider)

            {

                MyData = new DataClass();

                MyData.data1 = 10;

                //This is another dependency property which is bound to the dependency prop

                //of child of A

                MyData.data2 = activity11_Test1;

                MyData.data3 = true;   

                base.OnClosed(provider);

            }

     public class DataClass

        {

            public int data1;

            public string data2;

            public bool data3;

        }

     

     

    Thursday, December 7, 2006 2:01 AM

All replies

  • You can define dependency properties, to store the ids, in the custom activity and bind them to the properties in the workflow. Take a look at the custom activity binding sample http://msdn2.microsoft.com/en-us/library/aa353576.aspx for more details

     

    Wednesday, December 6, 2006 7:18 PM
  • sorry what i meant was composite activity which has two simple activities that it needs to carry out. Both the simple activities have dependency property defined and the composite activity also has dependency properties.

    CompositeActivityA has subactivityB and subactivityC

    Workflow Wf -> Calls A

    Workflow needs the return values from subactivitiesB and C

    Thanks for your help.

    Wednesday, December 6, 2006 7:56 PM
  • Use the same approach. Declare dependency properties in A and bind them to properties in B and C. Later when you use A in workflow, bind the properties in A to that in the workflow. Does this help?

    Wednesday, December 6, 2006 9:53 PM
  • Yes, that helps. Thanks. Is it possibe to get multiple values as reponse, may be in the form of an xml or a business entity?
    Wednesday, December 6, 2006 10:54 PM
  • You can declare the dependency property in  activity A whose type is a business entity which wraps multiple values. You can assign value to this property in Onclosed method of the A so as to ensure that all child activities are executed and values for all the dependency properties are set. In this case you can use the entity directly in your workflow instead of creating multiple dependency properties.

    So you activity A might have something like this:

        public static DependencyProperty MyDataProperty = System.Workflow.ComponentModel.DependencyProperty.Register("MyData", typeof(DataClass), typeof(CustomActivity));

     

            [Description("Description")]

            [Category("This is the category which will be displayed in the Property Browser")]

            [Browsable(true)]

            [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]

            public DataClass MyData

            {

                get

                {

                    return ((DataClass)(base.GetValue(CustomActivity.MyDataProperty)));

                }

                set

                {

                    base.SetValue(CustomActivity.MyDataProperty, value);

                }

            }

    protected override void OnClosed(IServiceProvider provider)

            {

                MyData = new DataClass();

                MyData.data1 = 10;

                //This is another dependency property which is bound to the dependency prop

                //of child of A

                MyData.data2 = activity11_Test1;

                MyData.data3 = true;   

                base.OnClosed(provider);

            }

     public class DataClass

        {

            public int data1;

            public string data2;

            public bool data3;

        }

     

     

    Thursday, December 7, 2006 2:01 AM