QueueSystem.GetJobGroupWaitTimeSimple method

Determines the maximum expected time remaining for Project and Timesheet queues to process the specified job group.

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

Syntax

'Declaration
<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
'Usage
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
)

Parameters

  • trackingID
    Type: System.Guid

    Tracking GUID (JobGroupGUID) assigned to multiple jobs.

Return value

Type: System.Int32
Expected number of seconds for all jobs with the same trackingID to complete.

Remarks

The expected wait time for jobs is only approximate, based on the average wait times for jobs of similar type. GetJobGroupWaitTime also takes into account the position the jobs have on the queue and the job correlation priority.

The names of PSI methods that use the Project or Timesheet queue start with Queue, for example QueueCreateProject and QueueUpdateTimesheet. To set the tracking GUID for PSI methods that use the Project or Timesheet queue, add the tracking GUID to the SOAP header of each PSI Web service that you use for the queue method calls.

Project Server Permissions

Permission

Description

ManageQueue

Allows the user to manage the Project Server queue. Global permission.

Examples

The following procedure shows how to modify the WebRequest method for the Project Web service.

To add a tracking GUID to the SOAP header for Project PSI calls:

  1. Set a Web reference to the Project Web service (https://ServerName/ProjectServerName/_vti_bin/psi/project.asmx). For example, name the Web reference ProjectWS.

  2. Add a class that derives from the ProjectWS.Project class. For example, name the class ProjectDerived.

  3. Add a private static class member for a GUID value. For example, name the member trackingUid.

    using System;
    using System.Net;
    
    namespace SomeNamespace.ProjectWS
    {
        class ProjectDerived : Project
        {
            private static Guid trackingUid = Guid.Empty;
            . . .
        }
    }
    
  4. Add a public method to the ProjectDerived class that sets the value of trackingUid, such as the following code.

    public static void SetTrackingGuid(Guid track)
    {
        trackingUid = track;
    }
    
    
  5. Override the GetWebRequest method and add the tracking GUID to the SOAP header.

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

    Note

    The name parameter in the Headers.Add method must be spelled "PSTrackingGuid" exactly as shown.

  6. In the other classes of your application, create and initialize a ProjectDerived object for calls to the Project Web service, for example:

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

The GetExpectedGroupWaitTime method in the following example is in a class named QueueSystemUtilities. The method returns the expected wait time for all queue jobs related to the QueueProjectPublish method. Jobs in the group are specified by the trackingGuid parameter. QueueSystemWS is an arbitrary name of the QueueSystem Web reference.

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

The following code fragment makes normal calls to the PSI methods where the Project object adds the tracking GUID to the SOAP header, as described in the previous procedure.

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";

Both the QueueCreateProject and QueuePublish calls use the same tracking GUID which is set in the SOAP headers by the ProjectDerived object. The QueuePublish method spawns additional queue jobs such as sending the published project data to the Reporting database. The jobGroupWaitTime value shows the expected wait time of all related jobs that currently exist in both queues.

See also

Reference

QueueSystem class

QueueSystem members

WebSvcQueueSystem namespace

Other resources

How to: Use the QueueSystem Service