Project.QueueUpgradeProject Method

Upgrades the specified project proposal to a full project.

Namespace:  WebSvcProject
Assembly:  ProjectServerWebServices (in ProjectServerWebServices.dll)

Syntax

'Declaration
<SoapDocumentMethodAttribute("http://schemas.microsoft.com/office/project/server/webservices/Project/QueueUpgradeProject", RequestNamespace := "http://schemas.microsoft.com/office/project/server/webservices/Project/",  _
    ResponseNamespace := "http://schemas.microsoft.com/office/project/server/webservices/Project/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub QueueUpgradeProject ( _
    projectUID As Guid _
)
'Usage
Dim instance As Project
Dim projectUID As Guid

instance.QueueUpgradeProject(projectUID)
[SoapDocumentMethodAttribute("http://schemas.microsoft.com/office/project/server/webservices/Project/QueueUpgradeProject", RequestNamespace = "http://schemas.microsoft.com/office/project/server/webservices/Project/", 
    ResponseNamespace = "http://schemas.microsoft.com/office/project/server/webservices/Project/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void QueueUpgradeProject(
    Guid projectUID
)

Parameters

Remarks

QueueUpgradeProject is an asynchronous method that sends a message to the Project Server Queuing Service.

Project Web Access uses methods in the private PWA Web service to import a task list in Windows SharePoint Services as a project proposal. Project Server can drop an assignment in the SharePoint task list for the following set of conditions:

  1. A Project Server user with a Windows account (for example, DOMAIN/UserNotResource) does not have the User can be assigned as a resource checkbox selected on the Edit User page in Project Web Access (http://ServerName/ProjectServerName/_layouts/PWA/Admin/AddModifyUser.aspx).

  2. A task (for example T1) in the SharePoint task list is assigned to UserNotResource.

  3. You import the SharePoint task list to a new project proposal.

The task T1 is no longer assigned to UserNotResource in the proposal. If you use QueueUpgradeProject to upgrade the proposal to a project, the task remains unassigned.

For more information, see Windows SharePoint Services Infrastructure for Project Server.

Project Server Permissions

Permission

Description

NewProject

Can create a new project. Global permission.

Examples

The following example creates a sample project proposal, and then upgrades it to a full project.

Please see Prerequisites for Reference Code Samples for critical information on running this code sample.

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web.Services.Protocols;
using System.Threading;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace Microsoft.SDK.Project.Samples.QueueUpgradeProject
{
   class Program
   {
      [STAThread]
      static void Main()
      {
         try
         {
            #region Setup
            const string PROJECT_SERVER_URI = "http://ServerName/ProjectServerName/";
            const string PROJECT_SERVICE_PATH = "_vti_bin/psi/project.asmx";
            const string QUEUESYSTEM_SERVICE_PATH = "_vti_bin/psi/queuesystem.asmx";
            const string SESSION_DESC = "Sample utility";
            Guid jobId;

            Guid sessionId = Guid.NewGuid();

            // Set up the Web service objects
            ProjectWebSvc.Project projectSvc = new ProjectWebSvc.Project();

            projectSvc.Url = PROJECT_SERVER_URI + PROJECT_SERVICE_PATH;
            projectSvc.Credentials = CredentialCache.DefaultCredentials;

            QueueSystemWebSvc.QueueSystem q = new QueueSystemWebSvc.QueueSystem();
            q.Url = PROJECT_SERVER_URI + QUEUESYSTEM_SERVICE_PATH;
            q.Credentials = CredentialCache.DefaultCredentials;

            // Create a sample project
            Console.WriteLine("Creating the project");
            Guid projectId = CreateSampleProposalProject(projectSvc, q, sessionId);
            #endregion
            #region Upgrade project
            // Update the the proposal to a full project
            // Note: No Job ID is used because this method places
            //       multiple items on the queue
            Console.WriteLine("Creating the project");
            projectSvc.QueueUpgradeProject(projectId);
            #endregion
            #region Check in
            // Check in the project
            Console.WriteLine("Checking in the project");
            jobId = Guid.NewGuid();
            projectSvc.QueueCheckInProject(jobId, projectId, false, sessionId, SESSION_DESC);
            WaitForQueue(q, jobId);
            #endregion
         }
         #region Exception Handling and Final
         catch (SoapException ex)
         {
            PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
            PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
            string errMess = "==============================\r\nError: \r\n";
            for (int i = 0; i < errors.Length; i++)
            {
               errMess += "\n" + ex.Message.ToString() + "\r\n";
               errMess += "".PadRight(30, '=') + "\r\nPSCLientError Output:\r\n \r\n";
               errMess += errors[i].ErrId.ToString() + "\n";

               for (int j = 0; j < errors[i].ErrorAttributes.Length; j++)
               {
                  errMess += "\r\n\t" + errors[i].ErrorAttributeNames()[j] + ": " + errors[i].ErrorAttributes[j];
               }
               errMess += "\r\n".PadRight(30, '=');
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(errMess);
         }
         catch (WebException ex)
         {
            string errMess = ex.Message.ToString() +
               "\n\nLog on, or check the Project Server Queuing Service";
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Error: " + errMess);
         }
         catch (Exception ex)
         {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Error: " + ex.Message);
         }
         finally
         {
            Console.ResetColor();
            Console.WriteLine("\r\n\r\nPress any key...");
            Console.ReadKey();
         }
         #endregion
      }
      static private void WaitForQueue(QueueSystemWebSvc.QueueSystem q, Guid jobId)
      {
         QueueSystemWebSvc.JobState jobState;
         const int QUEUE_WAIT_TIME = 2; // two seconds
         bool jobDone = false;
         string xmlError = string.Empty;
         int wait = 0;

         //Wait for the project to get through the queue
         // - Get the estimated wait time in seconds
         wait = q.GetJobWaitTime(jobId);

         // - Wait for it
         Thread.Sleep(wait * 1000);
         // - Wait until it is done.

         do
         {
            // - Get the job state
            jobState = q.GetJobCompletionState(jobId, out xmlError);

            if (jobState == QueueSystemWebSvc.JobState.Success)
            {
               jobDone = true;
            }
            else
            {
               if (jobState == QueueSystemWebSvc.JobState.Unknown
               || jobState == QueueSystemWebSvc.JobState.Failed
               || jobState == QueueSystemWebSvc.JobState.FailedNotBlocking
               || jobState == QueueSystemWebSvc.JobState.CorrelationBlocked
               || jobState == QueueSystemWebSvc.JobState.Canceled)
               {
                  // If the job failed, error out
                  throw (new ApplicationException("Queue request " + jobState + " for Job ID " + jobId + ".\r\n" + xmlError));
               }
               else
               {
                  Console.WriteLine("Job State: " + jobState + "  Job ID: " + jobId);
                  Thread.Sleep(QUEUE_WAIT_TIME * 1000);
               }
            }
         }
         while (!jobDone);
      }
      static private Guid CreateSampleProposalProject(ProjectWebSvc.Project projectSvc, QueueSystemWebSvc.QueueSystem q,Guid sessionId)
      {
         ProjectWebSvc.ProjectDataSet projectDs = new ProjectWebSvc.ProjectDataSet();
         Guid jobId;
         // Create the project
         ProjectWebSvc.ProjectDataSet.ProjectRow projectRow = projectDs.Project.NewProjectRow();
         projectRow.PROJ_UID = Guid.NewGuid();
         projectRow.PROJ_NAME = "Its a wonderful project at " + 
            DateTime.Now.ToShortDateString().Replace("/", "") + " " + 
            DateTime.Now.ToShortTimeString().Replace(":", "");
         projectRow.PROJ_TYPE = (int)PSLibrary.Project.ProjectType.LightWeightProject;
         projectDs.Project.AddProjectRow(projectRow);

         // Add some tasks
         ProjectWebSvc.ProjectDataSet.TaskRow taskOne = projectDs.Task.NewTaskRow();
         taskOne.PROJ_UID = projectRow.PROJ_UID;
         taskOne.TASK_UID = Guid.NewGuid();
         //Task Duration format must be specified
         taskOne.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Day;
         taskOne.TASK_DUR = 4800;  // 8 hours in duration units (minute/10)
         taskOne.TASK_NAME = "Task One";
         taskOne.TASK_START_DATE = System.DateTime.Now.AddDays(1);
         projectDs.Task.AddTaskRow(taskOne);

         ProjectWebSvc.ProjectDataSet.TaskRow taskTwo = projectDs.Task.NewTaskRow();
         taskTwo.PROJ_UID = projectRow.PROJ_UID;
         taskTwo.TASK_UID = Guid.NewGuid();
         //Task Duration format must be specified
         taskTwo.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Day;
         taskTwo.TASK_DUR = 4800;  // 8 hours in duration units (minute/10)
         taskTwo.TASK_NAME = "Task Two";
         taskTwo.TASK_START_DATE = System.DateTime.Now.AddDays(1);
         projectDs.Task.AddTaskRow(taskTwo);

         // Save the project to the database
         jobId = Guid.NewGuid();
         projectSvc.QueueCreateProposalProjectAndCheckout(jobId,sessionId,"Sample Utility", projectDs, false,true);
         WaitForQueue(q, jobId);
         return projectRow.PROJ_UID;
      }
   }
}

See Also

Reference

Project Class

Project Members

WebSvcProject Namespace

Other Resources

Windows SharePoint Services Infrastructure for Project Server