Поделиться через


Метод Resource.ReadResourceAvailability

Возвращает набор данных о доступности ресурсов в структуре повременных данных.

Пространство имен:  WebSvcResource
Сборка:  ProjectServerServices (в ProjectServerServices.dll)

Синтаксис

'Декларация
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Resource/ReadResourceAvailability", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Resource/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Resource/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function ReadResourceAvailability ( _
    resUIDs As Guid(), _
    startDate As DateTime, _
    endDate As DateTime, _
    timeScale As Short, _
    includeProposedBookings As Boolean _
) As DataSet
'Применение
Dim instance As Resource
Dim resUIDs As Guid()
Dim startDate As DateTime
Dim endDate As DateTime
Dim timeScale As Short
Dim includeProposedBookings As Boolean
Dim returnValue As DataSet

returnValue = instance.ReadResourceAvailability(resUIDs, _
    startDate, endDate, timeScale, includeProposedBookings)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Resource/ReadResourceAvailability", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Resource/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Resource/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public DataSet ReadResourceAvailability(
    Guid[] resUIDs,
    DateTime startDate,
    DateTime endDate,
    short timeScale,
    bool includeProposedBookings
)

Параметры

  • resUIDs
    Тип: []

    Массив идентификаторов GUID ресурса.

  • includeProposedBookings
    Тип: System.Boolean

    Включите назначений, для которых предварительно запланированное для ресурса.

Возвращаемое значение

Тип: System.Data.DataSet
Набор данных с помощью таблицы дат и таблица повременных данных.

Замечания

Разрешения Project Server

Разрешение

Описание

ViewResourceAvailability

Позволяет пользователям просматривать данные о выделении ресурсов. Глобальное разрешение.

Примеры

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 Необходимые условия для примеров кода на основе WCF в Project 2013.

Метод ReadResourceAvailability возвращает набор данных resourceDS. Содержимое набора данных должны записываться ResourceAvailability.xml. Ниже показан пример структуры TimephasedData фактического вывода.

Примечание

Метод ReadResourceAvailabilityForGrid аналогично методу ReadResourceAvailability , за исключением того, как метод ReadResourceAvailabilityForGrid не возвращает GUID ресурса или идентификатор GUID проекта в DataSet.   ReadResourceAvailabilityForGrid используется только в Project Web App для отображения данных в JS Grid

<TimephasedData>
    <AssignmentUID>b2e5a49e-8cd7-42b3-97d8-4b9829f19a8f</AssignmentUID>
    <ProjectName>Capacity</ProjectName>
    <ResourceName>Fourth Coffee</ResourceName>
    <RowType>0</RowType>
    <ProjUID>00000000-0000-0000-0000-000000000000</ProjUID>
    <ResUID>2a4ba1a7-1d96-4086-8fa5-6dea243ed6b5</ResUID>
    <BookingType>0</BookingType>
    <Interval0>72000</Interval0>
    <Interval1>96000</Interval1>
    <Interval2>110400</Interval2>
    <Interval3>105600</Interval3>
    <Interval4>100800</Interval4>
    <Interval5>19200</Interval5>
  </TimephasedData>

Ниже приведен полный код:

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.
            ConfigClientEndpoints(RES_ENDPOINT);
            
            // If directory does not exist,create it.
            if (!Directory.Exists(OUTPUT_FILES))
            {
                Directory.CreateDirectory(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.
            resourceGridDS.WriteXml(outFilePathResourcesAvailabilityGrid);

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

            // 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.
            resourceDS.WriteXml(outFilePathResourceAvailability);
            Console.WriteLine("\nSee XML output of Resource Dataset at {0}", 
                outFilePathResourceAvailability);
            Console.ReadKey();
        }
        // Configure the custom field client end points.
        public static void ConfigClientEndpoints(string endpt)
        {
            resourceClient = new SvcResource.ResourceClient(endpt);
        }
    }
}

См. также

Справочные материалы

Resource класс

Элементы Resource

Пространство имен WebSvcResource