ProjectContext.Projects-Eigenschaft
Ruft die Auflistung von Projekten in der Project Web App -Instanz.
Namespace: Microsoft.ProjectServer.Client
Assembly: Microsoft.ProjectServer.Client (in Microsoft.ProjectServer.Client.dll)
Syntax
'Declaration
Public ReadOnly Property Projects As ProjectCollection
Get
'Usage
Dim instance As ProjectContext
Dim value As ProjectCollection
value = instance.Projects
public ProjectCollection Projects { get; }
Eigenschaftswert
Typ: Microsoft.ProjectServer.Client.ProjectCollection
Eine Auflistung von Projekten.
Hinweise
Project-Entität enthält zusätzliche Entitätstypen, wie Aufgaben, Ressourcen und Zuordnungen.
Beispiele
Das folgende Beispiel verwendet das ProjectContext -Objekt die veröffentlichten Projekte in Project Web Appaufgelistet. Verwenden des ProjectServer -Objekts derselben Anwendung, finden Sie unter ProjectContext.Projects. Informationen zum Erstellen einer einfachen CSOM-Anwendung im Microsoft Visual Studiofinden Sie unter 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);
}
}
}