Skip to content

Manas Bhardwaj's Stream Posts

Problem with Wireless Adapter or Access Point

After moving to a new Network Provider and of course to new Modem/Wireless Adapter (HUAWEI-HG655d), I could connect all my devices except my Windows 7 laptop.
I repeatedly received error stating that connection was not successful. After some more steps with Windows Help and Diagnostics, Windows finally said:
‘Problem with Wireless Adapter or Access Point’
Now, I was like WOW. What an explanation :). Did some googling but wasn’t getting anyway near to it. So decided to call the help desk from Though, I am usually not very optimistic of getting any help from help desks; this guy was just on spot. He asked to change the following settings and it now works like Charm 🙂
Mode: 802.11b/g/n -> 802.11b/g
WPA encryption:   AES -> TKIP/AES

An introduction to SharePoint 2010 workflows


SharePoint 2010 introduces many new capabilities that are categorized into six different workloads, one of which is the composites workload. A key component of creating composite applications is SharePoint 2010’s ability to create custom workflows, allowing end users to attach behaviour to data.

Workflows in SharePoint Server 2010 enable enterprises to reduce the amount of unnecessary interactions between people as they perform business processes. For example, to reach a decision, groups typically follow a series of steps. The steps can be a formal, standard operating procedure, or an informal implicitly understood way to operate. Collectively, the steps represent a business process. The number of human interactions that occur in business processes can inhibit speed and the quality of decisions.

Workflow in SharePoint 2010

SharePoint Foundation 2010 workflows are made available to end-users at the list or document-library level. Workflows can be added to documents or list items. Workflow can also be added to content types. Multiple workflows may be available for a given item. Multiple workflows can run simultaneously on the same item, but only one instance of a specific workflow can run on a specific item at any given time. For example, you might have two workflows, called SpecReview and LegalReview, available for a specific content type, Specification. Although both workflows can run simultaneously on a specific item of the Specification content type, you cannot have two instances of the LegalReview workflow running on the same item at the same time.

The figure below illustrates the conceptual workflow architecture in SharePoint Foundation. Each content type, list, and document library in the farm is linked to the workflows added to it through the workflow association table. Each workflow has a workflow definition. This XML definition specifies the identity of the actual workflow assembly, and class within that assembly, as well as the location of any workflow forms the workflow needs to run.


Share point workflow Life Cycle

Fig. below illustrates the four stages of the SharePoint workflow life cycle. These stages allow for the assignment of workflows to content type, handle the different ways for starting workflows, and keep the workflow infrastructure flexible during execution. This custom life cycle is provided by the SharePoint-specific workflow hosting environment. During some of the following stages, forms can be used to gather additional user input as parameters, which are required for this stage to execute.


Workflow Solution Spectrum



 ‘Out of the box’ Workflows

SharePoint 2010 Standard and Enterprise include a selection of ‘out of the box’ workflows.  These tools help you automate the most common business tasks – sharing and collecting feedback on documents.

Workflow Types

Windows Workflow Foundation supports two fundamental workflow styles. You can create workflows of either type for Microsoft SharePoint Foundation 2010.

Sequential Workflows

A sequential workflow represents a workflow as a procession of steps that execute in order until the last activity completes. However, sequential workflows are not purely sequential in their execution. Because they can receive external events, and include parallel logic flows, the exact order of activity execution can vary somewhat.


State machine workflow

A state machine workflow represents a set of states, transitions, and actions. One state is denoted as the start state, and then, based on an event, a transition can be made to another state. The state machine can have a final state that determines the end of the workflow.

In the state machine style of workflow authoring, the author models the workflow as a state machine. The workflow itself consists of a set of states. One state is denoted as a start state. Each state can receive a certain set of events. Based on an event, a transition can be made to another state. The state machine workflow can have a final state. When a transition is made to the final state, the workflow is completed.

The following flowchart is an example of a state machine workflow.



Workflows Development Tools

Workflows for SharePoint can be designed in Visio and/or developed using Share point designer or visual studio.

Schematic diagram of the tools available for developing SharePoint workflows is as follows:


Designing workflows

It is also possible to design the share point workflows using Microsoft Visio and export it to share point designer for further development.

Points to consider:

  1. Only design of the workflow is possible (the business logic conditions need to be filled in later after importing to share point designer)
  2. Microsoft Visio Premium or higher is required to design the share point workflows

Developing SharePoint workflows

Share point workflows can be developed in SharePoint designer or visual studio.

Points to consider:

  1. Workflows created in Share point Designer can be exported and imported to visual studio but the other way around is not possible
  2. If input is needed for workflows, the forms for input can be done either using InfoPath or custom page.
  3. Custom workflow activities can be developed in visual studio and can be used in share point designer along with the other built-in activities to create workflows.


Share point designer activities reference:

Custom activities:


Workflows authored with SharePoint Designer 2010 can run in a protected environment called the sandbox where they cannot put the farm in danger; workflows generated with Visual Studio must run in the farm mode, but not in a sandbox environment.



Workflow versioning is a very important technique. When a workflow goes idle, the state of the workflow is and saved (hydrated) into the database. This saving of a workflow’s state is called hydration. When the workflow resumes, the state is dehydrated out of the database and the workflow starts processing again. Versioning is important because if you change the assembly while the workflow is hydrated (saved in the database), there’s no guarantee that when the workflow dehydrated it will match the construct of the new assembly. If it doesn’t match the construct upon de-serialization, the workflow will break. Changes like adding or removing activities and changing property values may necessitate a new workflow version. The best practice is to create a new version every time rather than just push the assembly and cross your fingers.


Delete Similar Databases


I had these similar databases on my dev environment which I had to delete multiple times during development. As this process was becoming more and more mechanical, I wanted to have a script which would do this for me.

Using the code

Below is the script which looks for the database(s) with name pattern and deletes them. I use the @DatabaseSearch variable to look for the databases with similar names.


[codesyntax lang=”sql”]


DECLARE @DatabaseSearch nvarchar(48)
DECLARE @Sql nvarchar(max)

SET @DatabaseSearch = 'DeleteDatabasesLikeThis%'

DECLARE @DatabaseName nvarchar(48)

[Name] AS [DatabaseName]
INTO #Databases
FROM sys.databases
[Name] LIKE @DatabaseSearch

DECLARE DBNameCursor CURSOR FOR SELECT DatabaseName FROM #Databases
OPEN DBNameCursor
FETCH NEXT FROM DBNameCursor INTO @DatabaseName
SET @Sql =
@DatabaseName +
'DROP DATABASE [' + @DatabaseName +'];'


FETCH NEXT FROM DBNameCursor INTO @DatabaseName
CLOSE DBNameCursor

DROP TABLE #Databases



Extracting Table Data from Word Document using Aspose Words

For one my projects, I had a requirement where the data from word documents had to be extracted and exported to a database. The biggest challenge was that I had to support the existing word documents. Basically, there were thousands of word documents of same format which had chunks of data. This document format was never designed to be read by another system. This means, no bookmarks, merge fields, styles to identify the actual data from the standard instructions etc.Luckily, for our rescue all the input fields were in the table. But these tables were again of different formats, some with single row/cell and some with varying number.

I use Aspose Words extensively for creating and manipulating word documents. And considering the expertise I had with the component, I decided to go with it. To solve the issue, I created a similar table model in C# so that I can use it later on while reading the documents.

Below, you can see I created a class called WordDocumentTable with three properties i.e. TableID, RowID and ColumnID. As I explained earlier that we had no support for TableID/RowIDs, these properties simply imply the position in the word document. The start index is assumed to be 0.

public class WordDocumentTable
	public WordDocumentTable(int TableID) 
		TableID = TableID; 

	public WordDocumentTable(int TableID, int ColumnID) 
		TableID = TableID;  
		ColumnID = ColumnID; 

	public WordDocumentTable(int TableID, int ColumnID, int RowID) 
		TableID = TableID;  
		ColumnID = ColumnID;  
		RowID = RowID; 

	private int TableID = 0;

	public int TableID 
		get { return TableID; }  
		set { TableID = value; } 

	private int RowID = 0;    
	public int RowID 
		get { return RowID; }  
		set { RowID = value; } 

	private int ColumnID = 0;    
	public int ColumnID 
		get { return ColumnID; }  
		set { ColumnID = value; } 


Now comes the extraction part. Below, you will see the collection of table cells which I want to read from the document.

private List<WordDocumentTable> WordDocumentTables
		List<WordDocumentTable> wordDocTable = new List<WordDocumentTable>();      
		//Reads the data from the first Table of the document.    
		wordDocTable.Add(new WordDocumentTable(0));      
		//Reads the data from the second table and its second column. This table has only one row .    
		wordDocTable.Add(new WordDocumentTable(1, 1));      
		//Reads the data from third table, second row and second cell.    
		wordDocTable.Add(new WordDocumentTable(2, 1, 1));  
		return wordDocTable;  

Below is the method which extract the data from Aspose Word Document based on the Table, Row and Cell.

public void ExtractTableData(byte[] PobjData)
	using (MemoryStream Stream = new MemoryStream(PobjData)) 
		Document AsposeDocument = new Document(Stream);     
		foreach(WordDocumentTable wordDocTable in WordDocumentTables)  
			Aspose.Words.Tables.Table table = (Aspose.Words.Tables.Table)AsposeDocument.GetChild(NodeType.Table, wordDocTable.TableID, true);   
			string cellData = table.Range.Text;

			if (wordDocTable.ColumnID > 0)   
				if (wordDocTable.RowID == 0)    
					NodeCollection Cells = table.GetChildNodes(NodeType.Cell, true);     
					cellData = Cells[wordDocTable.ColumnID].ToTxt();
					NodeCollection Rows = table.GetChildNodes(NodeType.Row, true);     
					cellData = ((Row)(Rows[wordDocTable.RowID])).Cells[wordDocTable.ColumnID].ToTxt();    

			Console.WriteLine(String.Format("Data in Table {0}, Row {1}, Column {2} : {3}",           

How to get column values as comma separated string in SQL

Ever wondered that how to get a comma (pipe or whatever) separated result for a column in a table in SQL Server?

The following statement show a simple example you can take as a starting point.

Select (Stuff((Select ', ' + FName From Accounts FOR XML PATH('')),1,2,''))

Update: Elina Blank suggested an alternative to the approach above on my CodeProject Tip. Thanks Elina 🙂

Have a look at alternative here at CodeProject.