简体   繁体   English

是否有一个REST端点来获取Project Server中项目任务分配的列表?

[英]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.

相关问题 如何通过 REST 从项目 Web 应用程序获取任务的“唯一 ID”? - How to get a Task's "Unique ID" from a Project Web App via REST? 如何按项目类别获取所有项目的列表 - Jira rest api - how to get list of all projects by project category - Jira rest api Project Server 15的REST Web服务 - REST Webservice of Project Server 15 无法访问 Springboot Rest web 项目中的端点 URL - Can not access endpoint URL in Springboot Rest web project Visual Studio项目REST API - Visual Studio project(s) REST api Coverity的REST API是否可以解决每个项目和每个流的问题? - Does Coverity's REST API have way to get issues per project and stream? 如何在JAVA中使用REST调用获取Atlassian-stash项目上的分支列表 - How to get list of branches on a atlassian-stash project using REST call in JAVA 使用JIRA Rest API获取板上所有用户的列表而不是项目? - Using JIRA Rest API to get a list of all users on a board instead of project? TeamCity - 如何通过rest api获取每个项目最后完成的构建列表? - TeamCity - How do you get a list of the last finished build of each project through rest api? 在SharePoint中获取网站集列表的REST终结点URL是什么? - What is the REST endpoint URL to get the list of site collections in Sharepoint?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM