[英]Is there a REST endpoint to get a list of a project's task assignments in Project Server?
I've tried sending a request to "/_api/ProjectServer/Projects('projectid')/Assignments", but all it does is return duplicates of the last assignment which is weird because the number of objects it returns is always equal to the number of assignments there are in the project. 我尝试将请求发送到“ / _api / ProjectServer / Projects('projectid')/ Assignments”,但它所做的只是返回上次分配的重复值,这很奇怪,因为它返回的对象数始终等于项目中的作业数量。
Basically if I assign a resource to each of a hundred different tasks, the call returns 100 duplicates of the last task's assignment in the list. 基本上,如果我为一百个不同的任务分配资源,则该调用将返回列表中最后一个任务分配的100个重复项。
I suspect it might be a bug, I'd appreciate it if someone could confirm or deny my assumption and/or let me know if there's any other way to retrieve the list of assignments in a project. 我怀疑这可能是一个错误,如果有人可以确认或拒绝我的假设和/或让我知道是否还有其他方法可以检索项目中的任务清单,我将不胜感激。
I didn't exactly know how to work with rest but I would like to provide you with litle lines of code using CSOM that, if I understood properly the question, it might help you: 我并不完全知道如何休息,但我想使用CSOM为您提供少量的代码行,如果我正确理解这个问题,它可能会对您有所帮助:
private static void ListPublishedProjects()
{
// Get the list of projects on the server.
projContext.Load(projContext.Projects);
projContext.ExecuteQuery();
var proj = projContext.Projects.First(p => p.Name == "<project name>");
projContext.ExecuteQuery();
//You must ckeck out the project and load it's tasks
var draftProj = proj.CheckOut();
projContext.Load(draftProj.Tasks);
projContext.ExecuteQuery();
//Loop between all tasks
foreach (DraftTask task in draftProj.Tasks)
{
// Load all assignments in that task
projContext.Load(task.Assignments);
projContext.ExecuteQuery();
//Loop between al assignments
foreach (var assignment in task.Assignments)
{
projContext.Load(assignment.Owner, temp => temp.LoginName, temp => temp.Email);
projContext.Load(assignment.Resource);
projContext.ExecuteQuery();
Console.WriteLine("\n\t RESOURCE NAME:" + assignment.Resource.Name + " => " + assignment.ActualWork);
}
}
//Remember to publish and checkin the project when you finish your TODOs
draftProj.Publish(true);
draftProj.CheckIn(true);
QueueJob qJob = projContext.Projects.Update();
JobState jobState = projContext.WaitForQueue(qJob, 200);
}
}
Hope it helps, 希望能帮助到你,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.