簡體   English   中英

ExecutionEngineException用於取消我的SharePoint 2013工作流

[英]ExecutionEngineException for canceling my SharePoint 2013 Workflow

我正在使用SharePoint 2013,VS2013和工作流引擎4.5。 我有一個自定義的“應用程序”頁面,可用於工作流流程的下一步。 此頁面上的按鈕之一是取消按鈕。 當我的用戶單擊此按鈕時,我將使用ajax調用我的MVC Web應用程序。 我的MVC5.0應用程序首先更新Entity Framework數據庫記錄,然后嘗試取消工作流程。

下面是我的MVC代碼。 為什么我在此行得到ExecutionEngineException錯誤clientContext.Load(instances); 注意:如果采用以下代碼並將其復制到控制台應用程序,則可以正常工作!

            //cancel the workflow
            ClientContext clientContext = new ClientContext(baseUrl);
            WorkflowServicesManager wfsm = new WorkflowServicesManager(clientContext, clientContext.Web);
            WorkflowInstanceService instanceService = wfsm.GetWorkflowInstanceService();
            WorkflowInstanceCollection instances = instanceService.EnumerateInstancesForListItem(listId, itemId);
            **clientContext.Load(instances);**
            clientContext.ExecuteQuery();

            foreach (WorkflowInstance instance in instances)
            {
                if (instance.Id == new Guid(instanceId))
                {
                    instanceService.CancelWorkflow(instance);
                }
            }

任何幫助,將不勝感激。

馬雷克:

我已經與Microsoft(MS)開了一個案子。 他們最初的回答是,他們知道SharePoint和MVC5的安全性和其他問題。 我嘗試使用SharePoint WCF服務項目廣告獲得了相同的結果。 我會讓您知道MS響應時的發現。 至於Fiddler,我嘗試了一下,但是並沒有告訴我太多,或者也許我沒有正確解釋結果。 我真的以為我是否提供了明確的憑據(與可以使用的控制台應用程序相同),但是卻出現了相同的錯誤。

我發現CSOM代碼(上面)需要用以下代碼替換。 注意:我還必須以提升的特權運行以下代碼。

SPSecurity.RunWithElevatedPrivileges(delegate()
{
   using (SPSite site = new SPSite(baseUrl))
   {
      using (SPWeb web = site.OpenWeb())
      {
         SPList list = web.Lists["Documents"];
         Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager wsm = new Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager(web);
         Microsoft.SharePoint.WorkflowServices.WorkflowInstanceService service = wsm.GetWorkflowInstanceService();
         var instances = service.EnumerateInstancesForListItem(gPageList, pageID);
         foreach (var instance in instances)
         {
            service.CancelWorkflow(instance);
         }
      }
   }                   
 });

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM