如何设置当前自动化活动的下一个活动?

时间:2012-07-18 09:04:12

标签: tridion tridion-2011

我正在尝试从当前活动决定下一个活动(自动决策活动)以下是我的代码。如何设置下一个活动?

public void DebugUserCheck(string workitemid)
{
  CoreServiceSession client = new CoreServiceSession();
  SessionAwareCoreServiceClient csClient = client.GetClient();
  var readoption = new ReadOptions();
  WorkItemData workitem = (WorkItemData)csClient.Read(workitemid, readoption);          


  ActivityInstanceData currentactivity = (ActivityInstanceData)csClient.Read(workitem.Activity.IdRef, readoption);
  TridionActivityDefinitionData activitydefinition = (TridionActivityDefinitionData)csClient.Read(currentactivity.ActivityDefinition.IdRef, readoption);
  ProcessDefinitionData processdefinition = (ProcessDefinitionData)csClient.Read(activitydefinition.ProcessDefinition.IdRef, readoption);
  IList<ActivityDefinitionData> activityDefinitions = new List<ActivityDefinitionData>(processdefinition.ActivityDefinitions);

  string superuseractivitytitle = "";
  string superuseractivityid = "";
  string normaluseractivitytitle = "";
  string normaluseractivityid = "";

  foreach (var activity in activityDefinitions)
  {
    if (activity.Title == "Override")
    {
      superuseractivitytitle = activity.Title;
      superuseractivityid = activity.Id;                    
    }
    if (activity.Title == "Author Decision")
    {
      normaluseractivitytitle = activity.Title;
      normaluseractivityid = activity.Id;
    }
  }


  UserData user = csClient.GetCurrentUser();

  if (user.Id == "tcm:0-141-65552")
  {
    ActivityDefinitionData nextactivity = (ActivityDefinitionData)csClient.Read(superuseractivityid, readoption);
    ActivityFinishData finishdata = new ActivityFinishData();
    finishdata.Message = "Automatic decision activity finished";
    csClient.FinishActivity(currentactivity.Id, finishdata, readoption);
  }
  else
  {
    ActivityDefinitionData nextactivity = (ActivityDefinitionData)csClient.Read(normaluseractivityid, readoption);
    ActivityFinishData finishdata = new ActivityFinishData();
    finishdata.Message = "Automatic decision activity finished";
    csClient.FinishActivity(currentactivity.Id, finishdata, readoption);
  }            

}   

1 个答案:

答案 0 :(得分:11)

而不是ActivityFinishData使用DecisionActivityFinishData

var decisionActivityFinishData = new DecisionActivityFinishData
{
  NextActivity = new LinkToActivityDefinitionData{IdRef = "next activity ID"}
};
csClient.FinishActivity(currentactivity.Id, decisionActivityFinishData, 
                        readoption);