zoukankan      html  css  js  c++  java
  • 如何在ProjectServer用代码修改用户属性?

    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);
             }
          }
       }
    }
    

      

  • 相关阅读:
    盯盘的基本技巧
    教你一招短线选股法
    卖咖啡8.0i企业版,详细设置规则。让杀毒软件发挥真正的作用!
    PHP获取 当前页面名称、主机名、URL完整地址、URL参数、获取IP
    mysql乱码处理一则
    word2007怎样显示预览快速打印按扭
    一个简单功能强大的Google Map 搜索源码
    Google和百度、雅虎的站内搜索代码
    FCKeditor 2.5 使用方法 配置ASP上传功能 & PHP实例:FCKeditor2.6 的配置和使用方法
    PHP获取当前url路径的函数及服务器变量:QUERY_STRING、REQUEST_URI、SCRIPT...
  • 原文地址:https://www.cnblogs.com/olay/p/2727020.html
Copyright © 2011-2022 走看看