WWF Important

on Monday, August 24, 2009

Runtime Services

  • Workflow Persistance Service
  • Tracking Service
  • Manual Scheduler Service
  • Transaction Service

Important Activities

  • Listen Activity= Only one event gets triggered
  • Parallel Activity
  • Conditioned Activity Group
  • Event Handling Scope
  • While,IfElse

Local Service

[ExternalDataExchange]
public interface ICommunicationService
{
event EventHandler DataEntered;
}

[Serializable]
public class CommArgs : ExternalDataEventArgs
{
public int val1;
public int val2;
public string op;
public CommArgs(Guid instanceId,string[] args)
: base(instanceId)
{
val1 = int.Parse(args[0]);
val2 = int.Parse(args[1]);
op = args[2];

}
}
[Serializable]
public class CommunicationService : ICommunicationService
{

public event EventHandler DataEntered;


public void SupplyData(Guid instanceId,int val1, int val2, string op)
{
string[] args = new string[3];
args[0] = val1.ToString();
args[1] = val2.ToString();
args[2] = op;

if (DataEntered != null)
{
this.DataEntered(this, new CommArgs(instanceId, args));
}
}

}

Host Application

ExternalDataExchangeService exService = new ExternalDataExchangeService();
CommunicationService c = new CommunicationService();
using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
workflowRuntime.AddService(exService);
exService.AddService(c);
//workflowRuntime.AddService(service);
AutoResetEvent waitHandle = new AutoResetEvent(false);
workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
{
Console.WriteLine(e.OutputParameters["Result"].ToString());
waitHandle.Set();
};
workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{

Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};

Console.WriteLine("Enter Num1");
int num1;
int.TryParse(Console.ReadLine(), out num1);
Console.WriteLine("Enter Num2");
int num2;
int.TryParse(Console.ReadLine(), out num2);

Console.WriteLine("Enter Operation");
string operation = Console.ReadLine();

Dictionary data = new Dictionary();
data.Add("Num1", num1);
data.Add("Num2", num2);
data.Add("Operation", operation);
List employees = new List();
employees.Add("b");
employees.Add("a");
data.Add("employees", employees);
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication1.Workflow1), data);
instance.Start();
//Thread.Sleep(TimeSpan.FromSeconds(5));
for (int i = 0; i < 3; i++) c.SupplyData(instance.InstanceId, num1, num2, operation); //service = workflowRuntime.GetService();
//if (service != null)
// service.RunWorkflow(instance.InstanceId);

waitHandle.WaitOne();
Console.WriteLine("Workflow Completed");
}

0 comments: