This documentation is archived and is not being maintained.

Resource.ReadResourceAvailability Method

Returns a dataset of resource availability in a timephased data structure.

Namespace:  [Resource Web service]
Service reference: http://ServerName:32843/[Project Service Application GUID]/PSI/Resource.svc
Web service reference: http://ServerName/ProjectServerName/_vti_bin/PSI/Resource.asmx?wsdl

[SoapDocumentMethodAttribute("", RequestNamespace = "", 
	ResponseNamespace = "", 
	Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public DataSet ReadResourceAvailability(
	Guid[] resUIDs,
	DateTime startDate,
	DateTime endDate,
	short timeScale,
	bool includeProposedBookings


Type: []
Array of resource GUIDs.
Type: System.DateTime
Beginning of the period.
Type: System.DateTime
End of the period.
Type: System.Int16
Desired scale of the TimephasedData table, in the TimeScaleClass.TimeScale enumeration.
Type: System.Boolean
Include assignments for which the resource is only tentatively scheduled.

Return Value

Type: System.Data.DataSet
Dataset with a table of dates and a table of timephased data.

Project Server Permissions




Allows a user to view resource allocation data. Global permission.

The example uses the SvcResource namespace in the ProjectServerServices.dll proxy assembly. The ConfigClientEndpoints method uses an app.config file for setting the WCF binding, behavior, and endpoint. For information about creating a PSI proxy assembly and an app.config file, see Prerequisites for WCF-Based Code Samples.

The ReadResourceAvailability method returns the dataset resourceDS. The contents of the dataset are written to ResourceAvailability.xml.A sample of the TimephasedData structure from the actual output is shown below:


The ReadResourceAvailabilityForGrid method is similar to the ReadResourceAvailability method, except the ReadResourceAvailabilityForGrid method does not return the resource GUID or project GUID in the DataSet.   ReadResourceAvailabilityForGrid is used only in Project Web App for displaying data in the JS Grid

    <ResourceName>Fourth Coffee</ResourceName>

The complete code is given below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.ServiceModel;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace Microsoft.SDK.Project.Samples.Resources
    class Resources
        private static SvcResource.ResourceClient resourceClient;
        private const string RES_ENDPOINT = "basicHttp_Resource";
        private const string OUTPUT_FILES = @"C:\Projects\Samples\Output\";
        private static string outFilePathResourcesAvailabilityGrid;
        private static string outFilePathResourceAvailability;

        static void Main(string[] args)
            Guid[] resourceID = new Guid[2];
            resourceID[0] = new Guid("2a4ba1a7-1d96-4086-8fa5-6dea243ed6b5");
            resourceID[1] = new Guid("f6c846fa-b21b-49eb-9921-fe6bdec60242");
            DateTime startDate = new DateTime(2010, 1, 10);
            DateTime finishDate = new DateTime(2010, 6, 6);

            // Configure the end points.
            // If directory does not exist,create it.
            if (!Directory.Exists(OUTPUT_FILES))

            // Assign the path where the output XML file will be saved.
            outFilePathResourcesAvailabilityGrid = OUTPUT_FILES + "ResourcesAvailabilityGrid.xml";
            outFilePathResourceAvailability = OUTPUT_FILES + "ResourceAvailability.xml";

            // Read the resource availability.
            System.Data.DataSet resourceGridDS = resourceClient.ReadResourceAvailabilityForGrid(
                resourceID, startDate, finishDate, (short)PSLibrary.Resource.TimeScale.Months, true);
            // Write the contents of the DataSet to an XML file.

            Console.WriteLine("\nSee XML output of the DataSet at {0}",

            // Read the resource availability for grid.
            System.Data.DataSet resourceDS = resourceClient.ReadResourceAvailability(
                resourceID, startDate, finishDate, (short)PSLibrary.Resource.TimeScale.Months, true);

            // Write the DataSet contents to an XML file.
            Console.WriteLine("\nSee XML output of Resource Dataset at {0}", 
        // Configure the custom field client end points.
        public static void ConfigClientEndpoints(string endpt)
            resourceClient = new SvcResource.ResourceClient(endpt);