Project.ReadProjectList 方法
获取项目名称、 GUID、 和每个项目都位于Project Web App实例的类型。
命名空间: WebSvcProject
程序集: ProjectServerServices(位于 ProjectServerServices.dll 中)
语法
声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/ReadProjectList", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Project/", _
ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Project/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function ReadProjectList As ProjectDataSet
用法
Dim instance As Project
Dim returnValue As ProjectDataSet
returnValue = instance.ReadProjectList()
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/ReadProjectList", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Project/",
ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Project/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public ProjectDataSet ReadProjectList()
返回值
类型:WebSvcProject.ProjectDataSet
ProjectDataSet架构包含仅Project表与以下字段: PROJ_UID、 PROJ_NAME和PROJ_TYPE。
备注
ReadProjectStatus可用于获取对项目服务器的任何用户可见的项目的列表。因为它将获取的所有项目的列表, ReadProjectList用于管理实用程序和要求较高的权限级别。
应用程序必须登录到具有有效的用户凭据的 Project Server 实例执行ReadProjectList之前。
使用ProjectDataSet的Project属性访问的项目的列表。
Project Server 权限
权限 |
说明 |
---|---|
允许用户管理队列服务。全局权限。 |
|
允许用户来管理安全设置。全局权限。 |
示例
下面的示例创建一个示例项目并列出找到的项目。
有关运行此代码示例的关键信息,请参阅Project 2013 中基于 ASMX 的代码示例的先决条件。
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web.Services.Protocols;
using System.Data;
using System.Threading;
using PSLibrary = Microsoft.Office.Project.Server.Library;
namespace Microsoft.SDK.Project.Samples.ReadProjectList
{
class Program
{
[STAThread]
static void Main()
{
try
{
const string PROJECT_SERVER_URI = "https://ServerName/ProjectServerName/";
const string PROJECT_SERVICE_PATH = "_vti_bin/psi/project.asmx";
// Set up the web service objects.
SvcProject.Project projectSvc = new SvcProject.Project();
projectSvc.Url = PROJECT_SERVER_URI + PROJECT_SERVICE_PATH;
projectSvc.Credentials = CredentialCache.DefaultCredentials;
// Read and display the project list.
Console.WriteLine("Reading the project list");
SvcProject.ProjectDataSet projectDs = projectSvc.ReadProjectList();
foreach (SvcProject.ProjectDataSet.ProjectRow projectRow in projectDs.Project)
{
Console.WriteLine(projectRow.PROJ_NAME + " (" + projectRow.PROJ_UID + ")");
}
}
catch (SoapException ex)
{
PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
string errMess = "==============================\r\nError: \r\n";
for (int i = 0; i < errors.Length; i++)
{
errMess += "\n" + ex.Message.ToString() + "\r\n";
errMess += "".PadRight(30, '=') + "\r\nPSCLientError Output:\r\n \r\n";
errMess += errors[i].ErrId.ToString() + "\n";
for (int j = 0; j < errors[i].ErrorAttributes.Length; j++)
{
errMess += "\r\n\t" + errors[i].ErrorAttributeNames()[j] + ": " + errors[i].ErrorAttributes[j];
}
errMess += "\r\n".PadRight(30, '=');
}
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(errMess);
}
catch (WebException ex)
{
string errMess = ex.Message.ToString() +
"\n\nLog on, or check the Project Server Queuing Service";
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Error: " + errMess);
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Error: " + ex.Message);
}
finally
{
Console.ResetColor();
Console.WriteLine("\r\n\r\nPress any key...");
Console.ReadKey();
}
}
}
}