Archive.ReadArchivedProjectsList 方法
會取得封存專案 ; 的清單清單會包含的專案名稱和 GUID。
命名空間: WebSvcArchive
組件: ProjectServerServices (在 ProjectServerServices.dll 中)
語法
'宣告
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Archive/ReadArchivedProjectsList", 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 ReadArchivedProjectsList As ArchivedProjectsDataSet
'用途
Dim instance As Archive
Dim returnValue As ArchivedProjectsDataSet
returnValue = instance.ReadArchivedProjectsList()
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/office/project/server/webservices/Archive/ReadArchivedProjectsList", 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 ArchivedProjectsDataSet ReadArchivedProjectsList()
傳回值
類型:WebSvcArchive.ArchivedProjectsDataSet
備註
![]() |
---|
此方法會擷取草稿專案和已發佈的專案。 |
Project Server 權限
權限 |
描述 |
---|---|
允許使用者刪除或移動的專案。通用權限。 |
|
可讓使用者排程,或執行 Project Server 實體的備份。通用權限。 |
|
可讓使用者執行 Project Server 實體的備份。通用權限。 |
範例
下列範例會指定專案的複本從發佈資料庫儲存至封存資料庫,並擷取封存專案的清單
For information about running this code sample, see Prerequisites for WCF-Based Code Samples.
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 Main(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);
// Assign the path where the output XML file will be saved.
outFilePath = OUTPUT_FILES + "ArchivedProjectsList.xml";
// Queue 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;
}
}
}