Project.QueueCreateProjectAndCheckOut 方法
与指定的实体创建一个项目并使草稿数据库中签出项目。
命名空间: WebSvcProject
程序集: ProjectServerServices(位于 ProjectServerServices.dll 中)
语法
声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/QueueCreateProjectAndCheckOut", 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 Sub QueueCreateProjectAndCheckOut ( _
jobUid As Guid, _
sessionUid As Guid, _
sessionDescription As String, _
dataset As ProjectDataSet, _
validateOnly As Boolean _
)
用法
Dim instance As Project
Dim jobUid As Guid
Dim sessionUid As Guid
Dim sessionDescription As String
Dim dataset As ProjectDataSet
Dim validateOnly As Boolean
instance.QueueCreateProjectAndCheckOut(jobUid, _
sessionUid, sessionDescription, _
dataset, validateOnly)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Project/QueueCreateProjectAndCheckOut", 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 void QueueCreateProjectAndCheckOut(
Guid jobUid,
Guid sessionUid,
string sessionDescription,
ProjectDataSet dataset,
bool validateOnly
)
参数
jobUid
类型:System.Guid队列作业的 GUID。
sessionUid
类型:System.Guid队列作业提交的会话的 GUID。
sessionDescription
类型:System.String上课时间的描述。
dataset
类型:WebSvcProject.ProjectDataSet包含的项目数据。
validateOnly
类型:System.Boolean如果true,仅验证输入的数据并不会执行该操作。
备注
当您想要在此会话中对项目进行其他更改时使用QueueCreateProjectAndCheckOut 。这将保存到服务器的调用。如果您不想进行其他更改,使用QueueCreateProject。
QueueCreateProjectAndCheckOut是将消息发送到项目服务器队列服务的异步方法。
备注
由于 PSI 不会不支持声明身份验证的QueueCreateProjectAndCheckOut方法不支持用于Windows Workflow Foundation 4 (WF4) 的工作流定义的企业项目类型 (EPT)。
PSI 可用于创建与 EPTs 有任何工作流或使用旧版的 WF3.5 定义的项目。若要创建与 EPT 的 WF4 定义的项目使用 CSOM。
如QueueCreateProjectAndCheckOut, Project类方法不能创建、 编辑或删除成本资源。如果ProjectDataSet在dataset参数中包括的成本资源方法返回ResourceCannotCreateCostResource错误 2076年。您可以使用CreateResources方法来创建成本资源但Resource类方法不能对其进行编辑。更多的信息请参阅PSI 可实现的操作和不可实现的操作。
项目服务器接口 (PSI) 不能用于在项目中创建本地自定义域。但 PSI 不支持编辑在任务、 资源和工作分配的本地自定义域值。
在创建ProjectDataSet.TaskRow时必须指定TASK_DUR_FMT。否则以后的项目专家在此项目使用可能导致不可预知的行为包括可能的数据丢失。
对ProjectDataSet.ProjectResourceRow中的企业资源属性所做的任何更改将会丢失项目专业刷新项目服务器中的数据在下一次。
当您将任务添加到ProjectDataSet时,不要设置TASK_WBS属性。TASK_WBS属性是只读、 尽管它被标记为读/写在 PSI。如果TASK_WBS属性设置为指定的值添加任务,项目专业人员会忽略从 PSI 设置的值并赋值根据任务大纲位置时打开的项目。若要查看项目专业导致,检查任务信息对话框中的高级选项卡上的WBS 代码值。
Project Server 权限
权限 |
说明 |
---|---|
使用户可以在 Project Server 上创建一个新的全局权限。仅适用于常规项目不建议。 |
|
允许用户打开一个项目。类别的权限。仅适用于由项目详细信息页面 (PDP) 并从企业级模板创建的项目。 |
|
允许用户保存项目。类别的权限。仅适用于项目的项目详细信息页面 (PDP) 发起的。 |
|
允许用户编辑一个项目。类别的权限。仅适用于项目的项目详细信息页面 (PDP) 发起的。 |
示例
下面的示例将创建一个项目、 将其保存到服务器但留检出,然后签入该项目。
有关运行此代码示例的关键信息,请参阅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;
namespace Microsoft.SDK.Project.Samples.QueueCreateProjectAndCheckOut
{
class Program
{
[STAThread]
static void Main(string[] args)
{
try
{
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";
const string SESSION_DESC = "Sample utility";
Guid sessionId = Guid.NewGuid();
Guid jobId;
// 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.Credentials = CredentialCache.DefaultCredentials;
SvcQueueSystem.QueueSystem q = new SvcQueueSystem.QueueSystem();
q.Url = PROJECT_SERVER_URI + QUEUESYSTEM_SERVICE_PATH;
q.UseDefaultCredentials = true;
// Create a sample project.
Console.WriteLine("Creating project data");
projectDs = new SvcProject.ProjectDataSet();
// 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();
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();
taskTwo.TASK_NAME = "Task Two";
taskTwo.TASK_START_DATE = System.DateTime.Now.AddDays(1);
projectDs.Task.AddTaskRow(taskTwo);
// Save the project to the database.
Console.WriteLine("Saving project data to the server and checking out");
jobId = Guid.NewGuid();
projectSvc.QueueCreateProjectAndCheckOut(jobId,sessionId,SESSION_DESC, projectDs, false);
WaitForQueue(q, jobId);
// Add your additional changes here.
// Check in the project so that it is available for more changes.
Console.WriteLine("Checking in the project");
jobId = Guid.NewGuid();
projectSvc.QueueCheckInProject(jobId,projectRow.PROJ_UID,false, sessionId, SESSION_DESC);
WaitForQueue(q, jobId);
}
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();
}
}
static private void WaitForQueue(SvcQueueSystem.QueueSystem q, Guid jobId)
{
SvcQueueSystem.JobState jobState;
const int QUEUE_WAIT_TIME = 2; // two seconds
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.
Thread.Sleep(wait * 1000);
// 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 failed \"" + jobState + "\" Job ID: " + jobId + ".\r\n" + xmlError));
}
else
{
Console.WriteLine("Job State: " + jobState + " Job ID: " + jobId);
Thread.Sleep(QUEUE_WAIT_TIME * 1000);
}
}
}
while (!jobDone);
}
}
}