While creating several State Machine SharePoint 2010 workflows using visual studio for a client I had some concerns related to upgrading and redeploying those workflows because as we all know, changes are inevitable!

Where following are the concerns and my solution to them

1- How can we redeploy or upgrade workflow?

I found a nice article which goes in details of upgrading workflow approaches, and as per my analysis Versioning workflows seems to be the only feasible solution.

2- When it’s required to version my workflows and how can I minimized it?

Versioning is required only when UI changes are done on workflow e.g. modification in state, activities etc. as this will break running instance of workflows due to failure in deserialization.

As a strategy we chose multi-layer architecture, which means whole logic in a separate Class library (business) and workflows in separate Library where workflow only defines flow as shown below.

This means for code level changes or bug fixes, we only redeploy business solution wsp not affecting workflows wsp.

3- How to Version Workflow solution and any step by step instructions?

While goggling I could not found comprehensive step by step instructions.

Where following contain the step by step instruction how I implemented it.

Step 1: Upgrade Assemble

· Go to Workflow Solution -> AssemblyInfo Class and update assembly version and file version as shown below.

Step 2: Upgrade Workflow Element.xml

Go to modified workflows and Open their Element.xml files then

· Update 'CodeBesideAssembly' attribute assembly version.

· Update ‘Name’ with Version number at end e.g. xyz version 1.0.0.1 (for your convenience).

· Update 'ID' attribute with a new GUID (Tools->Create GUID).

Step 3: Workflow Feature Update

· Remove any existing feature that deploy workflows from solution

· Add a new Site Scope Feature with 'Name' e.g. PrjectNameWorkflowsVersionX.X.X.X

· Add only modified Workflows inside this feature (Step 2 modified ones only)

Step 4: Upgrade Solution Package

   Double Click Package and then

· Update the 'SolutionId' with a new GUID.

· Update 'Name' with modified version.

Step 5: Deployment

· Build and deploy the new workflow wsp solution and IIS Reset.

     Note: this will register a new version of the workflow assembly in the GAC.

Step 6: Association and No New instance

· Associate newly deployed workflow e.g. xyz version 1.0.0.1

· Go to Associated list Workflow Settings -> Remove workflow and Put the old version workflows as "No New instance".

Note:  As my solution contains several workflows so I created a utility for Programmatically performing step 6 operation, here are some methods that I created that might be helpful.

''' <summary>

''' To Programmatically associate workflow with a List or library

''' </summary>

Public Shared Sub AssociateWorkflow(ByVal web As SPWeb, _

ByVal WorkflowGUID As String, _

ByVal WorkflowName As String, _

ByVal ListName As String, _

ByVal TaskListName As String, _

ByVal HistoryListName As String, _

ByVal AllowManual As Boolean, _

ByVal AutoStartChange As Boolean, _

ByVal AutoStartCreate As Boolean)

'Bind to lists.

Dim ListToAssociate As SPList = web.Lists(ListName)

Dim TasksListToAssociate As SPList = web.Lists(TaskListName)

Dim workflowHistoryList As SPList = web.Lists(HistoryListName)

'Get workflow Template

Dim workflowTemplate As SPWorkflowTemplate = web.WorkflowTemplates(New Guid(WorkflowGUID))

If ListToAssociate.WorkflowAssociations.Count > 0 Then

Throw New Exception(String.Format("List '{0}' is already associated with Workflow '{1}', Please Disassociate this workflow first.", ListToAssociate.Title, ListToAssociate.WorkflowAssociations(0).Name))

End If

'Create workflow association.

Dim workflowAssociation As SPWorkflowAssociation = SPWorkflowAssociation.CreateListAssociation(workflowTemplate, WorkflowName, TasksListToAssociate, workflowHistoryList)

'Set workflow options.

        workflowAssociation.AllowManual = AllowManual

        workflowAssociation.AutoStartChange = AutoStartChange

        workflowAssociation.AutoStartCreate = AutoStartCreate

       ' Hint: WorkflowAssociation.Enabled = false means 'No new instantace'

'Add workflow association.

ListToAssociate.WorkflowAssociations.Add(workflowAssociation)

End Sub

''' <summary>

''' To programmatically start workflow already associated with a List or library

''' </summary>

Public Shared Sub ManuallyStartWorkflow(ByVal objWeb As SPWeb, ByVal listTitle As String, ByVal itemID As Integer)

Using elevatedSite = New SPSite(objWeb.Url, SiteHelper.GetSystemUserSecruityToken(objWeb))

Using web = elevatedSite.OpenWeb()

                web.AllowUnsafeUpdates = True

Dim elevatedList As SPList = web.Lists(listTitle)

'Get Associated Workflow

Dim item As SPListItem = elevatedList.GetItemById(itemID)

If item.Workflows.Count = 0 Then

Dim myAssociation As SPWorkflowAssociation = GetWorkflowAssociation(elevatedList.WorkflowAssociations)

elevatedSite.WorkflowManager.StartWorkflow(item, myAssociation, myAssociation.AssociationData)

End If

End If

                web.AllowUnsafeUpdates = False

End Using

End Using

End Sub

Where even after reading this article you don’t like any of the solution and you want to develop few workflows that are not complex, then go with Event Receivers you can build your logic by code resulting in better performance and you don’t have to worry about versioning or anything J

Upgrading or Redeploying SharePoint 2010 Workflows的更多相关文章

  1. Upgrade from SharePoint 2010 to SharePoint 2016

    [转]http://nikcharlebois.com/upgrade-from-sharepoint-2010-to-sharepoint-2016/ In this blog, I will go ...

  2. SharePoint 2010升级到sharePoint 2013后,人员失去对网站的权限的原因及解决方法。The reason and solution for permission lost after the upgrading

    昨天碰到了一个问题,一个网站在从SharePoint 2010升级到SharePoint 2013后,人员都不能登录了,必须重加赋权,人员才能登录,这样非常麻烦. 原因:是认证方式的问题.在Share ...

  3. 使用SharePoint 2010 母版页

    SharePoint 2010母版页所用的还是ASP.NET 2.0中的技术.通过该功能,实现了页面框架布局与实际内容的分离.虽然在本质上自定义母版页的过程和以前版本的SharePoint大致相同,但 ...

  4. [SharePoint 2010]Sandboxed Solution (沙箱解決方案)

    現有的SharePoint 2007系統中,我們如果要安裝客製化的程式碼到系統中,我們必須製作一個解決方案包裝檔(Solution Package),然後在系統的中央管理後台中,真對整個伺服器農場Fa ...

  5. SharePoint 2010 将带有工作流的模板移动到另一个站点集

    HOWTO Move or Migrate SharePoint 2010 List-based Workflows between Sites and Site Collections I’ve e ...

  6. 在SharePoint 2010中,如何找回丢失的服务账号(Service Account)密码

    背景信息: 通常在SharePoint环境中我们会使用很多的服务账号来运行各种不同的服务,尤其在企业环境中,由于权限管理条例严格,这些服务账号更是只能多不能少.面对如此多的服务账号,各个企业都会有自己 ...

  7. 安装InfoPath 2013后 SharePoint 2010 出现 “找不到 Microsoft.Office.InfoPath, Version=14.0.0....” 的错误的解决方案

    1. 症状 您的SharePoint 2010的服务器是不是最近一直出现这个错误呢? Could not load file or assembly 'Microsoft.Office.InfoPat ...

  8. [SharePoint 2010] 自定义字段类型开发(二)

    在SharePoint 2010中实现View Action Button效果. http://www.sharepointblogs.be/blogs/vandest/archive/2008/06 ...

  9. SharePoint 2010 + 左侧导航(Left Nav Bar)二级菜单的修改

    SharePoint 2010 + 修改左侧导航类似顶部导航菜单的样式 查找aspmenu的控件,ID为“V4QuickLaunchMenu”,修改分别将属性“StaticDisplayLevels” ...

随机推荐

  1. Office2016下载地址

    Office 2016 专业增强版32 位: 文件名:SW_DVD5_Office_Professional_Plus_2016_W32_ChnSimp_MLF_X20-41351.ISO SHA1: ...

  2. 利用SSIS发送邮件

    璎Nicole珞 博客园 闪存 首页 新随笔 联系 管理 订阅 随笔- 15  文章- 0  评论- 0  SSIS 利用发送邮件服务 Send Email Task   1. 在SSIS中如何发送邮 ...

  3. Lambda动态创建

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  4. NPM使用详解(上)

    1.NPM是什么? NPM是JavaScript的包管理工具,在安装NodeJS(什么?你不知道node?来,我们合计合计:https://nodejs.org/)的时候,会自动安装上npm. 要查看 ...

  5. [Node.js] BDD和Mocha框架

    原文地址:http://www.moye.me/2014/11/22/bdd_mocha/ 引子 今天造了个轮子:写了个深拷贝任意JavaScript对象的模块(事实上npm上已经有类似的模块,纯造轮 ...

  6. Linux网络管理

    关于OSI七层模型.TCP五层模型.TCP的三次握手.HTTP协议.DNS解析等相关的网络基础知识请参考我整理的一篇博客:http://www.cnblogs.com/wxisme/p/4699049 ...

  7. [python]在场景中理解装饰器

    原来我也自己通过查资料,来学习python的装饰器,但是效果不好.因为没有接触过需要用到装饰器的场景,所以 一起的资料都只停留在纸面上,但是今天偶然看到了vimer的这篇文章:http://www.v ...

  8. sql server service broker中调用存储过程执行跨库操作,不管怎么设置都一直提示 服务器主体 "sa" 无法在当前安全上下文下访问数据库 "dbname"。

    用sql server自带的消息队列service borker,调用存储过程中,执行了一个跨库的操作,先是用了一个用户,权限什么都给够了,但是一直提示 服务器主体 "user" ...

  9. css中px,em和rem的区别

    css中px,em和rem的区别 今天,突然间发现一个特别有意思的问题,就是无意间看到一个网站中的em并不是16px,下面展开了对于px和em以及rem的探究. 首先,px是绝对长度单位,是相对于显示 ...

  10. [C#] CSharp 基本语法

    CSharp Language Specification 一.基础 1.规范: 除常量外,所有变量用驼峰命名方式,其它用帕斯卡命名方式. 2.编译: 首先由csc.exe将cs文件编译成MSIL.当 ...