Compartilhar via


Archive.QueueArchiveProject method

Salva uma cópia do projeto especificado do banco de dados publicado no banco de dados de arquivamento e cria uma versão do projeto.

Namespace:  WebSvcArchive
Assembly:  ProjectServerServices (in ProjectServerServices.dll)

Syntax

'Declaração
<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
'Uso
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
)

Parâmetros

  • projectUID
    Type: System.Guid

    O GUID do projeto para arquivar.

  • archivedProjectUID
    Type: System.Guid

    O GUID do projeto arquivado.

  • versionDescription
    Type: System.String

    A descrição da versão do projeto.

  • retentionPolicy
    Type: System.Int32

    Especifica a política de retenção; valores podem ser -2, -1, 0ou greater than 0.

  • permanentArchive
    Type: System.Boolean

    Defina true para manter uma cópia permanente e evitar a exclusão acidental.

Valor retornado

Type: System.Guid
Retorna um GUID para a versão do projeto.

Comentários

QueueArchiveProject é um método assíncrono que envia uma mensagem para o serviço de enfileiramento do Project Server.

A seguir estão os valores para a política de retenção.

Valor da retentionPolicy

Descrição

>0

Definir a diretiva de retenção de projeto; Substitua a política de retenção padrão do Project Server.

0

Retenção ilimitada. Arquivar o projeto e verifica a exclusão de retenção.

-1

Usar a diretiva de projeto se tiver sido definido; Caso contrário, use o padrão do Project Server.

-2

Usar a diretiva de retenção de padrão do Project Server e desmarque a política de retenção de projeto.

Salve a versão do projeto retornado GUID a ser usada com QueueRestoreProject.

Permissões do Project Server

Permissão

Descrição

ManageProjectServerBackup

Permite que um usuário agendar ou executar um backup das entidades do Project Server. Permissão global.

Examples

O código a seguir salva uma cópia do projeto especificado do banco de dados publicado no banco de dados arquivado e recupera a lista de projetos arquivados.

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 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;
    }
  }
}

Ver também

Referência

Archive class

Archive members

WebSvcArchive namespace