Recurrence Class |
Namespace: HiTSoftware.DBMoto.Application
The Recurrence type exposes the following members.
| Name | Description | |
|---|---|---|
| RecurrenceType |
Returns the RecurrenceType of the recurrence.
| |
| TimeSchedules |
Returns the time schedules of the recurrence.
|
| Name | Description | |
|---|---|---|
| Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
| Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
| GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| ToString | Returns a string that represents the current object. (Inherited from Object.) |
| RecurrenceType | Recurrence 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 |
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(); } } } }