locked
Creating a workflow dynamically RRS feed

  • Question

  • Hi all,

    I am thinking about using WF in a new product the company that I work for is developing. The product will have two parts:

    - a workflow app to execute a simple 'job order' workflow
    - a web app to create/modify the actual job order

    I believe I will need to utilise the ExternalDataExchangeService to setup the interaction between the web app and the workflow app.  At the moment, I'm more concerned about the workflow itself.

    I'll be using a state machine workflow as it seems the most appropriate.  An example of the job order is:

    1. Operator creates job order (e.g. fix oven X in kitchen A) and assigns it to worker.
    2. Worker does the job, and completes the order with details of the work performed.

    Unfortunately, it could get more complicated for other customers using this software, e.g:

    1. Operator creates job order and assigns it to manager.
    2. Manager approves the job order and assigns it to worker.
    3. Worker does the job, fills in details and assigns the order to manager.
    4. Manager completes the job order.

    I am wondering how I should go about handling the different requirements. I don't like the idea of giving end-users a graphical workflow design tool like the type inside Visual Studio. Instead, I will provide users with something like a grid of actions to be performed and will allow them to change the order in which the actions can be performed (and change the actions themselves). This data will then be stored in an SQL database which the workflow program will read on startup. 

    The workflow will be determined before the workflow application is started. Once the workflow is configured, it will not be changed, so the workflow app doesn't actually need to handle changes on-the-fly.  However, it does need to generate the workflow initially.  I know that I can use WorkflowChanges to process changes to a workflow at runtime.  My question is, should I create the entire workflow dynamically at runtime (I assume this is possible although I have seen no examples of it anywhere), or should I create the most basic workflow possible inside Visual Studio and use that as the base and then add activities to it dynamically at runtime?

    Andrew
    • Changed type laconical Monday, March 9, 2009 4:30 AM More of a question than a discussion
    Monday, March 9, 2009 4:04 AM

Answers

  • Hello, since you don't need to change the workflow at runtime, I think you can create a XOML file dynamically, and then create a workflow based on the XOML. You have some pre-defined activities. They may or may not have code behind. But the workflow the users created must be XOML only, which contains the pre-defined activities. You can build any user interface you like. You only need to know how to write the XOML file based on the user's input on the design surface. This is the approach we take in our Azure .NET Workflow Service.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by laconical Wednesday, March 11, 2009 2:41 AM
    Tuesday, March 10, 2009 7:32 AM
  • Hello laconical

    There is a sample of a workflow that is created dymanically it's called In-Memory and allows you to create a workflow on the fly with your custom activities. The user doesn't change the workflow in the designer but in a form.

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

    Hope this will help
    • Marked as answer by laconical Thursday, March 12, 2009 9:15 AM
    Wednesday, March 11, 2009 9:38 AM

All replies

  • Hello, since you don't need to change the workflow at runtime, I think you can create a XOML file dynamically, and then create a workflow based on the XOML. You have some pre-defined activities. They may or may not have code behind. But the workflow the users created must be XOML only, which contains the pre-defined activities. You can build any user interface you like. You only need to know how to write the XOML file based on the user's input on the design surface. This is the approach we take in our Azure .NET Workflow Service.
    Lante, shanaolanxing This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by laconical Wednesday, March 11, 2009 2:41 AM
    Tuesday, March 10, 2009 7:32 AM
  • Hi laconical

    I think you are very good in workflows.

    if it is not a problem for u,can you please send me one small asp.net workflow example?

    and one more thing i have a doubt in workflow.

    My Application Scenario is:

    i have a registration page, in that user will be registered.The registration will be accepted by 3 different users(PO,AO,RO).

    When PO user logs into his account, he will get all the newly registered applications.Now based on the requirements he can approve it or decline it.

    Once PO User approved it , the application will be forward  to  AO users.When AO user logs into his account, he will get all the newly registered applications which were forwarded by PO User.Now based on the requirements he can approve it or decline it.


    Once AO User approved it , the application will be forward  to  RO users.When RO user logs into his account, he will get all the newly registered applications which were forwarded by AO User.Now based on the requirements he can approve it or decline it.

    I dont know how to implement this functionality.Can you please tell me how to do this?

    Thanks in Advance.

    I am very sorry for posting my question in ur forum.Please excuse me.

    Regards
    Krishna Kishore


    Tuesday, March 10, 2009 9:18 AM
  • Krishna,

    Unfortunately I cannot provide any examples as I have never written a workflow before. I am just beginning to learn how to use workflows and only know the theory at this point.  It sounds like you want a state-machine workflow as there are different states in your application - there is a good state-machine workflow example at http://msdn.microsoft.com/en-us/magazine/cc163281.aspx

    Andrew

    Wednesday, March 11, 2009 2:47 AM
  • Hello laconical

    There is a sample of a workflow that is created dymanically it's called In-Memory and allows you to create a workflow on the fly with your custom activities. The user doesn't change the workflow in the designer but in a form.

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

    Hope this will help
    • Marked as answer by laconical Thursday, March 12, 2009 9:15 AM
    Wednesday, March 11, 2009 9:38 AM
  • That is just what I was looking for, thanks for that!
    Thursday, March 12, 2009 9:16 AM