返回作者不工作,不给出任何错误

时间:2012-07-17 14:05:25

标签: tridion tridion-2011

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

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

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

3 个答案:

答案 0 :(得分:3)

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

finishData.NextAssignee = new LinkToTrusteeData { 
        IdRef = processInstance.Activities[0].Performer.IdRef, 
        Title = processInstance.Activities[0].Performer.Title };

答案 1 :(得分:1)

您可以查看ActivityInstanceData.ActivityStateprocessInstance.Activities[0])财产吗?当它已经完成时,你会得到你提到的例外。在这种情况下,您需要重新启动活动:ICoreService2011.RestartActivity(activityInstanceId, readBackOptions)

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

答案 2 :(得分:1)

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