Monday, July 5, 2010
Sesquential Workflow
Workflow.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace WorkflowConsoleApplication7
{
public sealed partial class Workflow6: SequentialWorkflowActivity
{
public Workflow6()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Start workflow");
}
private void codeActivity2_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("step1");
}
private void codeActivity3_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("step2");
}
private void codeActivity4_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("End workflow");
Console.ReadLine();
}
}
}
Program.cs
using System;
using System.Collections.Generic;using System.Text;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace WorkflowConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{ AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();}; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication7.Workflow7));
instance.Start();
waitHandle.WaitOne();
}
}
}
}
Workflow Delay
workflow.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace WorkflowConsoleApplication7
{
public sealed partial class Workflow5: SequentialWorkflowActivity
{
public Workflow5()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Start workflow");
}
private void codeActivity2_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Left Side1");
}
private void codeActivity3_ExecuteCode(object sender, EventArgs e)
{ Console.WriteLine("Right side2");
}
private void codeActivity4_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Left side2");
}
private void delayActivity1_InitializeTimeoutDuration(object sender, EventArgs e)
{
}
private void codeActivity7_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Right side1");
}
private void codeActivity6_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Right side3");
}
private void codeActivity5_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("End workflow");
Console.ReadLine();
}
}
}
program.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace WorkflowConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();}; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication7.Workflow3));
instance.Start();
waitHandle.WaitOne();
}
}
}
}
Workflow While Loop
workflow.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace WorkflowConsoleApplication7
{
public sealed partial class Workflow3: SequentialWorkflowActivity
{
public Workflow3()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{ Console.WriteLine("Start");
}
private void codeActivity2_ExecuteCode(object sender, EventArgs e)
{ Console.WriteLine("Left side flow");
}
private void codeActivity3_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Right side flow");
}
private void codeActivity4_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("End");
Console.ReadLine();
}
}
}
program.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace WorkflowConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();}; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication7.Workflow3));
instance.Start();
waitHandle.WaitOne();
}
}
}
}
Sunday, July 4, 2010
Parallel Workflow
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace WorkflowConsoleApplication7
{
public sealed partial class Workflow3: SequentialWorkflowActivity
{
public Workflow3()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e) { Console.WriteLine("Start");
}
private void codeActivity2_ExecuteCode(object sender, EventArgs e) {
Console.WriteLine("Left side flow");
}
private void codeActivity3_ExecuteCode(object sender, EventArgs e) {
Console.WriteLine("Right side flow");
}
private void codeActivity4_ExecuteCode(object sender, EventArgs e) {
Console.WriteLine("End");
Console.ReadLine();
}
}
}
Program.cs
using System;using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace WorkflowConsoleApplication7
{ class Program
{
static void Main(string[] args)
{
using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();}; workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication7.Workflow3));
instance.Start();
waitHandle.WaitOne();
}
}
}
}
Sharepoint workflow IfElse Condition
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace WorkflowConsoleApplication7
{
public sealed partial class Workflow2: SequentialWorkflowActivity
{
public Workflow2()
{
InitializeComponent();
}
private string x;
private void codeActivity2_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("yes"); Console.ReadLine();
}
private void codeActivity3_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("no");
Console.ReadLine();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Type yes/no");
x = Convert.ToString(Console.ReadLine());
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace WorkflowConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e) {waitHandle.Set();
};
workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication7.Workflow2));
instance.Start();
waitHandle.WaitOne();
}
}
}
}
Sharepoint Workflow
it is a simple workflow to display the "Hello world"
program.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Workflow.Runtime;
using System.Workflow.Runtime.Hosting;
namespace WorkflowConsoleApplication7
{
class Program { static void Main(string[] args)
{
using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent waitHandle = new AutoResetEvent(false); workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
{
waitHandle.Set();
};
workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { Console.WriteLine(e.Exception.Message); waitHandle.Set(); };
WorkflowInstance instance = workflowRuntime.CreateWorkflow(typeof(WorkflowConsoleApplication7.Workflow1)); instance.Start();
waitHandle.WaitOne();
}
}
}
}
workflow.cs
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
namespace WorkflowConsoleApplication7
{
public sealed partial class Workflow1: SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e) { Console.WriteLine("Hello world");
Console.ReadLine();
}
}
}