Resource.UpdateResources 方法

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

语法

声明
<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
用法
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
)

参数

  • validateOnly
    类型:System.Boolean

    如果true,仅验证数据,并不会创建新资源。

  • autoCheckIn
    类型:System.Boolean

    如果true,自动签入的资源数据。

返回值

类型:WebSvcResource.ResourceDataSet
返回的ResourceDataSet包含所做的更改。

备注

UpdateResources删除资源,如果ResourceDataSet参数不包含的现有资源的信息,如果该资源中的企业资源库中,不存在或者使用新数据更新现有资源创建资源。

若要修改或删除每个资源需要签出到当前经过身份验证的用户调用UpdateResources之前。

Project Server 权限

权限

说明

ManageUsersAndGroups

使用户能够管理所有企业用户、 资源和组。全局权限。

NewResource

允许用户创建新资源。全局权限。

ManageActiveDirectorySettings

允许用户管理用户信息。全局权限。

EditEnterpriseResourceData

允许用户编辑或删除此资源。类别权限。

示例

下面的示例获取所有现有的企业资源的列表、 签出的第一个资源、 更新的资源的名称,然后将更改保存到服务器和签入资源。

Please see Project 2013 中基于 ASMX 的代码示例的先决条件 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
            SvcResource.Resource resourceSvc = new SvcResource.Resource();
            SvcResource.ResourceDataSet resourceDs = new SvcResource.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);
         }
      }
   }
}

另请参阅

引用

Resource 类

Resource 成员

WebSvcResource 命名空间