ProjectCollection 類別

代表PublishedProject物件的集合。

繼承階層架構

System.Object
  Microsoft.SharePoint.Client.ClientObject
    Microsoft.SharePoint.Client.ClientObjectCollection
      Microsoft.SharePoint.Client.ClientObjectCollection<PublishedProject>
        Microsoft.ProjectServer.Client.ProjectCollection

命名空間:  Microsoft.ProjectServer.Client
組件:  Microsoft.ProjectServer.Client (在 Microsoft.ProjectServer.Client.dll 中)

語法

'宣告
<ScriptTypeAttribute("PS.ProjectCollection", ServerTypeId := "{8d842010-5471-4748-ab8a-ed6df0494f3d}")> _
Public Class ProjectCollection _
    Inherits ClientObjectCollection(Of PublishedProject)
'用途
Dim instance As ProjectCollection
[ScriptTypeAttribute("PS.ProjectCollection", ServerTypeId = "{8d842010-5471-4748-ab8a-ed6df0494f3d}")]
public class ProjectCollection : ClientObjectCollection<PublishedProject>

備註

若要查看已發佈的專案進行編輯,使用**PublishedProjectCheckOut()**方法。

Project Server 建立每個草稿專案尚未發佈,虛擬PublishedProject物件。虛擬已發佈的專案會確保您可以透過ProjectCollection物件,擷取的草稿專案是否或不發佈。擷取的專案從 Project 資料庫中的草稿表格取得屬性。

例如,如果您使用 PSI,建立草稿專案,然後閱讀使用 CSOM 的所有專案, ProjectCollection物件會包含已解除發佈的草稿專案。您可以決定是否繼承自Project.LastPublishedDatePublishedProject.LastPublishedDate屬性的值所發佈的專案。針對已解除發佈的專案, LastPublishedDate屬性值為DateTime.Min (1/1/0001)。下列的 CSOM 程式碼片段會建立草稿專案,但不會保存或將它發佈。

ProjectContext projContext = new ProjectContext("https://ServerName/pwa");
ProjectCreationInformation newProj = new ProjectCreationInformation();

newProj.Id = Guid.NewGuid();
newProj.Name = "Test project not published";
newProj.Start = DateTime.Today.Date;

PublishedProject newPublishedProj = projContext.Projects.Add(newProj);

projContext.Load(newPublishedProj);
projContext.ExecuteQuery();

DateTime pubDate = newPublishedProj.LastPublishedDate;
Console.Write("\n\tLastPublishedDate before publishing: {0}", pubDate.ToString());

執行緒安全

這類型的任何公用 static (共用 於 Visual Basic 中) 成員是安全執行緒。不保證任何執行個體成員都是安全執行緒。

請參閱

參照

ProjectCollection 成員

Microsoft.ProjectServer.Client 命名空間

Project

ProjectCreationInformation

DraftProject

PublishedProject

Projects