Partilhar via


Classe DeleteAuditDataRequest

Aplica-se a: CRM 2015 on-prem, CRM Online

Contains the data that is needed to delete all audit data records up until a specified end date.

Namespace: Microsoft.Crm.Sdk.Messages
Assembly: Microsoft.Crm.Sdk.Proxy (em Microsoft.Crm.Sdk.Proxy.dll)

Sintaxe

'Declaração
<DataContractAttribute(Namespace:="https://schemas.microsoft.com/crm/2011/Contracts")> _
Public NotInheritable Class DeleteAuditDataRequest
    Inherits OrganizationRequest
[DataContractAttribute(Namespace="https://schemas.microsoft.com/crm/2011/Contracts")] 
public sealed class DeleteAuditDataRequest : OrganizationRequest

Exemplo

The following example shows how to use this message. For this sample to work correctly, you must be connected to the server to get an IOrganizationService interface. For the complete sample, see the link later in this topic.

// Get the list of audit partitions.
RetrieveAuditPartitionListResponse partitionRequest =
    (RetrieveAuditPartitionListResponse)_service.Execute(new RetrieveAuditPartitionListRequest());
AuditPartitionDetailCollection partitions = partitionRequest.AuditPartitionDetailCollection;

// Create a delete request with an end date earlier than possible.
DeleteAuditDataRequest deleteRequest = new DeleteAuditDataRequest();
deleteRequest.EndDate = new DateTime(2000, 1, 1);

// Check if partitions are not supported as is the case with SQL Server Standard edition.
if (partitions.IsLogicalCollection)
{
    // Delete all audit records created up until now.
    deleteRequest.EndDate = DateTime.Now;
}

// Otherwise, delete all partitions that are older than the current partition.
// Hint: The partitions in the collection are returned in sorted order where the 
// partition with the oldest end date is at index 0.
else
{
    for (int n = partitions.Count - 1; n >= 0; --n)
    {
        if (partitions[n].EndDate <= DateTime.Now && partitions[n].EndDate > deleteRequest.EndDate)
        {
            deleteRequest.EndDate = (DateTime)partitions[n].EndDate;
            break;
        }
    }
}

// Delete the audit records.
if (deleteRequest.EndDate != new DateTime(2000, 1, 1))
{
    _service.Execute(deleteRequest);
    Console.WriteLine("Audit records have been deleted.");
}
else
    Console.WriteLine("There were no audit records that could be deleted.");

Comentários

Message Availability

Para que esta mensagem funcione, o chamador deve estar conectado ao servidor.

Usage

Pass an instance of this class to the Execute method, which will return an instance of DeleteAuditDataResponse.

Privileges and Access Rights

For a list of the privileges required, see DeleteAuditData Privileges.

Notes for Callers

This message behaves slightly different depending on the version of Microsoft SQL Server that is installed on the Microsoft Dynamics CRM server. See Retrieve and Delete the History of Audited Data Changes for more information.

Hierarquia de Herança

System.Object
   Microsoft.Xrm.Sdk.OrganizationRequest
    Microsoft.Crm.Sdk.Messages.DeleteAuditDataRequest

Segurança do Thread

Todos os membros estáticos (Shared in Visual Basic) desse tipo são protegidos por thread. Não há nenhum garantia de que os membros de instância sejam protegidos por thread.

Plataformas

Plataformas de desenvolvimento

Windows Vista, Windows Server 2003 e

Plataformas de destino

Windows Vista,Windows XP

Change History

Consulte também

Referência

Membros de DeleteAuditDataRequest
Namespace Microsoft.Crm.Sdk.Messages

Outros recursos

Audit Entity Data Changes in Microsoft Dynamics CRM
Sample: Audit Entity Data Changes

Send comments about this topic to Microsoft.
© 2014 Microsoft Corporation. All rights reserved.