Tuesday, December 23, 2008

"Table of Contents" webpart is missing

I was trying to add a "Table of Contents" Webpart to one of my SharePoint page during customization. But i couldn't find it in the web part gallery. I remember i used this webpart in one of my previous project with out any specific steps.

I tried different things to get the webpart in a trial and error manner. At last i was able to get this webpart after activating the "Publishing features".

In my previous project i activated the "Publishing features" for some other purpose, which also added the TOC webpart. So, when i tried to add the TOC webpart it was available right there. I didn't realise it is part of "Publishing features".

Wednesday, December 17, 2008

Persistence in SharePoint workflow

While creating the long running windows workflows it is mandatory to persist the workflow state at some point of time.
  • to release the memory taken by workflow for execution
  • to restore its state during the hardware failure
  • to maintain the scalability of system

So, it is best practice to implement SqlWorkflowPersistenceService and using that we can persist the data in SQL database. This is the out of the box class provided by Microsoft for using SQL db as data store. But if we are going to use different data store we need to create our own persistence service class by inheriting the WorkflowPersistenceService class. Here is a good example given in this blog(http://www.devx.com/dotnet/Article/32247/0) to implement persistence using SqlWorkflowPersistenceService

Well , but what is happening in SharePoint workflows is entirely different process. We will not be having access to the workflow host application like windows workflows. Here SharePoint is hosting the workflow and the persistence service is implemented in it using SqlWorkflowPersistenceService. So, when a SharePoint workflow's controls goes in to some event based activities like "OnTaskChanged" or "OnTaskDeleted" activity, the workflow's state is dehydrated or persisted automatically in to the ContentDB of the particular SharePoint web application.

We can't implement our own persistence logic here because it should be written in the workflow host application rather than the workflow application. While developing SharePoint workflows we will not be having our own separate workflow host application because SharePoint is actually the host and controls the workflow execution. It is still using the workflow runtime to execute the workflows. But it is customized lot to support MOSS with lot of additional features. Persistence is one among those features.

Persistence in MOSS is implemented by SPWinOePersistenceService which is actually inherited from SqlWorkflowPersistenceService. It stores the workflow state in the Workflow table of the ContentDB.


The following picture shows that the workflow's instance state are actually stored in the "Instancedatasize" column of the table.


Once the workflow is completed the instance data is actually released from the database.