Sharepoint 从状态工作流中启动顺序工作流

Sharepoint 从状态工作流中启动顺序工作流,sharepoint,visual-studio-2010,sharepoint-2010,sharepoint-workflow,Sharepoint,Visual Studio 2010,Sharepoint 2010,Sharepoint Workflow,从正在运行的工作流中启动工作流的正确方法是什么 我们目前正在使用Visual Studio 2010,正在运行的工作流是Sharepoint 2010。以前,此工作流在Sharepoint 2007中正常运行,没有问题。将包迁移到2010年后,状态工作流正常运行,但无法正确启动顺序工作流。如果手动启动序列,它将正常运行 下面是我们用来从状态中调用sequential的代码 // Starts CAB Implementation Workflow. SPWorkflowManager wfMan

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

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

下面是我们用来从状态中调用sequential的代码

// 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;
            }
        }

在创建此问题时,我们找到了解决方案。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;
            }
        }
//启动CAB实施工作流。
SPWorkflowManager wfManager=this.workflowProperties.Site.WorkflowManager;
SPWorkflowAssociationCollection associationCol=this.workflowProperties.List.WorkflowAssociations;
foreach(associationCol中的SPWorkflowAssociation)
{
//将{xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}替换为要调用的工作流的Id
if(association.BaseId.ToString(“B”)等于({af0775b9-8f10-468d-9201-792a4f539c03}))
{
wfManager.StartWorkflow(this.workflowProperties.Item,关联“”,true);
打破
}
}

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

最好学会比较GUID而不是字符串。association.BaseId==新Guid({af0775b9-8f10-468d-9201-792a4f539c03}”)