Classe SnapshotGenerationAgent

Provides the functionality of the Replication Snapshot Agent.

Hiérarchie d'héritage

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

Espace de noms :  Microsoft.SqlServer.Replication
Assembly :  Microsoft.SqlServer.Replication (en Microsoft.SqlServer.Replication.dll)

Syntaxe

'Déclaration
<ComVisibleAttribute(True)> _
<GuidAttribute("80016755-0016-4129-A778-1461AD058C86")> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public NotInheritable Class SnapshotGenerationAgent _
    Inherits AgentCore _
    Implements ISnapshotGenerationAgent
'Utilisation
Dim instance As SnapshotGenerationAgent
[ComVisibleAttribute(true)]
[GuidAttribute("80016755-0016-4129-A778-1461AD058C86")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
public sealed class SnapshotGenerationAgent : AgentCore, 
    ISnapshotGenerationAgent
[ComVisibleAttribute(true)]
[GuidAttribute(L"80016755-0016-4129-A778-1461AD058C86")]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
public ref class SnapshotGenerationAgent sealed : public AgentCore, 
    ISnapshotGenerationAgent
[<SealedAttribute>]
[<ComVisibleAttribute(true)>]
[<GuidAttribute("80016755-0016-4129-A778-1461AD058C86")>]
[<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)>]
type SnapshotGenerationAgent =  
    class 
        inherit AgentCore 
        interface ISnapshotGenerationAgent 
    end
public final class SnapshotGenerationAgent extends AgentCore implements ISnapshotGenerationAgent

Le type SnapshotGenerationAgent expose les membres suivants.

Constructeurs

  Nom Description
Méthode publique SnapshotGenerationAgent Creates an instance of the SnapshotGenerationAgent class.

Haut de la page

Propriétés

  Nom Description
Propriété publique AbortPolicy Gets or sets how running replication agent threads are terminated when an unanticipated shutdown occurs. (hérité de AgentCore.)
Propriété publique BcpBatchSize Gets or set the number of rows to send to the Distributor in a bulk copy operation.
Propriété publique ComErrorCollection Gets information on errors that occur during agent execution. (hérité de AgentCore.)
Propriété publique Distributor Gets or sets the name of the instance of SQL Server acting as the Distributor for the publication.
Propriété publique DistributorDeadlockPriority Gets or sets the priority of the Snapshot Agent connection to the Distributor when a deadlock occurs.
Propriété publique DistributorEncryptedPassword Infrastructure. Gets or sets the encrypted password for the distributor.
Propriété publique DistributorEncryptionLevel Gets of sets the level of Secure Sockets Layer (SSL) encryption used by the Snapshot Agent when connecting to the Distributor.
Propriété publique DistributorLogin Gets or sets the login name used when connecting locally to the Distributor using SQL Server Authentication.
Propriété publique DistributorNetworkLibrary Infrastructure. Gets or sets the Network library used when connecting locally to the Distributor using SQL Server Authentication.
Propriété publique DistributorPassword Sets the password used when connecting locally to the Distributor using SQL Server Authentication.
Propriété publique DistributorSecurityMode Gets or sets the security mode used when connecting locally to the Distributor.
Propriété publique DynamicFilterHostName Gets or sets the value supplied to the HOST_NAME function used in a parameterized row filter.
Propriété publique DynamicFilterLogin Gets or sets the value supplied to the SUSER_SNAME function used in a parameterized row filter.
Propriété publique 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.
Propriété publique FieldDelimiter Gets or sets the character or character sequence that marks the end of a field in the SQL Server bulk-copy data file.
Propriété publique FlatExceptionCollection Infrastructure. Gets the collection of exception objects accessed using the IEnumerable interface. (hérité de AgentCore.)
Propriété publique HistoryVerboseLevel Gets or sets the amount of history logged during agent execution. (hérité de AgentCore.)
Propriété publique HRBcpBlocks Infrastructure. Gets or sets the HR bulk copy program blocks.
Propriété publique HRBcpBlockSize Infrastructure. Gets or sets the HR bulk copy program block size.
Propriété publique HRBcpDynamicBlocks Infrastructure. Gets or sets the HR bulk copy program dynamic blocks.
Propriété publique LoginTimeout Get or sets the number of seconds before the login times out for connections made by the agent. (hérité de AgentCore.)
Propriété publique MaxBcpThreads Gets or sets the number of bulk copy operations that can be performed in parallel.
Propriété publique MaxNetworkOptimization Gets or sets whether out-of-partition deletes are sent to the Subscriber.
Propriété publique OnetimeDynamicSnapshot Infrastructure. Gets or sets the one time dynamic snapshot.
Propriété publique Output Gets or sets the name and path of the agent output file. (hérité de AgentCore.)
Propriété publique OutputVerboseLevel Gets or sets the level of detail of information written to the agent output file. (hérité de AgentCore.)
Propriété publique PacketSize Infrastructure. Gets or sets the packet size associated with the agent. (hérité de AgentCore.)
Propriété publique ProfileName Gets or sets an agent profile to use when running the agent. (hérité de AgentCore.)
Propriété publique Publication Gets or sets the name of the publication.
Propriété publique Publisher Gets or sets the name of the instance of SQL Server that is the Publisher.
Propriété publique PublisherDatabase Gets or sets the name of the publication database.
Propriété publique PublisherDeadlockPriority Gets or sets the priority of the Snapshot Agent connection to the Publisher when a deadlock occurs.
Propriété publique PublisherEncryptedPassword Infrastructure. Gets or sets the encrypted password for the publisher.
Propriété publique PublisherEncryptionLevel Gets of sets the level of Secure Sockets Layer (SSL) encryption used by the Snapshot Agent when connecting to the Distributor.
Propriété publique PublisherFailoverPartner Gets or sets the failover partner instance of SQL Server participating in a database mirroring session with the publication database. (hérité de AgentCore.)
Propriété publique PublisherLogin Gets or sets the login name used when connecting to the Publisher using SQL Server Authentication.
Propriété publique PublisherNetworkLibrary Infrastructure. Gets or sets the Network library used when connecting locally to the Publisher using SQL Server Authentication.
Propriété publique PublisherPassword Sets the password used when connecting to the Publisher using SQL Server Authentication.
Propriété publique PublisherSecurityMode Gets or sets the security mode used when connecting to the Publisher.
Propriété publique QueryTimeout Gets or sets the number of seconds before a query times out. (hérité de AgentCore.)
Propriété publique ReplicationType Gets or sets the type of publication.
Propriété publique RowDelimiter Gets or sets the character or character sequence that marks the end of a row in the SQL Server bulk-copy data file.
Propriété publique SecureDistributorEncryptedPassword Infrastructure. Sets the encrypted password used when connecting locally to the Distributor using SQL Server Authentication.
Propriété publique SecureDistributorPassword Sets the password (as a SecureString object) used when connecting locally to the Distributor using SQL Server Authentication.
Propriété publique SecurePublisherEncryptedPassword Infrastructure. Sets the encrypted password used when connecting to the Publisher using SQL Server Authentication.
Propriété publique SecurePublisherPassword Sets the password (as a SecureString object) used when connecting to the Publisher using SQL Server Authentication.
Propriété publique 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.
Propriété publique Supports70Subscribers Gets or sets whether the generated snapshot supports SQL Server 7.0 Subscribers.

Haut de la page

Méthodes

  Nom Description
Méthode publique Abort Aborts the process of the current instance. (hérité de AgentCore.)
Méthode publique CreateObjRef Informations critiques de sécurité. (hérité de MarshalByRefObject.)
Méthode publique Equals (hérité de Object.)
Méthode publique GenerateSnapshot Starts the Snapshot Agent to generate the snapshot.
Méthode publique GetHashCode (hérité de Object.)
Méthode publique GetLifetimeService Informations critiques de sécurité. (hérité de MarshalByRefObject.)
Méthode publique GetType (hérité de Object.)
Méthode publique InitializeLifetimeService Informations critiques de sécurité. (hérité de MarshalByRefObject.)
Méthode publique ResetParametersToDefault Resets the value of the parameters to default. (hérité de AgentCore.)
Méthode publique ToString (hérité de Object.)

Haut de la page

Événements

  Nom Description
Événement public ComStatus Infrastructure. Occurs when a running agent returns synchronization Com status information. (hérité de AgentCore.)
Événement public Status Occurs when a running agent returns status information. (hérité de AgentCore.)

Haut de la page

Implémentations d'interfaces explicites

  Nom Description
Implémentation d'interface expliciteMéthode privée ISnapshotGenerationAgent.ResetParametersToDefault Resets the parameters to its default value.

Haut de la page

Notes

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.

Exemples

This example generates a standard snapshot for a transactional publication.

         // Set the Publisher, publication database, and publication names.
            string publicationName = "AdvWorksProductTran";
            string publicationDbName = "AdventureWorks2012";
            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 = "AdventureWorks2012"
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 = "AdventureWorks2012";
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 = "AdventureWorks2012"
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 = "AdventureWorks2012";
            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 = "AdventureWorks2012"
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

Sécurité des threads

Tous les membres publics static (Shared dans Visual Basic) de ce type sont thread-safe. Tous les membres de l'instance ne sont pas garantis comme étant thread-safe.

Voir aussi

Référence

Espace de noms Microsoft.SqlServer.Replication

Autres ressources

Procédure : créer l'instantané initial (programmation RMO)

Procédure : créer un instantané pour une publication de fusion avec des filtres paramétrables (programmation RMO)

Agent d'instantané de réplication