Export (0) Print
Expand All

ReplicationAgentSchedule Class

 

Applies To: SQL Server 2016 Preview

Represents the schedule for a replication agent job.

Namespace:   Microsoft.SqlServer.Replication
Assembly:  Microsoft.SqlServer.Rmo (in Microsoft.SqlServer.Rmo.dll)

System.Object
  Microsoft.SqlServer.Replication.ReplicationAgentSchedule

public sealed class ReplicationAgentSchedule

NameDescription
System_CAPS_pubmethodReplicationAgentSchedule()

Creates a new instance of the ReplicationAgentSchedule class.

NameDescription
System_CAPS_pubpropertyActiveEndDate

Gets or sets the date the scheduled activity is to stop running.

System_CAPS_pubpropertyActiveEndTime

Gets or sets the time the scheduled activity is to stop running.

System_CAPS_pubpropertyActiveStartDate

Gets or sets the date of the first occurrence of the scheduled activity.

System_CAPS_pubpropertyActiveStartTime

Gets or sets the time of the first occurrence of the scheduled activity.

System_CAPS_pubpropertyFrequencyInterval

Gets or sets the interval between occurrences of a scheduled activity.

System_CAPS_pubpropertyFrequencyRecurrenceFactor

Gets or sets the frequency recurrence factor.

System_CAPS_pubpropertyFrequencyRelativeInterval

Gets or sets a time of occurrence that is relative to the first day of the month.

System_CAPS_pubpropertyFrequencySubDay

Gets or sets the frequency in minutes for scheduled activities that occur several times a day.

System_CAPS_pubpropertyFrequencySubDayInterval

Gets or sets the interval between scheduled activities that occur several times in one day.

System_CAPS_pubpropertyFrequencyType

Gets or sets the frequency for a scheduled activity.

NameDescription
System_CAPS_pubmethodEquals(Object)

(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Object.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

System_CAPS_pubmethodUpdate()

Updates an existing schedule on the server.

This namespace, class, or member is supported only in version 2.0 of the .NET Framework.

Any public static (Shared in Microsoft Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Legacy Code Example

			// 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();
			}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft