/// <summary> /// Adds a job to the timer to operate asyncronously. /// </summary> /// <param name="Schedule">The schedule that this delegate is to be run on.</param> /// <param name="f">The delegate to run</param> /// <param name="Params">The method parameters to pass if you leave any DateTime parameters unbound, then they will be set with the scheduled run time of the /// method. Any unbound object parameters will get this Job object passed in.</param> public void AddAsyncJob(IScheduledItem Schedule, Delegate f, params object[] Params) { TimerJob Event = new TimerJob(Schedule, new DelegateMethodCall(f, Params)); Event.SyncronizedEvent = false; _Jobs.Add(Event); }
public TimerJob(IScheduledItem schedule, IMethodCall method, string proFileName) { Schedule = schedule; Method = method; _ExecuteHandler = new ExecuteHandler(ExecuteInternal); ProfileName = proFileName; }
private void _UpdateItem(IScheduledItem item) { Func <IScheduledItem, IScheduledItemStateObject> newStatedObjectCreator; if (_IsItemAProgram(item)) { newStatedObjectCreator = ScheduledItemService.Instance.CreateProgramStateObject; } else { newStatedObjectCreator = ScheduledItemService.Instance.CreateSequenceStateObject; } IScheduledItemStateObject scheduledItemStateObject = _FindStateObject(item); IScheduledItemStateObject newScheduledItemStateObject = newStatedObjectCreator(item); if (scheduledItemStateObject == null || newScheduledItemStateObject == null) { return; } if (ScheduledItemService.Instance.ScheduledItemQualifiesForExecution(newScheduledItemStateObject)) { _ReplaceItem(scheduledItemStateObject, newScheduledItemStateObject); } else { _RemoveItem(scheduledItemStateObject); _AddItem(newScheduledItemStateObject); } }
public void AddAsyncTask(string key, IScheduledItem Schedule, Delegate f, params object[] Params) { Task task = new Task(Schedule, new DelegateMethodCall(f, Params)); task.SyncronizedEvent = false; this.container.Add(key, task); }
static List <Object> TestList(IScheduledItem item, DateTime dtStart, DateTime dtEnd) { var list = new List <Object>(); item.AddEventsInInterval(dtStart, dtEnd, list); return(list); }
private static ArrayList TestList(IScheduledItem item, DateTime Start, DateTime End) { ArrayList List = new ArrayList(); item.AddEventsInInterval(Start, End, List); return(List); }
public void Schedule(IScheduledItem item) { if (item == null) { return; } ScheduledItem scheduledItem = item as ScheduledItem; if (scheduledItem == null) { throw new NotSupportedException("Scheduled Item type is not supported by this scheduler"); } if (m_TransactionMode) { m_ScheduleTransactions.Add(scheduledItem); } else { if (m_ScheduledItems.Contains(scheduledItem)) { throw new ArgumentException(string.Concat("Cannot schedule function ", scheduledItem, " more than once")); } else { m_ScheduledItems.Add(scheduledItem); } } }
/// <summary> /// Add event is used in conjunction with the Elaspsed event handler. /// Set the Elapsed handler, add your schedule and call start. /// </summary> /// <param name="schedule">The schedule to fire the event at. Adding additional schedules will cause the event to fire whenever either schedule calls for it.</param> public void AddScheduleEvent(IScheduledItem schedule) { if (null == Elapsed) { throw new ArgumentNullException("schedule", "member variable is null."); } AddJob(new TimerJob(schedule, new DelegateMethodCall(Elapsed))); }
static void TestItem(IScheduledItem item, DateTime input, bool allowExact, DateTime dtExpectedOutput) { var dtResult = item.NextRunTime(input, allowExact); Console.WriteLine(dtResult == dtExpectedOutput ? "Success" : String.Format("Failure: Received: {0} Expected: {1}", dtResult, dtExpectedOutput)); }
public void AddReportEvent(IScheduledItem Schedule, int reportNo) { if (Elapsed == null) { throw new Exception("You must set elapsed before adding Events"); } AddJob(new TimerJob(Schedule, new DelegateMethodCall(Handler, Elapsed, reportNo), ProfileName)); }
public void AddReportEvent(IScheduledItem schedule, int reportNo) { if (null == Elapsed) { throw new Exception("You must set elapsed before adding Events"); } AddJob(new TimerJob(schedule, new DelegateMethodCall(Handler, Elapsed, reportNo))); }
public void AddEvent(string key, IScheduledItem Schedule) { if (this.Elapsed == null) { throw new ArgumentNullException("Elapsed", "member variable is null."); } base.AddTask(key, new Task(Schedule, new DelegateMethodCall(this.Elapsed))); }
public void UpdateProgram(IScheduledItem item) { if (item == null) { throw new ArgumentNullException("item"); } _UpdateItem(item); }
/// <summary> /// Adds a job to the timer to operate asyncronously. /// </summary> /// <param name="schedule">The schedule that this delegate is to be run on.</param> /// <param name="func">The delegate to run</param> /// <param name="parameters">The method parameters to pass if you leave any DateTime parameters unbound, then they will be set with the scheduled run time of the /// method. Any unbound object parameters will get this Job object passed in.</param> public void AddAsyncJob(IScheduledItem schedule, Delegate func, params object[] parameters) { var timerJob = new TimerJob(schedule, new DelegateMethodCall(func, parameters)) { IsSyncronized = false }; _CollJobs.Add(timerJob); }
/// <summary> /// Add event is used in conjunction with the Elaspsed event handler. Set the Elapsed handler, add your schedule and call start. /// </summary> /// <param name="Schedule">The schedule to fire the event at. Adding additional schedules will cause the event to fire whenever either schedule calls for it.</param> public void AddEvent(IScheduledItem Schedule) { if (Elapsed == null) { throw new ArgumentNullException("Elapsed", "member variable is null."); } AddJob(new TimerJob(Schedule, new DelegateMethodCall(Elapsed))); }
public void RemoveProgram(IScheduledItem item) { if (item == null) { throw new ArgumentNullException("item"); } _RemoveItem(_FindStateObject(item)); }
public static void Register(this ScheduleTimer timer, string key, IScheduledRule rule, Delegate @delegate, params object[] args) { IScheduledItem scheduledItem = SchedulerFactory.Provider(rule); if (scheduledItem == null) { return; } timer.AddAsyncTask(key, scheduledItem, @delegate, args); }
public void AddProgram(IScheduledItem item) { if (item == null) { throw new ArgumentNullException("item"); } IScheduledItemStateObject scheduledProgram = ScheduledItemService.Instance.CreateProgramStateObject(item); _AddItem(scheduledProgram); }
public void AddSequence(IScheduledItem item) { if (item == null) { throw new ArgumentNullException("item"); } IScheduledItemStateObject scheduledSequence = ScheduledItemService.Instance.CreateSequenceStateObject(item); _AddItem(scheduledSequence); }
public void AddAsyncReportEvent(IScheduledItem Schedule, int reportNo) { if (Elapsed == null) { throw new Exception("You must set elapsed before adding Events"); } TimerJob Event = new TimerJob(Schedule, new DelegateMethodCall(Handler, Elapsed, reportNo), ProfileName); Event.SyncronizedEvent = false; AddJob(Event); }
private void _AddItem(IScheduledItem item) { if (_IsItemAProgram(item)) { AddProgram(item); } else { AddSequence(item); } }
private void _AddScheduledItemToStateMachine(IScheduledItem scheduledItem) { if (scheduledItem.ItemFilePath.EndsWith(Program.Extension)) { _stateMachine.AddProgram(scheduledItem); } else { _stateMachine.AddSequence(scheduledItem); } // Otherwise don't add it. }
public void AddReportEvent(string key, IScheduledItem Schedule, int reportNo) { if (this.Elapsed == null) { throw new Exception("You must set elapsed before adding Events"); } base.AddTask(key, new Task(Schedule, new DelegateMethodCall(ReportTimer.Handler, new object[] { this.Elapsed, reportNo }))); }
public ScheduledSequence(IScheduledItem item) { if (item == null) { throw new ArgumentNullException("item"); } OriginatingItem = item; Start = ScheduledItemService.Instance.CalculateConcreteStartDateTime(item); End = ScheduledItemService.Instance.CalculateConcreteEndDateTime(item); }
public void AddAsyncReportEvent(IScheduledItem schedule, int reportNo) { if (null == Elapsed) { throw new Exception("You must set elapsed before adding Events"); } var Event = new TimerJob(schedule, new DelegateMethodCall(Handler, Elapsed, reportNo)) { IsSyncronized = false }; AddJob(Event); }
private static void TestItem(IScheduledItem item, DateTime input, bool AllowExact, DateTime ExpectedOutput) { DateTime Result = item.NextRunTime(input, AllowExact); if (Result == ExpectedOutput) { Console.WriteLine("Success"); } else { Console.WriteLine(string.Format("Failure: Received: {0} Expected: {1}", Result, ExpectedOutput)); } }
public static void Register(this ScheduleTimer timer, string key, IList <IScheduledRule> rules, Delegate @delegate, params object[] args) { EventQueue eventQueue = new EventQueue(); foreach (IScheduledRule current in rules) { IScheduledItem scheduledItem = SchedulerFactory.Provider(current); if (scheduledItem != null) { eventQueue.Add(scheduledItem); } } timer.AddAsyncTask(key, eventQueue, @delegate, args); }
private static IScheduledItem BaseRule(ScheduledRule rule) { if (rule == null) { return(null); } IScheduledItem result = null; try { string type; switch (type = rule.Rule.Type) { case "BySecond": case "ByMinute": case "Hourly": case "Daily": case "Weekly": case "Monthly": result = new ScheduledTime(rule.Rule.Type, rule.Rule.Offest); break; case "BySleep": if (rule.Count == 0 && (rule.End == DateTime.MaxValue || rule.End == DateTime.MinValue)) { result = new SimpleInterval(DateTime.Now, TimeSpan.Parse(rule.Rule.Offest)); } else { if (rule.Count > 0) { result = new SimpleInterval(DateTime.Now, TimeSpan.Parse(rule.Rule.Offest), rule.Count); } else { if (rule.End != DateTime.MaxValue) { result = new SimpleInterval(DateTime.Now, TimeSpan.Parse(rule.Rule.Offest), rule.End); } } } break; } } catch { } return(result); }
public void Unschedule(IScheduledItem item) { ScheduledItem scheduledItem = item as ScheduledItem; if (scheduledItem != null) { if (this.m_TransactionMode) { this.m_UnscheduleTransactions.Add(scheduledItem); } else if (!this.RemovedScheduledItemAt(this.m_ScheduledItems.IndexOf(scheduledItem))) { throw new ArgumentException("Cannot unschedule unknown scheduled function " + scheduledItem); } } }
public void Add(IScheduledItem time) { object obj; Monitor.Enter(obj = EventQueue.syncObject); try { if (time != null) { this.container.Add(time); } } finally { Monitor.Exit(obj); } }
public TimerJob(IScheduledItem schedule, IMethodCall method, string proFileName) { Schedule = schedule; Method = method; _ExecuteHandler = new ExecuteHandler(ExecuteInternal); ProfileName = proFileName; }
public void AddProgram(IScheduledItem item) { if(item == null) throw new ArgumentNullException("item"); IScheduledItemStateObject scheduledProgram = ScheduledItemService.Instance.CreateProgramStateObject(item); _AddItem(scheduledProgram); }
public void AddSequence(IScheduledItem item) { if(item == null) throw new ArgumentNullException("item"); IScheduledItemStateObject scheduledSequence = ScheduledItemService.Instance.CreateSequenceStateObject(item); _AddItem(scheduledSequence); }
/// <summary> /// Adds a job to the timer to operate asyncronously. /// </summary> /// <param name="schedule">The schedule that this delegate is to be run on.</param> /// <param name="func">The delegate to run</param> /// <param name="parameters">The method parameters to pass if you leave any DateTime parameters unbound, then they will be set with the scheduled run time of the /// method. Any unbound object parameters will get this Job object passed in.</param> public void AddAsyncJob(IScheduledItem schedule, Delegate func, params object[] parameters) { var timerJob = new TimerJob(schedule, new DelegateMethodCall(func, parameters)) { IsSyncronized = false }; _CollJobs.Add(timerJob); }
public void AddAsyncReportEvent(IScheduledItem Schedule, int reportNo) { if (Elapsed == null) throw new Exception("You must set elapsed before adding Events"); TimerJob Event = new TimerJob(Schedule, new DelegateMethodCall(Handler, Elapsed, reportNo)); Event.SyncronizedEvent = false; AddJob(Event); }
public ScheduledProgram(IScheduledItem item) { if(item == null) throw new ArgumentNullException("item"); OriginatingItem = item; Start = ScheduledItemService.Instance.CalculateConcreteStartDateTime(item); End = ScheduledItemService.Instance.CalculateConcreteEndDateTime(item); }
public void AddAsyncReportEvent(IScheduledItem schedule, int reportNo) { if (null == Elapsed) throw new Exception("You must set elapsed before adding Events"); var Event = new TimerJob(schedule, new DelegateMethodCall(Handler, Elapsed, reportNo)) { IsSyncronized = false }; AddJob(Event); }
private void _AddScheduledItemToStateMachine(IScheduledItem scheduledItem) { if (scheduledItem.ItemFilePath.EndsWith(Program.Extension)) { _stateMachine.AddProgram(scheduledItem); } else { _stateMachine.AddSequence(scheduledItem); } // Otherwise don't add it. }
/// <summary> /// Add event is used in conjunction with the Elaspsed event handler. Set the Elapsed handler, add your schedule and call start. /// </summary> /// <param name="Schedule">The schedule to fire the event at. Adding additional schedules will cause the event to fire whenever either schedule calls for it.</param> public void AddEvent(IScheduledItem Schedule) { if (Elapsed == null) throw new ArgumentNullException("Elapsed", "member variable is null."); AddJob(new TimerJob(Schedule, new DelegateMethodCall(Elapsed))); }
private void _AddScheduledItemToStateMachine(IScheduledItem scheduledItem) { if (SequenceTypeService.Instance.IsValidSequenceFileType(scheduledItem.ItemFilePath)) { _stateMachine.AddSequence(scheduledItem); } else if (scheduledItem.ItemFilePath.EndsWith(Program.Extension)) { _stateMachine.AddProgram(scheduledItem); } // Otherwise don't add it. }
/// <summary> /// Adds a job to the timer. This method passes in a delegate and the parameters similar to the Invoke method of windows forms. /// </summary> /// <param name="schedule">The schedule that this delegate is to be run on.</param> /// <param name="func">The delegate to run</param> /// <param name="parameters">The method parameters to pass if you leave any DateTime parameters unbound, then they will be set with the scheduled run time of the /// method. Any unbound object parameters will get this Job object passed in.</param> public void AddJob(IScheduledItem schedule, Delegate func, params object[] parameters) { _CollJobs.Add(new TimerJob(schedule, new DelegateMethodCall(func, parameters))); }
public IScheduledItem CreateScheduledItem(IScheduledItem scheduledItem) { return new ScheduledItem(scheduledItem.Id, scheduledItem.ItemFilePath, scheduledItem.DayOfWeek, scheduledItem.StartTime, scheduledItem.RunLength); }
public IScheduledItemStateObject CreateSequenceStateObject(IScheduledItem item) { return new ScheduledSequence(item); }
public void RemoveSequence(IScheduledItem item) { if(item == null) throw new ArgumentNullException("item"); _RemoveItem(_FindStateObject(item)); }
public TimerJob(IScheduledItem schedule, IMethodCall method) { Schedule = schedule; Method = method; _ExecuteHandler = ExecuteInternal; }
private void _UpdateItem(IScheduledItem item) { Func<IScheduledItem, IScheduledItemStateObject> newStatedObjectCreator; if(_IsItemAProgram(item)) { newStatedObjectCreator = ScheduledItemService.Instance.CreateProgramStateObject; } else { newStatedObjectCreator = ScheduledItemService.Instance.CreateSequenceStateObject; } IScheduledItemStateObject scheduledItemStateObject = _FindStateObject(item); IScheduledItemStateObject newScheduledItemStateObject = newStatedObjectCreator(item); if(scheduledItemStateObject == null || newScheduledItemStateObject == null) return; if(ScheduledItemService.Instance.ScheduledItemQualifiesForExecution(newScheduledItemStateObject)) { _ReplaceItem(scheduledItemStateObject, newScheduledItemStateObject); } else { _RemoveItem(scheduledItemStateObject); _AddItem(newScheduledItemStateObject); } }
public DateTime CalculateConcreteEndDateTime(IScheduledItem item) { return CalculateConcreteStartDateTime(item) + item.RunLength; }
public BlockWrapper(IScheduledItem item, string timeBase, string beginOffset, string endOffset) { _item = item; _begin = new ScheduledTime(timeBase, beginOffset); _end = new ScheduledTime(timeBase, endOffset); }
public void RegisterItem(IScheduledItem item) { RegisteredItems.Add(item); }
public BlockWrapper(IScheduledItem item, string StrBase, string BeginOffset, string EndOffset) { _Item = item; _Begin = new ScheduledTime(StrBase, BeginOffset); _End = new ScheduledTime(StrBase, EndOffset); }
public BlockFilter(IScheduledItem item, String eventTime, String offsetBegin, String offsetEnd) { _Item = item; _Begin = new ScheduledTime(eventTime, offsetBegin); _End = new ScheduledTime(eventTime, offsetEnd); }
private bool _IsItemAProgram(IScheduledItem item) { return item.ItemFilePath.EndsWith(Program.Extension); }
/// <summary> /// Adds a job to the timer to operate asyncronously. /// </summary> /// <param name="Schedule">The schedule that this delegate is to be run on.</param> /// <param name="f">The delegate to run</param> /// <param name="Params">The method parameters to pass if you leave any DateTime parameters unbound, then they will be set with the scheduled run time of the /// method. Any unbound object parameters will get this Job object passed in.</param> public void AddAsyncJob(IScheduledItem Schedule, Delegate f, params object[] Params) { TimerJob Event = new TimerJob(Schedule, new DelegateMethodCall(f, Params)); Event.SyncronizedEvent = false; _Jobs.Add(Event); }
public DateTime CalculateConcreteStartDateTime(IScheduledItem item) { return new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, (int)item.StartTime.TotalHours, item.StartTime.Minutes, item.StartTime.Seconds); }
/// <summary> /// Adds a job to the timer. This method passes in a delegate and the parameters similar to the Invoke method of windows forms. /// </summary> /// <param name="Schedule">The schedule that this delegate is to be run on.</param> /// <param name="f">The delegate to run</param> /// <param name="Params">The method parameters to pass if you leave any DateTime parameters unbound, then they will be set with the scheduled run time of the /// method. Any unbound object parameters will get this Job object passed in.</param> public void AddJob(IScheduledItem Schedule, Delegate f, params object[] Params) { _Jobs.Add(new TimerJob(Schedule, new DelegateMethodCall(f, Params))); }
public IScheduledItemStateObject CreateProgramStateObject(IScheduledItem item) { return new ScheduledProgram(item); }
public EventInstance(DateTime time, IScheduledItem scheduleItem, object data) { Time = time; ScheduleItem = scheduleItem; Data = data; }
public void AddReportEvent(IScheduledItem schedule, int reportNo) { if (null == Elapsed) throw new Exception("You must set elapsed before adding Events"); AddJob(new TimerJob(schedule, new DelegateMethodCall(Handler, Elapsed, reportNo))); }
/// <summary> /// Adds a ScheduledTime to the queue. /// </summary> /// <param name="time">The scheduled time to add</param> public void Add(IScheduledItem time) { _List.Add(time); }
public EventComparable(DateTime datetime, IScheduledItem scheduleItem, Object data) { DateTime = datetime; ScheduleItem = scheduleItem; Data = data; }