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:


Posted in 1. Leave a Comment »

Design Bits #2

This is a model showing how the workflow engine can call a remote application’s method using .NET remoting:

 

Posted in 1. Leave a Comment »

Design Bits #1

This is how the embedded engine executes your own application’s method:

 

Posted in 1. Leave a Comment »
Follow

Get every new post delivered to your Inbox.