SharePoint2010代码启动工作流

1.

private void StartWorkFlow()
        {
            //获得该列表上的发布的所有工作流
            SPWorkflowAssociationCollection wfAssociationColls = this.List.WorkflowAssociations;
            if (wfAssociationColls != null && wfAssociationColls.Count > 0)
            {
                CultureInfo ci = CultureInfo.CurrentCulture;
                SPWorkflowAssociation spWFAss = GetAssociation(wfAssociationColls);
                SPContext.Current.Web.AllowUnsafeUpdates = true;
                this.List.ParentWeb.Site.WorkflowManager.StartWorkflow(this.ListItem, spWFAss, spWFAss.AssociationData, true);
                SPContext.Current.Web.AllowUnsafeUpdates = false;
            }
        }
        //获取当前要启动的工作流
        private SPWorkflowAssociation GetAssociation(SPWorkflowAssociationCollection wfAssociationColls)
        {
            SPWorkflowAssociation spWFAss = wfAssociationColls[0];
            foreach (SPWorkflowAssociation item in wfAssociationColls)
            {
                //根据工作流创建的时间将最后一次发布的工作流取出来
                if (item.Created > spWFAss.Created)
                {
                    spWFAss = item;
                }
            }
            return spWFAss;
        }

 

你可能感兴趣的:(SharePoint)