Share via


Resource.UpdateResources Method

Updates, deletes, or creates one or more resources.

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

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Resource/UpdateResources", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Resource/",  _
    ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Resource/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function UpdateResources ( _
    rds As ResourceDataSet, _
    validateOnly As Boolean, _
    autoCheckIn As Boolean _
) As ResourceDataSet
'Usage
Dim instance As Resource
Dim rds As ResourceDataSet
Dim validateOnly As Boolean
Dim autoCheckIn As Boolean
Dim returnValue As ResourceDataSet

returnValue = instance.UpdateResources(rds, _
    validateOnly, autoCheckIn)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Resource/UpdateResources", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Resource/", 
    ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Resource/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public ResourceDataSet UpdateResources(
    ResourceDataSet rds,
    bool validateOnly,
    bool autoCheckIn
)

Parameters

  • validateOnly
    Type: System.Boolean
    If true, only validates the data and does not create the new resources.
  • autoCheckIn
    Type: System.Boolean
    If true, automatically checks in the resource data.

Return Value

Type: [Resource Web service].ResourceDataSet
The returned ResourceDataSet contains the changes made.

Remarks

UpdateResources deletes a resource if the ResourceDataSet parameter does not contain information for an existing resource, creates a resource if the resource does not exist in the enterprise resource pool, or updates existing resources with new data.

Each resource to be modified or deleted needs to be checked out to the current authenticated user before calling UpdateResources.

Project Server Permissions

Permission

Description

ManageUsersAndGroups

Allows a user to manage all enterprise users, resources and groups. Global permission.

NewResource

Allows a user to create a new resource. Global permission.

ManageActiveDirectorySettings

Allows a user to manage user information. Global permission.

EditEnterpriseResourceData

Allows a user to edit or delete this resource. Category permission.

Examples

The following example gets a list of all existing enterprise resources, checks out the first resource, updates the name of the resource, and then saves the change to the server and checks in the resource.

Please see Prerequisites for ASMX-Based Code Samples for critical information on running this code sample.

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

namespace Microsoft.Office.Project.Samples.UpdateResources
{
   class Program
   {
       static void Main(string[] args)
      { 
         const string PROJECT_SERVER_URI    = "https://ServerName/ProjectServerName/";
         const string RESOURCE_SERVICE_PATH = "_vti_bin/psi/resource.asmx";
         
         try
         {
            // Set up the resource object and dataset
            ResourceWebSvc.Resource resourceSvc = new ResourceWebSvc.Resource();
            ResourceWebSvc.ResourceDataSet resourceDs = new ResourceWebSvc.ResourceDataSet();            
            resourceSvc.Url = PROJECT_SERVER_URI + RESOURCE_SERVICE_PATH;
            resourceSvc.Credentials = CredentialCache.DefaultCredentials;

            // Read read all the resources
            resourceDs = resourceSvc.ReadResources(string.Empty, false);

            // Check out the first resource for updating.
            //  - This assumes the resource is checked in.
            //  - An error occurs if the resource is already checked out.
            resourceSvc.CheckOutResources(new Guid[] { resourceDs.Resources[0].RES_UID });

            // Update the resource name of the first row.
            Console.WriteLine ("Modifying resource " + resourceDs.Resources[0].RES_ID + " (" + resourceDs.Resources[0].RES_NAME + ")");
            resourceDs.Resources[0].RES_NAME += " Modified at: " + DateTime.Now.ToShortTimeString();

            // Send the update to the server and automatically check in the changed row
            resourceSvc.UpdateResources(resourceDs, false, true);
         }
         catch (System.Web.Services.Protocols.SoapException ex)
         {
            string errMess = "";
            PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
            PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();

            for (int j = 0; j < errors.Length; j++)
               errMess = errMess + errors[j].ErrId.ToString() + "\n";
            errMess = errMess + "\n" + ex.Message.ToString();

            MessageBox.Show(errMess, "Error", MessageBoxButtons.OK,
               MessageBoxIcon.Error);
         }
         catch (WebException ex)
         {
            string message = ex.Message.ToString() +
               "\n\nLog on, or check the Project Server Queuing Service";
            MessageBox.Show(message, "Project Creation Error",
               MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         catch (Exception ex)
         {
            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
         MessageBoxIcon.Error);
         }
      }
   }
}

See Also

Reference

Resource Class

Resource Members

Resource Web Service