Return Values from Custom Activity
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
[497 byte] By [
Stags] at [2007-12-27]
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.
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;
}