我正在尝试使用coresrvice将项目发送回工作流程中,以下是我的代码,在将usrdata转换为linktotrusteedata时会出现编译错误。
WorkItemData workitem = (WorkItemData)csClient.Read(workitemid, readoption);
ProcessInstanceData processInstance = (ProcessInstanceData)csClient.Read(workitem.Process.IdRef, readoption);
IEnumerable<ActivityData> ieActivities = processInstance.Activities;
if (ieActivities != null)
{
ActivityInstanceData targetactivity = (ActivityInstanceData)csClient.Read(processInstance.Activities[0].Id, readoption);
UserData lastperformer = (UserData)csClient.Read(processInstance.Activities[0].Owner.IdRef, readoption);
ActivityFinishData finishData = new ActivityFinishData();
finishData.Message = "Finished automatically";
finishData.NextAssignee = lastperformer;
csClient.FinishActivity(targetactivity.Id, finishData, readoption);
csClient.Close();
}
答案 0 :(得分:1)
NextAssignee属性的类型为Link<TrusteeData>
,但您将其设置为UserData
对象。您可能需要创建一个新链接并填写其ID和标题。
这应该有效(未经测试):
[...]
Link<UserData> lastperformer = processInstance.Activities[0].Owner;
ActivityFinishData finishData = new ActivityFinishData();
finishData.Message = "Finished automatically";
finishData.NextAssignee = new Link<TrusteeData> { Id = lastperformer.Id, Title = lastperformer.Title };
csClient.FinishActivity(targetactivity.Id, finishData, readoption);
[...]
如果你只是将NextAssignee设置为lastperformer变量,它也可以工作,因为UserData继承自TrusteeData - 但我不确定。试一试?
答案 1 :(得分:0)
您已拥有LinkToUserData
个对象,因此无法将processInstance.Activities[0].Owner
分配给finishData.NextAssignee
,或使用Owner
属性(LinkToUserData
)来构建一个新的数据对象?
或者您是否有特定原因阅读UserData
?