将项目发回给作者时出现Trusteedata错误

时间:2012-07-17 08:30:17

标签: tridion tridion-2011

我正在尝试使用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(); 

        }

2 个答案:

答案 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