0

从正在运行的工作流中启动工作流的正确方法是什么?

我们目前正在使用 Visual Studio 2010,并且正在运行的工作流是 Sharepoint 2010。以前,此工作流在 Sharepoint 2007 中运行没有问题。将包迁移到 2010 后,状态工作流运行正常,但无法正确启动顺序工作流。如果手动启动顺序,它将正常运行。

这是我们用来从状态中调用顺序的代码。

// Starts CAB Implementation Workflow.
SPWorkflowManager wfManager = this.workflowProperties.Site.WorkflowManager;
        SPWorkflowAssociationCollection associationCol = this.workflowProperties.List.WorkflowAssociations;
        foreach (SPWorkflowAssociation association in associationCol)
        {
            // Replace {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} with the Id of the workflow you want to invoke 
            if (association.BaseId.ToString("B").Equals("{af0775b9-8f10-468d-9201-792a4f539c03}"))
            {
                wfManager.StartWorkflow(this.workflowProperties.Item, association, "", true);
                break;
            }
        }
4

1 回答 1

0

在创建这个问题时,我们找到了解决方案。如果协会数据为空,MOSS 2007 似乎并不介意。MOSS 2010 不喜欢空数据,会启动工作流,但很快就会失败。解决方案是提供一个空的 xml 标记作为关联数据。

// Starts CAB Implementation Workflow.
        SPWorkflowManager wfManager = this.workflowProperties.Site.WorkflowManager;
        SPWorkflowAssociationCollection associationCol = this.workflowProperties.List.WorkflowAssociations;
        foreach (SPWorkflowAssociation association in associationCol)
        {
            // Replace {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} with the Id of the workflow you want to invoke 
            if (association.BaseId.ToString("B").Equals("{af0775b9-8f10-468d-9201-792a4f539c03}"))
            {
                wfManager.StartWorkflow(this.workflowProperties.Item, association, "<root />", true);
                break;
            }
        }

现在顺序工作流从状态成功启动,没有问题。

于 2010-07-08T12:38:59.513 回答