共用方式為


ProjectContext.Projects property

Project Web App執行個體中取得專案的集合。

Namespace:  Microsoft.ProjectServer.Client
Assembly:  Microsoft.ProjectServer.Client (in Microsoft.ProjectServer.Client.dll)

Syntax

'宣告
Public ReadOnly Property Projects As ProjectCollection
    Get
'用途
Dim instance As ProjectContext
Dim value As ProjectCollection

value = instance.Projects
public ProjectCollection Projects { get; }

Property value

Type: Microsoft.ProjectServer.Client.ProjectCollection
專案的集合。

備註

專案實體包含其他實體類型,例如任務、 資源及工作分派。

Examples

下列範例會使用ProjectContext物件,若要列出在Project Web App中已發佈的專案。若要查看使用ProjectServer物件的相同應用程式,請參閱ProjectContext.Projects。在Microsoft Visual Studio中建立簡單的 CSOM 應用程式相關的資訊,請參閱Microsoft.ProjectServer.Client

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.
        
        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);
        }
    }
}

請參閱

參照

ProjectContext class

ProjectContext members

Microsoft.ProjectServer.Client namespace