Share via


Microsoft.ProjectServer.Client 命名空间

Classes in this namespace define the client-side object model (CSOM) for Microsoft Project Server 2013.

The CSOM is accessible from both Project Online and from an on-premises Project Server installation, through the Microsoft.Project.Server.Client namespace. The Project Server CSOM is designed to be a relatively easy to use API that directly consumes or provides data by name, rather than by passing datasets or by using changeXml parameters. The CSOM implements the main functionality of the Project Server Interface (PSI) for the primary entities such as Project, Task, EnterpriseResource, and Assignment. It includes additional entities such as CustomField, LookupTable, WorkflowActivities, EventHandler, and QueueJob, which support other common Project Server functionality.

The CSOM is an API that is built on top of the PSI; it does not replace the PSI or implement all of the PSI functionality. The CSOM can be accessed in the following ways:

  • As an assembly to use with Microsoft .NET Framework 4.0: %ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.ProjectServer.Client.dll

    The Microsoft.ProjectServer.Client namespace in the Class library and Web Service Reference section of the Project 2013 SDK documents the managed code for general development of .NET-based CSOM applications.

  • As an assembly to use for development with Silverlight: %ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\ClientBin\Microsoft.ProjectServer.Client.Silverlight.dll

  • As an assembly to use for development of apps for Microsoft Windows Phone 8: %ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\ClientBin\Microsoft.ProjectServer.Client.Phone.dll

  • As a file to use for development of web applications with JavaScript: %ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\PS.js or PS.debug.js

    For the JavaScript reference to the CSOM, see JavaScript API reference for Project Server 2013.

  • A web app can also access the CSOM through REST. For example, you can use the following query to get data for all of the projects in a Project Web App instance:

    https://ServerName/ProjectServerName/_api/ProjectServer/Projects
    

    For more information, see Client-side object model (CSOM) for Project Server and Programming using the SharePoint 2013 REST service.

The Project 2013 SDK download also includes the assemblies and JavaScript files for the Project Server CSOM. If you update Project Server with a service pack, you should copy the updated assemblies and JavaScript files to your development computer.

The primary Project Server entities are generally represented in the CSOM by six classes, for example:

  • The base class, such as Assignment, contains the common properties for the draft entity and the published entity.

  • The creation information class, such as AssignmentCreationInformation, contains the properties that are used to create an entity.

  • The draft class, such as DraftAssignment, includes the read/write properties that represent the entity for editing.

  • The published class, such as PublishedAssignment, includes the read-only properties that represent the published entity.

  • The draft collection class, such as DraftAssignmentCollection, includes the Add method to add a draft entity to the collection, the GetById method to get a specific entity for editing, and the Remove method to delete an entity.

  • The published collection class, such as PublishedAssignmentCollection, generally includes the GetById method to get a specific entity for reading or for checking out to edit.

The ProjectContext class and the ProjectServer class each maintain the client-side context for application development, and contain entity collections that are globally accessible in a Project Web App instance, such as Projects, EnterpriseResources, EnterpriseProjectTypes, CustomFields, LookupTables, and Events. Because the ProjectServer class is provided for internal use by client-side objects, applications should use the ProjectContext class, which is initialized with the Project Web App path.

For a simple example of programming with the CSOM, see the Example section later on this page. For more information about development with the CSOM, see Project Server 2013 的客户端对象模型 (CSOM). The managed code reference in the Project 2013 SDK provides basic descriptions and remarks for the properties of entities, which are also described in the classes for namespaces in the PSI. For detailed information about the properties of entities, see Available fields reference.

The CSOM for Project Server 2013 is built on the CSOM for SharePoint Foundation 2013. For more information, see Choose the right API set in SharePoint 2013.

  说明
公共类 Assignment 包含绘制分配和发布的分配的通用属性。
公共类 AssignmentCreationInformation 包含创建工作分配时,可以设置的属性。
公共类 BaseCalendarException 代表的基准日历例外项的集合。
公共类 Calendar 表示项目服务器日历。
公共类 CalendarCollection 表示日历对象的集合。
公共类 CalendarCreationInformation 表示用来创建新的日历的信息。
公共类 CalendarException 表示从星期日到星期六的差异 (异常)。
公共类 CalendarExceptionCollection 表示日历例外项的集合。
公共类 CalendarExceptionCreationInformation 提供有关创建日历例外日期的信息。
公共类 CustomField 包含的属性和方法,用于创建企业自定义域。
公共类 CustomFieldCollection 表示CustomField对象的集合。
公共类 CustomFieldCreationInformation 提供了用于创建自定义字段的信息。
公共类 DraftAssignment 启用草稿分配项目的创建。
公共类 DraftAssignmentCollection 表示DraftAssignment对象的集合。
公共类 DraftProject 表示一个项目,即项目已签出的草稿版本。
公共类 DraftProjectResource 表示一个签出项目中的企业资源。
公共类 DraftProjectResourceCollection 表示DraftProjectResource对象的集合。
公共类 DraftTask 代表已签出项目中的任务。
公共类 DraftTaskCollection 表示DraftTask对象的集合。
公共类 DraftTaskLink 创建一个对象来访问草稿项目中的任务链接。
公共类 DraftTaskLinkCollection 表示DraftTaskLink对象的集合。
公共类 EnterpriseProjectType 创建一个对象,表示企业项目类型。
公共类 EnterpriseProjectTypeCollection 代表EnterpriseProjectType (EPT) 对象的集合。
公共类 EnterpriseProjectTypeCreationInformation 提供有关创建企业项目类型 (EPT) 的信息。
公共类 EnterpriseResource 表示由 Project Server 管理项目中的资源。
公共类 EnterpriseResourceCollection 表示EnterpriseResource对象的集合。
公共类 EnterpriseResourceCreationInformation 提供有关创建企业资源的信息。
公共类 EntityType 表示一种类型的项目服务器实体。
公共类 EntityTypes 表示可通过 CSOM 的 Project Server 实体的类型。
公共类 Event 表示和标识在业务对象数据发生更改时,在项目服务器中发生的活动。
公共类 EventCollection 表示Event对象的集合。
公共类 EventHandler 表示标识和 Project Server 事件处理程序的位置。
公共类 EventHandlerCollection 表示EventHandler对象的集合。
公共类 EventHandlerCreationInformation 提供有关创建事件处理程序的信息。
公共类 LookupCost 包含类型Cost的查阅表格的数据值。
公共类 LookupDate 包含类型Date的查阅表格的数据值。
公共类 LookupDuration 包含类型Duration的查阅表格的数据值。
公共类 LookupEntry 代表查阅表格项。
公共类 LookupEntryCollection 表示一个查阅表格的LookupEntry对象的集合。
公共类 LookupEntryCreationInformation 提供创建的查阅表格项的信息。
公共类 LookupEntryValue 表示值的查阅表格项。
公共类 LookupMask 表示分层的查找表级别的掩码定义。
公共类 LookupNumber 包含类型Number的查阅表格的数据值。
公共类 LookupTable 表示一个查阅表格。
公共类 LookupTableCollection 表示LookupTable对象的集合。
公共类 LookupTableCreationInformation 提供方法和属性设置创建的查阅表格。
公共类 LookupTables 表示查找表定义。
公共类 LookupText 定义类型Text的查阅表格中的一项。
公共类 Phase 表示集合的分组方式会在项目生命周期中标识一组公共的活动的阶段。
公共类 PhaseCollection 表示工作流Phase对象的集合。
公共类 PhaseCreationInformation 提供方法和属性设置中创建的工作流阶段使用。
公共类 PlanAssignment 在项目计划中提供有关工作分配的信息。
公共类 PlanAssignmentCollection 表示计划分配对象的集合。
公共类 PlanAssignmentCreationInformation 提供有关创建PlanAssignment对象的信息。
公共类 PlanAssignmentInterval 表示的时间间隔为项目计划分配的集合。
公共类 PlanAssignmentIntervalCollection 表示PlanAssignmentInterval对象的集合。
公共类 PlanAssignmentIntervalCreationInformation 提供用于创建PlanAssignmentInterval对象的信息。
公共类 Project 包含绘制项目和已发布的项目的公共属性。
公共类 ProjectCollection 表示PublishedProject对象的集合。
公共类 ProjectContext 维护与Project Web App实例,开发的客户端上下文和包含的项目服务器对象的Project Web App中存在的企业级集合。
公共类 ProjectCreationInformation 包含可以在创建项目时设置的属性。
公共类 ProjectDetailPage 表示项目详细信息页面 (PDP),它是用于创建、 查看或管理Project Web App中的项目属性的 Web 部件页。
公共类 ProjectDetailPageCollection 表示项目详细信息页面 (Pdp) 的集合。
公共类 ProjectDetailPageCreationInformation 提供用于创建企业项目类型的项目详细信息页面 (PDP) 的信息。
公共类 ProjectResource 提供了有关项目资源的信息。
公共类 ProjectResourceCreationInformation 提供属性设置和创建项目资源实体的方法。
公共类 ProjectServer 由客户端代码在内部使用。若要初始化开发项目服务器 CSOM 的客户端上下文,使用ProjectContext
公共类 ProjectServerData 表示到服务器的连接。
公共类 PublishedAssignment 表示在已发布的项目分配。
公共类 PublishedAssignmentCollection 表示集合的已发布的工作分配。
公共类 PublishedProject 表示在项目服务器发布的项目。
公共类 PublishedProjectResource 表示在项目服务器发布非企业资源。
公共类 PublishedProjectResourceCollection 表示已发布项目中的资源的集合。
公共类 PublishedTask 表示已发布项目中的任务。
公共类 PublishedTaskCollection 表示已发布项目中的任务的集合。
公共类 PublishedTaskLink 表示两个任务的开始日期和完成日期之间的依赖关系。
公共类 PublishedTaskLinkCollection 表示已发布项目中的任务链接的集合。
公共类 QueueJob 队列用于发布的项目。
公共类 QueueJobCollection 表示QueueJob对象的集合。
公共类 ResourceCalendarException 代表资源日历例外项。
公共类 ResourcePlan 表示高级查看哪些资源可能会需要的项目。
公共类 ScriptTypeFactory 此类及其成员仅供内部使用,不适合在您的代码中使用。
公共类 ServiceStatus 提供项目服务器服务的状态信息。
公共类 Stage 表示项目工作流的阶段。
公共类 StageCollection 表示工作流Stage对象的集合。
公共类 StageCreationInformation 提供方法和属性,可用于创建项目工作流阶段。
公共类 StageCustomField 表示自定义字段的项目阶段。
公共类 StageCustomFieldCollection 表示StageCustomField对象,是在某一工作流阶段的自定义字段的集合。
公共类 StageCustomFieldCreationInformation 提供属性设置和用来将自定义字段添加到项目阶段信息的方法。
公共类 StageDetailPage 表示某一工作流阶段项目详细信息页面 (PDP)。
公共类 StageDetailPageCollection 表示在某一工作流阶段中可见的项目详细信息页面 (Pdp) 的集合。
公共类 StageDetailPageCreationInformation 提供属性设置和用来创建工作流阶段的项目详细信息页面 (PDP) 的方法。
公共类 StatusAssignment 提供的对象,则分配的状态更新中。
公共类 StatusAssignmentCollection 表示工作分配的状态更新中的StatusAssignment对象的集合。
公共类 StatusAssignmentCreationInformation 提供属性设置和创建的状态分配对象的方法。
公共类 StatusTask 提供一个对象,用于跟踪任务的进度。
公共类 StatusTaskCreationInformation 提供属性设置和创建 task 对象状态的方法。
公共类 Task 包含方法和属性,可用于访问该任务的详细信息。
公共类 TaskCreationInformation 提供属性设置和方法用来创建任务。
公共类 TaskLink 表示两个任务的开始日期和完成日期之间的依赖关系。
公共类 TaskLinkCreationInformation 提供属性设置和用来创建一个任务链接的方法。
公共类 TimePhase 表示时间的分布的工作分配进度信息。
公共类 TimeSheet 包含的方法和属性来管理工时单。
公共类 TimeSheetLine 表示在时间表中的直线。
公共类 TimeSheetLineCollection 表示集合的时间表行。
公共类 TimeSheetLineCreationInformation 提供属性设置和用来创建时间表行的方法。
公共类 TimeSheetPeriod 表示定义的时间表的时间段。
公共类 TimeSheetPeriodCollection 表示TimeSheetPeriod对象的集合。
公共类 TimeSheetWork 表示不同类型的工时单的工作。
公共类 TimeSheetWorkCollection 工时单,提供了实际的工作项的集合。
公共类 TimeSheetWorkCreationInformation 提供属性设置和用来创建一个工时单工作对象的方法。
公共类 WorkflowActivities 包含封装 Project Server 工作流活动的方法和方法,与版本 4, Windows Workflow Foundation (WF4) 一起使用。
公共类 WorkflowDesigner 创建一个对象,可用于设计工作流。
公共类 WorkflowDesignerField 表示在工作流设计器中创建的字段。
公共类 WorkflowDesignerFieldCollection 表示企业项目自定义字段,可以在工作流设计器中使用的筛选的集合。

枚举

  枚举 说明
公共枚举 AccrueAt 成本累算模式指定何时以及如何资源成本计入任务成本。
公共枚举 BookingType 指定资源的工作分配的预订方式。
公共枚举 CalendarRecurrenceDays 表示重复的日历例外在一周中的星期几。
公共枚举 CalendarRecurrenceType 指定重复执行类型为日历例外。
公共枚举 CalendarRecurrenceWeek 指定用于设置一个计划一个月的一周。
公共枚举 CommittedDecisionResult 指定是否在优化程序函数或项目组合分析的规划器函数中包括一项。
公共枚举 ConstraintType 指定任务的限制类型。
公共枚举 CurrencySymbolPosition 指定货币符号的位置。
公共枚举 CustomFieldRollupType 指定一个自定义的字段的摘要汇总类型。
公共枚举 CustomFieldType 指定企业自定义字段的类型。
公共枚举 DependencyType 指定要建立两个任务之间的依赖项的类型。
公共枚举 EnterpriseResourceType 表示不同类型的企业资源。
公共枚举 FixedCostAccrual 指定何时以及如何固定的成本计入任务成本。
公共枚举 JobState Project Server 队列作业状态指定队列作业的状态。
公共枚举 LookupTableConstants 指定的最大值和最小值查找表实体。
公共枚举 LookupTableMaskSequence 指定的掩码序列,这是一个查阅表格的数据的类型。
公共枚举 LookupTableSortOrder 指定查找表的排序顺序。
公共枚举 OvertimeRateFormat 指定时间单位的资源加班工时的费率 ;即,每个时间单位,例如美元 / 小时的速度。
公共枚举 ProjectDetailPageType 指定的项目详细信息页面 (PDP) 的类型。
公共枚举 ProjectType 指定项目的类型。
公共枚举 QueueMsgType 指定队列的消息类型,用于将作业发送到项目服务器队列系统。
公共枚举 ReadyToLeaveProjectStageValue 指定项目阶段要求在项目服务器工作流程,以帮助确定工作流是否已准备好离开舞台。
公共枚举 ResourceType 指定资源的类型。
公共枚举 StandardRateFormat 指定时间单位的资源费率 ;即,每个时间单位,例如美元 / 小时的速度。
公共枚举 StrategicImpactBehavior 指定如何战略影响值在 Project Server 工作流容器中的行为。
公共枚举 TaskType 指定是否在项目中的任务类型固定单位,固定的工作,或固定工期。
公共枚举 TimeScale 指定时间分段数据的小数位数。
公共枚举 TimeSheetEntryMode 包含的工时单输入模式。
公共枚举 TimeSheetLineClass 表示定义时间表行的不同用途的分类。
公共枚举 TimeSheetLineStatus 代表可应用于工时单行的状态设置。
公共枚举 TimeSheetStatus 代表可应用于工时单的状态设置。
公共枚举 TimeSheetValidationType 指定验证的时间表行的类型的集。
公共枚举 TrackingMode 指定用于跟踪任务进度的模式。
公共枚举 UpdateProjectStageStatusFieldValue 在 Project Server 工作流中指定项目阶段的状态。
公共枚举 UtilizationType 指定用于当前的资源计划的资源的类型。
公共枚举 WorkFormat 包含一个值,该值表示一个工作格式。

示例

Following are the steps to create a simple console application named ReadProjectList that uses classes in the Microsoft.ProjectServer.Client namespace to read the collection of published projects.

  1. If you are developing on a remote computer, copy the following assemblies from the Project 2013 SDK download or from %ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI on the Project Server computer to a convenient folder on the development computer:

    • Microsoft.ProjectServer.Client.dll

    • Microsoft.SharePoint.Client.dll

    • Microsoft.SharePoint.Client.Runtime.dll

  2. In Visual Studio 2012, create a console application. For this example, name the application ReadProjectList. In the New Project dialog box, set the target framework to .NET Framework 4.5. You could also use Visual Studio 2010 with .NET Framework 4 (do not use .NET Framework 4 Client Profile).

  3. Set references to the assemblies that are specified in step 1.

  4. Replace the code in the Program.cs file with the following code.

    备注

    You should set the CSOM context by using the ProjectContext object, not by using the ProjectServer object.

  5. Press F5 to run the application.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ProjectServer.Client;

namespace ReadProjectList
{
    class Program
    {
        private const string pwaPath = "https://ServerName/PwaName/";    // Change the path for Project Web App.
        
        // Set the context for the Project Server CSOM.
        private static ProjectContext projContext;

        static void Main(string[] args)
        {
            projContext = new ProjectContext(pwaPath); 

            // Get the list of published projects in Project Web App.
            projContext.Load(projContext.Projects);
            projContext.ExecuteQuery();

            Console.WriteLine("\nProject ID : Project name : Created date");

            foreach (PublishedProject pubProj in projContext.Projects)
            {
                Console.WriteLine("\n\t{0}\n\t{1} : {2}", pubProj.Id.ToString(), pubProj.Name, 
                    pubProj.CreatedDate.ToString());
            }

            Console.Write("\nPress any key to exit: ");
            Console.ReadKey(false);
        }
    }
}

另请参阅

引用

其他资源

Client-side object model (CSOM) for Project Server

JavaScript API reference