匯出 (0) 列印
全部展開
本文章是由機器翻譯。 將指標移到文章內的文字上方即可查看原文。 其他資訊。
譯文
原文

DistributionDatabase.RegisterBusinessLogicHandler 方法

Topic Status: Some information in this topic is pre-release and subject to change in future releases. Pre-release information describes new features or changes to existing features in Microsoft SQL Server 2014.

在散發者端註冊商務邏輯處理常式組件。

命名空間:  Microsoft.SqlServer.Replication
組件:  Microsoft.SqlServer.Rmo (在 Microsoft.SqlServer.Rmo.dll 中)

public void RegisterBusinessLogicHandler(
	BusinessLogicHandler businessLogicHandler
)

參數

businessLogicHandler
型別:Microsoft.SqlServer.Replication.BusinessLogicHandler
BusinessLogicHandler 物件,表示正進行註冊的商務邏輯處理常式。

商務邏輯處理常式必須在散發者 (以及提取訂閱條件下的訂閱者)。 不過,實作商務邏輯處理常式的組件在執行合併代理程式的伺服器只需要安裝。

RegisterBusinessLogicHandler(BusinessLogicHandler) 方法可以由 sysadmin 固定伺服器角色的 db_owner 固定資料庫角色的成員和的成員只呼叫

呼叫 RegisterBusinessLogicHandler(BusinessLogicHandler) 與執行 sp_registercustomresolver相當於。

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

社群新增項目

新增
顯示:
© 2014 Microsoft