QueueSystem.GetJobGroupWaitTimeSimple 方法

确定项目队列和时间表队列处理指定的作业组的剩余的最大的预期的时间。

命名空间:  WebSvcQueueSystem
程序集:  ProjectServerServices(位于 ProjectServerServices.dll 中)

语法

声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/GetJobGroupWaitTimeSimple", 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 GetJobGroupWaitTimeSimple ( _
    trackingID As Guid _
) As Integer
用法
Dim instance As QueueSystem
Dim trackingID As Guid
Dim returnValue As Integer

returnValue = instance.GetJobGroupWaitTimeSimple(trackingID)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/GetJobGroupWaitTimeSimple", 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 GetJobGroupWaitTimeSimple(
    Guid trackingID
)

参数

  • trackingID
    类型:System.Guid

    跟踪 GUID (JobGroupGUID) 分配给多个作业。

返回值

类型:System.Int32
预计完成与同一trackingID的所有作业的秒数。

备注

作业的预期的等待时间才近似,基于相似类型的作业的平均等待时间。GetJobGroupWaitTime还考虑到作业队列和作业互联优先级具有的位置。

使用项目或时间表队列的 PSI 方法的名称从队列中,例如QueueCreateProject和QueueUpdateTimesheet开始。若要设置的跟踪 GUID 使用项目或时间表队列的 PSI 方法,将添加到的每个用于队列方法调用的 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. 将公用方法添加到设置trackingUid,如下面的代码的值的ProjectDerived类。

    public static void SetTrackingGuid(Guid track)
    {
        trackingUid = track;
    }
    
    
  5. 重写GetWebRequest方法,并向的 SOAP 标头添加跟踪 GUID。

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

    备注

    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类。该方法返回与QueueProjectPublish方法相关的所有队列作业的预期的等待时间。由trackingGuid参数指定的组中的作业。QueueSystemWS是QueueSystem Web 引用一个任意名称。

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

下面的代码片段调用正常的 PSI 方法Project对象将跟踪 GUID 添加到的 SOAP 标头,其中一过程中所述。

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.GetAllExpectedGroupWaitTime(queueSystem, trackingGuid);
string waitTime = "After QueuePublish:\t\t" + jobGroupWaitTime.ToString() + " seconds for all related jobs";

QueueCreateProject和QueuePublish呼叫使用的相同的跟踪 GUID 的 SOAP 标头中设置由ProjectDerived对象。QueuePublish方法生成如已发布的项目数据发送到报告数据库的其他队列作业。jobGroupWaitTime值显示在两个队列中的所有相关的作业的当前存在的预期的等待时间。

另请参阅

引用

QueueSystem 类

QueueSystem 成员

WebSvcQueueSystem 命名空间

其他资源

How to: Use the QueueSystem Service