當前位置: 首頁>>代碼示例>>C#>>正文


C# ScheduledEvents.Schedule類代碼示例

本文整理匯總了C#中ScheduleWidget.ScheduledEvents.Schedule的典型用法代碼示例。如果您正苦於以下問題:C# Schedule類的具體用法?C# Schedule怎麽用?C# Schedule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Schedule類屬於ScheduleWidget.ScheduledEvents命名空間,在下文中一共展示了Schedule類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SimpleScheduleIsOccurringTest2

 public void SimpleScheduleIsOccurringTest2()
 {
     var aEvent = CreateTodayEvent();
     var schedule = new Schedule(aEvent);
     Assert.IsNotNull(schedule);
     Assert.IsFalse(schedule.IsOccurring(DateTime.Today.AddDays(1)));
 }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:7,代碼來源:BasicTest.cs

示例2: Run

        public static void Run()
        {
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Running daily scenario 1 with a StartDateTime value of 12/1/2013");
            Console.WriteLine(Environment.NewLine);

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 1",
                Frequency = 1,        // daily
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 127,     // every day of week
                StartDateTime = new DateTime(2013, 12, 1)
            };

            var during = new DateRange()
            {
                StartDateTime = new DateTime(2013, 12, 1),
                EndDateTime = new DateTime(2013, 12, 31)
            };

            var schedule = new Schedule(aEvent);
            var dates = schedule.Occurrences(during);
            foreach (var date in dates)
            {
                Console.WriteLine(date.ToShortDateString());
            }

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Printed out all dates between {0} and {1}",
                during.StartDateTime.ToShortDateString(),
                during.EndDateTime.ToShortDateString());
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:34,代碼來源:DailyScenario1.cs

示例3: OneTimeOnlyTest2

        public void OneTimeOnlyTest2()
        {
            var laborDay = new DateTime(2012, 9, 1);

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Labor Day Extravaganza",
                Frequency = 0,        // one-time only
                OneTimeOnlyEventDate = laborDay,
                MonthlyInterval = 0,  // not applicable
                DaysOfWeek = 0        // not applicable
            };

            var schedule = new Schedule(aEvent);

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2012, 8, 1),
                EndDateTime = new DateTime(2012, 10, 1)
            };

            var occurrences = schedule.Occurrences(range);
            var count = 0;
            using (var items = occurrences.GetEnumerator())
            {
                while (items.MoveNext())
                    count++;
            }

            Assert.IsTrue(count > 0);
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:32,代碼來源:OneTimeOnlyTests.cs

示例4: WeeklyEventOnEveryMonWedFriTest

        public void WeeklyEventOnEveryMonWedFriTest()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Weekly on Monday, Wednesday, Friday",
                Frequency = 64,        // weekly on Monday, Wednesday, Friday
                DaysOfWeek = 42,      // every Mon, Wed and Fri
                StartDateTime = new DateTime(2013, 8, 2)
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 2)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 3)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 4)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 5)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 6)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 7)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 8)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2013, 8, 9)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 10)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 8, 11)));
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:31,代碼來源:WeeklyTests.cs

示例5: Run

        /// <summary>
        /// The canonical Critical Mass monthly bicycle ride
        /// </summary>
        public static void Run()
        {
            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Running monthly scenario 1.");
            Console.WriteLine(Environment.NewLine);

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Critical Mass",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                MonthlyIntervalOptions = MonthlyIntervalEnum.Last,
                DaysOfWeekOptions = DayOfWeekEnum.Fri
            };

            var during = new DateRange()
            {
                StartDateTime = new DateTime(2013, 12, 1),
                EndDateTime = new DateTime(2013, 12, 31)
            };

            var schedule = new Schedule(aEvent);
            var dates = schedule.Occurrences(during);
            foreach (var date in dates)
            {
                Console.WriteLine(date.ToShortDateString());
            }

            Console.WriteLine(Environment.NewLine);
            Console.WriteLine("Printed out all dates between {0} and {1}", 
                during.StartDateTime.ToShortDateString(), 
                during.EndDateTime.ToShortDateString());
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:36,代碼來源:MonthlyScenario1.cs

示例6: WeeklyEventFirstDayOfWeekMonday

        public void WeeklyEventFirstDayOfWeekMonday()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Every 2nd week. First day of week Monday",
                Frequency = 2,        // Weekly
                DaysOfWeek = 127,      // Every day
                RepeatInterval = 2,
                FirstDayOfWeek = Enums.DayOfWeekEnum.Mon,
                StartDateTime = new DateTime(2015, 1, 1)
            };

            var schedule = new Schedule(aEvent);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 1)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 2)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 3)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 4)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 5)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 6)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 7)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 8)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 9)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 10)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2015, 1, 11)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 1, 12)));
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:30,代碼來源:WeeklyTests.cs

示例7: MonthTest1

        public void MonthTest1()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 1",
                FrequencyTypeOptions = FrequencyTypeEnum.Monthly,
                MonthlyIntervalOptions = MonthlyIntervalEnum.EveryWeek,
                DaysOfWeekOptions = DayOfWeekEnum.Mon | DayOfWeekEnum.Fri
            };

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2013, 1, 15),
                EndDateTime = new DateTime(2013, 4, 30)
            };

            var occurringDate = new DateTime(2013, 1, 21);

            var schedule = new Schedule(aEvent);
            Assert.IsTrue(schedule.IsOccurring(occurringDate));

            var previousOccurrence = schedule.PreviousOccurrence(occurringDate, range);
            Assert.AreEqual(new DateTime(2013, 1, 18), previousOccurrence.Value);

            var nextOccurrence = schedule.NextOccurrence(occurringDate, range);
            Assert.AreEqual(new DateTime(2013, 1, 25), nextOccurrence.Value);

            var occurrences = schedule.Occurrences(range);

            Assert.AreEqual(30, occurrences.Count());
            Assert.AreEqual(new DateTime(2013, 1, 18), occurrences.First());
            Assert.AreEqual(new DateTime(2013, 4, 29), occurrences.Last());
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:34,代碼來源:MonthTests.cs

示例8: YearTest2

        public void YearTest2()
        {
            var aEvent = new Event()
            {
                ID = 1,
                Title = "Event 2",
                FrequencyTypeOptions = FrequencyTypeEnum.Yearly,
                Anniversary = new Anniversary()
                {
                    Month = 9,
                    Day = 27
                }
            };

            var schedule = new Schedule(aEvent);
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2014, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2015, 9, 27)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 9, 27)));

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2012, 1, 1),
                EndDateTime = new DateTime(2016, 12, 31)
            };

            var occurrences = schedule.Occurrences(range);

            Assert.AreEqual(5, occurrences.Count());
            Assert.AreEqual(new DateTime(2012, 9, 27), occurrences.First());
            Assert.AreEqual(new DateTime(2016, 9, 27), occurrences.Last());
        }
開發者ID:Rachitman,項目名稱:ScheduleWidget,代碼行數:31,代碼來源:YearTests.cs

示例9: SimpleScheduleIsOccurringTest1

 public void SimpleScheduleIsOccurringTest1()
 {
     var aEvent = CreateTodayEvent();
     var schedule = new Schedule(aEvent);
     Assert.IsNotNull(schedule);
     Assert.IsTrue(schedule.IsOccurring(DateTime.Today));
 }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:7,代碼來源:BasicTest.cs

示例10: AnniversaryTest2

        public void AnniversaryTest2()
        {
            var anniversary = new Anniversary()
            {
                Day = 5,
                Month = 6
            };

            var aEvent = new Event()
            {
                ID = 1,
                Title = "Give Flowers to Wife",
                Frequency = 16, // yearly
                Anniversary = anniversary
            };

            var schedule = new Schedule(aEvent);
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2009, 6, 4)));

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2010, 1, 1),
                EndDateTime = new DateTime(2020, 12, 31)
            };

            var occurrences = schedule.Occurrences(range).ToList();
            Assert.IsTrue(occurrences.Count.Equals(11));
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:28,代碼來源:AnniversaryTests.cs

示例11: FineGrainedRangeInYearNullEndDayTest

        public void FineGrainedRangeInYearNullEndDayTest()
        {
            var holidays = GetHolidays();
            var aEvent = CreateFineGrainedStreetCleaningEvent();

            // put up a null end day
            aEvent.RangeInYear.EndDayOfMonth = null;

            var schedule = new Schedule(aEvent, holidays);

            Assert.IsNotNull(holidays);
            Assert.IsNotNull(aEvent);
            Assert.IsNotNull(schedule);

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 6, 20)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 5, 16)));
            Assert.IsTrue(schedule.IsOccurring(new DateTime(2016, 6, 6)));

            Assert.IsTrue(schedule.IsOccurring(new DateTime(2018, 10, 15)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 11, 5)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 1, 1)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 2, 5)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2018, 3, 19)));

            Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 11, 1)));
            Assert.IsFalse(schedule.IsOccurring(new DateTime(2014, 12, 1)));
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:28,代碼來源:RangeEachYearTests.cs

示例12: EventOptionsPreviousOccurrenceTest

        public void EventOptionsPreviousOccurrenceTest()
        {
            var holidays = GetHolidays();
            var aEvent = CreateStreetCleaningEvent();
            var schedule = new Schedule(aEvent, holidays);

            Assert.IsNotNull(holidays);
            Assert.IsNotNull(aEvent);
            Assert.IsNotNull(schedule);

            var range = new DateRange()
            {
                StartDateTime = new DateTime(2016, 1, 1),
                EndDateTime = new DateTime(2016, 12, 31)
            };

            foreach (var item in schedule.Occurrences(range))
            {
                System.Diagnostics.Debug.WriteLine(item);
            }

            var prev = schedule.PreviousOccurrence(new DateTime(2016, 6, 6));
            Assert.IsTrue(prev.Equals(new DateTime(2016, 5, 16)));
            Assert.IsFalse(prev.Equals(new DateTime(2016, 6, 6)));
            Assert.IsFalse(prev.Equals(new DateTime(2016, 6, 20)));
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:26,代碼來源:EventOptionsTests.cs

示例13: GetSchedule

        private static ISchedule GetSchedule()
        {
            var schedule = new Schedule();
            var firstExpression = BuildStreetCleaningTemporalExpression();
            var firstScheduledEvent = new Event()
            {
                ID = 1,
                Title = "Street Cleaning",
                DateRange = new DateRange()
                {
                    StartDateTime = new DateTime(2011, 3, 1, 0, 0, 0),
                    EndDateTime = new DateTime(2011, 10, 30, 18, 0, 0)
                }
            };

            var secondExpression = BuildWitchingHourPrepTemporalExpression();
            var secondScheduledEvent = new Event()
            {
                ID = 2,
                Title = "Witching Hour Preparation",
                DateRange = new DateRange()
                {
                    StartDateTime = new DateTime(2012, 10, 1, 0, 0, 0),
                    EndDateTime = new DateTime(2012, 10, 31, 0, 0, 0)
                }
            };

            schedule.Add(firstScheduledEvent, firstExpression);
            schedule.Add(secondScheduledEvent, secondExpression);
            return schedule;
        }
開發者ID:hoopkjaz,項目名稱:ScheduleWidget,代碼行數:31,代碼來源:ScheduleDeserializationTests.cs

示例14: RecurringScheduleIsOccurringTest1

 public void RecurringScheduleIsOccurringTest1()
 {
     var aEvent = CreateRecurringEvent();
     var schedule = new Schedule(aEvent);
     Assert.IsNotNull(schedule);
     Assert.IsTrue(schedule.IsOccurring(new DateTime(2012, 10, 1)));
     Assert.IsFalse(schedule.IsOccurring(new DateTime(2013, 1, 18)));
 }
開發者ID:willemda,項目名稱:ScheduleWidget,代碼行數:8,代碼來源:BasicTest.cs

示例15: RecurringScheduleNextOccurrenceTest2

 public void RecurringScheduleNextOccurrenceTest2()
 {
     var aEvent = CreateRecurringEvent();
     var schedule = new Schedule(aEvent);
     Assert.IsNotNull(schedule);
     var nextOccurrence = schedule.NextOccurrence(new DateTime(2012, 12, 19));
     Assert.IsTrue(nextOccurrence == new DateTime(2013, 1, 2));
 }
開發者ID:willemda,項目名稱:ScheduleWidget,代碼行數:8,代碼來源:BasicTest.cs


注:本文中的ScheduleWidget.ScheduledEvents.Schedule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。