Example Workflow Activity

Here’s an example of a method within your application that hosts the embedded workflow engine:

public class Email

{

[WorkflowActivityExecuteAttribute(true, "General", "Send Email", 0)]

[WorkflowActivityExecuteInputParamAttribute("From", "", "string")]

[WorkflowActivityExecuteInputParamAttribute("To", "", "string")]

[WorkflowActivityExecuteInputParamAttribute("Subject", "", "string")]

[WorkflowActivityExecuteInputParamAttribute("Body", "", "string")]

[WorkflowActivityExecuteInputParamAttribute("SMTP Host", "", "string")]

[WorkflowActivityExecuteInputParamAttribute("SMTP Port", "25", "string")]

public WorkflowPropertyCollection SendEmail(object sender, WorkflowActivityExecuteEventArgs e)

{

try

{

SmtpClient SmtpClient = new SmtpClient();

 

MailMessage mail = new MailMessage(e.TaskNode["From"], e.TaskNode["To"]);

mail.Subject = e.TaskNode["Subject"];

mail.Body = e.TaskNode["Body"];

SmtpClient.Host = e.TaskNode["SMTP Host"];

SmtpClient.Port = Int16.Parse(e.TaskNode["SMTP Port"]);

SmtpClient.Send(mail);

}

catch (Exception ex)

{

Helpers.Logger.Error(“EXCEPTION: ” + ex.Message + “: ” + ex.StackTrace);

}

 

return e.Workitem;

}

}

 

You can have as many methods like this in a class as you want. Then all you have to do is call the AddActivities method on the workflow engine instantiation like thi:

oWorkflow.AddActivities(new Email());

You will see this in the web based workflow modeller:


Advertisement
Posted in 1. Leave a Comment »

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.