SnapshotGenerationAgent 类

Provides the functionality of the Replication Snapshot Agent.

继承层次结构

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

命名空间:  Microsoft.SqlServer.Replication
程序集:  Microsoft.SqlServer.Replication(在 Microsoft.SqlServer.Replication.dll 中)

语法

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

SnapshotGenerationAgent 类型公开以下成员。

构造函数

  名称 说明
公共方法 SnapshotGenerationAgent Creates an instance of the SnapshotGenerationAgent class.

页首

属性

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

页首

方法

  名称 说明
公共方法 Abort Aborts the process of the current instance. (从 AgentCore 继承。)
公共方法 CreateObjRef 安全关键。 (从 MarshalByRefObject 继承。)
公共方法 Equals (从 Object 继承。)
公共方法 GenerateSnapshot Starts the Snapshot Agent to generate the snapshot.
公共方法 GetHashCode (从 Object 继承。)
公共方法 GetLifetimeService 安全关键。 (从 MarshalByRefObject 继承。)
公共方法 GetType (从 Object 继承。)
公共方法 InitializeLifetimeService 安全关键。 (从 MarshalByRefObject 继承。)
公共方法 ResetParametersToDefault Resets the value of the parameters to default. (从 AgentCore 继承。)
公共方法 ToString (从 Object 继承。)

页首

事件

  名称 说明
公共事件 ComStatus 基础结构。Occurs when a running agent returns synchronization Com status information. (从 AgentCore 继承。)
公共事件 Status Occurs when a running agent returns status information. (从 AgentCore 继承。)

页首

显式接口实现

  名称 说明
显式接口实现私有方法 ISnapshotGenerationAgent.ResetParametersToDefault Resets the parameters to its default value.

页首

注释

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

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。不保证所有实例成员都是线程安全的。

请参阅

参考

Microsoft.SqlServer.Replication 命名空间

其他资源

如何创建初始快照(RMO 编程)

如何创建具有参数化筛选器的合并发布的快照(RMO 编程)

复制快照代理