Partilhar via


Classe SnapshotGenerationAgent

Provides the functionality of the Replication Snapshot Agent.

Hierarquia de herança

System. . :: . .Object
  System. . :: . .MarshalByRefObject
    Microsoft.SqlServer.Replication. . :: . .AgentCore
      Microsoft.SqlServer.Replication..::..SnapshotGenerationAgent

Namespace:  Microsoft.SqlServer.Replication
Assembly:  Microsoft.SqlServer.Replication (em Microsoft.SqlServer.Replication.dll)

Sintaxe

'Declaração
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<GuidAttribute("141945FD-18BD-4222-B6D9-F937704C7FFE")> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class SnapshotGenerationAgent _
    Inherits AgentCore _
    Implements ISnapshotGenerationAgent
'Uso
Dim instance As SnapshotGenerationAgent
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[GuidAttribute("141945FD-18BD-4222-B6D9-F937704C7FFE")]
[ComVisibleAttribute(true)]
public sealed class SnapshotGenerationAgent : AgentCore, 
    ISnapshotGenerationAgent
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[GuidAttribute(L"141945FD-18BD-4222-B6D9-F937704C7FFE")]
[ComVisibleAttribute(true)]
public ref class SnapshotGenerationAgent sealed : public AgentCore, 
    ISnapshotGenerationAgent
[<SealedAttribute>]
[<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)>]
[<GuidAttribute("141945FD-18BD-4222-B6D9-F937704C7FFE")>]
[<ComVisibleAttribute(true)>]
type SnapshotGenerationAgent =  
    class
        inherit AgentCore
        interface ISnapshotGenerationAgent
    end
public final class SnapshotGenerationAgent extends AgentCore implements ISnapshotGenerationAgent

O tipo SnapshotGenerationAgent expõe os membros a seguir.

Construtores

  Nome Descrição
Método público SnapshotGenerationAgent Creates an instance of the SnapshotGenerationAgent class.

Início

Propriedades

  Nome Descrição
Propriedade pública AbortPolicy Gets or sets how running replication agent threads are terminated when an unanticipated shutdown occurs. (Herdado de AgentCore.)
Propriedade pública BcpBatchSize Gets or set the number of rows to send to the Distributor in a bulk copy operation.
Propriedade pública ComErrorCollection Returns information on errors that occur during agent execution. (Herdado de AgentCore.)
Propriedade pública Distributor Gets or sets the name of the instance of SQL Server acting as the Distributor for the publication.
Propriedade pública DistributorDeadlockPriority Gets or sets the priority of the Snapshot Agent connection to the Distributor when a deadlock occurs.
Propriedade pública DistributorEncryptedPassword Infraestrutura.
Propriedade pública DistributorEncryptionLevel Gets of sets the level of Secure Sockets Layer (SSL) encryption used by the Snapshot Agent when connecting to the Distributor.
Propriedade pública DistributorLogin Gets or sets the login name used when connecting locally to the Distributor using SQL Server Authentication.
Propriedade pública DistributorNetworkLibrary Infraestrutura.
Propriedade pública DistributorPassword Sets the password used when connecting locally to the Distributor using SQL Server Authentication.
Propriedade pública DistributorSecurityMode Gets or sets the security mode used when connecting locally to the Distributor.
Propriedade pública DynamicFilterHostName Gets or sets the value supplied to the HOST_NAME function used in a parameterized row filter.
Propriedade pública DynamicFilterLogin Gets or sets the value supplied to the SUSER_SNAME function used in a parameterized row filter.
Propriedade pública DynamicSnapshotLocation Gets or sets the location of the partitioned snapshot for a subscription to a merge publication that is defined based-on a parameterized row filter.
Propriedade pública FieldDelimiter Gets or sets the character or character sequence that marks the end of a field in the SQL Server bulk-copy data file.
Propriedade pública FlatExceptionCollection Infraestrutura. (Herdado de AgentCore.)
Propriedade pública HistoryVerboseLevel Gets or sets the amount of history logged during agent execution. (Herdado de AgentCore.)
Propriedade pública HRBcpBlocks Infraestrutura.
Propriedade pública HRBcpBlockSize Infraestrutura.
Propriedade pública HRBcpDynamicBlocks Infraestrutura.
Propriedade pública LoginTimeout Get or sets the number of seconds before the login times out for connections made by the agent. (Herdado de AgentCore.)
Propriedade pública MaxBcpThreads Gets or sets the number of bulk copy operations that can be performed in parallel.
Propriedade pública MaxNetworkOptimization Gets or sets whether out-of-partition deletes are sent to the Subscriber.
Propriedade pública OnetimeDynamicSnapshot Infraestrutura.
Propriedade pública Output Get or sets the name and path of the agent output file. (Herdado de AgentCore.)
Propriedade pública OutputVerboseLevel Gets or sets the level of detail of information written to the agent output file. (Herdado de AgentCore.)
Propriedade pública PacketSize Infraestrutura. (Herdado de AgentCore.)
Propriedade pública ProfileName Gets or sets an agent profile to use when running the agent. (Herdado de AgentCore.)
Propriedade pública Publication Gets or sets the name of the publication.
Propriedade pública Publisher Gets or sets the name of the instance of SQL Server that is the Publisher.
Propriedade pública PublisherDatabase Gets or sets the name of the publication database.
Propriedade pública PublisherDeadlockPriority Gets or sets the priority of the Snapshot Agent connection to the Publisher when a deadlock occurs.
Propriedade pública PublisherEncryptedPassword Infraestrutura.
Propriedade pública PublisherEncryptionLevel Gets of sets the level of Secure Sockets Layer (SSL) encryption used by the Snapshot Agent when connecting to the Distributor.
Propriedade pública PublisherFailoverPartner Gets or sets the failover partner instance of SQL Server participating in a database mirroring session with the publication database. (Herdado de AgentCore.)
Propriedade pública PublisherLogin Gets or sets the login name used when connecting to the Publisher using SQL Server Authentication.
Propriedade pública PublisherNetworkLibrary Infraestrutura.
Propriedade pública PublisherPassword Sets the password used when connecting to the Publisher using SQL Server Authentication.
Propriedade pública PublisherSecurityMode Gets or sets the security mode used when connecting to the Publisher.
Propriedade pública QueryTimeout Get or sets the number of seconds before a query times out. (Herdado de AgentCore.)
Propriedade pública ReplicationType Gets or sets the type of publication.
Propriedade pública RowDelimiter Gets or sets the character or character sequence that marks the end of a row in the SQL Server bulk-copy data file.
Propriedade pública SecureDistributorEncryptedPassword Infraestrutura.
Propriedade pública SecureDistributorPassword Sets the password (as a SecureString object) used when connecting locally to the Distributor using SQL Server Authentication.
Propriedade pública SecurePublisherEncryptedPassword Infraestrutura.
Propriedade pública SecurePublisherPassword Sets the password (as a SecureString object) used when connecting to the Publisher using SQL Server Authentication.
Propriedade pública StartQueueTimeout Gets or sets the time that the Snapshot Agent waits when the maximum number of concurrent partitioned snapshot processes for a merge publication are already running.
Propriedade pública Supports70Subscribers Gets or sets whether the generated snapshot supports SQL Server 7.0 Subscribers.

Início

Métodos

  Nome Descrição
Método público Abort (Herdado de AgentCore.)
Método público CreateObjRef (Herdado de MarshalByRefObject.)
Método público Equals (Herdado de Object.)
Método protegido Finalize (Herdado de Object.)
Método público GenerateSnapshot Starts the Snapshot Agent to generate the snapshot.
Método público GetHashCode (Herdado de Object.)
Método público GetLifetimeService (Herdado de MarshalByRefObject.)
Método público GetType (Herdado de Object.)
Método público InitializeLifetimeService (Herdado de MarshalByRefObject.)
Método protegido MemberwiseClone() () () () (Herdado de Object.)
Método protegido MemberwiseClone(Boolean) (Herdado de MarshalByRefObject.)
Método público ResetParametersToDefault (Herdado de AgentCore.)
Método público ToString (Herdado de Object.)

Início

Eventos

  Nome Descrição
Evento público ComStatus (Herdado de AgentCore.)
Evento público Status Occurs when a running agent returns status information. (Herdado de AgentCore.)

Início

Implementações de interfaces explícitas

  Nome Descrição
Implementações de interfaces explícitasMétodo privado ISnapshotGenerationAgent. . :: . .ResetParametersToDefault

Início

Comentários

The SnapshotGenerationAgent class provides direct, programmatic access to the Snapshot Agent.

The SnapshotGenerationAgent class supports the ability to do the following replication tasks:

  • Generate the initial snapshot

  • Generate a partitioned snapshot for a subscription defined based-on a parameterized filter.

Exemplos

This example generates a standard snapshot for a transactional publication.

            // Set the Publisher, publication database, and publication names.
            string publicationName = "AdvWorksProductTran";
            string publicationDbName = "AdventureWorks2008R2";
            string publisherName = publisherInstance;
            string distributorName = publisherInstance;

            SnapshotGenerationAgent agent;

            try
            {
                // Set the required properties for Snapshot Agent.
                agent = new SnapshotGenerationAgent();
                agent.Distributor = distributorName;
                agent.DistributorSecurityMode = SecurityMode.Integrated;
                agent.Publisher = publisherName;
                agent.PublisherSecurityMode = SecurityMode.Integrated;
                agent.Publication = publicationName;
                agent.PublisherDatabase = publicationDbName;
                agent.ReplicationType = ReplicationType.Transactional;

                // Start the agent synchronously.
                agent.GenerateSnapshot();

            }
            catch (Exception ex)
            {
                // Implement custom application error handling here.
                throw new ApplicationException(String.Format(
                    "A snapshot could not be generated for the {0} publication."
                    , publicationName), ex);
            }
' Set the Publisher, publication database, and publication names.
Dim publicationName As String = "AdvWorksProductTran"
Dim publicationDbName As String = "AdventureWorks2008R2"
Dim publisherName As String = publisherInstance
Dim distributorName As String = publisherInstance

Dim agent As SnapshotGenerationAgent

Try
    ' Set the required properties for Snapshot Agent.
    agent = New SnapshotGenerationAgent()
    agent.Distributor = distributorName
    agent.DistributorSecurityMode = SecurityMode.Integrated
    agent.Publisher = publisherName
    agent.PublisherSecurityMode = SecurityMode.Integrated
    agent.Publication = publicationName
    agent.PublisherDatabase = publicationDbName
    agent.ReplicationType = ReplicationType.Transactional

    ' Start the agent synchronously.
    agent.GenerateSnapshot()

Catch ex As Exception
    ' Implement custom application error handling here.
    Throw New ApplicationException(String.Format( _
     "A snapshot could not be generated for the {0} publication." _
     , publicationName), ex)
End Try

This example generates a standard snapshot for a merge publication.

// Set the Publisher, publication database, and publication names.
string publicationName = "AdvWorksSalesOrdersMerge";
string publicationDbName = "AdventureWorks2008R2";
string publisherName = publisherInstance;
string distributorName = publisherInstance;

SnapshotGenerationAgent agent;

try
{
    // Set the required properties for Snapshot Agent.
    agent = new SnapshotGenerationAgent();
    agent.Distributor = distributorName;
    agent.DistributorSecurityMode = SecurityMode.Integrated;
    agent.Publisher = publisherName;
    agent.PublisherSecurityMode = SecurityMode.Integrated;
    agent.Publication = publicationName;
    agent.PublisherDatabase = publicationDbName;
    agent.ReplicationType = ReplicationType.Merge;

    // Start the agent synchronously.
    agent.GenerateSnapshot();

}
catch (Exception ex)
{
    // Implement custom application error handling here.
    throw new ApplicationException(String.Format(
        "A snapshot could not be generated for the {0} publication."
        , publicationName), ex);
}
' Set the Publisher, publication database, and publication names.
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2008R2"
Dim publisherName As String = publisherInstance
Dim distributorName As String = publisherInstance

Dim agent As SnapshotGenerationAgent

Try
    ' Set the required properties for Snapshot Agent.
    agent = New SnapshotGenerationAgent()
    agent.Distributor = distributorName
    agent.DistributorSecurityMode = SecurityMode.Integrated
    agent.Publisher = publisherName
    agent.PublisherSecurityMode = SecurityMode.Integrated
    agent.Publication = publicationName
    agent.PublisherDatabase = publicationDbName
    agent.ReplicationType = ReplicationType.Merge

    ' Start the agent synchronously.
    agent.GenerateSnapshot()

Catch ex As Exception
    ' Implement custom application error handling here.
    Throw New ApplicationException(String.Format( _
     "A snapshot could not be generated for the {0} publication." _
     , publicationName), ex)
End Try

This example overloads the HOST_NAME function to generate a filtered data snapshot for a subscription to a merge publication that has a parameterized filter.

           // Set the Publisher, publication database, and publication names.
            string publicationName = "AdvWorksSalesOrdersMerge";
            string publicationDbName = "AdventureWorks2008R2";
            string publisherName = publisherInstance;
            string distributorName = publisherInstance;

            SnapshotGenerationAgent agent;

            try
            {
                // Set the required properties for Snapshot Agent.
                agent = new SnapshotGenerationAgent();
                agent.Distributor = distributorName;
                agent.DistributorSecurityMode = SecurityMode.Integrated;
                agent.Publisher = publisherName;
                agent.PublisherSecurityMode = SecurityMode.Integrated;
                agent.Publication = publicationName;
                agent.PublisherDatabase = publicationDbName;
                agent.ReplicationType = ReplicationType.Merge;

                // Specify the partition information to generate a 
                // filtered snapshot based on Hostname.
                agent.DynamicFilterHostName = hostname;

                // Start the agent synchronously.
                agent.GenerateSnapshot();
            }
            catch (Exception ex)
            {
                // Implement custom application error handling here.
                throw new ApplicationException(String.Format(
                    "A snapshot could not be generated for the {0} publication."
                    , publicationName), ex);
            }
' Set the Publisher, publication database, and publication names.
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2008R2"
Dim publisherName As String = publisherInstance
Dim distributorName As String = publisherInstance

Dim agent As SnapshotGenerationAgent

Try
    ' Set the required properties for Snapshot Agent.
    agent = New SnapshotGenerationAgent()
    agent.Distributor = distributorName
    agent.DistributorSecurityMode = SecurityMode.Integrated
    agent.Publisher = publisherName
    agent.PublisherSecurityMode = SecurityMode.Integrated
    agent.Publication = publicationName
    agent.PublisherDatabase = publicationDbName
    agent.ReplicationType = ReplicationType.Merge

    ' Specify the partition information to generate a 
    ' filtered snapshot based on Hostname.
    agent.DynamicFilterHostName = hostname

    ' Start the agent synchronously.
    agent.GenerateSnapshot()
Catch ex As Exception
    ' Implement custom application error handling here.
    Throw New ApplicationException(String.Format( _
     "A snapshot could not be generated for the {0} publication." _
     , publicationName), ex)
End Try

Segurança de thread

Qualquer membro público static (Shared no Visual Basic) desse tipo é seguro para threads. Não há garantia de que qualquer membro de instância seja seguro para threads.