共用方式為


ProjectServer.Projects property

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

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

Syntax

'宣告
<RemoteAttribute> _
Public ReadOnly Property Projects As ProjectCollection
    Get
'用途
Dim instance As ProjectServer
Dim value As ProjectCollection

value = instance.Projects
[RemoteAttribute]
public ProjectCollection Projects { get; }

Property value

Type: Microsoft.ProjectServer.Client.ProjectCollection
Project物件的集合。

備註

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

Examples

注意事項注意事項

我們建議您使用ProjectContext物件,而不是ProjectServer。

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

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

namespace ReadProjectList
{
    class Program
    {
        private const string pwaPath = "https://ServerName/PwaName/";    // Change the path for Project Web App.
        private static ProjectServer projSvr;
        private static ClientRuntimeContext context;

        static void Main(string[] args)
        {
            context = new ClientContext(pwaPath);
            projSvr = new ProjectServer(context);

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

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

            foreach (PublishedProject pubProj in projSvr.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);
        }
    }
}

請參閱

參照

ProjectServer class

ProjectServer members

Microsoft.ProjectServer.Client namespace