Freigeben über


DistributionDatabase.RegisterBusinessLogicHandler Methode

Definition

Registriert eine Geschäftslogikhandler-Assembly beim Verteiler.

public:
 void RegisterBusinessLogicHandler(Microsoft::SqlServer::Replication::BusinessLogicHandler ^ businessLogicHandler);
public void RegisterBusinessLogicHandler (Microsoft.SqlServer.Replication.BusinessLogicHandler businessLogicHandler);
member this.RegisterBusinessLogicHandler : Microsoft.SqlServer.Replication.BusinessLogicHandler -> unit
Public Sub RegisterBusinessLogicHandler (businessLogicHandler As BusinessLogicHandler)

Parameter

businessLogicHandler
BusinessLogicHandler

Ein BusinessLogicHandler-Objekt, das den Geschäftslogikhandler darstellt, der registriert wird.

Beispiele

// Specify the Distributor name and business logic properties.
string distributorName = publisherInstance;
string assemblyName = @"C:\Program Files\Microsoft SQL Server\110\COM\CustomLogic.dll";
string className = "Microsoft.Samples.SqlServer.BusinessLogicHandler.OrderEntryBusinessLogicHandler";
string friendlyName = "OrderEntryLogic";

ReplicationServer distributor;
BusinessLogicHandler customLogic;

    // Create a connection to the Distributor.
ServerConnection distributorConn = new ServerConnection(distributorName);

try
{
    // Connect to the Distributor.
    distributorConn.Connect();

    // Set the Distributor properties.
    distributor = new ReplicationServer(distributorConn);

    // Set the business logic handler properties.
    customLogic = new BusinessLogicHandler();
    customLogic.DotNetAssemblyName = assemblyName;
    customLogic.DotNetClassName = className;
    customLogic.FriendlyName = friendlyName;
    customLogic.IsDotNetAssembly = true;

    Boolean isRegistered = false;

    // Check if the business logic handler is already registered at the Distributor.
    foreach (BusinessLogicHandler registeredLogic
        in distributor.EnumBusinessLogicHandlers())
    {
        if (registeredLogic == customLogic)
        {
            isRegistered = true;
        }
    }

    // Register the custom logic.
    if (!isRegistered)
    {
        distributor.RegisterBusinessLogicHandler(customLogic);
    }
}
catch (Exception ex)
{
    // Do error handling here.
    throw new ApplicationException(string.Format(
        "The {0} assembly could not be registered.",
        assemblyName), ex);
}
finally
{
    distributorConn.Disconnect();
}
' Specify the Distributor name and business logic properties.
Dim distributorName As String = publisherInstance
Dim assemblyName As String = "C:\Program Files\Microsoft SQL Server\110\COM\CustomLogic.dll"
Dim className As String = "Microsoft.Samples.SqlServer.BusinessLogicHandler.OrderEntryBusinessLogicHandler"
Dim friendlyName As String = "OrderEntryLogic"

Dim distributor As ReplicationServer
Dim customLogic As BusinessLogicHandler

' Create a connection to the Distributor.
Dim distributorConn As ServerConnection = New ServerConnection(distributorName)

Try
    ' Connect to the Distributor.
    distributorConn.Connect()

    ' Set the Distributor properties.
    distributor = New ReplicationServer(distributorConn)

    ' Set the business logic handler properties.
    customLogic = New BusinessLogicHandler()
    customLogic.DotNetAssemblyName = assemblyName
    customLogic.DotNetClassName = className
    customLogic.FriendlyName = friendlyName
    customLogic.IsDotNetAssembly = True

    Dim isRegistered As Boolean = False

    ' Check if the business logic handler is already registered at the Distributor.
    For Each registeredLogic As BusinessLogicHandler _
    In distributor.EnumBusinessLogicHandlers
        If registeredLogic Is customLogic Then
            isRegistered = True
        End If
    Next

    ' Register the custom logic.
    If Not isRegistered Then
        distributor.RegisterBusinessLogicHandler(customLogic)
    End If
Catch ex As Exception
    ' Do error handling here.
    Throw New ApplicationException(String.Format( _
     "The {0} assembly could not be registered.", _
     assemblyName), ex)
Finally
    distributorConn.Disconnect()
End Try

Hinweise

Der Geschäftslogikhandler muss beim Verteiler (und beim Abonnenten im Fall eines Pullabonnements) registriert werden. Die Assembly, die den Geschäftslogikhandler implementiert, muss jedoch nur auf dem Server installiert werden, auf dem der Merge-Agent ausgeführt wird.

Die <xref:Microsoft.SqlServer.Replication.ReplicationServer.RegisterBusinessLogicHandler%2A> Methode kann nur von Mitgliedern der sysadmin festen Serverrolle und Mitgliedern der db_owner festen Datenbankrolle aufgerufen werden.

Das Aufrufen <xref:Microsoft.SqlServer.Replication.ReplicationServer.RegisterBusinessLogicHandler%2A> entspricht der Ausführung sp_registercustomresolver.

Gilt für:

Weitere Informationen