Project.GetProjectNameFromProjectUid メソッド
下書きデータベース内の指定したprojectUidのプロジェクト名を取得します。
名前空間: WebSvcProject
アセンブリ: ProjectServerServices (ProjectServerServices.dll 内)
構文
'宣言
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/GetProjectNameFromProjectUid", 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 GetProjectNameFromProjectUid ( _
projectUid As Guid, _
dataStore As DataStoreEnum _
) As String
'使用
Dim instance As Project
Dim projectUid As Guid
Dim dataStore As DataStoreEnum
Dim returnValue As String
returnValue = instance.GetProjectNameFromProjectUid(projectUid, _
dataStore)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/GetProjectNameFromProjectUid", 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 string GetProjectNameFromProjectUid(
Guid projectUid,
DataStoreEnum dataStore
)
パラメーター
projectUid
型: System.Guidプロジェクトの GUID。
dataStore
型: WebSvcProject.DataStoreEnumデータベース プロジェクトのデータがある (下書き、発行、またはアーカイブ)。
戻り値
型: System.String
プロジェクトの名前。
注釈
プロジェクトのprojectUidではなく名前でReadProjectStatusを使用します。
プロジェクト サーバーのアクセス許可
権限 |
説明 |
---|---|
グローバル プロジェクト情報を表示することができます。グローバル アクセス権。 |
|
プロジェクト センターにアクセスすることができます。 |
|
指定したプロジェクトをリソース共有元からリソースを割り当てることができます。 |
|
Build Teamオプションを使用して、利用可能なリソースの一覧を確認するのには、ユーザーことができます。 |
例
次の例では、サンプル プロジェクトを作成しその名前を使用して、プロジェクトの一意の ID を取得します。
このコード サンプルを実行する重要な情報は、 Project 2013 での ASMX ベースのコード サンプルの前提条件を参照してください。
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web.Services.Protocols;
using System.Threading;
using PSLibrary = Microsoft.Office.Project.Server.Library;
[assembly: CLSCompliant(true)]
namespace Microsoft.SDK.Project.Samples.GetProjectNameFromProjectUid
{
class Program
{
[STAThread]
static void Main(string[] args)
{
try
{
#region Setup
const string PROJECT_SERVER_URI = "https://ServerName/ProjectServerName/";
const string PROJECT_SERVICE_PATH = "_vti_bin/psi/project.asmx";
const string QUEUESYSTEM_SERVICE_PATH = "_vti_bin/psi/queuesystem.asmx";
Guid projectId;
// Set up the web service objects.
SvcProject.Project projectSvc = new SvcProject.Project();
SvcProject.ProjectDataSet projectDs = new SvcProject.ProjectDataSet();
projectSvc.Url = PROJECT_SERVER_URI + PROJECT_SERVICE_PATH;
projectSvc.UseDefaultCredentials = true;
SvcQueueSystem.QueueSystem q = new SvcQueueSystem.QueueSystem();
q.Url = PROJECT_SERVER_URI + QUEUESYSTEM_SERVICE_PATH;
q.UseDefaultCredentials = true;
// Create a sample project.
Console.WriteLine("Creating Sample project");
projectId = CreateSampleProject(projectSvc, q);
Console.WriteLine("Created " + projectId.ToString());
#endregion
#region Get Name from UID
// Get the name from the Uid.
string projName = projectSvc.GetProjectNameFromProjectUid(projectId, SvcProject.DataStoreEnum.WorkingStore);
Console.WriteLine(projName + " was retrieved.");
#endregion
}
#region Exception Handling and Final
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();
}
#endregion
}
// Wait for the job to finish.
// Outputs job status to the console.
static public void WaitForQueue(SvcQueueSystem.QueueSystem q, Guid jobId)
{
SvcQueueSystem.JobState jobState;
const int QUEUE_WAIT_TIME = 1; // one second
bool jobDone = false;
string xmlError = string.Empty;
int wait = 0;
// Wait for the project to get through the queue.
// Get the estimated wait time in seconds.
wait = q.GetJobWaitTime(jobId);
// Wait for it.
Console.Write("Waiting on queue. Estimate: {0} seconds.\r\n ", wait);
// Wait until it is finished.
do
{
// Get the job state.
jobState = q.GetJobCompletionState(jobId, out xmlError);
if (jobState == SvcQueueSystem.JobState.Success)
{
jobDone = true;
}
else
{
if (jobState == SvcQueueSystem.JobState.Unknown
|| jobState == SvcQueueSystem.JobState.Failed
|| jobState == SvcQueueSystem.JobState.FailedNotBlocking
|| jobState == SvcQueueSystem.JobState.CorrelationBlocked
|| jobState == SvcQueueSystem.JobState.Canceled)
{
// If the job failed, error out.
throw (new ApplicationException("Queue request " + jobState + " for Job ID " + jobId + ".\r\n" + xmlError));
}
else
{
//Console.WriteLine("Job State: " + jobState + " for Job ID: " + jobId);
Console.Write("~");
Thread.Sleep(QUEUE_WAIT_TIME * 1000);
}
}
}
while (!jobDone);
Console.Write("\r\n");
}
static private Guid CreateSampleProject(SvcProject.Project projectSvc, SvcQueueSystem.QueueSystem q)
{
SvcProject.ProjectDataSet projectDs = new SvcProject.ProjectDataSet();
Guid jobId;
// Create the project.
SvcProject.ProjectDataSet.ProjectRow projectRow = projectDs.Project.NewProjectRow();
projectRow.PROJ_UID = Guid.NewGuid();
projectRow.PROJ_NAME = "Its a wonderful project at " +
DateTime.Now.ToShortDateString().Replace("/", "") + " " +
DateTime.Now.ToShortTimeString().Replace(":", "");
projectRow.PROJ_TYPE = (int)PSLibrary.Project.ProjectType.Project;
projectDs.Project.AddProjectRow(projectRow);
// Add some tasks.
SvcProject.ProjectDataSet.TaskRow taskOne = projectDs.Task.NewTaskRow();
taskOne.PROJ_UID = projectRow.PROJ_UID;
taskOne.TASK_UID = Guid.NewGuid();
// The Task Duration format must be specified.
taskOne.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Day;
taskOne.TASK_DUR = 4800; // 8 hours in duration units (minute/10)
taskOne.TASK_NAME = "Task One";
taskOne.TASK_START_DATE = System.DateTime.Now.AddDays(1);
projectDs.Task.AddTaskRow(taskOne);
SvcProject.ProjectDataSet.TaskRow taskTwo = projectDs.Task.NewTaskRow();
taskTwo.PROJ_UID = projectRow.PROJ_UID;
taskTwo.TASK_UID = Guid.NewGuid();
// The Task Duration format must be specified.
taskTwo.TASK_DUR_FMT = (int)PSLibrary.Task.DurationFormat.Day;
taskTwo.TASK_DUR = 4800; // 8 hours in duration units (minute/10)
taskTwo.TASK_NAME = "Task Two";
taskTwo.TASK_START_DATE = System.DateTime.Now.AddDays(1);
projectDs.Task.AddTaskRow(taskTwo);
// Save the project to the database.
jobId = Guid.NewGuid();
projectSvc.QueueCreateProject(jobId, projectDs, false);
WaitForQueue(q, jobId);
return projectRow.PROJ_UID;
}
}
}