TransSynchronizationAgent 类

Provides the functionality of the Replication Distribution Agent.

继承层次结构

System. . :: . .Object
  System. . :: . .MarshalByRefObject
    Microsoft.SqlServer.Replication..::..TransSynchronizationAgent

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

语法

声明
<GuidAttribute("adeda98a-bdfc-4029-b6fb-991d6b468395")> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
<ComVisibleAttribute(True)> _
<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public Class TransSynchronizationAgent _
    Inherits MarshalByRefObject _
    Implements IDisposable, ITransSynchronizationAgent
用法
Dim instance As TransSynchronizationAgent
[GuidAttribute("adeda98a-bdfc-4029-b6fb-991d6b468395")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)]
[ComVisibleAttribute(true)]
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public class TransSynchronizationAgent : MarshalByRefObject, 
    IDisposable, ITransSynchronizationAgent
[GuidAttribute(L"adeda98a-bdfc-4029-b6fb-991d6b468395")]
[ClassInterfaceAttribute(ClassInterfaceType::AutoDispatch)]
[ComVisibleAttribute(true)]
[PermissionSetAttribute(SecurityAction::Demand, Name = L"FullTrust")]
public ref class TransSynchronizationAgent : public MarshalByRefObject, 
    IDisposable, ITransSynchronizationAgent
[<GuidAttribute("adeda98a-bdfc-4029-b6fb-991d6b468395")>]
[<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)>]
[<ComVisibleAttribute(true)>]
[<PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")>]
type TransSynchronizationAgent =  
    class
        inherit MarshalByRefObject
        interface IDisposable
        interface ITransSynchronizationAgent
    end
public class TransSynchronizationAgent extends MarshalByRefObject implements IDisposable, ITransSynchronizationAgent

TransSynchronizationAgent 类型公开以下成员。

构造函数

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

页首

属性

  名称 说明
公共属性 AltSnapshotFolder Gets or sets the alternate snapshot folder for the subscription.
公共属性 ComErrorCollection Gets a collection of errors that are generated by the replication agent.
公共属性 Distributor Gets or sets the name of the instance of Microsoft SQL Server that is acting as the Distributor for the subscription.
公共属性 DistributorAddress Gets or sets the network address that is used to connect to the Distributor when the DistributorNetwork property is specified.
公共属性 DistributorEncryptedPassword 基础结构。
公共属性 DistributorLogin Gets or sets the login name that is used when connecting to the Distributor by using SQL Server Authentication.
公共属性 DistributorNetwork Gets or sets the client Net-Library that is used when connecting to the Distributor.
公共属性 DistributorPassword Sets the password that is used when connecting to the Distributor by using SQL Server Authentication.
公共属性 DistributorSecurityMode Gets or sets the security mode that is used when connecting to the Distributor.
公共属性 DtsPackageFileName Gets or sets the name and path of a Microsoft SQL Server 2000 Data Transformation Services (DTS) package that is used to transform command rowsets before they are applied to a Subscriber.
公共属性 DtsPackagePassword Gets or sets the owner password that used to access the Microsoft SQL Server 2000 Data Transformation Services (DTS) package specified by the DtsPackageFileName property.
公共属性 FileTransferType Gets or sets how the initial snapshot files are transferred to the Subscriber.
公共属性 HostName 基础结构。
公共属性 LastUpdatedTime Gets the timestamp of the last time that replication agent synchronized the subscription.
公共属性 LoginTimeout Gets or sets the maximum number of seconds to wait for connections to be established.
公共属性 MaxDeliveredTransactions Gets or sets the maximum number of transactions that are applied to the Subscriber during a single agent execution.
公共属性 Output Gets or sets the file name and path of the agent output file.
公共属性 OutputVerboseLevel Gets or sets the amount of information that is logged by the Distribution Agent in the agent output file.
公共属性 ProfileName Gets or sets the name of the profile that is used by the agent.
公共属性 Publication Gets or sets the name of the publication.
公共属性 Publisher Gets or sets the name of the instance of Microsoft SQL Server that is the Publisher for the subscription.
公共属性 PublisherDatabase Gets or sets the name of the publication database.
公共属性 QueryTimeout Gets or sets the number of seconds that are allowed for internal queries to complete.
公共属性 SecureDistributorEncryptedPassword 基础结构。
公共属性 SecureSubscriberEncryptedPassword 基础结构。
公共属性 SkipErrors Gets or sets a colon-separated list of the error numbers that are to be skipped by this agent.
公共属性 Subscriber Gets or sets the name of the instance of Microsoft SQL Server that is the Subscriber.
公共属性 SubscriberDatabase Gets or sets the name of the subscription database.
公共属性 SubscriberDatabasePath 基础结构。
公共属性 SubscriberDataSourceType Gets or sets the type of data source that is used as the Subscriber.
公共属性 SubscriberEncryptedPassword 基础结构。
公共属性 SubscriberLogin Gets or sets the login name that is used when connecting to the Subscriber by using SQL Server Authentication.
公共属性 SubscriberPassword Sets the password that is used when connecting to the Subscriber by using SQL Server Authentication.
公共属性 SubscriberSecurityMode Gets or sets the security mode that is used when connecting to the Publisher.
公共属性 SubscriptionType Gets or sets whether the subscription is a push or pull subscription.
公共属性 UndeliveredCommands 基础结构。
公共属性 UndeliveredTransactions 基础结构。
公共属性 UseInProcLoader Gets or sets whether to use the BULK INSERT command when applying snapshot files at the Subscriber.
公共属性 WorkingDirectory Gets or sets the working directory from which snapshot files are accessed when File Transfer Protocol (FTP) is used.

页首

方法

  名称 说明
公共方法 Abort 基础结构。
公共方法 CreateObjRef (从 MarshalByRefObject 继承。)
公共方法 Dispose() () () () 基础结构。
受保护方法 Dispose(Boolean)
公共方法 Equals (从 Object 继承。)
受保护方法 Finalize 基础结构。 (覆盖 Object. . :: . .Finalize() () () ()。)
公共方法 GetHashCode (从 Object 继承。)
公共方法 GetLifetimeService (从 MarshalByRefObject 继承。)
公共方法 GetType (从 Object 继承。)
公共方法 InitializeLifetimeService (从 MarshalByRefObject 继承。)
公共方法 IsSnapshotRequired Connects to the Distributor and the Subscriber to determine whether a new snapshot will be applied during the next agent synchronization.
受保护方法 MemberwiseClone() () () () (从 Object 继承。)
受保护方法 MemberwiseClone(Boolean) (从 MarshalByRefObject 继承。)
公共方法 Synchronize Starts the Distribution Agent to synchronize the subscription.
公共方法 ToString (从 Object 继承。)

页首

事件

  名称 说明
公共事件 ComStatus 基础结构。
公共事件 Status Occurs when the Distribution Agent returns synchronization status information.

页首

注释

The TransSynchronizationAgent class supports the ability to programmatically synchronize subscriptions to transactional or snapshot publications.

示例

In the following example, the Synchronize method is called on the instance of the TransSynchronizationAgent class that is accessed from the SynchronizationAgent property to synchronize the push subscription.

          // Define the server, publication, and database names.
            string subscriberName = subscriberInstance;
            string publisherName = publisherInstance;
            string publicationName = "AdvWorksProductTran";
            string subscriptionDbName = "AdventureWorksReplica";
            string publicationDbName = "AdventureWorks";

            // Create a connection to the Publisher.
            ServerConnection conn = new ServerConnection(publisherName);

            TransSubscription subscription;

            try
            {
                // Connect to the Publisher.
                conn.Connect();

                // Define the push subscription.
                subscription = new TransSubscription();
                subscription.ConnectionContext = conn;
                subscription.DatabaseName = publicationDbName;
                subscription.PublicationName = publicationName;
                subscription.SubscriptionDBName = subscriptionDbName;
                subscription.SubscriberName = subscriberName;

                // If the push subscription exists, start the synchronization.
                if (subscription.LoadProperties())
                {
                    // Check that we have enough metadata to start the agent.
                    if (subscription.SubscriberSecurity != null)
                    {
                        // Synchronously start the Distribution Agent for the subscription.
                        subscription.SynchronizationAgent.Synchronize();
                    }
                    else
                    {
                        throw new ApplicationException("There is insufficent metadata to " +
                            "synchronize the subscription. Recreate the subscription with " +
                            "the agent job or supply the required agent properties at run time.");
                    }
                }
                else
                {
                    // Do something here if the push subscription does not exist.
                    throw new ApplicationException(String.Format(
                        "The subscription to '{0}' does not exist on {1}",
                        publicationName, subscriberName));
                }
            }
            catch (Exception ex)
            {
                // Implement appropriate error handling here.
                throw new ApplicationException("The subscription could not be synchronized.", ex);
            }
            finally
            {
                conn.Disconnect();
            }
' Define the server, publication, and database names.
Dim subscriberName As String = subscriberInstance
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksProductTran"
Dim subscriptionDbName As String = "AdventureWorksReplica"
Dim publicationDbName As String = "AdventureWorks"

' Create a connection to the Publisher.
Dim conn As ServerConnection = New ServerConnection(publisherName)

Dim subscription As TransSubscription

Try
    ' Connect to the Publisher.
    conn.Connect()

    ' Define the push subscription.
    subscription = New TransSubscription()
    subscription.ConnectionContext = conn
    subscription.DatabaseName = publicationDbName
    subscription.PublicationName = publicationName
    subscription.SubscriptionDBName = subscriptionDbName
    subscription.SubscriberName = subscriberName

    ' If the push subscription exists, start the synchronization.
    If subscription.LoadProperties() Then
        ' Check that we have enough metadata to start the agent.
        If Not subscription.SubscriberSecurity Is Nothing Then

            ' Synchronously start the Distribution Agent for the subscription.
            subscription.SynchronizationAgent.Synchronize()
        Else
            Throw New ApplicationException("There is insufficent metadata to " + _
             "synchronize the subscription. Recreate the subscription with " + _
             "the agent job or supply the required agent properties at run time.")
        End If
    Else
        ' Do something here if the push subscription does not exist.
        Throw New ApplicationException(String.Format( _
         "The subscription to '{0}' does not exist on {1}", _
         publicationName, subscriberName))
    End If
Catch ex As Exception
    ' Implement appropriate error handling here.
    Throw New ApplicationException("The subscription could not be synchronized.", ex)
Finally
    conn.Disconnect()
End Try

线程安全

The TransSynchronizationAgent class does not support multithreaded apartments. You can specify a single-threaded apartment by declaring the [STAThread] attribute on the method that is the main entry point for the application. This is the default for Microsoft Windows-based applications that are created by using Microsoft Visual Studio.