Beispiel #1
0
        public override object Clone()
        {
            WeeklyCalendar clone = (WeeklyCalendar)base.Clone();

            bool[] excludeCopy = new bool[excludeDays.Length];
            Array.Copy(excludeDays, excludeCopy, excludeDays.Length);
            clone.excludeDays = excludeCopy;
            return(clone);
        }
Beispiel #2
0
        public bool Equals(WeeklyCalendar obj)
        {
            if (obj == null)
            {
                return(false);
            }
            bool baseEqual = GetBaseCalendar() == null || GetBaseCalendar().Equals(obj.GetBaseCalendar());

            return(baseEqual && (ArraysEqualElementsOnEqualPlaces(obj.DaysExcluded, DaysExcluded)));
        }
Beispiel #3
0
        public bool Equals(WeeklyCalendar obj)
        {
            if (obj == null)
            {
                return(false);
            }
            bool baseEqual = GetBaseCalendar() == null || GetBaseCalendar().Equals(obj.GetBaseCalendar());

            return(baseEqual && obj.DaysExcluded.SequenceEqual(DaysExcluded));
        }
Beispiel #4
0
        public override ICalendar Clone()
        {
            WeeklyCalendar clone = new WeeklyCalendar();

            CloneFields(clone);
            bool[] excludeCopy = new bool[excludeDays.Length];
            Array.Copy(excludeDays, excludeCopy, excludeDays.Length);
            clone.excludeDays = excludeCopy;
            return(clone);
        }
        /// <summary>
        /// Builds a <see cref="LocalWeeklyCalendar"/> based on the given allowed days of weeks.
        /// </summary>
        /// <param name="dayofWeekSpecs">The day of week specs.</param>
        /// <returns></returns>
        private ICalendar BuildCalendarOnDayOfWeek(ICalendar baseCalendar, string[] dayofWeekSpecs, TimeZoneInfo timeZone)
        {
            //create calendar and exclude all days
            WeeklyCalendar calendar = null;

            if (baseCalendar != null)
                calendar = new WeeklyCalendar(baseCalendar);
            else
                calendar = new WeeklyCalendar();

            calendar.DaysExcluded = new bool[7] { true, true, true, true, true, true, true };

            var dayOfWeeks = GrammarHelper.GetDayOfWeekValues(dayofWeekSpecs);

            foreach (var item in dayOfWeeks)
            {
                calendar.SetDayExcluded(item, false);
            }

            calendar.TimeZone = timeZone;
            return calendar;
        }
Beispiel #6
0
 static void InitializeWeekly(WeeklyCalendar weeklyCalendar, IWeeklyCalendar calendar) {
     weeklyCalendar.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(Persistent.Base.General.RegistryTimeZoneProvider.GetRegistryKeyNameByTimeZoneId(calendar.TimeZone));
     calendar.DaysOfWeekExcluded.ForEach(week => weeklyCalendar.SetDayExcluded(week, true));
     calendar.DaysOfWeekIncluded.ForEach(week => weeklyCalendar.SetDayExcluded(week, false));
 }
 public void Setup()
 {
     cal = new WeeklyCalendar();
     cal.TimeZone = TimeZoneInfo.Utc; //assume utc if not specified.
 }
Beispiel #8
0
        public bool Equals(WeeklyCalendar obj)
        {
            if (obj == null)
                return false;
            bool baseEqual = GetBaseCalendar() != null ?
                             GetBaseCalendar().Equals(obj.GetBaseCalendar()) : true;

            return baseEqual && (ArraysEqualElementsOnEqualPlaces(obj.DaysExcluded,DaysExcluded));
        }
        /// <summary>
        /// create a dummy calendar
        /// </summary>
        /// <param name="description">Description</param>
        /// <returns>ICalendar</returns>
        protected static ICalendar CreateCalendar(string description="week days only")
        {
            var calendar = new WeeklyCalendar();

            calendar.SetDayExcluded(DayOfWeek.Saturday, true);
            calendar.SetDayExcluded(DayOfWeek.Sunday,true);

            calendar.Description = description;

            return calendar;
        }
        /// <summary>
        /// Create a dummy Trigger
        /// </summary>
        /// <param name="name">Name</param>
        /// <param name="group">Group</param>
        /// <param name="jobKey">JobKey</param>
        /// <param name="cronExpression">unix cron expression</param>
        /// <param name="calendarName">unix cron expression</param>
        /// <returns>IOperableTrigger</returns>
        protected static IOperableTrigger CreateTrigger(string name, string group, JobKey jobKey, string cronExpression = "0 0 0 * * ?", string calendarName = "testCalendar")
        {
            var trigger =
                TriggerBuilder.Create()
                              .ForJob(jobKey)
                              .WithIdentity(name, group)
                              .WithSchedule(CronScheduleBuilder.CronSchedule(cronExpression))
                              .UsingJobData("testTrigger", "testTrigger")
                              .WithDescription("TriggerTesting")
                              .Build();

            var abstractTrigger = (AbstractTrigger)trigger;

            if (abstractTrigger != null)
            {
                var calendar = new WeeklyCalendar { DaysExcluded = null };
                abstractTrigger.ComputeFirstFireTimeUtc(calendar);
                abstractTrigger.CalendarName = calendarName;
            }

            return abstractTrigger ?? (IOperableTrigger)trigger;
        }
Beispiel #11
0
 public WeeklyCalendarDto(WeeklyCalendar calendar) : base(calendar)
 {
     DaysExcluded = calendar.DaysExcluded.ToList();
     TimeZone = new TimeZoneDto(calendar.TimeZone);
 }