Sharepoint 2010事件接收器和工作流未开始

问题描述 投票:1回答:1

我创建了一个事件接收器,该事件接收器应触发SharePoint设计器工作流,但是永远不会发生。对于guid和工作流关联,这部分代码永远不会评估为true:if(association.BaseId ==工作流Guid)。我有些困惑,不太确定为什么它不起作用。任何见解将不胜感激...而我的代码如下。基本上,当一个项目添加到我的列表中时,它应该触发我的Sharepoint设计器工作流,但这永远不会发生,我可以手动启动该工作流。

public override void ItemAdded(SPItemEventProperties properties)
{
       base.ItemAdded(properties);
       startWF(properties);
}

private void startWF(SPItemEventProperties properties)
{
       try
       {
           //bool startWF = false;
           string strWorkflowID = "{c66ff94f-ba7c-4495-82fe-e73cdd18bad9}";
           //string statusVal = properties.AfterProperties["eRequest Division"].ToString();
           SPListItem li = properties.ListItem;
           //using (SPWeb web = li.Web)
           using (SPWeb web = properties.OpenWeb())
           {
               using (SPSite site = web.Site)
               {
                   SPWorkflowManager mgr = site.WorkflowManager;
                   SPList parentList = li.ParentList;
                   //SPList list = web.Lists["Charitable and Political"];
                   SPWorkflowAssociationCollection associationCollection = parentList.WorkflowAssociations;
                   LookUpAndStart(li, mgr, associationCollection, "{c66ff94f-ba7c-4495-82fe-e73cdd18bad9}");
               }

           }

       }
       catch (Exception ex)
       {

       }
   }

private static void LookUpAndStart(SPListItem listItem, SPWorkflowManager mgr, SPWorkflowAssociationCollection associationCollection, string workflowID)
{

    foreach (SPWorkflowAssociation association in associationCollection)
    {
           Guid workflowGuid = new Guid(workflowID);
           //if (association.Name.ToLower().Equals(workflowGuid))
          //if (association.BaseId == workflowGuid)
           //if (association.BaseId.ToString("B").Equals(workflowGuid))
           if (association.BaseId == workflowGuid)
           {
               string data = association.AssociationData;
               SPWorkflow wf = mgr.StartWorkflow(listItem, association, data, true);
               break;
           }
       }
    }
  }
}

我创建了一个事件接收器,该事件接收器应触发SharePoint设计器工作流,但是永远不会发生。这部分代码对于guid和工作流关联永远不会评估为true:if(...

sharepoint sharepoint-workflow event-receiver
1个回答
0
投票

就我而言,以下是问题所在。

© www.soinside.com 2019 - 2024. All rights reserved.