0

以下返回作者的代码不适用于基于核心服务的工作流程。

并且没有给出任何错误。有什么建议么?

public void BackToAuthor(string workitemid)
{
  var client = new CoreServiceSession();
  var csClient = client.GetClient();
  var readoption = new ReadOptions();

  var workitem = (WorkItemData)csClient.Read(workitemid, readoption);
  var processInstance = (ProcessInstanceData)csClient.Read(
                                             workitem.Process.IdRef, readoption);
  var ieActivities = processInstance.Activities;

  if (ieActivities != null)
  {
    var targetactivity = (ActivityInstanceData)csClient.Read(
                                  processInstance.Activities[0].Id, readoption);
    var finishData = new ActivityFinishData();
    finishData.Message = "Finished automatically";
    finishData.NextAssignee = new LinkToTrusteeData { 
        IdRef = processInstance.Activities[0].Performers[0].IdRef, 
        Title = processInstance.Activities[0].Performers[0].Title };
      csClient.FinishActivity(targetactivity.Id, finishData, readoption);
      logdetails("Finished the activity");
      csClient.Close();
  }
}
4

3 回答 3

3

我相信您必须将活动发送回表演者而不是所有者(第一个活动是“每个人”)。您可能需要更改以下代码行...

finishData.NextAssignee = new LinkToTrusteeData { 
        IdRef = processInstance.Activities[0].Performer.IdRef, 
        Title = processInstance.Activities[0].Performer.Title };
于 2012-07-17T14:59:47.290 回答
1

我建议您首先让代码在调试器下运行,并验证 Id 是否符合您的期望。例如,流程实例是否正确,各种活动和执行者是否符合您的预期?

于 2012-07-18T12:53:46.050 回答
1

你能检查ActivityInstanceData.ActivityState( processInstance.Activities[0]) 属性吗?当它已经完成时,你会得到你提到的异常。在这种情况下,您需要重新启动活动:ICoreService2011.RestartActivity(activityInstanceId, readBackOptions)

那么,您的流程定义如何?在流程定义中的第一个活动之后,是否从自动活动调用 BackToAuthor?

于 2012-07-17T16:24:47.677 回答