Search code examples
c#c#-4.0workflow-foundation-4

Generate a workflow service programmatically


I am working on an asp .net project which I develop a workflow service according to some selections of the user. When the user follow the appropriate steps it generates a flowchart. This flowchart is added to the body of a workflow service at the end with the following code.

          Flowchart flowchart = new Flowchart();
          flowchart = (Code to fill the flowchart)...

            Receive reserveSeat = new Receive();

            WorkflowService service = new WorkflowService()
        {

            Body = flowchart,
            Endpoints ={
            new Endpoint
            {
            ServiceContractName="IService",
            AddressUri = new Uri("http://localhost:2757"),
            Binding = new BasicHttpBinding(),
            }

            }
        };

Is there a way to add a Receive activity inside the body at the above code and not touch the flowchart?. I tried

Body = reserveSeat + flowchar, 

But is not working. Any ideas?


Solution

  • You can add both the Receive activity and the flowchart as child activities of a Sequence activity

    Body = new Sequence()
    {
      Activities = {
       reserveSeat,
       flowchar
      }
    }