Windows Workflow Foundation

Dear Buddies....


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()

Introduction

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

In the database world, partitioning is the horizontal splitting of rows in a table or index defined on a table in separate, smaller logical units. In fact, every table in SQL Server 2005 has at least one partition. You are essentially breaking one table or index up into smaller tables or indexes that act as one table or index. This can greatly increase performance because you are querying several smaller tables rather than one much larger one. The advantages increase when the server has multiple processors, which allow the partitions to be queried in parallel in the same query, and when the partitions are spread across multiple file groups.
Basically partitions help in improving the performance, scalability and managing of the large tables. As the table grows larger and larger the performance in accessing the data is affected, scalability and managing issues arises. With the help of partitioning a table we can achieve a great level of performance and managing of tables.
Let us see in how we can create partitioned tables in detail. The procedure for creating a partitioned table is as follows.
Beginning with this we have to have various filegroups for the database if we need to place the partitioned tables on different filegroups. We already discussed how to filegroups created in the last post.
1. Creation of Partition Function.
When a table is partitioned, it is broken horizontally into smaller table partitions that are used together to assimilate the whole table. To do this, SQL Server has to know how to break the table into smaller parts. This is where a Partition Function comes into play. A Partition Function is the logic that maps the rows of a table or index into predefined partitions based on the values in a field of data.
The partition function is created for setting the range partitions. The ranges can be set for a lower or upper threshold. The syntax is as follows
CREATE PARTITION FUNCTION ()
AS
RANGE LEFT/RIGHT FOR VALUES (,,…)
RANGE LEFT: Specifies that partition values will be less than or equal to the values defined in the Partition Function.
RANGE RIGHT: Specifies that partition values will be less than the values defined in the Partition Function.
For Example,

CREATE PARTITION FUNCTION [testPartition](int) AS RANGE LEFT
FOR VALUES (1000, 2000, 3000)
This creates a partitions function with ranges for an integer column having thresholds 1000, 2000, 3000. So this indicates there would be three partitions where first partition would be less than equal to 1000, the second between 1001 and less than equal to 2000, the third one between 2001 and less than equal to 3000.
2. Creation of Partition Scheme
You tell SQL Server how to horizontally split a table with a Partition Function. You also need to indicate how the partitions will be stored in the database. In SQL Server 2005, you map a table partition to a filegroup, which is basically a logic grouping that the database uses to store its data files and transaction log files. Every database has at least one filegroup named the Primary filegroup and additional filegroups for administrative and performance purposes. In a Partition Scheme, you can define that all partitions are mapped to the same filegroup, or you can use the scheme to split up the partitions across filegroups. The advantage is that, when the filegroups are split across individual disks, SQL Server will be better equipped to use resources when retrieving data. This advantage becomes even greater when you are running queries against the partitioned tables on a server with multiple processors.
The syntax for creating Partition scheme,
CREATE PARTITION SCHEME
AS
PARTITION
TO (,,….)
For Example,

CREATE PARTITION SCHEME [testPartitionScheme] AS PARTITION [testPartition]
ALL TO ([PRIMARY])
3. Creation of Partition Table
The next step is to create the partitioned table which would be associated with the defined partition scheme
Example partition table for the above partition scheme as follows,

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
Hence using the above 3 steps, we can create the partitioned table.
I’m going to make sure the partitions are working correctly by running some queries on the data.
The following querry will return all partitions that are mapped to the customer table ,

SELECT * From sys.partitions
WHERE OBJECT_NAME(object_id) = 'customer'
The following query returns all rows from the customer table,
SELECT $partition.[testPartition](Id), *
FROM customer
Query for the data from a particular partition,
SELECT * FROM customer WHERE $PARTITION.[testPartition](Id)=2
Query for Knowing the Partition Number,
SELECT $PARTITION.[testPartition](1654)
Query for find the count of records in each partition,

SELECT $PARTITION.[testPartition](Id) AS Partition, COUNT(*) AS [COUNT] FROM customer GROUP BY $PARTITION.[testPartition](Id)ORDER BY Partition ;
The partitions can be split by splitting the partition ranges. The splitting is done by using the alter partition command. We have to note that before we split the partition there should be a additional filegroup already associated in the partition scheme. If there is no unused filegroup available then we cannot split. So before splitting we have to ensure that a filegroup is added to the partition scheme. This is as shown below
Query for splitting partition,
ALTER PARTITION FUNCTION testPartition() SPLIT RANGE(75)
This would create a new partition range between >75 and less than equal to 1000.
Merging of Partition,
The partitions can be merged by merging the partition ranges. The partition range value mentioned will merge that to the next greater partition range value into a singe partition. This is as shown below.
Query for merging partition,

ALTER PARTITION FUNCTION testPartition() MERGE RANGE(2000)
This returns a new merged partitions for 2000 and 75 . So now there would be only 75, 1000, 2001 as the new range values for partitions

Creation of FileGroups in SQLServer 2005

We have to have various file groups for the database if we need to place the partitioned tables on different filegroups.

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 ADD FILEGROUP

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 = , FILENAME = , SIZE = , MAXSIZE = , FILEGROWTH =
)
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

Use the following code for getting the value from edit text in VC++ using 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

Abstract keyword can be used with both classes and methods in C#. We can’t initialize the Abstract classes. But another class can inherit from an Abstract class and can create their instances.

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

An interface is a reference type object with no implementation. To make our code more reusable, we can provide interfaces to our implementation. Here I have written a sample code for Interface in DotNet using C#.


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.

Personality
I love thinking really abstractly and solving puzzles but I'd rather not be bothered with troublesome details and I'll happily let someone else actually implement my ideas. I can't stand crowds and am very uncomfortable in large groups of unfamiliar people.

Physical
Tall (185.5cm [over 6 ft.]) thin (56kg) Black eyes and dark hair.

Habits
I 'm a vegetarian and also non vegetarian. Although I also love to try strange new foods whenever the opportunity arises.

Education
In May of 2006 I finished MCA at Bharathidasan University, Trichirappalli.

Professional
Now I started to working with DotNet as a Programmer. Every day I learn something new, but I also find that many of the lessons from the past still apply

Interests
I'm passionate about a great many things and continually learning about the things that interest me. They are wearable computers, User Interface Design, Artificial life, Industrial music.