次の方法で共有


MergeDynamicSnapshotJob クラス

パラメーター化された行フィルターでマージ パブリケーションに対するサブスクリプションのデータ スナップショットを生成するスナップショット エージェント ジョブに関する情報を含みます。

継承階層

System.Object
  Microsoft.SqlServer.Replication.MergeDynamicSnapshotJob

名前空間:  Microsoft.SqlServer.Replication
アセンブリ:  Microsoft.SqlServer.Rmo (Microsoft.SqlServer.Rmo.dll)

構文

'宣言
Public NotInheritable Class MergeDynamicSnapshotJob
'使用
Dim instance As MergeDynamicSnapshotJob
public sealed class MergeDynamicSnapshotJob
public ref class MergeDynamicSnapshotJob sealed
[<SealedAttribute>]
type MergeDynamicSnapshotJob =  class end
public final class MergeDynamicSnapshotJob

MergeDynamicSnapshotJob 型は、以下のメンバーを公開しています。

コンストラクター

  名前 説明
パブリック メソッド MergeDynamicSnapshotJob MergeDynamicSnapshotJob クラスの新しいインスタンスを作成します。

先頭に戻る

プロパティ

  名前 説明
パブリック プロパティ DynamicFilterHostName パラメーター化された行フィルターが HOST_NAME (Transact-SQL) 関数を使用して定義されている場合、データ スナップショットを生成するためにこの関数に渡される値を取得します。値の設定も可能です。
パブリック プロパティ DynamicFilterLogin パラメーター化された行フィルターが SUSER_SNAME (Transact-SQL) 関数を使用して定義されている場合、データ スナップショットを生成するためにこの関数に渡される値を取得します。値の設定も可能です。
パブリック プロパティ DynamicSnapshotLocation このスナップショット エージェント ジョブによって生成される、フィルター選択されたスナップショットの格納に使用されるオペレーティング システム フォルダーを取得します。値の設定も可能です。
パブリック プロパティ JobId サブスクライバーのフィルター選択されたスナップショットを生成する Microsoft SQL Server エージェント ジョブ ID を、16 進形式で取得します。値の設定も可能です。
パブリック プロパティ Name サブスクライバーのフィルター選択されたスナップショットを生成するスナップショット エージェント ジョブの名前を取得します。値の設定も可能です。
パブリック プロパティ UserData MergeDynamicSnapshotJob のこのインスタンスにカスタム データをアタッチするためのオブジェクトを取得します。値の設定も可能です。

先頭に戻る

メソッド

  名前 説明
パブリック メソッド Equals (Object から継承されています。)
パブリック メソッド GetHashCode (Object から継承されています。)
パブリック メソッド GetType (Object から継承されています。)
パブリック メソッド ToString (Object から継承されています。)

先頭に戻る

説明

この名前空間、クラス、またはメンバーは、Microsoft .NET Framework 2.0 でのみサポートされています。

スレッド セーフ

この型の public static (Microsoft Visual Basic では Shared) のすべてのメンバーは、マルチスレッド操作で安全に使用できます。 インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

使用例

           // Define the server, database, and publication names
            string publisherName = publisherInstance;
            string publicationName = "AdvWorksSalesOrdersMerge";
            string publicationDbName = "AdventureWorks2012";
            string distributorName = publisherInstance;

            MergePublication publication;
            MergePartition partition;
            MergeDynamicSnapshotJob snapshotAgentJob;
            ReplicationAgentSchedule schedule;
            
            // Create a connection to the Publisher.
            ServerConnection publisherConn = new ServerConnection(publisherName);

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

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

                // Set the required properties for the publication.
                publication = new MergePublication();
                publication.ConnectionContext = publisherConn;
                publication.Name = publicationName;
                publication.DatabaseName = publicationDbName;


                // If we can't get the properties for this merge publication, 
                // then throw an application exception.
                if (publication.LoadProperties() || publication.SnapshotAvailable)
                {
                    // Set a weekly schedule for the filtered data snapshot.
                    schedule = new ReplicationAgentSchedule();
                    schedule.FrequencyType = ScheduleFrequencyType.Weekly;
                    schedule.FrequencyRecurrenceFactor = 1;
                    schedule.FrequencyInterval = Convert.ToInt32(0x001);

                    // Set the value of Hostname that defines the data partition. 
                    partition = new MergePartition();
                    partition.DynamicFilterHostName = hostname;
                    snapshotAgentJob = new MergeDynamicSnapshotJob();
                    snapshotAgentJob.DynamicFilterHostName = hostname;

                    // Create the partition for the publication with the defined schedule.
                    publication.AddMergePartition(partition);
                    publication.AddMergeDynamicSnapshotJob(snapshotAgentJob, schedule);
                }
                else
                {
                    throw new ApplicationException(String.Format(
                        "Settings could not be retrieved for the publication, " +
                        " or the initial snapshot has not been generated. " +
                        "Ensure that the publication {0} exists on {1} and " +
                        "that the Snapshot Agent has run successfully.",
                        publicationName, publisherName));
                }
            }
            catch (Exception ex)
            {
                // Do error handling here.
                throw new ApplicationException(string.Format(
                    "The partition for '{0}' in the {1} publication could not be created.",
                    hostname, publicationName), ex);
            }
            finally
            {
                publisherConn.Disconnect();
                if (distributorConn.IsOpen) distributorConn.Disconnect();
            }
' Define the server, database, and publication names
Dim publisherName As String = publisherInstance
Dim publicationName As String = "AdvWorksSalesOrdersMerge"
Dim publicationDbName As String = "AdventureWorks2012"
Dim distributorName As String = publisherInstance

Dim publication As MergePublication
Dim partition As MergePartition
Dim snapshotAgentJob As MergeDynamicSnapshotJob
Dim schedule As ReplicationAgentSchedule

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

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

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

    ' Set the required properties for the publication.
    publication = New MergePublication()
    publication.ConnectionContext = publisherConn
    publication.Name = publicationName
    publication.DatabaseName = publicationDbName


    ' If we can't get the properties for this merge publication, 
    ' then throw an application exception.
    If (publication.LoadProperties() Or publication.SnapshotAvailable) Then
        ' Set a weekly schedule for the filtered data snapshot.
        schedule = New ReplicationAgentSchedule()
        schedule.FrequencyType = ScheduleFrequencyType.Weekly
        schedule.FrequencyRecurrenceFactor = 1
        schedule.FrequencyInterval = Convert.ToInt32("0x001", 16)

        ' Set the value of Hostname that defines the data partition. 
        partition = New MergePartition()
        partition.DynamicFilterHostName = hostname
        snapshotAgentJob = New MergeDynamicSnapshotJob()
        snapshotAgentJob.DynamicFilterHostName = hostname

        ' Create the partition for the publication with the defined schedule.
        publication.AddMergePartition(partition)
        publication.AddMergeDynamicSnapshotJob(snapshotAgentJob, schedule)
    Else
        Throw New ApplicationException(String.Format( _
         "Settings could not be retrieved for the publication, " + _
         " or the initial snapshot has not been generated. " + _
         "Ensure that the publication {0} exists on {1} and " + _
         "that the Snapshot Agent has run successfully.", _
         publicationName, publisherName))
    End If
Catch ex As Exception
    ' Do error handling here.
    Throw New ApplicationException(String.Format( _
     "The partition for '{0}' in the {1} publication could not be created.", _
     hostname, publicationName), ex)
Finally
    publisherConn.Disconnect()
    If distributorConn.IsOpen Then
        distributorConn.Disconnect()
    End If
End Try

スレッド セーフ

この型の public static (Visual Basic では Shared) のメンバーはすべて、スレッド セーフです。インスタンス メンバーの場合は、スレッド セーフであるとは限りません。

関連項目

参照

Microsoft.SqlServer.Replication 名前空間

AddMergeDynamicSnapshotJob

ScriptMergeDynamicSnapshotJob

その他の技術情報

パラメーター化されたフィルターを使用してマージ パブリケーションのスナップショットを作成する方法 (RMO プログラミング)

パラメーター化されたフィルターを使用してマージ パブリケーションのパーティションを管理する方法 (RMO プログラミング)

パラメーター化されたフィルターを使用したマージ パブリケーションのスナップショット