MergeDynamicSnapshotJob Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Contient des informations sur le job Agent d'instantané qui génère l’instantané de données pour un abonnement à une publication de fusion avec un filtre de lignes paramétrés.
public ref class MergeDynamicSnapshotJob sealed
public sealed class MergeDynamicSnapshotJob
type MergeDynamicSnapshotJob = class
Public NotInheritable Class MergeDynamicSnapshotJob
- Héritage
-
MergeDynamicSnapshotJob
Exemples
// 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
Remarques
Cet espace de noms, cette classe ou ce membre est pris en charge uniquement dans la version 2.0 du Microsoft .NET Framework.
Sécurité des threads
Tout membre statique public (Shareddans Microsoft Visual Basic) de ce type est sûr pour les opérations multithreads. Il n'y a aucune garantie que les membres d’instance soient thread-safe.
Constructeurs
| Nom | Description |
|---|---|
| MergeDynamicSnapshotJob() |
Crée une instance de la classe MergeDynamicSnapshotJob. |
Propriétés
| Nom | Description |
|---|---|
| DynamicFilterHostName |
Obtient ou définit la valeur fournie à la fonction HOST_NAME (Transact-SQL) pour générer l’instantané de données, lorsque le filtre de lignes paramétré est défini à l’aide de cette fonction. |
| DynamicFilterLogin |
Obtient ou définit la valeur fournie à la fonction SUSER_SNAME (Transact-SQL) pour générer l’instantané de données, lorsque le filtre de lignes paramétrés est défini à l’aide de cette fonction. |
| DynamicSnapshotLocation |
Obtient ou définit le dossier du système d’exploitation utilisé pour stocker le snapshot filtré généré par ce travail Agent d'instantané. |
| JobId |
Obtient ou définit l’ID de job Microsoft SQL Server Agent, au format hexadécimal, qui génère l’instantané filtré pour l’abonné. |
| Name |
Obtient ou définit le nom du job Agent d'instantané qui génère le snapshot filtré pour l’abonné. |
| UserData |
Obtient ou définit un objet qui permet d’attacher des données personnalisées à cette instance de MergeDynamicSnapshotJob. |
S’applique à
Voir aussi
- AddMergeDynamicSnapshotJob(MergeDynamicSnapshotJob, ReplicationAgentSchedule)
- ScriptMergeDynamicSnapshotJob(MergeDynamicSnapshotJob, ReplicationAgentSchedule, ScriptOptions)
- SUSER_SNAME (Transact-SQL)
- Comment : Gérer les partitions pour une publication de fusion avec des filtres paramétrés (Programmation RMO)