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.
类
枚举
枚举 | 说明 | |
---|---|---|
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.
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
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).
Set references to the assemblies that are specified in step 1.
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.
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);
}
}
}