語言

BusinessLogicHandler 類別

定義

代表實作商業邏輯處理器的管理程式碼組合的伺服器註冊。

public ref class BusinessLogicHandler sealed
public sealed class BusinessLogicHandler
type BusinessLogicHandler = class
Public NotInheritable Class BusinessLogicHandler
繼承
BusinessLogicHandler

範例

// 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

備註

商業邏輯處理器透過呼叫 RegisterBusinessLogicHandler註冊 。 在呼叫 RegisterBusinessLogicHandler之前,必須先設定物件的BusinessLogicHandler性質。

透過呼叫 UnregisterBusinessLogicHandler來移除商業邏輯處理程序的註冊。

呼叫 EnumBusinessLogicHandlers 以取得伺服器上註冊的商業邏輯處理器清單。

建構函式

名稱 Description
BusinessLogicHandler()

初始化 BusinessLogicHandler 類別的新執行個體。

屬性

名稱 Description
DotNetAssemblyName

取得或設定實作商業邏輯處理器的組合名稱。

DotNetClassName

取得或設定實作商業邏輯處理器的類別名稱。

FriendlyName

取得或設定伺服器上註冊商業邏輯處理器的名稱。

IsDotNetAssembly

取得或設定一個值,指示註冊的商業邏輯處理器是否為受管理程式碼組合。

UserData

取得或設定一個物件,讓使用者可以附加自己的資料。

方法

名稱 Description
CheckValidDefinition(Boolean)

表示該定義是否有效。

適用於

另請參閱