Export (0) Print
Expand All

SnapshotGenerationAgent Class

Topic Status: Some information in this topic is pre-release and subject to change in future releases. Pre-release information describes new features or changes to existing features in Microsoft SQL Server 2014.

Provides the functionality of the Replication Snapshot Agent.

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

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

[ComVisibleAttribute(true)]
[GuidAttribute("80016755-0016-4129-A778-1461AD058C86")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
public sealed class SnapshotGenerationAgent : AgentCore, 
	ISnapshotGenerationAgent

The SnapshotGenerationAgent type exposes the following members.

  NameDescription
Public methodSnapshotGenerationAgentCreates an instance of the SnapshotGenerationAgent class.
Top

  NameDescription
Public propertyAbortPolicyGets or sets how running replication agent threads are terminated when an unanticipated shutdown occurs. (Inherited from AgentCore.)
Public propertyBcpBatchSizeGets or set the number of rows to send to the Distributor in a bulk copy operation.
Public propertyComErrorCollectionGets information on errors that occur during agent execution. (Inherited from AgentCore.)
Public propertyDistributorGets or sets the name of the instance of SQL Server acting as the Distributor for the publication.
Public propertyDistributorDeadlockPriorityGets or sets the priority of the Snapshot Agent connection to the Distributor when a deadlock occurs.
Public propertyDistributorEncryptedPasswordInfrastructure. Gets or sets the encrypted password for the distributor.
Public propertyDistributorEncryptionLevelGets of sets the level of Secure Sockets Layer (SSL) encryption used by the Snapshot Agent when connecting to the Distributor.
Public propertyDistributorLoginGets or sets the login name used when connecting locally to the Distributor using SQL Server Authentication.
Public propertyDistributorNetworkLibraryInfrastructure. Gets or sets the Network library used when connecting locally to the Distributor using SQL Server Authentication.
Public propertyDistributorPasswordSets the password used when connecting locally to the Distributor using SQL Server Authentication.
Public propertyDistributorSecurityModeGets or sets the security mode used when connecting locally to the Distributor.
Public propertyDynamicFilterHostNameGets or sets the value supplied to the HOST_NAME function used in a parameterized row filter.
Public propertyDynamicFilterLoginGets or sets the value supplied to the SUSER_SNAME function used in a parameterized row filter.
Public propertyDynamicSnapshotLocationGets or sets the location of the partitioned snapshot for a subscription to a merge publication that is defined based-on a parameterized row filter.
Public propertyFieldDelimiterGets or sets the character or character sequence that marks the end of a field in the SQL Server bulk-copy data file.
Public propertyFlatExceptionCollectionInfrastructure. Gets the collection of exception objects accessed using the IEnumerable interface. (Inherited from AgentCore.)
Public propertyHistoryVerboseLevelGets or sets the amount of history logged during agent execution. (Inherited from AgentCore.)
Public propertyHRBcpBlocksInfrastructure. Gets or sets the HR bulk copy program blocks.
Public propertyHRBcpBlockSizeInfrastructure. Gets or sets the HR bulk copy program block size.
Public propertyHRBcpDynamicBlocksInfrastructure. Gets or sets the HR bulk copy program dynamic blocks.
Public propertyLoginTimeoutGet or sets the number of seconds before the login times out for connections made by the agent. (Inherited from AgentCore.)
Public propertyMaxBcpThreadsGets or sets the number of bulk copy operations that can be performed in parallel.
Public propertyMaxNetworkOptimizationGets or sets whether out-of-partition deletes are sent to the Subscriber.
Public propertyOnetimeDynamicSnapshotInfrastructure. Gets or sets the one time dynamic snapshot.
Public propertyOutputGets or sets the name and path of the agent output file. (Inherited from AgentCore.)
Public propertyOutputVerboseLevelGets or sets the level of detail of information written to the agent output file. (Inherited from AgentCore.)
Public propertyPacketSizeInfrastructure. Gets or sets the packet size associated with the agent. (Inherited from AgentCore.)
Public propertyProfileNameGets or sets an agent profile to use when running the agent. (Inherited from AgentCore.)
Public propertyPublicationGets or sets the name of the publication.
Public propertyPublisherGets or sets the name of the instance of SQL Server that is the Publisher.
Public propertyPublisherDatabaseGets or sets the name of the publication database.
Public propertyPublisherDeadlockPriorityGets or sets the priority of the Snapshot Agent connection to the Publisher when a deadlock occurs.
Public propertyPublisherEncryptedPasswordInfrastructure. Gets or sets the encrypted password for the publisher.
Public propertyPublisherEncryptionLevelGets of sets the level of Secure Sockets Layer (SSL) encryption used by the Snapshot Agent when connecting to the Distributor.
Public propertyPublisherFailoverPartnerGets or sets the failover partner instance of SQL Server participating in a database mirroring session with the publication database. (Inherited from AgentCore.)
Public propertyPublisherLoginGets or sets the login name used when connecting to the Publisher using SQL Server Authentication.
Public propertyPublisherNetworkLibraryInfrastructure. Gets or sets the Network library used when connecting locally to the Publisher using SQL Server Authentication.
Public propertyPublisherPasswordSets the password used when connecting to the Publisher using SQL Server Authentication.
Public propertyPublisherSecurityModeGets or sets the security mode used when connecting to the Publisher.
Public propertyQueryTimeoutGets or sets the number of seconds before a query times out. (Inherited from AgentCore.)
Public propertyReplicationTypeGets or sets the type of publication.
Public propertyRowDelimiterGets or sets the character or character sequence that marks the end of a row in the SQL Server bulk-copy data file.
Public propertySecureDistributorEncryptedPasswordInfrastructure. Sets the encrypted password used when connecting locally to the Distributor using SQL Server Authentication.
Public propertySecureDistributorPasswordSets the password (as a SecureString object) used when connecting locally to the Distributor using SQL Server Authentication.
Public propertySecurePublisherEncryptedPasswordInfrastructure. Sets the encrypted password used when connecting to the Publisher using SQL Server Authentication.
Public propertySecurePublisherPasswordSets the password (as a SecureString object) used when connecting to the Publisher using SQL Server Authentication.
Public propertyStartQueueTimeoutGets 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.
Public propertySupports70SubscribersGets or sets whether the generated snapshot supports SQL Server 7.0 Subscribers.
Top

  NameDescription
Public methodAbortAborts the process of the current instance. (Inherited from AgentCore.)
Public methodCreateObjRefSecurity Critical. (Inherited from MarshalByRefObject.)
Public methodEquals (Inherited from Object.)
Public methodGenerateSnapshotStarts the Snapshot Agent to generate the snapshot.
Public methodGetHashCode (Inherited from Object.)
Public methodGetLifetimeServiceSecurity Critical. (Inherited from MarshalByRefObject.)
Public methodGetType (Inherited from Object.)
Public methodInitializeLifetimeServiceSecurity Critical. (Inherited from MarshalByRefObject.)
Public methodResetParametersToDefaultResets the value of the parameters to default. (Inherited from AgentCore.)
Public methodToString (Inherited from Object.)
Top

  NameDescription
Public eventComStatusInfrastructure. Occurs when a running agent returns synchronization Com status information. (Inherited from AgentCore.)
Public eventStatusOccurs when a running agent returns status information. (Inherited from AgentCore.)
Top

  NameDescription
Explicit interface implemetationPrivate methodISnapshotGenerationAgent.ResetParametersToDefaultResets the parameters to its default value.
Top

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.

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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Community Additions

Show:
© 2014 Microsoft