EnterpriseResource.GetSelf 方法

获取当前已登录的用户。

命名空间:  Microsoft.ProjectServer.Client
程序集:  Microsoft.ProjectServer.Client(位于 Microsoft.ProjectServer.Client.dll 中)

语法

声明
<RemoteAttribute> _
Public Shared Function GetSelf ( _
    Context As ClientRuntimeContext _
) As EnterpriseResource
用法
Dim Context As ClientRuntimeContext
Dim returnValue As EnterpriseResource

returnValue = EnterpriseResource.GetSelf(Context)
[RemoteAttribute]
public static EnterpriseResource GetSelf(
    ClientRuntimeContext Context
)

参数

返回值

类型:Microsoft.ProjectServer.Client.EnterpriseResource
当前登录的EnterpriseResource 。

示例

下面的示例获取应用程序的用户的名称。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ProjectServer.Client;

namespace WhoAmI
{
    class Program
    {
        private const string pwaPath = "https://ServerName/pwa/"; // Change the path for your Project Web App.
        private static ProjectContext projContext;
       
        static void Main(string[] args)
        {
            projContext = new ProjectContext(pwaPath);

            // Load the application user, who must be an enterprise resource.
            EnterpriseResource self = EnterpriseResource.GetSelf(projContext);
            projContext.Load(self);
            projContext.ExecuteQuery();

            Console.WriteLine("I am: {0}", self.Name);

            Console.Write("\nPress any key to exit: ");
            Console.ReadKey(false);
        }
    }
}

另请参阅

引用

EnterpriseResource 类

EnterpriseResource 成员

Microsoft.ProjectServer.Client 命名空间