共用方式為


Resource.ReadResourceAvailabilityForGrid method

此成員是保留給內部使用,而不是用來直接從您的程式碼使用傳回JS Grid control的時段式資料結構中的資源可用性的資料集。

Namespace:  WebSvcResource
Assembly:  ProjectServerServices (in ProjectServerServices.dll)

Syntax

'宣告
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Resource/ReadResourceAvailabilityForGrid", 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 ReadResourceAvailabilityForGrid ( _
    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.ReadResourceAvailabilityForGrid(resUIDs, _
    startDate, endDate, timeScale, includeProposedBookings)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Resource/ReadResourceAvailabilityForGrid", 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 ReadResourceAvailabilityForGrid(
    Guid[] resUIDs,
    DateTime startDate,
    DateTime endDate,
    short timeScale,
    bool includeProposedBookings
)

參數

  • resUIDs
    Type: []

    資源的 Guid 的陣列。

  • includeProposedBookings
    Type: System.Boolean

    包含只是暫時排程資源的工作分派。

傳回值

Type: System.Data.DataSet
以日期和時段式資料的資料集。

備註

ReadResourceAvailabilityForGrid方法是在內部使用的JS Grid control。若要取得資源可用性的資料,使用ReadResourceAvailability方法。

專案伺服器權限

權限

說明

ViewResourceAvailability

可讓使用者檢視資源配置資料。通用的權限。

Examples

這個範例使用 ProjectServerServices.dll proxy 組件中的SvcResource命名空間。ConfigClientEndpoints方法會使用設定 WCF 繫結、 行為和端點的 app.config 檔案。如需有關建立 PSI proxy 組件和 app.config 檔案的資訊,請參閱Prerequisites for WCF-Based Code Samples

ReadResourceAvailabilityForGrid方法會傳回資料集resourceGridDS。ResourceAvailabilityGrid.xml會寫入資料集的內容。TimephasedData結構從實際輸出的範例如下所示:

注意事項注意事項

除了 ReadResourceAvailabilityForGrid 方法不會傳回 GUID 的資源或專案 GUID 中DataSet, ReadResourceAvailabilityForGrid方法很類似ReadResourceAvailability方法。ReadResourceAvailabilityForGrid是只能用於Project Web App在 JS 方格中顯示資料

<TimephasedData>
<AssignmentUID>2ba3b898-3fa7-421b-8643-56f0088e7cae</AssignmentUID>
<ProjectName>Capacity</ProjectName>
<ResourceName>Fourth Coffee </ResourceName>
<RowType>0</RowType>
<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 class

Resource members

WebSvcResource namespace