Invoking a WorkFlow Activity

Posted: January 11, 2011 in WF4.0
Tags: , , , , , , ,

WorkflowInvoker class provides a means for invoking a workflow as if it were a method call.

Namespace:System.Activities
Assembly:System.Activities (in System.Activities.dll)

A custom activity example which we will call using WorkFlowInvoker :

public sealed class SendEmailActivity : CodeActivity
{

[RequiredArgument]
public InArgument Subject { get; set; }

[RequiredArgument]
public InArgument Body { get; set; }

[RequiredArgument]
public InArgument To { get; set; }

[RequiredArgument]
public InArgument From { get; set; }

protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Subject input argument
string text = context.GetValue(this.Subject);
}
}

Invokes SendEmailActivity :
public void TestSendEmailActivity()
{

WorkflowInvoker invoker = new WorkflowInvoker(
new SendEmailActivity
{
From = "Anupama_roy@testmail.com",
To = "Anupama_roy@testmail.com",
Subject = "Hello",
Body="How are you?"

});

invoker.Invoke();

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s