locked
How to create and schedule custom activity using in parameters RRS feed

  • Question

  • I need to schedule other activities under my NativeActivity named ActivitityController. The custom activities will be created and scheduled according to the parameter InArgument of the parent NativeActivity.

     

    PS: The custom made activities also need to use other InArgument parameters. I don’t know in this case how to schedule these code activities. In my mind I should create all the activities in the constructor, add metadata then schedule them in the Execute method. But i don't know how to get NativeActivityContext object in order to use Context.GetValue() method.

    Need your help and thank you in advance.

    Description codes here:

     

     

    public class ActivityController : NativeActivity 
    { 
        public InArgument<String> value { getset; }
    } 

    string condition = context.GetValue(this.value);
    switch (condition)
    {
    	case "Case1":
    	{
    		CustomActivity changeAccess = new CustomActivity
    		{
    			//Create activity and assign value
     		};
    		break;
    	}
    	case "Case2":
    	{
            	//Create activity and assign value
    	};
    	break;
    	defaultbreak;
    }

     


    Wednesday, August 24, 2011 2:05 PM

Answers

  • Hi, Terry

    ->"In fact, i want to create custom activities in the constructor and under the constructor i want to use InArguments the same time, i don't know if it is possible."
    Please note that Values of Arguments and Variables are actually stored in Activity Context(say, NativeActivityContext). and we can use it after workflow start running.
    How about defining a plain c# property instead of InArgument.

    Hope this helps
    Regards



    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    • Marked as answer by Andrew_Zhu Friday, September 9, 2011 6:00 AM
    Thursday, September 1, 2011 2:01 AM

All replies

  • Hi,

    ->"The custom made activities also need to use other InArgument parameters. I don’t know in this case how to schedule these code activities. In my mind I should create all the activities in the constructor, add metadata then schedule them in the Execute method."
    See a sample here:
    http://xhinker.com/post/WF4My-Composite-Activity.aspx

    ->"But i don't know how to get NativeActivityContext object in order to use Context.GetValue() method."
    When workflow is in execution,In the Execute method, you can use context.GetValue() to get the value of InArgument

    If your Activity involves no custom activity designer, you can create your child activities in the constructed method and then schedule it in Execute method.

    Hope this helps
    Regards


    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    Monday, August 29, 2011 2:33 AM
  • Thank you a lot for your response. By the way i have already read your book WF 4.0 cookbook, it is helpful for me : )

    In fact, i want to create custom activities in the constructor and under the constructor i want to use InArguments the same time, i don't know if it is possible.

    That is to say create the activities according to the value of InArgument. (Can i create one constructor with some InArgument parameters?)

     

    Regards,

    TERRY

    Monday, August 29, 2011 9:44 AM
  • Hi, Terry

    ->"In fact, i want to create custom activities in the constructor and under the constructor i want to use InArguments the same time, i don't know if it is possible."
    Please note that Values of Arguments and Variables are actually stored in Activity Context(say, NativeActivityContext). and we can use it after workflow start running.
    How about defining a plain c# property instead of InArgument.

    Hope this helps
    Regards



    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    • Marked as answer by Andrew_Zhu Friday, September 9, 2011 6:00 AM
    Thursday, September 1, 2011 2:01 AM
  • I have the same problem, being new with WF I cannot believe the framework has so much limitation preventing you to do things that you could normally do! Why Microsoft is not repsoning to this thread!

     And in response to the last post by Andrew, how would you set the property (Not Argument) within the designer?

     Another question,

    Why when I set the Execution property to some data I like to share among my activities, it can only be seen by children activites. Why not by siblings? How else can propagate data among activies without doing InArgument all over the place???

    This is getting too frustrating....

    Please someone help.


    Tuesday, September 27, 2011 2:25 AM
  • Hi,  Anonymous6063

    For your questions and concerns, I would highly recommand you read throught these articles:
    “WF4 internals”
    http://blogs.msdn.com/b/flow/archive/2010/02/21/workflow-foundation-internals-i.aspx
    http://blogs.msdn.com/b/flow/archive/2010/02/21/workflow-foundation-internals-ii.aspx
    http://blogs.msdn.com/b/flow/archive/2010/02/21/workflow-foundation-internals-iii.aspx

    And WF4 data model:
    http://blogs.msdn.com/b/flow/archive/2010/04/05/workflow-foundation-4-0-activity-data-model-i.aspx
    http://blogs.msdn.com/b/flow/archive/2010/04/06/workflow-foundation-4-0-activity-data-model-ii.aspx

    Hope these would be helpful to you.
    Regards
    MSDN Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
    Microsoft Windows Workflow Foundation 4.0 Cookbook
    Tuesday, September 27, 2011 2:37 AM