-1

从工作流发布组件后,我正在尝试完成活动。

发布完成,设置完成活动消息后出现错误(“对象实例未设置为实例对象”)。

ActivityFinishData activityfinish = new ActivityFinishData();
activityfinish.Message = "Published to WIP Publication Target";
logdetails("Finish Message able to Set using Code,the below is the finish message");
logdetails(activityfinish.Message);
ProcessInstanceData processInstance = new ProcessInstanceData();
ActivityInstanceData activityInstance = (ActivityInstanceData)processInstance.Activities[0];
logdetails(activityInstance.Title.ToString());
logdetails(activityInstance.Id.ToString());
csClient.FinishActivity(activityInstance.Id, activityfinish, readoption);
logdetails("Workflow Finished");
4

1 回答 1

2

以下方法对我有用:

SessionAwareCoreServiceClient client = Client.GetCoreService();
ReadOptions options = new ReadOptions();

WorkItemData workItem = (WorkItemData)client.Read(currentWorkItemId, options);
ProcessInstanceData processInstance =
    (ProcessInstanceData)client.Read(workItem.Process.IdRef, options);
ActivityInstanceData activityInstance =
   (ActivityInstanceData)client.Read(processInstance.Activities[0].Id, options);

ActivityFinishData finishData = new ActivityFinishData();
finishData.Message = "Finished automatically";

client.FinishActivity(activityInstance.Id, finishData, options);
client.Close();

您可以看到我从当前工作项的 Id 开始,并从那里获取现有对象。我创建为“新”的唯一对象是那些尚不存在的对象。

于 2012-07-11T12:38:42.767 回答