Example #1
0
        public bool ShouldTrigger(RFInterval interval)
        {
            var shouldTrigger = Schedules.Any(s => s.ShouldTrigger(interval));
            var isAllowed     = Range == null || Range.InRange(interval);

            return(IsEnabled && shouldTrigger && isAllowed);
        }
Example #2
0
        protected override void Run()
        {
            var prevNow = DateTime.Now;

            if (_intervalLength > 1000)
            {
                // if interval is longer than a second, align ticks to next full minute
                var secondsToAlign = 60 - prevNow.TimeOfDay.Seconds;
                for (int n = 0; n < secondsToAlign && !IsExiting(); ++n)
                {
                    Thread.Sleep(1000);
                }
            }
            while (!IsExiting())
            {
                if (!_isSuspended)
                {
                    var now      = DateTime.Now;
                    var interval = new RFInterval(prevNow, now);
                    if (!IsDowntime(interval))
                    {
                        _eventManager.RaiseEvent(this, new RFIntervalEvent(interval), null);
                        prevNow = now;
                    }
                }

                // sleep one second max at a time
                for (int n = 0; n < _intervalLength / 1000 && !IsExiting(); ++n)
                {
                    Thread.Sleep(1000);
                }
            }
        }
        public virtual bool ShouldTrigger(RFInterval interval)
        {
            var stInterval  = ConvertToScheduleZone(interval);
            var nextTrigger = GetNextTrigger(stInterval.IntervalStart);

            return(stInterval.Includes(nextTrigger));
        }
        protected override bool InternalInRange(RFInterval interval)
        {
            var isAllowed  = (AllowRanges.Count == 0 || AllowRanges.Any(r => r.InRange(interval)));
            var isDenied   = (DenyRanges.Count > 0 && DenyRanges.Any(r => r.InRange(interval)));
            var isExplicit = (ExplicitRanges.Count == 0 || ExplicitRanges.All(r => r.InRange(interval)));

            return(isAllowed && !isDenied && isExplicit);
        }
        protected override bool InternalInRange(RFInterval interval)
        {
            var refDate     = interval.IntervalEnd.Date;
            var windowStart = refDate;
            var windowEnd   = refDate;
            var window      = new RFInterval(windowStart.Add(WindowStart), windowEnd.Add(WindowEnd));

            return(window.Includes(interval.IntervalStart) && window.Includes(interval.IntervalEnd));
        }
 public bool InRange(RFInterval interval)
 {
     if (IsEnabled)
     {
         var stInterval = ConvertToScheduleZone(interval);
         return(InternalInRange(stInterval));
     }
     return(false);
 }
Example #7
0
 protected RFInterval ConvertToScheduleZone(RFInterval interval)
 {
     if (!string.IsNullOrWhiteSpace(TimeZone))
     {
         var stIntervalStart = ConvertToScheduleZone(interval.IntervalStart);
         var stIntervalEnd   = ConvertToScheduleZone(interval.IntervalEnd);
         return(new RFInterval(stIntervalStart, stIntervalEnd));
     }
     return(interval);
 }
        protected override bool InternalInRange(RFInterval interval)
        {
            var today = new RFDate(interval.IntervalEnd.Date);

            if (CalendarDay.HasValue && today.OffsetDays(CalendarDay.Value - 1) != today.LastCalendarDayOfTheMonth())
            {
                return(false);
            }
            if (WeekDay.HasValue && today.OffsetWeekdays(WeekDay.Value - 1) != today.LastWorkdayOfTheMonth())
            {
                return(false);
            }
            return(true);
        }
        protected override bool InternalInRange(RFInterval interval)
        {
            var intervalDay = interval.IntervalEnd.Day;

            if (CalendarDay.HasValue && intervalDay != CalendarDay.Value)
            {
                return(false);
            }
            if (WeekDay.HasValue && new RFDate(interval.IntervalEnd.Date).FirstDayOfTheMonth().OffsetWeekdays(WeekDay.Value - 1).Day != intervalDay)
            {
                return(false);
            }
            return(true);
        }
Example #10
0
        public override void Start()
        {
            _context.SystemLog.Debug(this, "Scheduler Service starting");
            while (!IsExiting())
            {
                Thread.Sleep(1000 - DateTime.Now.Millisecond);

                if (IsExiting())
                {
                    return;
                }

                var now      = DateTime.Now;
                var interval = new RFInterval(_lastTrigger, now);
                lock (_sync)
                {
                    foreach (var config in _configs)
                    {
                        if (config.ShouldTrigger(interval))
                        {
                            var key = config.TriggerKey;
                            if (config.GraphInstance != null)
                            {
                                key = key.CreateForInstance(config.GraphInstance(interval));
                                _context.SaveEntry(RFDocument.Create(key, new RFGraphProcessorTrigger {
                                    TriggerStatus = true, TriggerTime = interval.IntervalEnd
                                }));
                            }
                            else
                            {
                                _context.SaveEntry(RFDocument.Create(key, new RFScheduleTrigger {
                                    LastTriggerTime = interval.IntervalEnd
                                }));
                            }
                        }
                    }
                    _lastTrigger = now;
                }
            }
        }
 public override bool ShouldTrigger(RFInterval interval)
 {
     return(DailySchedules.Any(d => d.ShouldTrigger(interval)) || IntervalSchedules.Any(d => d.ShouldTrigger(interval)));
 }
        protected override bool InternalInRange(RFInterval interval)
        {
            var intervalDay = interval.IntervalEnd.DayOfWeek;

            return(DaysOfWeek.Contains(intervalDay));
        }
 protected abstract bool InternalInRange(RFInterval interval);
Example #14
0
 public RFIntervalEvent(RFInterval interval)
 {
     Interval = interval;
 }
 protected override bool InternalInRange(RFInterval interval)
 {
     return(!Range.InRange(interval));
 }
 public RFEngineProcessorIntervalParam(RFInterval interval)
 {
     Interval = interval;
 }
Example #17
0
 public RFIntervalInstruction(string processName, RFIntervalEvent e) : base(processName)
 {
     Interval = e.Interval;
 }
Example #18
0
 private bool IsDowntime(RFInterval interval)
 {
     return(_downtime?.InRange(interval) ?? false);
 }