TransSynchronizationAgent Classe

Définition

Fournit la fonctionnalité de l’Agent de Agent de distribution de Réplication.

public ref class TransSynchronizationAgent : MarshalByRefObject, IDisposable, Microsoft::SqlServer::Replication::ITransSynchronizationAgent
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComSourceInterfaces(typeof(Microsoft.SqlServer.Replication.IComStatusEvent))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.Guid("adeda98a-bdfc-4029-b6fb-991d6b468395")]
public class TransSynchronizationAgent : MarshalByRefObject, IDisposable, Microsoft.SqlServer.Replication.ITransSynchronizationAgent
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComSourceInterfaces(typeof(Microsoft.SqlServer.Replication.IComStatusEvent))>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Runtime.InteropServices.Guid("adeda98a-bdfc-4029-b6fb-991d6b468395")>]
type TransSynchronizationAgent = class
    inherit MarshalByRefObject
    interface IDisposable
    interface ITransSynchronizationAgent
Public Class TransSynchronizationAgent
Inherits MarshalByRefObject
Implements IDisposable, ITransSynchronizationAgent
Héritage
TransSynchronizationAgent
Attributs
Implémente

Exemples

Dans l’exemple suivant, la Synchronize méthode est appelée sur l’instance de la TransSynchronizationAgent classe qui est accédée depuis la SynchronizationAgent propriété pour synchroniser l’abonnement push.

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

// 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 = "AdventureWorks2012Replica"
Dim publicationDbName As String = "AdventureWorks2012"

' 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

Remarques

La TransSynchronizationAgent classe permet de synchroniser programmatiquement les abonnements à des publications transactionnelles ou snapshot.

Constructeurs

Nom Description
TransSynchronizationAgent()

Crée une instance de la classe TransSynchronizationAgent.

Propriétés

Nom Description
AltSnapshotFolder

Obtient ou définit le dossier d’instantanés alternatif pour l’abonnement.

ComErrorCollection

Obtient un ensemble d’erreurs générées par l’agent de réplication.

Distributor

Obtient ou définit le nom de l’instance de Microsoft SQL Server qui agit comme distributeur pour l’abonnement.

DistributorAddress

Obtient ou définit l’adresse réseau utilisée pour se connecter au distributeur lorsque la DistributorNetwork propriété est spécifiée.

DistributorEncryptedPassword

Obtient ou définit le mot de passe chiffré utilisé lors de la connexion au distributeur en utilisant l’authentification SQL Server.

DistributorLogin

Obtient ou définit le nom de connexion utilisé lors de la connexion au distributeur en utilisant l’authentification SQL Server.

DistributorNetwork

Obtient ou définit le Net-Library client utilisé lors de la connexion au distributeur.

DistributorPassword

Obtient ou définit le mot de passe utilisé lors de la connexion au distributeur en utilisant l’authentification SQL Server.

DistributorSecurityMode

Obtient ou règle le mode de sécurité utilisé lors de la connexion au distributeur.

DtsPackageFileName

Obtient ou définit le nom et le chemin d’un paquet Microsoft SQL Server 2000 Data Transformation Services (DTS) utilisé pour transformer des lignes de commandes avant qu’elles ne soient appliquées à un abonné.

DtsPackagePassword

Obtient ou définit le mot de passe propriétaire qui avait utilisé l’accès au package Microsoft SQL Server 2000 Data Transformation Services (DTS) spécifié par la DtsPackageFileName propriété.

FileTransferType

Obtient ou définit la manière dont les fichiers instantanés initiaux sont transférés à l’abonné.

HostName

Obtient ou définit le nom d’hôte utilisé.

LastUpdatedTime

Obtient l’heure de la dernière fois que cet agent de réplication a synchronisé l’abonnement.

LoginTimeout

Prend ou règle le nombre maximal de secondes pour attendre que les connexions soient établies.

MaxDeliveredTransactions

Obtient ou définit le nombre maximal de transactions appliquées à l’Abonné lors d’une exécution d’un seul agent.

Output

Obtient ou définit le nom du fichier et le chemin du fichier de sortie de l’agent.

OutputVerboseLevel

Obtient ou définit la quantité d’informations enregistrées par l’Agent Distribution dans le fichier de sortie de l’agent.

ProfileName

Obtient ou définit le nom du profil utilisé par l’agent.

Publication

Obtient ou donne le nom de la publication.

Publisher

Obtient ou définit le nom de l’instance de Microsoft SQL Server qui est le Publisher de l’abonnement.

PublisherDatabase

Obtient ou définit le nom de la base de données de publication.

QueryTimeout

Obtient ou définit le nombre de secondes autorisées pour que les requêtes internes se complètent.

SecureDistributorEncryptedPassword

Obtient ou définit le mot de passe sécurisé et chiffré pour le distributeur.

SecureSubscriberEncryptedPassword

Obtient ou définit le mot de passe sécurisé et chiffré pour l’abonné.

SkipErrors

Obtient ou définit une liste séparée par les deux-points des numéros d’erreur à ignorer par cet agent.

Subscriber

Obtient ou définit le nom de l’instance de Microsoft SQL Server qui est abonnée.

SubscriberDatabase

Obtient ou définit le nom de la base de données par abonnement.

SubscriberDatabasePath

Obtenez ou définissez le chemin de la base de données pour l’abonné.

SubscriberDataSourceType

Obtient ou définit le type de source de données utilisé comme abonné.

SubscriberEncryptedPassword

Obtient ou définit le mot de passe chiffré pour l’abonné.

SubscriberLogin

Obtient ou définit le nom de connexion utilisé lors de la connexion à l’abonné en utilisant l’authentification SQL Server.

SubscriberPassword

Obtient ou définit le mot de passe utilisé lors de la connexion à l’abonné en utilisant l’authentification SQL Server.

SubscriberSecurityMode

Obtient ou définit le mode de sécurité utilisé lors de la connexion à l’éditeur.

SubscriptionType

Obtient ou détermine si l’abonnement est un abonnement push ou pull.

UndeliveredCommands

Ça obtient le nombre de commandes non délivrées.

UndeliveredTransactions

Obtient le nombre de transactions non livrées.

UseInProcLoader

Obtient ou définit une valeur qui indique s’il faut utiliser la commande BULK INSERT lors de l’application de fichiers snapshot à l’abonné.

WorkingDirectory

Obtient ou définit le répertoire de travail à partir duquel les fichiers instantanés sont consultés lorsque le protocole de transfert de fichiers (FTP) est utilisé.

Méthodes

Nom Description
Abort()

Annulation de l’opération TransSynchronizationAgent .

Dispose()

Libère toutes les ressources utilisées par l’instance actuelle de la TransSynchronizationAgent classe.

Dispose(Boolean)

Libère toutes les ressources utilisées par la TransSynchronizationAgent classe.

Finalize()

Finalise le TransSynchronizationAgent.

IsSnapshotRequired()

Se connecte au distributeur et à l’abonné pour déterminer si un nouvel instantané sera appliqué lors de la prochaine synchronisation de l’agent.

Synchronize()

Lance l’Agent de Distribution pour synchroniser l’abonnement.

Événements

Nom Description
ComStatus

Se produit lorsque l’Agent Distribution retourne les informations de statut de la synchronisation Com.

Status

Se produit lorsque l’Agent Distribution renvoie les informations sur le statut de synchronisation.

S’applique à

Cohérence de thread

La TransSynchronizationAgent classe ne prend pas en compte les appartements multithread. Vous pouvez spécifier un appartement à thread unique en déclarant l’attribut [STAThread] sur la méthode qui constitue le point d’entrée principal de l’application. C’est la norme pour les applications basées sur Microsoft Windows créées en utilisant Microsoft Visual Studio.