Share via


QueueSystem.ReadJobStatus Method

Gets the status of the specified jobs in the Project Server Queuing Service.

Namespace:  [QueueSystem Web service]
Service reference: http://ServerName:32843/[Project Service Application GUID]/PSI/QueueSystem.svc
Web service reference: http://ServerName/ProjectServerName/_vti_bin/PSI/QueueSystem.asmx?wsdl

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/ReadJobStatus", 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 ReadJobStatus ( _
    qsrDS As QueueStatusRequestDataSet, _
    includeWaitTime As Boolean, _
    sortColumn As SortColumn, _
    sortOrder As SortOrder _
) As QueueStatusDataSet
'Usage
Dim instance As QueueSystem
Dim qsrDS As QueueStatusRequestDataSet
Dim includeWaitTime As Boolean
Dim sortColumn As SortColumn
Dim sortOrder As SortOrder
Dim returnValue As QueueStatusDataSet

returnValue = instance.ReadJobStatus(qsrDS, _
    includeWaitTime, sortColumn, sortOrder)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/QueueSystem/ReadJobStatus", 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 QueueStatusDataSet ReadJobStatus(
    QueueStatusRequestDataSet qsrDS,
    bool includeWaitTime,
    SortColumn sortColumn,
    SortOrder sortOrder
)

Parameters

  • includeWaitTime
    Type: System.Boolean
    If true, include the expected wait time field.

Return Value

Type: [QueueSystem Web service].QueueStatusDataSet
Status of the requested jobs, with the QueueStatusDataSet.StatusRow data for each job.

Remarks

ReadJobStatus can return status data for specific jobs or for a group of jobs which have the same tracking GUID.

PSI methods that use a queue begin with the word Queue in the method name. 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;
    }
    NoteNote
    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 GetStatusOfQueueJobs method in the following example is in a class named QueueSystemUtilities. GetStatusOfQueueJobs is an overload of the same method name in the example for ReadJobStatusSimple. The method returns the status of all jobs with the same tracking ID. Jobs in the group are specified by the trackingGuid parameter. QueueSystemWS is an arbitrary name of the QueueSystem Web reference.

public QueueSystemWS.QueueStatusDataSet GetStatusOfQueueJobs(
    QueueSystemWS.QueueSystem q,
    Guid jobGuid,
    Guid trackingGuid, 
    int jobState,
    int msgType,
    QueueSystemWS.SortColumn sortColumn,
    QueueSystemWS.SortOrder sortOrder,
    bool includeWaitTime)
{
    QueueSystemWS.QueueStatusRequestDataSet dsQStatusRequest = 
        new QueueSystemWS.QueueStatusRequestDataSet();
    QueueSystemWS.QueueStatusRequestDataSet.StatusRequestRow qStatusRow =
        dsQStatusRequest.StatusRequest.NewStatusRequestRow();

    qStatusRow.JobGUID = jobGuid;
    qStatusRow.JobGroupGUID = trackingGuid;
    if (jobState != 0) 
        qStatusRow.JobCompletionState = jobState;
    if (msgType != 0)
        qStatusRow.MessageType = msgType;
    dsQStatusRequest.StatusRequest.AddStatusRequestRow(qStatusRow);

    QueueSystemWS.QueueStatusDataSet dsQStatus = q.ReadJobStatus(dsQStatusRequest, 
        includeWaitTime, 
        sortColumn, 
        sortOrder);
    return dsQStatus;
}

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 ProjectWS.ProjectDerived projectDerived = 
            new ProjectWS.ProjectDerived();
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);

Thread.Sleep(500);

jobGuid = Guid.Empty;
int jobState = (int)QueueSystemWS.JobState.Unknown;
int msgType = (int) QueueSystemWS.QueueMsgType.Unknown;
bool includeWaitTime = true;
QueueSystemWS.SortColumn sortColumn = QueueSystemWS.SortColumn.Undefined;
QueueSystemWS.SortOrder sortOrder = QueueSystemWS.SortOrder.Undefined;

WebSvcQueueSystem.QueueStatusDataSet dsQStatus = 
    queueSystemUtils.GetStatusOfQueueJobs(queueSystem, jobGuid, trackingGuid,
        jobState, msgType, sortColumn, sortOrder, includeWaitTime);
. . .

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. QueueStatusDataSet lists the status of all jobs that have the same tracking ID and have either completed processing or are on the queue. The following table shows some of the fields in the QueueStatusDataSet.Status table after running the previous code.

Queue

ID

Message

Type

Job

Completion

State

Queue

Position

Percent

Complete

Queue

Entry Time

Queue

Processing

Time

Queue

Completed

Time

Wait

Time

1

22

4

-1

100

6/26/2011

14:06

6/26/2011

14:06

6/26/2011

14:06

0

1

30

3

3

100

6/26/2011

14:06

6/26/2011

14:06

0

1

24

1

4

0

6/26/2011

14:06

1

QueueMessageType 22 is ProjectCreate. The job is no longer on the queue; JobState 4 is Success.

QueueMessageType 30 is PublishNotifications. The job is third on the queue; JobState 3 is QueueJobProcessing.

QueueMessageType 24 is ProjectPublish. The job is fourth on the queue; JobState 1 is ReadyForProcessing. The expected wait time is one second.

See Also

Reference

QueueSystem Class

QueueSystem Members

QueueSystem Web Service

ReadJobStatusSimple

Other Resources

How to: Use the QueueSystem Service