ReplicationAgentSchedule Klasse
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Repräsentiert den Zeitplan für einen Replikationsagentenjob.
public ref class ReplicationAgentSchedule sealed
public sealed class ReplicationAgentSchedule
type ReplicationAgentSchedule = class
Public NotInheritable Class ReplicationAgentSchedule
- Vererbung
-
ReplicationAgentSchedule
Beispiele
// 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
Hinweise
Dieser Namespace, diese Klasse oder dieses Mitglied wird nur in Version 2.0 des .NET Frameworks unterstützt.
Threadsicherheit
Alle öffentlichen statischen (Shared in Microsoft Visual Basic) Mitglieder dieses Typs sind für Multithread-Operationen sicher. Instanzenmitglieder sind nicht garantiert threadsicher.
Konstruktoren
| Name | Beschreibung |
|---|---|
| ReplicationAgentSchedule() |
Erstellt eine neue Instanz der ReplicationAgentSchedule Klasse. |
Eigenschaften
| Name | Beschreibung |
|---|---|
| ActiveEndDate |
Bekommt oder legt das Datum fest, an dem die geplante Aktivität aufhören soll. |
| ActiveEndTime |
Bekommt oder legt die Zeit fest, zu der die geplante Aktivität aufhören soll. |
| ActiveStartDate |
Erhält oder legt das Datum des ersten Auftretens der geplanten Aktivität fest. |
| ActiveStartTime |
Erhält oder setzt die Zeit für das erste Auftreten der geplanten Aktivität. |
| FrequencyInterval |
Erhält oder setzt das Intervall zwischen den Ereignissen einer geplanten Aktivität. |
| FrequencyRecurrenceFactor |
Erhält oder setzt den Frequenzrekurrenzfaktor. |
| FrequencyRelativeInterval |
Erhält oder setzt eine Ereigniszeit, die relativ zum ersten Tag des Monats ist. |
| FrequencySubDay |
Erhält oder stellt die Frequenz in Minuten für geplante Aktivitäten ein, die mehrmals täglich stattfinden. |
| FrequencySubDayInterval |
Bekommt oder legt das Intervall zwischen geplanten Aktivitäten fest, die mehrmals an einem Tag stattfinden. |
| FrequencyType |
Bekommt oder stellt die Frequenz für eine geplante Aktivität fest. |
Methoden
| Name | Beschreibung |
|---|---|
| Update() |
Aktualisiert einen bestehenden Zeitplan auf dem Server. |