zoukankan      html  css  js  c++  java
  • How to unlock the locked tasks in Sharepoint Workflow

    How to unlock the locked tasks in Sharepoint Workflow

     
    Sometimes in Sharepoint Workflow, tasks will get locked and you will not be able to proceed further.

    These locks are placed to prevent the task being updated simultaneously. The workflow runtime locks tasks by setting a field (WorkflowVersion)and persisting that to the database.

    if workflowversion is 1 then the tasks are "not locked". Any value apart from "1" symbolises that these tasks are "locked".

    Ideally to remove the locks, we need to update WorkflowVersion of the task to "1".

    Here you go, the sample for it.


    public static void UnlockWorkflowTasks(string siteUrl, string webUrl, string listName)
            {
                using (SPSite site = new SPSite(siteUrl))
                {
                    using (SPWeb web = site.OpenWeb(webUrl))
                    {
                        SPList list = web.Lists[listName];
                        SPListItemCollection items = list.Items;
     
                        foreach (SPListItem item in items)
                        {
                            SPWorkflowCollection workflows = item.Workflows;
                            foreach (SPWorkflow workflow in workflows)
                            {
                                SPWorkflowTaskCollection tasks = workflow.Tasks;
                                foreach (SPWorkflowTask task in tasks)
                                {
                                    if (task[SPBuiltInFieldId.WorkflowVersion].ToString() != "1")
                                    {
                                        task[SPBuiltInFieldId.WorkflowVersion] = 1;
                                        task.SystemUpdate();
                                    }
                                }
                            }
                        }
                    }
                }
            }
     

    Happy Coding :)
  • 相关阅读:
    DDos游戏行业受攻击最多
    木马——本质就是cs socket远程控制,反弹木马是作为c端向外发起网络请求
    IPS
    C&C控制服务的设计和侦测方法综述——DDoS攻击,上传从宿主机偷窃的到的信息,定时给感染机文件加密勒索等。
    Fast Flux技术——本质就是跳板,控制多个机器,同一域名指向极多的IP(TTL修改为0),以逃避追踪
    DNS解析污染原理——要么修改包,要么直接丢弃你的网络包
    将string当字节流使
    Memcached常用命令及使用说明
    在Linux上安装Memcached服务
    安装和使用memcached
  • 原文地址:https://www.cnblogs.com/ahghy/p/2731303.html
Copyright © 2011-2022 走看看