Windows Workflow Foundation
Here is I am going to explain the Windows Workflow Foundation for .Net Framework 3.0.
I welcomes all of you to Windows Workflow Foundation
One of the newest buzz phrases in the framework industry is "Windows Workflow Foundation" (WF). This article is like a tutorial for how to start with Windows Workflow Foundation in .Net framework 3.0. Basic knowledge of .NET Framework is the only prerequisite for marching on with this article.
First of all we need to What is Workflow?
The answer for the above question is in the following scenarios....
Mr. X see a beatiful girl and wants to propose love to her....
1. He goes to near her and give a smile.
2. He introduced himself
3. He came to know each other
4. He praised her fair
5. He proposed his love
From the above, there are 5 steps for a man propose a love to a girl. From here, the number of 'steps' for complete an 'action'. The desired action (love Proposal) is dependent on the number of steps. Looking around makes us realize everything around us follows a certain pattern/sequence of steps in order to achieve the desired result. Now this very realization leads us to the definition of workflow.
Workflow: Series of steps, decisions and rules needed to complete a specific task.
Windows Workflow Foundation:
Windows Workflow Foundation is a technology for defining, executing and managing workflows. This is one of three major frameworks (the other two are related to presentation and communication) that .NET 3.0 introduced.
Workflow Foundation consists of runtime, workflow library, services and a programming model. Workflow projects are not applications themselves, rather they constitute an application, so 'host' is needed for workflow runtime. As in the running loan-request workflow, a banking application will act like a 'host'. The host can be a: smart-client, ASP.NET worker thread, service, or a simple console application.
'Runtime' manages workflows, managing means creating workflow and responding to events like resuming, suspending, terminating, unloading etc.. As we have noticed, many business processes consist of similar activities but are used in different contexts. For example: conditional loops, parallel activities, and calling a web service are common activities that could be part of a different multitude of applications, so Microsoft has provided a base activity library that has a common set of usable activities. Of course, one can write their own custom activity or extend existing ones.
Services are another part of WF that help runtime perform various operations on workflow; again services can be extended / customized as needed. A few services that come with WF are: scheduling, transaction, persistence, tracking services.
There are two major types in Windows workflow Foundation:
Sequential: a series of activities are called in order.
State machine: activities are called on the basis of the 'state' of different parameters.
Steps to create a Windows Workflow Foundation...
Open up Visual Studio 2005 IDE and click on 'New Project'
Select 'Sequential Workflow Console Application' as project type. As pointed out earlier, there are two types of workflows: sequential and state machine. Our chosen scenario follows a particular sequence and doesn't have any state machine involved in it, hence the selection.
Select an appropriate project name, mine is 'MyWF'. Check the 'Location' of the project on disk drive and click 'OK'.
Workflow is currently empty and you can drag-drop any number of activities from the 'toolbox window' into it.
Here, first we select 'Code Activity' and drop it on Workflow Designer.
You can see from the 'properties' window that this new activity is named as 'codeActivity1'. To define what this code activity will do, we will click the 'Generate Handlers' hyperlink in 'properties' window. This will generate the default handler 'ExecuteCode' for this activity.
The following code will be produced after performing all of these steps.
public sealed partial class Workflow1: SequentialWorkflowActivity
{
public Workflow1()
{
InitializeComponent();
}
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
} In the above event, we can add code for getting any value...
I am going to write as follows,
private void codeActivity1_ExecuteCode(object sender, EventArgs e)
{
Console.WriteLine("Enter Name : ");
string Name = Console.ReadLine();
Console.WriteLine("Your Name Saved!");
}
}
Hence we have started our Windows Workflow project. After here I will post next steps in Windows Workflow....
:)
Cheers...
...S.VinothkumaR.
CardSpace for .Net Framework 3.0
When a CardSpace-enabled application or website wishes to obtain personal information about the user, the application or website demands a particular set of claims or a particular token type from the user. CardSpace then appears, locking the display to the CardSpace program representing the stored identities as virtual information cards. The user selects the card to use and the CardSpace software contacts the issuer of the identity to obtain a digitally signed XML token that contains the requested information.
CardSpace allows users to create self-issued identities for themselves, which can contain one or more of around 15 fields of telephone book-quality identity information. Other transactions may require a managed identity issued by a trusted identity provider, such as a bank, employer or a governmental agency.
Windows CardSpace is built on top of Web Services Protocol Stack, an open set of XML-based protocols, including WS-Security, WS-Trust, WS-MetadataExchange and WS-SecurityPolicy. This means that any technology or platform which supports WS-* protocols can integrate with CardSpace. In order to accept information cards, a website developer simply needs to declare an HTML
If an Identity Provider (IP) wants to issue tokens, they must provide a means by which a user can obtain a managed card and provide a Security Token Service (STS) which handles WS-Trust requests and returns an appropriate encrypted & signed token. If an IP does not wish to build an STS, they will be able to obtain one from a variety of vendors including PingID, BMC, Sun, Microsoft or Siemens, as well as other companies or organizations.
Because it is token-agnostic, CardSpace does not compete directly with other Internet identity architectures like OpenID and Liberty Alliance. In some ways the three approaches to identity can be seen as complementary.
In February 2006, IBM and Novell announced that they will support the Higgins trust framework to provide a development framework that subsumes a support for the Web Services Protocol Stack underlying CardSpace within a broader, extensible support for other identity-related technologies, such as SAML and OpenID.
Microsoft included Windows CardSpace within its new operating system Windows Vista, and is also available as part of Microsoft's .NET Framework 3.0 for Windows XP and Windows Server 2003.
.Net Framework 3.0
.NET Framework 3.0, formerly called WinFX, includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems. It is also available for Windows XP SP2 and Windows Server 2003 as a download.
.NET Framework 3.0 consists of four major new components:
1. Windows Presentation Foundation (WPF), formerly code-named Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies. See WPF SDK for developer articles and documentation on WPF.
2. Windows Communication Foundation (WCF), formerly code-named Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services.
3. Windows Workflow Foundation (WWF) allows for building of task automation and integrated transactions using workflows.
4. Windows CardSpace (WCS), formerly code-named InfoCard; a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website.
Reading xml file in Javascript
Dear Buddies....
Here I am trying to read a xml file using javascript and displaying it's tag value and attribute values
menux.xml file is as follows....
In javascript the following functions will be using for reading xml file...
var xmlDoc;
var nodedisplay="\n\n";
var idDisplay="\n\n";
var nameDisplay="\n\n";
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.load("menus.xml")
getValuesie();
}
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
function getValuesie()
{
nodes=xmlDoc.documentElement.childNodes
for(var i=0;i
nodedisplay=nodedisplay+nodes.item(i).text+"\n";
idDisplay=idDisplay+nodes.item(i).getAttribute('id')+"\n";
nameDisplay=nameDisplay+nodes.item(i).getAttribute('name')+"\n";
}
nodeValue.innerText=nodedisplay;
idValue.innerText=idDisplay;
nameValue.innerText=nameDisplay;
}
function afor()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc.async=false;
var isLoaded = xmlDoc.load("menus.xml");
if (isLoaded == true)
{
length=xmlDoc.getElementsByTagName("menu").length;
for(var i=0;i
nodedisplay = nodedisplay + xmlDoc.getElementsByTagName("menu")[i].childNodes[0].nodeValue+"\n";
}
return nodedisplay;
}
}
}
function bfor()
{
if (document.implementation && document.implementation.createDocument)
{
xmlDoc.async=false;
var isLoaded = xmlDoc.load("menus.xml");
if (isLoaded == true)
{
length=xmlDoc.getElementsByTagName("menu").length;
for(var i=0;i
idDisplay = idDisplay + xmlDoc.getElementsByTagName("menu")[i].getAttribute("id")+"\n";
}
return idDisplay;
}
}
}
function cfor()
{
if (document.implementation && document.implementation.createDocument)
{
var c="\n\n";
xmlDoc.async=false;
var isLoaded = xmlDoc.load("menus.xml");
if (isLoaded == true)
{
length=xmlDoc.getElementsByTagName("menu").length;
for(var i=0;i
nameDisplay = nameDisplay + xmlDoc.getElementsByTagName("menu")[i].getAttribute("name")+"\n";
}
return nameDisplay;
}
}
}
In the body ....there are three span's with ids....in each span ...after the span tag closed in script, write the following code...
In first span with Id of "nodeValue"
if (document.implementation && document.implementation.createDocument)
{
document.getElementById("nodeValue").innerHTML=afor();
}
next span with the Id of "idValue"
if (document.implementation && document.implementation.createDocument)
{
document.getElementById("idValue").innerHTML=bfor();
}
last span with the Id of "nameValue"
if (document.implementation && document.implementation.createDocument)
{
document.getElementById("nameValue").innerHTML=cfor();
}
Formats for DateTime.ToString()
Here is the lot of formats are given for how to use the DateTime.ToString() in our C# Project.
The DateTime class is most usefull for our time based programs. But we dont' know how to use the DateTime.ToString() function with appropriate formats. Here I am giving some formats for using DateTime.ToString().
Code
In our C# Program, we should declare the datetime and write the code as follows,
The result also given in right side...
DateTime dt = DateTime.Now;
String strDate="";
strDate = dt.ToString("MM/dd/yyyy"); // 07/21/2007
strDate = dt.ToString("dddd, dd MMMM yyyy"); //Saturday, 21 July 2007
strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm"); // Saturday, 21 July 2007 14:58
strDate = dt.ToString("dddd, dd MMMM yyyy hh:mm tt"); // Saturday, 21 July 2007 03:00 PM
strDate = dt.ToString("dddd, dd MMMM yyyy H:mm"); // Saturday, 21 July 2007 5:01
strDate = dt.ToString("dddd, dd MMMM yyyy h:mm tt"); // Saturday, 21 July 2007 3:03 PM
strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm:ss"); // Saturday, 21 July 2007 15:04:10
strDate = dt.ToString("MM/dd/yyyy HH:mm"); // 07/21/2007 15:05
strDate = dt.ToString("MM/dd/yyyy hh:mm tt"); // 07/21/2007 03:06 PM
strDate = dt.ToString("MM/dd/yyyy H:mm"); // 07/21/2007 15:07
strDate = dt.ToString("MM/dd/yyyy h:mm tt"); // 07/21/2007 3:07 PM
strDate = dt.ToString("MM/dd/yyyy HH:mm:ss"); // 07/21/2007 15:09:29
strDate = dt.ToString("MMMM dd"); // July 21
strDate = dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"); // 2007-07-21T15:11:19.1250000+05:30
strDate = dt.ToString("ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"); // Sat, 21 Jul 2007 15:12:16 GMT
strDate = dt.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss"); // 2007-07-21T15:12:57
strDate = dt.ToString("HH:mm"); // 15:14
strDate = dt.ToString("hh:mm tt"); // 03:14 PM
strDate = dt.ToString("H:mm"); // 5:15
strDate = dt.ToString("h:mm tt"); // 3:16 PM
strDate = dt.ToString("HH:mm:ss"); // 15:16:29
strDate = dt.ToString("yyyy'-'MM'-'dd HH':'mm':'ss'Z'"); // 2007-07-21 15:17:20Z
strDate = dt.ToString("dddd, dd MMMM yyyy HH:mm:ss"); // Saturday, 21 July 2007 15:17:58
strDate = dt.ToString("yyyy MMMM"); // 2007 July
Hence we can format and getting the datetime value.
Creation of Table Partitions in SQL Server 2005
CREATE PARTITION FUNCTION [testPartition](int) AS RANGE LEFT
FOR VALUES (1000, 2000, 3000)
CREATE PARTITION SCHEME [testPartitionScheme] AS PARTITION [testPartition]
ALL TO ([PRIMARY])
IF OBJECT_ID('customer')>0
DROP TABLE [customer];
GO
CREATE TABLE [dbo].[customer]
(
[Id] [int] IDENTITY(1,1),
[FirstName] [varchar](50) NULL,
[LastName] [varchar](50),
[Company] [varchar](50) NULL,
[Email] [varchar](100),
)ON [testPartitionScheme](Id)
GO
DECLARE @i SMALLINT
SET @i = 1
WHILE (@i <=10000)
BEGIN
INSERT INTO customer(FirstName, LastName, Company,Email)
VALUES('Vinoth', 'kumar', 'myComp', 'myId@my.com' )
INSERT INTO customer(FirstName, LastName, Company,Email)
VALUES('Krishna','kumar', 'myComp', 'myId@my.com' )
INSERT INTO customer(FirstName, LastName, Company,Email)
VALUES('Mohan','kumar', 'myComp', 'myId@my.com' )
SET @i = @i + 1
END
SELECT * From sys.partitions
WHERE OBJECT_NAME(object_id) = 'customer'
FROM customer
SELECT $PARTITION.[testPartition](Id) AS Partition, COUNT(*) AS [COUNT] FROM customer GROUP BY $PARTITION.[testPartition](Id)ORDER BY Partition ;
ALTER PARTITION FUNCTION testPartition() MERGE RANGE(2000)
Creation of FileGroups in SQLServer 2005
We can create filegroups in SQL Server by two different ways, one is Alter Command and the second is using Interface.
a) Using the Alter Command
The syntax for Alter Command is,
ALTER DATABASE
For Example,
Alter Database TestDB ADD FILEGROUP FG1
After adding a filegroup we need to add files to the filegroup.
The Syntax for adding files,
ALTER DATABASE
ADD FILE
(
NAME =
)
TO FILEGROUP
For Example,
ALTER DATABASE TestDB
ADD FILE
(
NAME = FILE1, FILENAME = 'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\FILE1.ndf', SIZE = 1MB, MAXSIZE = 10MB, FILEGROWTH = 1MB
)
TO FILEGROUP FG1;
b) Using the Interface
We can create the filegroup in SQLServer 2005 using Interface by following steps,
1. Select the DB and right click -> Properties
2. Select the Filegroup section and add the necessary details and click the add button.
3. Next we will click on the Files section and add a new file and associate this file to the created filegroup
4. Then finally click on the OK button.
Using these two different ways, we can create filegroups in SQLServer.
Getting string from edit text using VC++ Win32 application
case WM_COMMAND:
if(LOWORD(wParam)==IDC_btnStrCmp)
{
int length = GetWindowTextLength(GetDlgItem(hDlg, IDC_EDIT1));
if(length > 0)
{
char* tempChar;
tempChar= (char*)GlobalAlloc(GPTR, length + 1);
GetDlgItemText(hDlg, IDC_EDIT1, LPWSTR(tempChar), length + 1);
MessageBox(NULL,LPWSTR(tempChar),L"test",MB_OK);
}
}
Abstract class in Dot Net
Here is the example which is an abstract class but non abstract method,
using System;
using System.Collections.Generic;
using System.Text;
namespace testWinApp
{
public class AbstractTest:abstTesting
{
}
public abstract class abstTesting
{
public void myAbstract()
{
Console.Write("Abstract Test");
}
}
}
private void button1_Click(object sender, EventArgs e)
{
AbstractTest a = new AbstractTest();
a.myAbstract();
}
Interface in DotNet
using System;
using System.Collections.Generic;
using System.Text;
namespace testWinApp
{
interface ItestInterface1
{
void MyFunctionI1();
}
interface ItestInterface2
{
void MyFunctionI2();
}
public class InterfaceTest : ItestInterface1, ItestInterface2
{
public void MyFunctionI1()
{
Console.Write("Test ItestInterface1");
}
public void MyFunctionI2()
{
Console.Write("Test ItestInterface2");
}
}
}
then in button click event,
private void button1_Click(object sender, EventArgs e)
{
InterfaceTest t = new InterfaceTest();
ItestInterface1 i1 = (ItestInterface1)t;
i1.MyFunctionI1();
ItestInterface2 i2 = (ItestInterface2)t;
i2.MyFunctionI2();
}
Introduction
Hi..Viewers..I wish to all. This is Vinoth. This is where I try to condense everything that you need to know about me into a single page.