共用方式為


QueueSystem.GetJobGroupWaitTime 方法

會決定在工作群組中,指定類型的程序工作之佇列的預計間隔時間。

命名空間:  WebSvcQueueSystem
組件:  ProjectServerServices (在 ProjectServerServices.dll 中)

語法

'宣告
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/GetJobGroupWaitTime", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function GetJobGroupWaitTime ( _
    trackingID As Guid, _
    messageType As QueueMsgType _
) As Integer
'用途
Dim instance As QueueSystem
Dim trackingID As Guid
Dim messageType As QueueMsgType
Dim returnValue As Integer

returnValue = instance.GetJobGroupWaitTime(trackingID, _
    messageType)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/GetJobGroupWaitTime", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public int GetJobGroupWaitTime(
    Guid trackingID,
    QueueMsgType messageType
)

參數

  • trackingID
    類型:System.Guid

    追蹤指派給多個工作的 GUID (JobGroupGUID)。

傳回值

類型:System.Int32
預期的工作使用相同的trackingID秒與指定類型,才可完成的數字。

備註

之工作的預期的等待時間才大約,根據類似類型的工作的平均等待時間。GetJobGroupWaitTime還需考慮工作已在佇列和工作相互關聯優先順序的位置。

PSI 方法使用的專案或時程表佇列名稱開始使用佇列,例如QueueCreateProject和QueueUpdateTimesheet。若要設定的 PSI 方法使用的專案或時程表佇列追蹤 GUID,新增您使用的佇列方法呼叫每個 PSI Web 服務的 SOAP 標頭的追蹤 GUID。

Project Server 權限

權限

描述

ManageQueue

可讓使用者管理 Project Server 佇列。通用權限。

範例

下列程序示範如何修改 [Project Web 服務的WebRequest方法。

若要新增 Project PSI 呼叫 SOAP 標頭的追蹤 GUID:

  1. 設定 Project Web 服務 (https://ServerName/ProjectServerName/_vti_bin/psi/project.asmx) 的 Web 參考。例如,名稱為 Web 參考ProjectWS。

  2. 加入衍生自ProjectWS.Project類別的類別。例如,名稱ProjectDerived的類別。

  3. 新增私用靜態類別成員的 GUID 值。例如,名稱成員trackingUid。

    using System;
    using System.Net;
    
    namespace SomeNamespace.ProjectWS
    {
        class ProjectDerived : Project
        {
            private static Guid trackingUid = Guid.Empty;
            . . .
        }
    }
  4. 新增公用方法ProjectDerived類別的設定值trackingUid,例如下列程式碼所示。

    public static void SetTrackingGuid(Guid track)
    {
        trackingUid = track;
    }
  5. 覆寫GetWebRequest方法,並將追蹤 GUID 新增至 SOAP 標頭。

    protected override WebRequest GetWebRequest(Uri uri)
    {
        WebRequest webRequest = base.GetWebRequest(uri);
        webRequest.Headers.Add("PSTrackingGuid", trackingUid.ToString());
    
        return webRequest;
    }
    注意事項注意事項

    Name 參數中的Headers.Add方法必須拼法"PSTrackingGuid"與顯示內容完全相同。

  6. 在其他類別中的應用程式,建立和初始化ProjectDerived物件的通話至 Project Web 服務,例如:

    private static SomeNameSpace.ProjectWS.ProjectDerived projectDerived = 
        new SomeNameSpace.ProjectWS.ProjectDerived();
    . . .
        projectDerived.Url = "https://ServerName/ProjectServerName/_vti_bin/Project.asmx";
        projectDerived.Credentials = CredentialCache.DefaultCredentials;

下列範例會將GetExpectedGroupWaitTime方法是在名為QueueSystemUtilities類別。如專案發佈傳送給報表資料庫的資料,則方法會傳回預期的等待時間。trackingGuid參數會指定群組中的工作。QueueSystemWS是QueueSystem Web 參考 (英文) 任意名稱。

public int GetExpectedGroupWaitTime(QueueSystemWS.QueueSystem q, 
    Guid trackingGuid, QueueSystemWS.QueueMsgType msgType)
{
    int wait = q.GetJobGroupWaitTime(trackingGuid, msgType);
    return wait;
}

下列程式碼片段會 PSI 方法的一般呼叫其中Project物件新增至 SOAP 標題中的追蹤 GUID 在先前程序中所述。

using System.Threading;
using PSLibrary = Microsoft.Office.Project.Server.Library;
. . .
private static QueueSystemWS.QueueSystem queueSystem =
    new QueueSystemWS.QueueSystem(); 
private static QueueSystemUtils queueSystemUtils = new QueueSystemUtils();
. . .
ProjectWS.ProjectDataSet dsProject =
    new ProjectWS.ProjectDataSet();
ProjectWS.ProjectDataSet.ProjectRow projectRow =
    dsProject.Project.NewProjectRow();

Guid projectGuid = Guid.NewGuid();
projectRow.PROJ_UID = projectGuid;
projectRow.PROJ_NAME = "Name of Project";
projectRow.PROJ_TYPE =
    Convert.ToInt32(PSLibrary.Project.ProjectType.Project);

dsProject.Project.AddProjectRow(projectRow);

// Create the queue job and tracking GUIDs, and then set the tracking 
// GUID for SOAP calls to the derived Project object.
Guid jobGuid = Guid.NewGuid();
Guid trackingGuid = Guid.NewGuid();
SomeNameSpace.ProjectWS.ProjectDerived.SetTrackingGuid(trackingGuid);

bool validateOnly = false;
// Create and save project to the Draft database. 
projectDerived.QueueCreateProject(jobGuid, dsProject, validateOnly);
// Wait a few seconds, or create a WaitForQueue method.
Thread.Sleep(3000);

ProjectWS.ProjectRelationsDataSet dsProjectRelations =
    new ProjectWS.ProjectRelationsDataSet();
jobGuid = Guid.NewGuid();

string wssUrl = "" // Default SharePoint project workspace, 
bool fullPublish = true;

// Publish the project to the Published database.
dsProjectRelations = projectDerived.QueuePublish(jobGuid, projectGuid, fullPublish, wssUrl);

// Try various wait times to see the effect of additional queue jobs 
// spawned by QueuePublish.
Thread.Sleep(500);

QueueSystemWS.QueueMsgType msgType = QueueSystemWS.QueueMsgType.ReportingProjectPublish;
int jobGroupWaitTime = queueSystemUtils.GetExpectedGroupWaitTime(queueSystem, trackingGuid, msgType);
string waitTime = "After QueuePublish:\t\t" + jobGroupWaitTime.ToString() + " seconds for the ReportingProjectPublish job";
. . .

QueueCreateProject和QueuePublish通話使用相同的 tracking SOAP 標頭設ProjectDerived物件的 GUID。QueuePublish方法會產生額外的佇列工作,例如已發佈的專案資料傳送到報表資料庫。jobGroupWaitTime值顯示僅ReportingProjectPublish工作的預期的等待時間。

請參閱

參照

QueueSystem 類別

QueueSystem 成員

WebSvcQueueSystem 命名空間

其他資源

How to: Use the QueueSystem Service