none
CodeActivity & general process

    Dotaz

  • I have several code activities, which  can be selected in workflow designer (these are exposed to the end users).

    But the each of these code activities, must follow some generic logic which I want to define in a custom activity

    e.g. (simplified)

    if users adds code activity A, workflow should execute
       
       do while
    code activity
           wait for bookmark
       check bookmark result and loop if necessary

    how would i do this, without having to design this generic workflow over and over again in designer?
    I just want the users to be able to drop a custom activity inside the designer and that it automatically follows the generic logic.


    16. dubna 2012 14:50

Odpovědi

Všechny reakce

  • Hi,

    You can create a configured instance of activity colletions by using your own ActivityTemplateFactory. The code looks like:

    using System;
    using System.Activities;
    using System.Activities.Statements;

    namespace Microsoft.Samples.IActivityTemplateFactory
    {
        public sealed class MyFactory: System.Activities.Presentation.IActivityTemplateFactory
        {  

            public System.Activities.Activity Create(System.Windows.DependencyObject target)
            {
                return new DoWhile()
                {
                    Body = new Sequence()
                    {
                        Activities = {
                           new YourCodeActivity()
                        }
                    }               
                };           
            }
            public MyFactory()
            {
            }    
        }
    }


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    18. dubna 2012 9:04
    Moderátor
  • Will the whole structure (DoWhile..,Sequence,...) be visible in the designer?  I don't want to show the implementation (dowhile etc) in the designer, but I want one activity in the designer (mycodeactivity, which has it's own designer for custom properties and custom arguments), so the user does not have to bother with the implementation...


    18. dubna 2012 10:39
  • Hi,

    ->Will the whole structure (DoWhile..,Sequence,...) be visible in the designer?

    Yes, the whole structure will be visible in the designer with ActivityTemplateFactory . If you don't want it visible, you'll need to create a custom activity which has its own designer and its own child activities. You can refer to the following sample:

    Custom Composite using Native Activity

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


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    19. dubna 2012 9:03
    Moderátor