locked
ActivityBuilder or DynamicActivity for authoring workflow using imperative code RRS feed

  • Question

  • Hi all, 

    I'm currently investigating what's the best way to author a workflow using imperative code. I found this link :

    http://msdn.microsoft.com/en-us/library/ee358749.aspx

    but, I'm still curious, which one is better as the main ingredient to author workflow using imperative code, is it ActivityBuilder or DynamicActivity?

    The requirement is to write a workflow but we don't need it to be a type. We want to execute the created workflow, as well as perform modification (using code) such as adding/deleting argument, modify the variable, add/delete the sequence etc.

    What are the differences between ActivityBuilder and DynamicActivity?


    arinto
    Tuesday, November 30, 2010 7:29 AM

Answers

  • Please refer to this link.

    it answers your question, I think.

    http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/fa553e87-2e76-4bc1-bf63-e970935b31da

     

    simply speaking, if you are create workflow from workflow designer in VS, it will use activity builder automatically, and you click F5, it will be converted to run time type to execute the workflow.

    if you don't want to create workflow from designer, dynamicactivity will be your choise.

    • Marked as answer by arinto Wednesday, December 1, 2010 2:34 AM
    Tuesday, November 30, 2010 7:45 AM
  • That is a good discussion referenced in the post above. One other different; if you are going to want to serialize out your workflow definitions to Xaml then you should use ActivityBuilder; here are some examples of that:

    http://msdn.microsoft.com/en-us/library/ff458319.aspx

    If you just want to create the activity types on the fly and use them, then DynamicActivity is good for that.

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

    • Marked as answer by arinto Wednesday, December 1, 2010 2:34 AM
    Tuesday, November 30, 2010 10:49 PM

All replies

  • Please refer to this link.

    it answers your question, I think.

    http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/fa553e87-2e76-4bc1-bf63-e970935b31da

     

    simply speaking, if you are create workflow from workflow designer in VS, it will use activity builder automatically, and you click F5, it will be converted to run time type to execute the workflow.

    if you don't want to create workflow from designer, dynamicactivity will be your choise.

    • Marked as answer by arinto Wednesday, December 1, 2010 2:34 AM
    Tuesday, November 30, 2010 7:45 AM
  • That is a good discussion referenced in the post above. One other different; if you are going to want to serialize out your workflow definitions to Xaml then you should use ActivityBuilder; here are some examples of that:

    http://msdn.microsoft.com/en-us/library/ff458319.aspx

    If you just want to create the activity types on the fly and use them, then DynamicActivity is good for that.

    Thanks,

    Steve Danielson [Microsoft]
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm

    • Marked as answer by arinto Wednesday, December 1, 2010 2:34 AM
    Tuesday, November 30, 2010 10:49 PM
  • Thanks Steve and Yu for the discussion :)
    arinto
    Wednesday, December 1, 2010 2:34 AM
  • Please refer to this link.

    it answers your question, I think.

    http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/fa553e87-2e76-4bc1-bf63-e970935b31da

     

    simply speaking, if you are create workflow from workflow designer in VS, it will use activity builder automatically, and you click F5, it will be converted to run time type to execute the workflow.

    if you don't want to create workflow from designer, dynamicactivity will be your choise.

    Hi Ye Yu, 

    You mentioned that when we pressed F5, ActivityBuilder will be converted to run time type for WorkflowExecution.

    Initially I thought I can use ActivityBuilder.Implementation as the input to WorkflowApplication constructor. But I'm wrong. ActivityBuilder.Implementation doesn't include ActivityBuilder's Arguments. 

    The Arguments are contained in ActivityBuilder.Properties.

    My question here is how to convert ActivityBuilder into its runtime type so that I can use it in WorkflowApplication class?

     

    Regards, 

     


    arinto
    Tuesday, January 11, 2011 8:04 AM
  • If the xaml file exists, I can use this statement to get the runtime type:

    Activity activity = ActivityXamlServices.Load(ActivityBuilderFilePath);
    

    Where ActivityBuilderFilePath is the XAML file path that was deserialized to construct ActivityBuilder.

    But, what if I modify the ActivityBuilder and I want to execute the ActivityBuilder using WorkflowApplication or WorkflowInvoker.

    I can write the ActivityBuilder and then read the just-written file using code snippet above. But, is there any more efficient way that doesn't involve writing into storage?

     

    Regards

     


    arinto
    Tuesday, January 11, 2011 8:11 AM
  • If the xaml file exists, I can use this statement to get the runtime type:

     

    Activity activity = ActivityXamlServices.Load(ActivityBuilderFilePath);
    
    

     

    Where ActivityBuilderFilePath is the XAML file path that was deserialized to construct ActivityBuilder.

    But, what if I modify the ActivityBuilder and I want to execute the ActivityBuilder using WorkflowApplication or WorkflowInvoker.

    I can write the ActivityBuilder and then read the just-written file using code snippet above. But, is there any more efficient way that doesn't involve writing into storage?

     

    Regards

     


    arinto


    Hi,

    You can directly use ActivityBuilder's Implemention properties to retrieve tha activity instance.

    ActivityBuilder ab = new ActivityBuilder();
    ...
    WorkflowInvoker.Invoke(ab.Implementation);

    jhlim21

     

    Tuesday, January 11, 2011 11:34 AM