六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 208|回复: 0

如何在ProjectServer用代码修改用户属性?

[复制链接]

升级  80%

54

主题

54

主题

54

主题

秀才

Rank: 2

积分
170
 楼主| 发表于 2013-1-6 05:15:12 | 显示全部楼层 |阅读模式
<div id="cnblogs_post_body"><div class="cnblogs_Highlighter">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    = "http://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);         }      }   }}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表