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; 
      } 
     } 
+0

更好地學習比較guids而不是字符串。 association.BaseId == new Guid(「{af0775b9-8f10-468d-9201-792a4f539c03}」) – 2010-07-08 12:53:40

回答

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

現在順序工作流成功從州啓動,沒有問題。