Condividi tramite


Classe SnapshotGenerationAgent

Provides the functionality of the Replication Snapshot Agent.

Gerarchia di ereditarietà

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

Spazio dei nomi  Microsoft.SqlServer.Replication
Assembly:  Microsoft.SqlServer.Replication (in Microsoft.SqlServer.Replication.dll)

Sintassi

'Dichiarazione
<ComVisibleAttribute(True)> _
<GuidAttribute("80016755-0016-4129-A778-1461AD058C86")> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public NotInheritable Class SnapshotGenerationAgent _
    Inherits AgentCore _
    Implements ISnapshotGenerationAgent
'Utilizzo
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

Nel tipo SnapshotGenerationAgent sono esposti i membri seguenti.

Costruttori

  Nome Descrizione
Metodo pubblico SnapshotGenerationAgent Creates an instance of the SnapshotGenerationAgent class.

In alto

Proprietà

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

In alto

Metodi

  Nome Descrizione
Metodo pubblico Abort Aborts the process of the current instance. Ereditato da AgentCore.
Metodo pubblico CreateObjRef Criticità per la sicurezza. Ereditato da MarshalByRefObject.
Metodo pubblico Equals Ereditato da Object.
Metodo pubblico GenerateSnapshot Starts the Snapshot Agent to generate the snapshot.
Metodo pubblico GetHashCode Ereditato da Object.
Metodo pubblico GetLifetimeService Criticità per la sicurezza. Ereditato da MarshalByRefObject.
Metodo pubblico GetType Ereditato da Object.
Metodo pubblico InitializeLifetimeService Criticità per la sicurezza. Ereditato da MarshalByRefObject.
Metodo pubblico ResetParametersToDefault Resets the value of the parameters to default. Ereditato da AgentCore.
Metodo pubblico ToString Ereditato da Object.

In alto

Eventi

  Nome Descrizione
Evento pubblico ComStatus Infrastruttura. Occurs when a running agent returns synchronization Com status information. Ereditato da AgentCore.
Evento pubblico Status Occurs when a running agent returns status information. Ereditato da AgentCore.

In alto

Implementazioni esplicite dell'interfaccia

  Nome Descrizione
Implementazione esplicita dell'interfacciaMetodo privato ISnapshotGenerationAgent.ResetParametersToDefault Resets the parameters to its default value.

In alto

Osservazioni

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.

Esempi

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

Protezione dei thread

I membri static (Shared in Visual Basic) pubblici di questo tipo sono affidabili. Non è invece garantita la sicurezza dei membri dell'istanza.

Vedere anche

Riferimento

Spazio dei nomi Microsoft.SqlServer.Replication

Altre risorse

Procedura: Creazione dello snapshot iniziale (programmazione RMO)

Procedura: Creazione di uno snapshot per una pubblicazione di tipo merge con filtri con parametri (programmazione RMO)

Agente snapshot repliche