Click or drag to resize

Recurrence Class

Abstract class that handles a replication recurrence. A recurrence can be either a refresh recurrence (used to implement a recurrent refresh operation) or a mirroring recurrence (used to implement an interruption in the continuous mirroring process).
Inheritance Hierarchy

Namespace:  HiTSoftware.DBMoto.Application
Assembly:  APILibrary (in APILibrary.dll) Version: 7.0.0.0 (9.8.1.7)
Syntax
public abstract class Recurrence

The Recurrence type exposes the following members.

Properties
  NameDescription
Public propertyRecurrenceType
Returns the RecurrenceType of the recurrence.
Public propertyTimeSchedules
Returns the time schedules of the recurrence.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
This class is abstract and therefore it is not possible to directly create instances of the class. Use the Recurrence object referenced in the replication object or, if you need to create a new recurrence, instantiate one of the specific Recurrence subclasses defined for each recurrence type:
RecurrenceTypeRecurrence Class
RecurrenceType.Hourly Create an instance of the HourlyRecurrence class
RecurrenceType.Daily Create an instance of the DailyRecurrence class
RecurrenceType.Weekly Create an instance of the WeeklyRecurrence class
RecurrenceType.Monthly Create an instance of the MonthlyRecurrence class
RecurrenceType.Yearly Create an instance of the YearlyRecurrence class
Examples
using System;
using System.Collections.Generic;
using System.Text;
using HiTSoftware.DBMoto.Application;
using HiTSoftware.DBMoto.ObjectModel;

namespace APISamples
{
    /// <summary>
    /// This example shows how to add replication schedules programmatically
    /// </summary>
    public class SampleDefineSchedules
    {
        public static void Main()
        {
            DBMotoApplication dbmApp = null;
            IServer dbmServer = null;
            IMetadata currentMetadata = null;

            try
            {
                // Static singletone constructor
                dbmApp = DBMotoApplication.Instance;
                // Retrieving from the local server from the list available in the DBMotoApplication instance
                dbmServer = dbmApp.Servers["local"];
                // Connecting to the server agent using anonymous authentication
                dbmServer.Connect("admin", "admin", BindingProtocol.TcpBinding);
                // Define and load the current metadata
                currentMetadata = dbmServer.Metadatas.DefaultMetadata;
                currentMetadata.Load(true);

                IReplication repl = currentMetadata.Replications["EMPLOYEES"];
                repl.Schedules.Clear();
                currentMetadata.Replications.Save(repl, false);

                ISchedule scheduleRefresh1 = repl.Schedules.DefInstance(true);
                scheduleRefresh1.Recurrence = new WeeklyRecurrence(WeekDays.Mon | WeekDays.Fri, 3);
                scheduleRefresh1.Recurrence.TimeSchedules.Add(new TimeSchedule(new TimeSpan(10, 30, 0)));
                repl.Schedules.Add(scheduleRefresh1);

                ISchedule scheduleRefresh2 = repl.Schedules.DefInstance(true);
                scheduleRefresh2.Recurrence = new MonthlyRecurrence(new MonthDays(10), 3);
                scheduleRefresh2.Recurrence.TimeSchedules.Add(new TimeSchedule(new TimeSpan(12, 30, 0)));
                repl.Schedules.Add(scheduleRefresh2);

                ISchedule scheduleRefresh3 = repl.Schedules.DefInstance(true);
                scheduleRefresh3.Recurrence = new MonthlyRecurrence(WeekNumber.Second, WeekDays.Fri, 2);
                scheduleRefresh3.Recurrence.TimeSchedules.Add(new TimeSchedule(new TimeSpan(12, 30, 0)));
                repl.Schedules.Add(scheduleRefresh3);

                ISchedule scheduleMirror1 = repl.Schedules.DefInstance(false);
                scheduleMirror1.Recurrence = new DailyRecurrence(3);
                scheduleMirror1.Recurrence.TimeSchedules.Add(new TimeSchedule(new TimeSpan(10, 30, 0), new TimeSpan(2, 0, 0)));
                scheduleMirror1.Recurrence.TimeSchedules.Add(new TimeSchedule(new TimeSpan(18, 30, 0), new TimeSpan(2, 0, 0)));
                repl.Schedules.Add(scheduleMirror1);

                ISchedule scheduleMirror2 = repl.Schedules.DefInstance(false);
                scheduleMirror2.Recurrence = new YearlyRecurrence(Months.April, new MonthDays(15), 4);
                scheduleMirror2.Recurrence.TimeSchedules.Add(new TimeSchedule(new TimeSpan(0, 30, 0), new TimeSpan(4, 30, 30)));
                scheduleMirror2.Recurrence.TimeSchedules.Add(new TimeSchedule(new TimeSpan(12, 30, 0), new TimeSpan(4, 30, 30)));
                repl.Schedules.Add(scheduleMirror2);

                repl.UseRefreshSchedule = true;
                repl.UseMirroringSchedule = true;

                currentMetadata.Replications.Save(repl, false);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                if (currentMetadata != null)
                    currentMetadata.Unload();
                if (dbmServer != null)
                    dbmServer.Disconnect();
                if (dbmApp != null)
                    dbmApp.Dispose();
            }
        }
    }
}
See Also