Apply new Master Page to existing My Sites in MS SharePoint 2010
Scenario:
SitesList.txt
http://mysites.inetaPakistan.org/personal/saqib_ilyas http://mysites.inetaPakistan.org/personal/hammad_rajjoub http://mysites.inetaPakistan.org/personal/adnan_hashmi
- The PROD farm in your organization has dozens, possibly hundreds, of user My Sites in existence.
- All My Sites use custom branding designed by your graphics department.
- The graphics department comes up with a new branding for the My Sites to reflect a change in the organization's strategic focus.
- A re-designed master page with the new branding (mysiteRedesigned.master) needs to be applied to ALL existing My Sites without re-provisioning them.
- Create a folder where you will be copying some files in the subsequent steps. (The script assumes that the folder is C:\temp)
- Create a text file in that folder called SitesList.txt
- On each separate line inside the SitesList.txt file, enter each of the My Site Urls that you want to apply the master page change to. (These are all the My Sites that already exist. You can get a list by going to Central Administration > View Al Site Collections)
- Drop the new/updated Master Page file in the folder you created in Step 1, i.e. C:\temp
- Run SharePoint 2010 Management Shell, and paste the following code in the PowerShell window.
$SourceFilePath = "C:\temp\SitesList.txt"
$SiteList = Get-Content $SourceFilePath
foreach ($SiteUrl in $SiteList) {
write-host "Applying master page to Url", $SiteUrl
$site=Get-SpSite $SiteUrl
$web=$site.RootWeb
$masterPageSrc = "C:\temp\mysiteRedesigned.master"
$masterPageDest = $web.GetFolder("Master Page Gallery")
Get-ChildItem $masterPageSrc | foreach {
$stream = [IO.File]::OpenRead($_.FullName)
$destUrl = $web.Url + "/_catalogs/masterpage/" + $_.Name.Replace(" ","")
$resultingfile = $masterPageDest.files.Add($destUrl, $stream, $true)
$stream.close()
}
$masterUrl = New-Object System.Uri($destUrl)
$web.MasterUrl = $masterUrl.AbsolutePath
$web.CustomMasterUrl = $masterUrl.AbsolutePath
$web.Update()
$web.Dispose()
$site.Dispose()
write-host "Done"
}
The accompanying SiteList.txt file should list each My Site Url to apply fix to.
SitesList.txt
http://mysites.inetaPakistan.org/personal/saqib_ilyas http://mysites.inetaPakistan.org/personal/hammad_rajjoub http://mysites.inetaPakistan.org/personal/adnan_hashmi

MOSS 2007 Workflow Forms: Everything you ever wanted to know but were afraid to ask (Part I)
Background
What differentiates a workflow from a typical process written in code is the ability of multiple actors (human or otherwise) to interact with the long-running workflow process during the course of execution. This allows the executing process to behave in a manner that external actors want it to, as opposed to just performing a sequence of operations along a single pre-defined path. The rule-of-thumb while choosing between Sequential and State-Machine Workflows is based on a simple premise based on the scenario for which the workflow is being created:
Developing a State-Machine workflow in Visual Studio 2005
Read the following posts to learn how to develop a state-machine workflow in VS 2005.
Apart from the workflow code file (*.cs and/or *.xoml), the workflow project should include the following files:
The life-cycle of a workflow involves the following stages:
Having got the above off my chest, lets delve into how users (workflow actors) interact with the workflow.
Workflow Forms
Workflows Forms (as the name implies) are typical forms that allow user input to be communicated to the workflow. In addition, workflow forms also allow data within the workflow to be presented to the actor so that they can take appropriate action. The 4 types of workflow forms that can be created are:
In my next post, I will cover how to develop each of the Workflow forms in a state-machine workflow using both ASP.NET and Microsoft InfoPath 2007.
What differentiates a workflow from a typical process written in code is the ability of multiple actors (human or otherwise) to interact with the long-running workflow process during the course of execution. This allows the executing process to behave in a manner that external actors want it to, as opposed to just performing a sequence of operations along a single pre-defined path. The rule-of-thumb while choosing between Sequential and State-Machine Workflows is based on a simple premise based on the scenario for which the workflow is being created:
- Sequential Workflow: Use when a pre-defined sequence of activities need to be executed, involving no external input, and the only repetitive activity executions are through loops.
- State-Machine Workflow: Use when external actors are involved, causing the workflow to stop and wait for input from the actor. Also use if the same activity needs to be executed multiple times based on a user-input or external event during the course of workflow execution.
Note: You can choose to use a Sequential workflow even when external actor interaction is involved. However, this will not allow you to jump to another activity, other than the one next in the sequence.
Developing a State-Machine workflow in Visual Studio 2005
Read the following posts to learn how to develop a state-machine workflow in VS 2005.
- Creating a MOSS state machine workflow - Part 1 of 4 : Concepts and planning
- Creating a MOSS state machine workflow - Part 2 of 4: Creating InfoPath forms
- Creating a MOSS state machine workflow - Part 3 of 4 : workflow development
- Creating a MOSS State Machine Workflow - Part 4 of 4: Workflow Deployment
Apart from the workflow code file (*.cs and/or *.xoml), the workflow project should include the following files:
- feature.xml (Contains information about the SharePoint feature)
- workflow.xml (Specifies the workflow properties for the SharePoint feature)
- PostBuildActions.bat (A batch file executed as a Post-build event inside Visual Studio that creates a sub-folder in the 'FEATURES' directory under 12 hive [C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE] and copies feature.xml and workflow.xml files into it; also executes the
stsadmcommand to activate the deployed feature on a SharePoint site)
Note: You can avoid creating the PostBuildActions.bat file if you use WSPBuilder to generate a SharePoint solution file (*.wsp) and deploy it from within the VS2005 environment.
The life-cycle of a workflow involves the following stages:
- Development: Visually creating the workflow in VS2005/VS2008 Workflow Designer and writing code for each activity. Also includes creating workflow.xml, feature.xml, and PostBuildActions.bat
- Deployment: Deploying the workflow to a SharePoint Server farm and activating it either using the PostBuildActions.bat batch file or using WSPBuilder. In either case, a new folder is created in the FEATURES directory (explained above), the workflow.xml & feature.xml files are copied to it, the workflow assembly (*.dll) is installed into the GAC or copied to the Virtual Directory's bin folder, and the stsadm command is used to activate the feature
- Association: Attaching the workflow to a list or content type and specifying when a new workflow instance should kick-off; either manually, OR automatically when a new item is created and/or updated.
- Execution:This stage involves the following sub-stages
- Initiation: This is the first stage for any workflow instance, happens ONLY once during the course of execution, and is marked by firing of the OnWorkflowActivated event.
- Passivation or De-hydration: This is the process of persisting the workflow instance to a datastore so that it can subsequently re-loaded into memory for further execution. Also, passivation or dehydration occurs when the workflow instance wants to wait for an external input or event to execute further.
- Re-hydration: This stage involves the workflow instance being loaded back into memory by the workflow engine, after a user input is received OR an external event fires.
- Activity Execution: This is characterized by the workflow engine executing the code in each of the workflow activities in the defined sequence, or transitioning states in case of a state-machine workflow.
- Modification: This stage is optional, but it allows workflow actors to inject new values into the workflow instance while it is in execution to alter its behavior. This also entails that the workflow has the logic built into it to process the new values.
- Completion: The competion stage is marked by the workflow instance completing execution successfully, and the status being written to the data store.
- Termination: This stage refers to the workflow instance stopping abruptly due to an internal error, or an actor explicitly ending the workflow instance. Any data written to the list by the workflow instance is NOT rolled-back if the workflow is terminated. Terminated workflows cannot be restarted again.
Having got the above off my chest, lets delve into how users (workflow actors) interact with the workflow.
Workflow Forms
Workflows Forms (as the name implies) are typical forms that allow user input to be communicated to the workflow. In addition, workflow forms also allow data within the workflow to be presented to the actor so that they can take appropriate action. The 4 types of workflow forms that can be created are:
- Association Forms: Displayed to the user at the time the workflow is being associated to a list or content type to allow user to enter any additional values that can be used in the workflow association process.
- Initiation Forms: When the users initiates a workflow instance, the Initiation Form is displayed to allow entry of additional parameter values that the workflow instance can process during execution.
- Modification Forms: Modofication forms are displayed either when the workflow instance encounters the EnableWorkflowModification activity, OR the user clicks the Modification link on the workflow status page.
- Task Forms: During execution, a workflow creates tasks in the Tasks List that tell the user what they need to do, and in most cases, move the workflow forward when a task is marked as complete. From the users' perspective, tasks enable them to know where the workflow stands, and what needs to be done to get to the next process in the flow sequence.
In my next post, I will cover how to develop each of the Workflow forms in a state-machine workflow using both ASP.NET and Microsoft InfoPath 2007.

Creating State Machine Workflows using SharePoint Designer 2007: Addendum
In my previous post, I gave an overview of how to mimic State Machine behavior using sequential workflows developed in SharePoint Designer (SPD) 2007. This post is actually a walk-thru of the development process in SPD 2007.
Create Lists
Create the following 2 lists (See description in previous post cited above):
Create 'Approval Initiation Workflow' on the 'Core.NET Content' list
Open an instance of SharePoint Designer 2007 on your machine. Go to File > Open Site... and enter the URL for the site you created the lists on.
Go to File > New... > Workflow..., enter Approval Initiation Workflow as the name of the workflow, and select Core.NET Content from the drop down list. Make sure that only the second checkbox (Automatically start this workflow when a new item is created) is checked, and click Next
.

Create workflow action to insert an item into the second list
Enter Initiate Approval process for uploaded content as the Step Name. Click the Actions dropdown button and select Create List Item
from the dropdown. Click the this list link on the action, select the Core.NET Approval Workflows list from the drop down at the top of the 'Create New List Item' dialog, and specify the values for each of the columns as shown below:
Click the Finish button to publish the workflow.

The above step simply takes values from the document library (Core.NET Content) and inserts into the Core.NET Approval Workflows list. We now turn our focus to the other list, and the second workflow.
Create 'Approval Process Workflow' on the 'Core.NET Approval Workflows' list
Create the workflow as below; enter Approval Process Workflow as the name of the workflow, and select 'Core.NET Approval Workflows' list from the drop-down. Make usre that the last 2 checkboxes (Automatically start this workflow when a new item is created + Automatically start this workflow whenever an item is changed) are checked.
Create Variables for the workflow
Click the Variables... button in the Workflow Designer window, and create variables as below:

The 'Approval Process Workflow' will consist of the following 3 steps:
Note: By updating the list in the very last step, the subsequent instance of the workflow (started on item update) can kick off immediately. If the current workflow updates the list while it still has some more activities to perform, the second workflow fails.
An explanation of each of the step follows:
Step 0: Terminate Workflow if already approved
This step is optional, hence I did not include it in the above list of steps. It simply checks to see if the item has already been approved, and if it is, terminates the workflow using the Stop Workflow activity.

Step 1: Get Workflow Data
This step simply intializes the values of the variables and comprises the following 2 steps:

Step 2: Process Workflow Status
This step relies on IF condition activities to process the workflow according to the Workflow Status for that particular instance of the workflow.

Refer to the diagram above; starting from the top

Note: You can get the user input for a 'Collect Data from a User' action by simply referencing the column of the Tasks list named after that specific input you specified in the 'Custom Task Wizard' dialog.

Step 3: Process Approval/Rejection by Manager
This step was included since its not possible to have a nested IF statement in the Actions sections of a step.

Either one of the conditions can only be true if and only if the workflow status is Awaiting Approval. If the Manager APPROVED the document, the NewStatus variable is set to Approved, if the Manager REJECTED the content document, the NewStatus variable is set to Pending Analysis & Review, sending the workflow back to the Analyst specified by the Repository Manager.
Step 4: Update Workflow Status
This step MUST execute at the very end, to allow the successful termination of the current workflow instance and initiation of the subsequent workflow instance. Also, the UpdateStatus variable was explicitly set to 'No' at the very start of the workflow instance, and unless a step hasn't set it to 'Yes', the update action in this step will not execute.

This step updates the 'Workflow Status' column
to the value in the NewStatus variable, and the 'Content Analyst' column to the value in the ContentAnalyst variable (shown below).

Create Lists
Create the following 2 lists (See description in previous post cited above):
- Core.NET Content (Document Library)
- Core.NET Approval Workflows (Custom List with following columns)
- Title: Single line of text
- File URL: Hyperlink or Picture
- Workflow Status: Choice (with following choice values)
- Content Analyst: User
- Awaiting Approval
- Pending Analysis & Review
- Awaiting Approval
- Approved
Create 'Approval Initiation Workflow' on the 'Core.NET Content' list
Open an instance of SharePoint Designer 2007 on your machine. Go to File > Open Site... and enter the URL for the site you created the lists on.
Go to File > New... > Workflow..., enter Approval Initiation Workflow as the name of the workflow, and select Core.NET Content from the drop down list. Make sure that only the second checkbox (Automatically start this workflow when a new item is created) is checked, and click Next
.

Create workflow action to insert an item into the second list
Enter Initiate Approval process for uploaded content as the Step Name. Click the Actions dropdown button and select Create List Item
from the dropdown. Click the this list link on the action, select the Core.NET Approval Workflows list from the drop down at the top of the 'Create New List Item' dialog, and specify the values for each of the columns as shown below:
- Title = Core.NET Content:Name
- File URL = Core.NET Content:URL Path
- Workflow Status = Awaiting Assignment
Click the Finish button to publish the workflow.

The above step simply takes values from the document library (Core.NET Content) and inserts into the Core.NET Approval Workflows list. We now turn our focus to the other list, and the second workflow.
Create 'Approval Process Workflow' on the 'Core.NET Approval Workflows' list
Create the workflow as below; enter Approval Process Workflow as the name of the workflow, and select 'Core.NET Approval Workflows' list from the drop-down. Make usre that the last 2 checkboxes (Automatically start this workflow when a new item is created + Automatically start this workflow whenever an item is changed) are checked.
Create Variables for the workflow
Click the Variables... button in the Workflow Designer window, and create variables as below:

The 'Approval Process Workflow' will consist of the following 3 steps:
- Get Workflow Data
- Process Workflow Status
- Process Approval/Rejection by Manager
- Update Workflow Status
Note: By updating the list in the very last step, the subsequent instance of the workflow (started on item update) can kick off immediately. If the current workflow updates the list while it still has some more activities to perform, the second workflow fails.
An explanation of each of the step follows:
Step 0: Terminate Workflow if already approved
This step is optional, hence I did not include it in the above list of steps. It simply checks to see if the item has already been approved, and if it is, terminates the workflow using the Stop Workflow activity.

Step 1: Get Workflow Data
This step simply intializes the values of the variables and comprises the following 2 steps:
- Set the ContentAnalyst variable to the value of the Content Analyst column in the Current item. (This value will be empty when the first instance executes)
- Initialize the UpdateStatus variable to 'No'.

Step 2: Process Workflow Status
This step relies on IF condition activities to process the workflow according to the Workflow Status for that particular instance of the workflow.

Refer to the diagram above; starting from the top
- The first time the workflow executes, the status is set to Awaiting Assignment, causing ONLY the Actions for the first Condition to execute. The action themselves are pretty straight-forward and self-explanatory.
- The second condition (where status equals 'Pending Analysis & Review') may be true a number of times, depending on the number of times the manager rejects the document.
Just like the second condition, this may be true multiple times depending on the number of times the workflow was submitted to the manager for approval.- Alternatively, you can also add a condition here to check if the workflow status is set if 'Approved', and terminate the workflow (as shown below).

Note: You can get the user input for a 'Collect Data from a User' action by simply referencing the column of the Tasks list named after that specific input you specified in the 'Custom Task Wizard' dialog.

Step 3: Process Approval/Rejection by Manager
This step was included since its not possible to have a nested IF statement in the Actions sections of a step.

Either one of the conditions can only be true if and only if the workflow status is Awaiting Approval. If the Manager APPROVED the document, the NewStatus variable is set to Approved, if the Manager REJECTED the content document, the NewStatus variable is set to Pending Analysis & Review, sending the workflow back to the Analyst specified by the Repository Manager.
Step 4: Update Workflow Status
This step MUST execute at the very end, to allow the successful termination of the current workflow instance and initiation of the subsequent workflow instance. Also, the UpdateStatus variable was explicitly set to 'No' at the very start of the workflow instance, and unless a step hasn't set it to 'Yes', the update action in this step will not execute.

This step updates the 'Workflow Status' column
to the value in the NewStatus variable, and the 'Content Analyst' column to the value in the ContentAnalyst variable (shown below).

Monday, April 14, 2008
Posted by Adnan Farooq Hashmi
Creating State Machine Workflows using SharePoint Designer 2007
NOTE: This is a workaround to mimic state-machine behavior from a sequential workflow developed using SharePoint Designer 2007.
To get up to speed with developing SharePoint workflows using Visual Studio 2005, watch the HOWTO: Series of SharePoint Workflow HOW-TO Videos by Robert Shelton.
Sequential workflows are fairly straight forward to create whether you are developing in Visual Studio (VS) or SharePoint Designer (SPD) 2007 and can be used to model most single or multi-step approval workflows. The only downside to Sequential workflows is that you cannot make the workflow jump back to a previous step/activity that may or may not have already executed or, in other words, cannot move from being in one state to the other like a state machine workflow. For most workflow developers/creators, this is reason enough to go for workflow development in VS. While VS worksflows work just the same as those develped using SPD 2007, keep in mind that SPD 2007 is more suited for managers and/or business analysts (non-developers) who may be reluctant to assign workflow development task because of time, resource, and budgetary constraints. This is where the following intuitive solution may come in handy. Lets look at a hypothetical scenario in detail.
Scenario:
A technical document needs to be analyzed, revised (if need be), and approved to exist in the repository.
Actors:

Workflow (see state-machine diagram above):
The above workflow is pretty straight-forward, and could easily have been created using SharePoint Designer if it were not for step 4, which can happen any number of times until the document gets approved by the Manager. To create a State Machine behavior in a SPD 2007 workflow, create a separate list (say "Content Approval Workflows") to maintain the state of the workflow at any given point in time. A separate list also ensures that the user cannot go and manually change the status. Also, 2 workflows would need to be created; one on the actual document library (called "Core.NET Content") that houses the uploaded documents, and the other on the Content Approval Workflows list. The 2 lists we are working with are summarized below:
Core.NET Content
List Type: Document Library
Workflow Name: Approval Initiation Workflow
Workflow Executed: On Item creation
Core.NET Approval Workflows
List Type: Custom List
Workflow Name: Approval Processing Workflow
Workflow Executed: On Item creation
; On Item update
Columns: Title, Document Status (Choice Column with each of the workflow states), WorkflowInstance Id (Lookup column that references ID column in the Core.NET Content document library)
To get an even better idea, take a look at the following diagram.

The steps modeled in the diagram above are:
Note: The IF condition on every step ensures that the workflow takes only one path depending on the value for Document Status. Also, using the "Collect Feedback" activity in SPD 2007 ensures that the workflow stay in the wait state until the actor specifies the required input, and clicks the "Complete Task" button.
[UPDATE: Read the process of creating the State-machine workflow using SharePoint Designer 2007 in the following post here]
To get up to speed with developing SharePoint workflows using Visual Studio 2005, watch the HOWTO: Series of SharePoint Workflow HOW-TO Videos by Robert Shelton.
Sequential workflows are fairly straight forward to create whether you are developing in Visual Studio (VS) or SharePoint Designer (SPD) 2007 and can be used to model most single or multi-step approval workflows. The only downside to Sequential workflows is that you cannot make the workflow jump back to a previous step/activity that may or may not have already executed or, in other words, cannot move from being in one state to the other like a state machine workflow. For most workflow developers/creators, this is reason enough to go for workflow development in VS. While VS worksflows work just the same as those develped using SPD 2007, keep in mind that SPD 2007 is more suited for managers and/or business analysts (non-developers) who may be reluctant to assign workflow development task because of time, resource, and budgetary constraints. This is where the following intuitive solution may come in handy. Lets look at a hypothetical scenario in detail.
Scenario:
A technical document needs to be analyzed, revised (if need be), and approved to exist in the repository.
Actors:
- Repository Managers
- Content Analysts
- Managers

Workflow (see state-machine diagram above):
- Document Uploaded to MOSS 2007 Document Library. [Document Status updated to Awaiting Assignment]
- Repository Manager assigns document to Content Analyst. [Document Status updated to Pending Analysis & Review]
- Analyst views documents, makes required changes, and submits document to Manager for approval. [Document Status updated to Awaiting Approval]
- If Manager rejects document, document routed to Content Analyst. [Document Status updated to Pending Analysis & Review]
- If Manager approves document, it is kept in the document library. [Document Status updated to Approved]
The above workflow is pretty straight-forward, and could easily have been created using SharePoint Designer if it were not for step 4, which can happen any number of times until the document gets approved by the Manager. To create a State Machine behavior in a SPD 2007 workflow, create a separate list (say "Content Approval Workflows") to maintain the state of the workflow at any given point in time. A separate list also ensures that the user cannot go and manually change the status. Also, 2 workflows would need to be created; one on the actual document library (called "Core.NET Content") that houses the uploaded documents, and the other on the Content Approval Workflows list. The 2 lists we are working with are summarized below:
Core.NET Content
List Type: Document Library
Workflow Name: Approval Initiation Workflow
Workflow Executed: On Item creation
Core.NET Approval Workflows
List Type: Custom List
Workflow Name: Approval Processing Workflow
Workflow Executed: On Item creation
; On Item update
Columns: Title, Document Status (Choice Column with each of the workflow states), WorkflowInstance Id (Lookup column that references ID column in the Core.NET Content document library)
To get an even better idea, take a look at the following diagram.

The steps modeled in the diagram above are:
- Document uploaded to Core.NET Content Document Library.
- Item creation in Core.NET Content Document Library kicks off Approval Initiation Workflow which creates an item in the Content Approval Workflows list (with the Document Status value set to "Awaiting Assignment") and completes.
- Creation of item in Content Approval Workflows list kicks off the Approval Processing Workflow that performs the following operations recursively i.e. completion of every step below updates the Document Status column value and in-turn starts another Approval Processing Workflow instance on the same item.
- Start on item creation - If Document Status is "Awaiting Assignment", create a task in the Tasks list for Repository Managers, using the "Collect Feedback from user" activity, assign the task to the username entered in the task, and set the Document Status value to "Pending Analysis & Review".
- Start on item update - If Document Status is "Pending Analysis & Review", create a task in the Tasks list for the user in the Content Analysts group who was assigned the Analysis & Review task in the preceding step, using the "Collect Feedback from user" activity, and set the Document Status value to "Awaiting Approval" when the user clicks the "Complete Task" button.
- Start on item update - If Document Status is "Awaiting Approval", create an approval task in the Tasks list for Managers using the "Collect Feedback from user" activity, to either approve or reject the document. If Manager approves the document, set the Document Status value to "Approved", else set the Document Status value to "Pending Review & Analysis" which re-starts the workflow from step 3-2.
Note: The IF condition on every step ensures that the workflow takes only one path depending on the value for Document Status. Also, using the "Collect Feedback" activity in SPD 2007 ensures that the workflow stay in the wait state until the actor specifies the required input, and clicks the "Complete Task" button.
[UPDATE: Read the process of creating the State-machine workflow using SharePoint Designer 2007 in the following post here]
Monday, March 31, 2008
Posted by Adnan Farooq Hashmi
Pakistan Developer Conference 2007
With physical presence at Lahore and Islamabad in addition to Karachi, the Pakistan Developer Conference 2007 would be the biggest annual developer event in the country.

Register now! I hope to see you there in Lahore and Karachi.

Register now! I hope to see you there in Lahore and Karachi.
Sunday, May 13, 2007
Posted by Adnan Farooq Hashmi
A Pal for Web 2.0
I blogged about SitePal a long time ago. I am blogging about it again, since I now have a demo account. This post is more of a strategy guide than a technology roadmap. If you have a Flash player installed (or you are reading this post while the demo account is still valid and active), you will be able to see (and hear) it on the right sidebar of my blog.
The technology news coming out of the World Economic Forum that concluded in Davos, Switzerland not very long ago, was abuzz with talk of Web 2.0. The essence of Web 2.0 are Rich Internet Applications that give users not only a rich user experience, but which may in fact comprise of data and services from many other 3rd party websites and online resouces.
In the Web 2.0 world, businesses increasingly have to rely on setting themselves apart through a mixture of content and design to ensure a continued audience and user-base. While the SitePal you see on the right is just a small demonstration of what websites can achieve using this technology, a SitePal can achieve a lot more for your online service than just playing a welcome message. Apart from its obvious usage on Social Networking sites, a SitePal can be leveraged in teaching students online, and for assisting users on insurance, healthcare, or recruitment wesbites. Imagine a website where students learn chemistry from Harry Potter, physics from Dexter, and computer programming from Jimmy Neutron; OR in a completely different scenario, allowing senior citizens to hear about diabetes, cancer, and health insurance benefits from a doctor SitePal, without having to read long text from a website or printed brochure.
The process of creating a SitePal character is pretty straight forward too. The tutorial movie on the SitePal website provides an easy-to-follow walk-thru of setting up and hosting a SitePal character. An existing SitePal character can be modified literally within seconds. I modified the current SitePal character on this blog within minutes, and amazingly, she looked completely different (see picture below). [Since I am very fond of blondes with glasses, I ended up using the previous version].

SitePal is not just limited to webpages. You can also embed a SitePal character into your PowerPoint presentation, taking interactivity to a whole new level.
Try it out for yourself. Certainly reminds one of S1m0ne (Simone), doesn't it?
The technology news coming out of the World Economic Forum that concluded in Davos, Switzerland not very long ago, was abuzz with talk of Web 2.0. The essence of Web 2.0 are Rich Internet Applications that give users not only a rich user experience, but which may in fact comprise of data and services from many other 3rd party websites and online resouces.
In the Web 2.0 world, businesses increasingly have to rely on setting themselves apart through a mixture of content and design to ensure a continued audience and user-base. While the SitePal you see on the right is just a small demonstration of what websites can achieve using this technology, a SitePal can achieve a lot more for your online service than just playing a welcome message. Apart from its obvious usage on Social Networking sites, a SitePal can be leveraged in teaching students online, and for assisting users on insurance, healthcare, or recruitment wesbites. Imagine a website where students learn chemistry from Harry Potter, physics from Dexter, and computer programming from Jimmy Neutron; OR in a completely different scenario, allowing senior citizens to hear about diabetes, cancer, and health insurance benefits from a doctor SitePal, without having to read long text from a website or printed brochure.
The process of creating a SitePal character is pretty straight forward too. The tutorial movie on the SitePal website provides an easy-to-follow walk-thru of setting up and hosting a SitePal character. An existing SitePal character can be modified literally within seconds. I modified the current SitePal character on this blog within minutes, and amazingly, she looked completely different (see picture below). [Since I am very fond of blondes with glasses, I ended up using the previous version].

SitePal is not just limited to webpages. You can also embed a SitePal character into your PowerPoint presentation, taking interactivity to a whole new level.
Try it out for yourself. Certainly reminds one of S1m0ne (Simone), doesn't it?
Sunday, April 01, 2007
Posted by Adnan Farooq Hashmi
DAL goes SubSonic
Oh boy! I have a lot of things to blog about, mainly posts on "Atlas [now ASP.NET AJAX Extensions] at last" and "MS Speech Application SDK". My reason for staying away from blogging was that I was buried in a project in Pakistan till December 2006, after I came back from the MVP Open Days in Turkey in September. Anyway, I have just shifted to USA, and will try to blog regularly from now on.
As developers (and architects) come to terms with the changes that would come with LINQ and the ADO.NET Entity Framework, and the impact it would have on business applications, many existing applications developed or ported to C# 2.0 or VB 8.0 from previous version would never be able to exploit its benefits. Architects and developers working on new software applications or application functionality, however, can make the wise choice of using the Web Service Software Factory to generate business entities, and expose them through web services. (more on that coming up in future posts, HOPEFULLY).
Hardly any developer would want to be bogged down with writing business object classes to represent the entity tables in an enterprise application. The alterative for O/R Mapping, in most cases, is to turn to techniques for code generation, that allow generation of business object code for data access; NHibernate being one of the most popular ones.
SubSonic is yet another O/R Mapper or DAL code generator on the horizon, and does not involve using a separate application for code generation. All the developer needs to do to use SubSonic is add a reference to the actionpack.dll file and add some tags to the web.config file, and thats it. Even more amazing is the fact that SubSonic allows developers to swiftly generate web pages for inserting, updating, and deleting records in the table, kind of like the ones used in administration sections of most websites. Check out the SubSonic site to learn more.
Without a doubt, code generation can give development teams a head-start, when it comes to rapidly generating business entities as soon as they have a database design in place. However, a fact that is often overlooked in enterprise applications, when there are literally hundreds of tables the code needs to be generated for, is that business entities seem to loose their original meaning, and instead exist only as code stubs for data access logic pertaining to the tables they were created for. The same thing happens if you use strongly typed datasets to represent business entities.
A good data-access pattern within a good system architecture, would be to have a separate layer between the DAL (mainly stored procs and logic residing on the database), and the business logic layer (which includes business objects). This new layer would comprise the code generated using an O/R Mapper. While developers building a project from scratch, and trying to get it completed in the scheduled time, would very much want to overlook this important aspect, since it would need to done manually without any code generation. I will try to illustrate using an example. A typical "Employee" business entity generated using an O/R Mapper might have methods like
For now, I would recommend a Webcast that should get you up and running with DAL generation at SubSonic speeds.
As developers (and architects) come to terms with the changes that would come with LINQ and the ADO.NET Entity Framework, and the impact it would have on business applications, many existing applications developed or ported to C# 2.0 or VB 8.0 from previous version would never be able to exploit its benefits. Architects and developers working on new software applications or application functionality, however, can make the wise choice of using the Web Service Software Factory to generate business entities, and expose them through web services. (more on that coming up in future posts, HOPEFULLY).
Hardly any developer would want to be bogged down with writing business object classes to represent the entity tables in an enterprise application. The alterative for O/R Mapping, in most cases, is to turn to techniques for code generation, that allow generation of business object code for data access; NHibernate being one of the most popular ones.
SubSonic is yet another O/R Mapper or DAL code generator on the horizon, and does not involve using a separate application for code generation. All the developer needs to do to use SubSonic is add a reference to the actionpack.dll file and add some tags to the web.config file, and thats it. Even more amazing is the fact that SubSonic allows developers to swiftly generate web pages for inserting, updating, and deleting records in the table, kind of like the ones used in administration sections of most websites. Check out the SubSonic site to learn more.
Without a doubt, code generation can give development teams a head-start, when it comes to rapidly generating business entities as soon as they have a database design in place. However, a fact that is often overlooked in enterprise applications, when there are literally hundreds of tables the code needs to be generated for, is that business entities seem to loose their original meaning, and instead exist only as code stubs for data access logic pertaining to the tables they were created for. The same thing happens if you use strongly typed datasets to represent business entities.
A good data-access pattern within a good system architecture, would be to have a separate layer between the DAL (mainly stored procs and logic residing on the database), and the business logic layer (which includes business objects). This new layer would comprise the code generated using an O/R Mapper. While developers building a project from scratch, and trying to get it completed in the scheduled time, would very much want to overlook this important aspect, since it would need to done manually without any code generation. I will try to illustrate using an example. A typical "Employee" business entity generated using an O/R Mapper might have methods like
Insert() and Update() for saving and updating a record in the Employee. For most development teams trying to meet the dealine, this is good enough. However, a great design would create the same Employee class (in a different namespace) that would have methods like Hire(), Create(), ChangeAddress(), IncrementSalary() etc. calling the same Insert() and Update() methods under the covers. Not only does this make the code far more readable and self-explanatory, but also highly maintainable. The advantage of using this approach becomes even more profound when you are dealing with tables that do not necessarily represent real-life entities, and require methods like Debit(), Credit, TakeBack(), Adjust(), Reconcile() etc.For now, I would recommend a Webcast that should get you up and running with DAL generation at SubSonic speeds.
Monday, March 19, 2007
Posted by Adnan Farooq Hashmi
I dream about Turkey!
That's the slogan of the Turkish tourism advertisement I saw on my flight from Istanbul to Antalya, on my way there for the Microsoft MVP Open Days event for MEA (Middleast and Africa) region this week, and let me tell you, I dream about Turkey from now on too.




Is this COOL or what?
This is a test post to check Windows Live Writer. You can get more information here.
Atlas at last! - Part III
Previously:
Atlas at last Part II: Looking to the road ahead
Atlas at last Part I: Getting down and dirty with JavaScript
Matt Gibbs has written an excellent "Atlas at last" article in the July 2006 issue of MSDN Magazine. Check it out: Atlas At Last: ASP.NET Atlas Powers the AJAX-Style Sites You’ve Been Waiting For.
So much can change between 2 posts is hard to imagine. For one, WinFX was renamed; now its called .NET 3.0 (combining WPF, WCF, WF, WCS). I touched upon the idea of WPF in the web browser in the previous Atlas at last post. An article on MSDN titled "Deploying Microsoft .NET Framework Version 3.0" explains how to detect if .NET 3.0 is installed on a PC from within JavaScript/JScript code running inside a browser. Get ready; we would be seeing sites developed using .NET 3.0, with WPF on the presentation tier, very soon. The keyword to remember is "Smart Client"; browser-based applications lending a rich presentation to a SOA (Service-Oriented Architecture) strategy.
There's more than one way to skin a cat, or so I heard, and that really depends on what you want to do after you've done it. In the same way, you have a choice to develop with Microsoft "Atlas" using 2 different approaches, depending on the type of project you are building, the development time you have, and/or the amount of responsiveness and richness you want in your web app. The 2 approaches are: Server-Centric and Client-Centric Development. The diagram below provides a glimpse of what these 2 approaches encompass.

Very briefly, the Server-Centric approach primarily involves using Atlas Server Controls to achieve the desired result. This essentially means adding the "UpdatePanel" control, and enclosing all other server controls within it. Control Extenders, as the name implies, allow developes to add DHTML behaviors to existing server or client controls. Although the current online literature on Atlas does not classify the use of Control Extenders as a server-centric approach, it is easy to explain Control Extenders to developers in context of the server-centric approach, mainly because they encapsulate DHTML behaviors, shielding the user from the complexity of the JavaScript code, and are used pretty much like pre-developed ASP.NET server controls.
The Client-Centric approach relies on client-side script (no surprises there) running inside the web browser to not only achieve most of the things possible with the server-centric approach, but to also create and add rich client-side interactivity within the webpage. Remember, these 2 approaches are not alternatives to each other. A single website, or even a single webpage, can have implementations of both approaches. The next 2 "Atlas at last" posts would look into more detail of both these approaches separately.
It is incorrect to assume that only the client-centric approach involves scripting. There are no clear guidelines in existence that would mandate the use of one approach instead of the other. Many web/ASP.NET developers who are just getting started with Microsoft "Atlas" would want to go with the UpdatePanel control since it requires the least effort and development time. However, the UpdatePanel might not hold the answer to what you wanted to achieve in the first place. I received a couple of queries from people who wanted to know which approach they should follow for their projects, and my answer was always the same: it depends. Its better to choose the approach for each webpage accordingly instead of making a choice of the approach to follow at the beginning of the project and adhereing to it throughout. Let me elaborate through some scenarios.
The above does not (and cannot possibly) cover all the scenarios that Microsoft "Atlas" is designed for. Stick around for more "Atlas at last" posts.
Atlas at last Part II: Looking to the road ahead
Atlas at last Part I: Getting down and dirty with JavaScript
Matt Gibbs has written an excellent "Atlas at last" article in the July 2006 issue of MSDN Magazine. Check it out: Atlas At Last: ASP.NET Atlas Powers the AJAX-Style Sites You’ve Been Waiting For.
So much can change between 2 posts is hard to imagine. For one, WinFX was renamed; now its called .NET 3.0 (combining WPF, WCF, WF, WCS). I touched upon the idea of WPF in the web browser in the previous Atlas at last post. An article on MSDN titled "Deploying Microsoft .NET Framework Version 3.0" explains how to detect if .NET 3.0 is installed on a PC from within JavaScript/JScript code running inside a browser. Get ready; we would be seeing sites developed using .NET 3.0, with WPF on the presentation tier, very soon. The keyword to remember is "Smart Client"; browser-based applications lending a rich presentation to a SOA (Service-Oriented Architecture) strategy.
There's more than one way to skin a cat, or so I heard, and that really depends on what you want to do after you've done it. In the same way, you have a choice to develop with Microsoft "Atlas" using 2 different approaches, depending on the type of project you are building, the development time you have, and/or the amount of responsiveness and richness you want in your web app. The 2 approaches are: Server-Centric and Client-Centric Development. The diagram below provides a glimpse of what these 2 approaches encompass.

Very briefly, the Server-Centric approach primarily involves using Atlas Server Controls to achieve the desired result. This essentially means adding the "UpdatePanel" control, and enclosing all other server controls within it. Control Extenders, as the name implies, allow developes to add DHTML behaviors to existing server or client controls. Although the current online literature on Atlas does not classify the use of Control Extenders as a server-centric approach, it is easy to explain Control Extenders to developers in context of the server-centric approach, mainly because they encapsulate DHTML behaviors, shielding the user from the complexity of the JavaScript code, and are used pretty much like pre-developed ASP.NET server controls.
The Client-Centric approach relies on client-side script (no surprises there) running inside the web browser to not only achieve most of the things possible with the server-centric approach, but to also create and add rich client-side interactivity within the webpage. Remember, these 2 approaches are not alternatives to each other. A single website, or even a single webpage, can have implementations of both approaches. The next 2 "Atlas at last" posts would look into more detail of both these approaches separately.
It is incorrect to assume that only the client-centric approach involves scripting. There are no clear guidelines in existence that would mandate the use of one approach instead of the other. Many web/ASP.NET developers who are just getting started with Microsoft "Atlas" would want to go with the UpdatePanel control since it requires the least effort and development time. However, the UpdatePanel might not hold the answer to what you wanted to achieve in the first place. I received a couple of queries from people who wanted to know which approach they should follow for their projects, and my answer was always the same: it depends. Its better to choose the approach for each webpage accordingly instead of making a choice of the approach to follow at the beginning of the project and adhereing to it throughout. Let me elaborate through some scenarios.
- The webpage comprises of static information.
Recommended approach: None; Since the data contained in the page does not change, it is pointless to use Atlas in it. - The webpage is used to present dynamic information stored on the server in a database/XML file, and loads inside a particular region of the page depending on the query string value.
Recommended approach: Server-Centric; The UpdatePanel would only change a portion of the page after a response is received from the server, while static portions of the page like header images, logos, menus etc. would not reload. - The webpage lists information from a database table, and the user should not have to navigate to a different webform page to enter new, or modify existing data from that table.
Recommended approach: Control Extenders; The 'Modal Popup Control Extender' provides an easy-to-implement mechanism to dislay a webform in a modal popup window, graying-out the rest of the portion of the screen outside the popup window, allowing the user to enter new, or change existing, information; When the modal popup closes, the portion of the page that lists the data from the table refreshes to show the updated information from the server (without a full postback). - The webpage consists of multiple dropdown lists (combo-boxes), and each one after the first dropdown list populates with values based on the value selected in a previous dropdown, like a City dropdown populating everytime for the Country seleted from another dropdown list.
Recommended approach: Control Extenders; The 'Cascading DropDown Control Extender' allows a dropdown list to call and web service in response to a selection made into it and populate the next dropdown list in the sequence. - You want to give the user the ability to either enter a new value into a textbox or else select from a list of values already stored in the database.
Recommended approach: Both Client-Centric and Server-Centric approaches support the Auto-Complete behavior (Also see next point). - You want to give the user the ability to either enter a new value into a textbox or else select from a list of values already stored in the database, based on a selection or preference specified ealier.
Recommended approach: Client-Centric; Only JavaScript would allow the Auto-complete list to be populated based on a condition, since XML-Script and the AutoComplete Control Extender only attach a web service (hard-code) to an autocomplete list, whereas JavaScript code provides the flexibility to select from a list of web services depending on a condition.
The above does not (and cannot possibly) cover all the scenarios that Microsoft "Atlas" is designed for. Stick around for more "Atlas at last" posts.
EID Presentation Upload
I apologize for not uploading the "Building Next Generation GUIs using Microsoft Expression Interactive Designer" presentation earlier. I just uploaded it to the Core.NET Yahoo Group in the "Files > PDC 2006 Slides and Demos > EID" Folder.
For samples and application demos, check out these URLs.
For samples and application demos, check out these URLs.
"Atlas" Presentation Slides and Demo Code

I got an overwhelming response from both of my presentations during the 3-day Pakistan Developer Conference 2006, or PDC 2006 as we like to call it. I have uploaded my presentation slides and demo code for all applications I demonstrated at Core.NET's Yahoo! Group account. Download away!
The three files pertaining to the presentation uploaded in the "Files > PDC 2006 Slides and Demos > AJAX & Atlas" folder are
- Atlas_AdnanHashmi.PDF
- PDC06.Demos.NaukriAtlas.ZIP
- PDC06.Session.Demos.ZIP
* The term 'Naukri' in Urdu means 'Job'. NaukriAtlas.NET is an AJAX-enabled job portal.
More on .NET 3.0
Good to see things getting clearer as Tech Ed 2006 approaches. These two articles provide a good understanding about what .NET 3.0 is all about.
Realize New Functionality in .NET 3.0
New Technology Offers Dev Challenges, UI Improvements
At a glance, .NET 3.0 [http://www.netfx3.com/] includes
Interestingly, the announcement made about .NET 3.0 on June 9 by Somasegar on his blog was exactly what I had forecasted and blogged about in my post just 3 days prior, and I had absolutely no idea at that time that it would come so soon.
Realize New Functionality in .NET 3.0
New Technology Offers Dev Challenges, UI Improvements
At a glance, .NET 3.0 [http://www.netfx3.com/] includes
- .NET Framework 2.0
- The 2.0 Common Language Runtime (CLR)
- The 2.0 Base Class Library
- ADO.NET 2.0, ASP.NET 2.0, Windows Forms 2.0
- VB 8.0 and C# 2.0
- WinFX
- Windows Communication Foundation (WCF) [http://wcf.netfx3.com/]
- Windows Presentation Foundation (WPF) [http://wpf.netfx3.com/]
- Windows Workflow Foundation (WF) [http://wf.netfx3.com/]
- InfoCard
Interestingly, the announcement made about .NET 3.0 on June 9 by Somasegar on his blog was exactly what I had forecasted and blogged about in my post just 3 days prior, and I had absolutely no idea at that time that it would come so soon.
.NET: 2 Fast, 3 Furious
I am not sure how the decision to rename WinFX (which encompasses WPF, WCF, and WF) to .NET 3.0 will go down with developers who are still in the process of trying to explore, and gradually coming to terms with the changes that new technologies like Atlas and WinFX brought to .NET 2.0. Developers, however, were content, knowing that WinFX was built on top of .NET 2.0 and will be supported for the next decade. This new change, in addition to creating a lot of confusion, will also raise a number of questions; Will existing investments in .NET 2.0 go down the drain soon? Should we wait for the new 3.0 platform to mature before we implement it? Is .NET 2.0 gone?
Hopefully, Microsoft would move swiftly to allay a lot of fears in the coming days. My best guess is that .NET 2.0 (along with its underlying technologies) would be a subset of .NET 3.0 along with Orcas/C# 3.0, WinFX, and LINQ. For now, I am keeping my fingers crossed.
Hopefully, Microsoft would move swiftly to allay a lot of fears in the coming days. My best guess is that .NET 2.0 (along with its underlying technologies) would be a subset of .NET 3.0 along with Orcas/C# 3.0, WinFX, and LINQ. For now, I am keeping my fingers crossed.


