1

我正在尝试使用 coresrvice 将项目发送回工作流中的 auther,以下是我的代码,在将 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(); 

        }
4

2 回答 2

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 - 但我不确定。试试看?

于 2012-07-17T08:40:43.593 回答
0

您已经拥有该LinkToUserData对象,所以您不能分配processInstance.Activities[0].OwnerfinishData.NextAssignee,或使用Owner属性 ( LinkToUserData) 来构造一个新的数据对象吗?

还是您阅读的特定原因UserData

于 2012-07-17T08:46:34.590 回答