本文整理汇总了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)));
}
示例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());
}
示例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);
}
示例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)));
}
示例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());
}
示例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)));
}
示例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());
}
示例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());
}
示例9: SimpleScheduleIsOccurringTest1
public void SimpleScheduleIsOccurringTest1()
{
var aEvent = CreateTodayEvent();
var schedule = new Schedule(aEvent);
Assert.IsNotNull(schedule);
Assert.IsTrue(schedule.IsOccurring(DateTime.Today));
}
示例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));
}
示例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)));
}
示例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)));
}
示例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;
}
示例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)));
}
示例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));
}