Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Microsoft.ProjectServer.Client;
- namespace ReadProjectList
- {
- class Program
- {
- private const string pwaPath = "http://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("nt{0}nt{1} : {2}", pubProj.Id.ToString(), pubProj.Name,
- pubProj.CreatedDate.ToString());
- }
- Console.Write("nPress any key to exit: ");
- Console.ReadKey(false);
- }
- }
- }
- SP.SOD.executeOrDelayUntilScriptLoaded(GetProjects, "PS.js");
- function GetProjects() {
- // Initialize the current client context.
- var projContext = PS.ProjectContext.get_current();
- // Get the projects collection.
- projects = projContext.get_projects();
- // Register the request that you want to run on the server.
- // This call includes an optional "Include" parameter to request only the
- // Name, CreatedDate, and Id properties of the projects in the collection.
- projContext.load(projects, 'Include(Name, CreatedDate, Id)');
- // Run the request on the server.
- projContext.executeQueryAsync(onQuerySucceeded, onQueryFailed);
- }
Add Comment
Please, Sign In to add comment