将指定的项目的副本从已发布数据库保存到存档数据库,并创建项目的版本。
命名空间: WebSvcArchive
程序集: ProjectServerServices(位于 ProjectServerServices.dll 中)
语法
声明
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Archive/QueueArchiveProject", RequestNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Archive/", _
ResponseNamespace := "https://schemas.microsoft.com/office/project/server/webservices/Archive/", _
Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function QueueArchiveProject ( _
jobUID As Guid, _
projectUID As Guid, _
archivedProjectUID As Guid, _
versionDescription As String, _
retentionPolicy As Integer, _
permanentArchive As Boolean _
) As Guid
用法
Dim instance As Archive
Dim jobUID As Guid
Dim projectUID As Guid
Dim archivedProjectUID As Guid
Dim versionDescription As String
Dim retentionPolicy As Integer
Dim permanentArchive As Boolean
Dim returnValue As Guid
returnValue = instance.QueueArchiveProject(jobUID, _
projectUID, archivedProjectUID, _
versionDescription, retentionPolicy, _
permanentArchive)
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Archive/QueueArchiveProject", RequestNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Archive/",
ResponseNamespace = "https://schemas.microsoft.com/office/project/server/webservices/Archive/",
Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public Guid QueueArchiveProject(
Guid jobUID,
Guid projectUID,
Guid archivedProjectUID,
string versionDescription,
int retentionPolicy,
bool permanentArchive
)
参数
jobUID
类型:System.Guid队列作业的 GUID。
projectUID
类型:System.Guid若要存档的项目的 GUID。
archivedProjectUID
类型:System.Guid存档项目的 GUID。
versionDescription
类型:System.String项目版本的描述。
retentionPolicy
类型:System.Int32指定保留策略 ;值可以是-2、 -1、 0或greater than 0。
permanentArchive
类型:System.Boolean设置true维护永久的副本,并避免意外删除。
返回值
类型:System.Guid
返回项目版本的 GUID。
备注
QueueArchiveProject是将邮件发送到 Project Server 队列服务的异步方法。
以下是保留策略的值。
retentionPolicy的值 |
说明 |
|---|---|
>0 |
设置项目的保留策略。覆盖 Project Server 的默认保留策略。 |
0 |
不受限制的保留。对项目进行存档和保留删除不检查。 |
-1 |
如果设置 ;,使用项目策略否则,使用默认的 Project Server。 |
-2 |
使用 Project Server 的默认保留策略,并清除项目保留策略。 |
保存返回的项目的版本与QueueRestoreProject一起使用的 GUID。
Project Server 权限
权限 |
说明 |
|---|---|
允许用户安排或执行备份的 Project Server 实体。全局权限。 |
示例
下面的代码将从已发布数据库的指定项目的副本保存到已存档的数据库,并检索存档项目的列表。
For information about running this code sample, see Project 2013 中基于 WCF 的代码示例的先决条件.
using System;
using System.IO;
using System.ServiceModel;
using System.Text;
using PSLibrary = Microsoft.Office.Project.Server.Library;
namespace Microsoft.SDK.Project.Samples.ReadArchivedProjectsList
{
class Program
{
private const string ENDPOINT = "basicHttp_Archive";
private const string ENDPOINT_Q = "basicHttp_QueueSystem";
private const string VERSION_DESCRIPTION = "2010-01-19 14:52:30";
private const string PID = "56B5C90D-28C0-42A1-A2CF-8BC205F062BA";
private const string OUTPUT_FILES = @"C:\Projects\Samples\Output\";
private const int RETENTION_POLICY = -2;
private static SvcArchive.ArchiveClient archiveClient;
private static SvcQueueSystem.QueueSystemClient queueSystemClient;
private static string outFilePath;
private static int numProjects;
static void Main1(string[] args)
{
try
{
Guid jobUID = Guid.NewGuid();
Guid projectUID = new Guid(PID);
Guid archivedProjectUID = Guid.NewGuid();
DateTime startTime = DateTime.Now;
numProjects = 1;
// Use the endpoints that are defined in app.config to configure the client.
SetClientEndpoints(ENDPOINT_Q);
ConfigClientEndpoints(ENDPOINT);
// If the directory does not exist, create it.
if (!Directory.Exists(OUTPUT_FILES))
{
Directory.CreateDirectory(OUTPUT_FILES);
}
// Assign the path where the output XML file will be saved.
outFilePath = OUTPUT_FILES + "ArchivedProjectsList.xml";
// Queue the archive project.
Guid projectVersionUID = archiveClient.QueueArchiveProject(
jobUID, projectUID, archivedProjectUID, VERSION_DESCRIPTION, RETENTION_POLICY, true);
Helpers.WaitForQueue(SvcQueueSystem.QueueMsgType.ProjectArchive, numProjects,
queueSystemClient, startTime);
Console.WriteLine("Projects archived successfully");
Console.WriteLine("Retrieving the list of archived projects...");
// Create a dataset.
SvcArchive.ArchivedProjectsDataSet archivedProjectsDs =
new SvcArchive.ArchivedProjectsDataSet();
// Assign the datasource to the dataset.
archivedProjectsDs = archiveClient.ReadArchivedProjectsList();
archivedProjectsDs.WriteXml(outFilePath);
// Get the count of projects.
Console.WriteLine("Number of archived projects: {0}",
archivedProjectsDs.Projects.Count.ToString());
archiveClient.Close();
// Write the list of projects to an XML file.
Console.WriteLine("\nSee XML output of the ArchivedProjectsDataSet at {0}",
outFilePath);
}
catch (CommunicationException e)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\n***System.ServiceModel.CommunicationException:");
Console.WriteLine(e.ToString());
Console.ResetColor();
}
finally
{
Console.Write("\r\n\r\nPress any key....");
Console.ReadKey();
}
}
// Configure the client endpoints.
public static void ConfigClientEndpoints(string endpt)
{
archiveClient = new SvcArchive.ArchiveClient(endpt);
}
// Configure the client endpoints.
public static void SetClientEndpoints(string qendpt)
{
queueSystemClient = new SvcQueueSystem.QueueSystemClient(qendpt);
}
}
// Utility class.
class Helpers
{
// Waits for the Project Server Queuing Service to finish archiving the project.
public static bool WaitForQueue(SvcQueueSystem.QueueMsgType jobType,
int numJobs, SvcQueueSystem.QueueSystemClient queueSystemClient, DateTime startTime)
{
const int maxSeconds2Wait = 50;
SvcQueueSystem.QueueStatusDataSet queueStatusDs = new SvcQueueSystem.QueueStatusDataSet();
int timeout = 0; // The number of secs waited.
Console.WriteLine("Waiting for job" + jobType.ToString());
SvcQueueSystem.QueueMsgType[] messageTypes = { jobType };
SvcQueueSystem.JobState[] jobStates = { SvcQueueSystem.JobState.Success };
while ((timeout < maxSeconds2Wait) && (queueStatusDs.Status.Count < numJobs))
{
System.Threading.Thread.Sleep(1000);
queueStatusDs = queueSystemClient.ReadMyJobStatus(
messageTypes,
jobStates,
startTime,
DateTime.Now,
numJobs,
true,
SvcQueueSystem.SortColumn.QueuePosition,
SvcQueueSystem.SortOrder.LastOrder);
timeout++;
Console.Write(".");
}
Console.WriteLine();
if (queueStatusDs.Status.Count == numJobs)
{
return true;
}
return false;
}
}
}