本文整理汇总了C#中RecurrencePattern类的典型用法代码示例。如果您正苦于以下问题:C# RecurrencePattern类的具体用法?C# RecurrencePattern怎么用?C# RecurrencePattern使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RecurrencePattern类属于命名空间,在下文中一共展示了RecurrencePattern类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PopulateiCalTimeZoneInfo
static private void PopulateiCalTimeZoneInfo(ITimeZoneInfo tzi, System.TimeZoneInfo.TransitionTime transition, int year)
{
Calendar c = CultureInfo.CurrentCulture.Calendar;
RecurrencePattern recurrence = new RecurrencePattern();
recurrence.Frequency = FrequencyType.Yearly;
recurrence.ByMonth.Add(transition.Month);
recurrence.ByHour.Add(transition.TimeOfDay.Hour);
recurrence.ByMinute.Add(transition.TimeOfDay.Minute);
if (transition.IsFixedDateRule)
{
recurrence.ByMonthDay.Add(transition.Day);
}
else
{
recurrence.ByDay.Add(new WeekDay(transition.DayOfWeek));
int daysInMonth = c.GetDaysInMonth(year, transition.Month);
int offset = (transition.Week * 7) - 7;
if (offset + 7 > daysInMonth)
offset = daysInMonth - 7;
// Add the possible days of the month this could occur.
for (int i = 1; i <= 7; i++)
recurrence.ByMonthDay.Add(i + offset + (int)transition.DayOfWeek);
}
tzi.RecurrenceRules.Add(recurrence);
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:29,代码来源:iCalTimeZone.cs
示例2: IsOccurrenceInRange
public static bool IsOccurrenceInRange(string valueToParse, DateTime start, DateTime end)
{
RecurrencePattern pattern = new RecurrencePattern();
if (RecurrencePatternHelper.TryParseRecurrencePattern(valueToParse, out pattern))
{
return pattern.GetOccurrences(start, start, end).Count() > 0;
}
return false;
}
开发者ID:Motaz-Al-Zoubi,项目名称:xaml-sdk,代码行数:10,代码来源:Helper.cs
示例3: ProcessRecurrencePattern
private IRecurrencePattern ProcessRecurrencePattern(IDateTime referenceDate)
{
RecurrencePattern r = new RecurrencePattern();
r.CopyFrom(Pattern);
// Convert the UNTIL value to one that matches the same time information as the reference date
if (r.Until != DateTime.MinValue)
r.Until = DateUtil.MatchTimeZone(referenceDate, new iCalDateTime(r.Until)).Value;
if (r.Frequency > FrequencyType.Secondly &&
r.BySecond.Count == 0 &&
referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
r.BySecond.Add(referenceDate.Second);
if (r.Frequency > FrequencyType.Minutely &&
r.ByMinute.Count == 0 &&
referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
r.ByMinute.Add(referenceDate.Minute);
if (r.Frequency > FrequencyType.Hourly &&
r.ByHour.Count == 0 &&
referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
r.ByHour.Add(referenceDate.Hour);
// If BYDAY, BYYEARDAY, or BYWEEKNO is specified, then
// we don't default BYDAY, BYMONTH or BYMONTHDAY
if (r.ByDay.Count == 0 &&
r.ByYearDay.Count == 0 &&
r.ByWeekNo.Count == 0)
{
// If the frequency is weekly, and
// no day of week is specified, use
// the original date's day of week.
// NOTE: fixes WeeklyCount1() and WeeklyUntil1() handling
if (r.Frequency == FrequencyType.Weekly)
r.ByDay.Add(new WeekDay(referenceDate.DayOfWeek));
// If BYMONTHDAY is not specified,
// default to the current day of month
// NOTE: fixes YearlyByMonth1() handling, added BYYEARDAY exclusion
// to fix YearlyCountByYearDay1() handling
if (r.Frequency > FrequencyType.Weekly &&
r.ByMonthDay.Count == 0)
r.ByMonthDay.Add(referenceDate.Day);
// If BYMONTH is not specified, default to
// the current month.
// NOTE: fixes YearlyCountByYearDay1() handling
if (r.Frequency > FrequencyType.Monthly &&
r.ByMonth.Count == 0)
r.ByMonth.Add(referenceDate.Month);
}
return r;
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:53,代码来源:RecurrencePatternEvaluator.cs
示例4: Create
public ActionResult Create(GroupInstance groupinstance)
{
if (ModelState.IsValid)
{
//default recurrence once a week forever
RecurrencePattern rp = new RecurrencePattern(FrequencyType.Weekly);
groupinstance.RecurrenceRule = "RRULE:" + rp.ToString();
db.GroupInstances.Add(groupinstance);
db.SaveChanges();
return Content(Boolean.TrueString);
}
//TODO: review error handling. This will fail since it is not filtering dropdowns for overlapping events!!!
ViewBag.GroupId = new SelectList(db.Groups, "GroupId", "Name", groupinstance.GroupId);
ViewBag.ClassroomId = new SelectList(db.Classrooms, "ClassroomID", "Name", groupinstance.ClassroomId);
return Content("Please review your form");
}
开发者ID:raskarov,项目名称:SchoolApp,代码行数:16,代码来源:GroupInstanceController.cs
示例5: Example
// From: http://sourcefield.blogspot.com/2011/06/dday-ical-example.html
public void Example()
{
// #1: Monthly meetings that occur on the last Wednesday from 6pm - 7pm
// Create an iCalendar
var iCal = new iCalendar();
// Create the event
var evt = iCal.Create<Event>();
evt.Summary = "Test Event";
evt.Start = new iCalDateTime(2008, 1, 1, 18, 0, 0); // Starts January 1, 2008 @ 6:00 P.M.
evt.Duration = TimeSpan.FromHours(1);
// Add a recurrence pattern to the event
var rp = new RecurrencePattern {Frequency = FrequencyType.Monthly};
rp.ByDay.Add(new WeekDay(DayOfWeek.Wednesday, FrequencyOccurrence.Last));
evt.RecurrenceRules.Add(rp);
// #2: Yearly events like holidays that occur on the same day each year.
// The same as #1, except:
var rp2 = new RecurrencePattern {Frequency = FrequencyType.Yearly};
evt.RecurrenceRules.Add(rp2);
// #3: Yearly events like holidays that occur on a specific day like the first monday.
// The same as #1, except:
var rp3 = new RecurrencePattern {Frequency = FrequencyType.Yearly};
rp3.ByMonth.Add(3);
rp3.ByDay.Add(new WeekDay(DayOfWeek.Monday, FrequencyOccurrence.First));
evt.RecurrenceRules.Add(rp3);
/*
Note that all events occur on their start time, no matter their
recurrence pattern. So, for example, you could occur on the first Monday
of every month, but if your event is scheduled for a Friday (i.e.
evt.Start = new iCalDateTime(2008, 3, 7, 18, 0, 0)), then it will first
occur on that Friday, and then the first Monday of every month after
that.
this can be worked around by doing this:
IPeriod nextOccurrence = pattern.GetNextOccurrence(dt);
evt.Start = nextOccurrence.StartTime;
*/
}
开发者ID:bernardwolff,项目名称:DDayiCalRecurrence,代码行数:44,代码来源:Recurrence.cs
示例6: RecurrenceForm
public RecurrenceForm(RecurrencePattern pattern, RecurrenceRange range)
{
InitializeComponent();
StringBuilder dow = new StringBuilder();
int n = dgRecurrencePattern.Rows.Add();
dgRecurrencePattern.Rows[n].Cells[0].Value = pattern.Type;
dgRecurrencePattern.Rows[n].Cells[1].Value = pattern.Interval;
dgRecurrencePattern.Rows[n].Cells[2].Value = pattern.DayOfMonth;
dgRecurrencePattern.Rows[n].Cells[3].Value = pattern.Month;
foreach (var item in pattern.DaysOfWeek)
{
dow.Append(item + "-");
}
dgRecurrencePattern.Rows[n].Cells[4].Value = dow;
dgRecurrencePattern.Rows[n].Cells[5].Value = pattern.FirstDayOfWeek;
dgRecurrencePattern.Rows[n].Cells[6].Value = pattern.Index;
int x = dgRecurrenceRange.Rows.Add();
dgRecurrenceRange.Rows[n].Cells[0].Value = range.Type;
dgRecurrenceRange.Rows[n].Cells[1].Value = range.StartDate;
dgRecurrenceRange.Rows[n].Cells[2].Value = range.EndDate;
dgRecurrenceRange.Rows[n].Cells[3].Value = range.NumberOfOccurrences;
dgRecurrenceRange.Rows[n].Cells[4].Value = range.RecurrenceTimeZone;
}
开发者ID:desjarlais,项目名称:restfuloutlook,代码行数:24,代码来源:RecurrenceForm.cs
示例7: TickRRule
public TickRRule(string iCalString)
{
if (iCalString.Contains(TT_COMPLETED_COUNT_KEY))
{
//CompletedRepeatCount = RepeatUtils.GetIntFromRRule(TT_COMPLETED_COUNT_KEY, iCalString);
//iCalString = RepeatUtils.RemoveKeyValueFromRRule(TT_COMPLETED_COUNT_KEY, iCalString);
}
String iCal;
if (iCalString.Contains(LUNAR_RRULE_NAME))
{
iCal = iCalString.Replace(LUNAR_RRULE_NAME, RRULE_NAME);
IsLunar = true;
}
else
{
iCal = iCalString;
IsLunar = false;
}
//rRule = new RRule(iCal);
//RecurringComponent = new DDay.iCal.RecurringComponent();
RRule = new RecurrencePattern();
//RRule = new RecurrencePattern(iCal);
//RecurringComponent.RecurrenceRules.Add(RRule);
}
开发者ID:fqncom,项目名称:tomcraporigami,代码行数:24,代码来源:TickRRule.cs
示例8: PopulateiCalTimeZoneInfo
static private void PopulateiCalTimeZoneInfo(ITimeZoneInfo tzi, System.TimeZoneInfo.TransitionTime transition, int year)
{
Calendar c = CultureInfo.CurrentCulture.Calendar;
RecurrencePattern recurrence = new RecurrencePattern();
recurrence.Frequency = FrequencyType.Yearly;
recurrence.ByMonth.Add(transition.Month);
recurrence.ByHour.Add(transition.TimeOfDay.Hour);
recurrence.ByMinute.Add(transition.TimeOfDay.Minute);
if (transition.IsFixedDateRule)
{
recurrence.ByMonthDay.Add(transition.Day);
}
else
{
if( transition.Week != 5 )
recurrence.ByDay.Add(new WeekDay(transition.DayOfWeek, transition.Week ));
else
recurrence.ByDay.Add( new WeekDay( transition.DayOfWeek, -1 ) );
}
tzi.RecurrenceRules.Add(recurrence);
}
开发者ID:alexed1,项目名称:dtrack,代码行数:24,代码来源:iCalTimeZone.cs
示例9: ConvertToRecurrencePattern
public override RecurrencePattern ConvertToRecurrencePattern()
{
RecurrencePattern pattern = new RecurrencePattern();
pattern.Frequency = RecurrenceFrequency.Yearly;
pattern.DayOrdinal = DayOfWeekIndexConverter.ConvertToDayOrdinal(DayOfWeekIndex);
pattern.DaysOfWeekMask = DaysOfWeekStringConverter.ConvertToRecurrenceDay(DaysOfWeek);
pattern.Month = (RecurrenceMonth) Enum.Parse(typeof(RecurrenceMonth), Month.ToString());
return pattern;
}
开发者ID:angelpetrov90,项目名称:aspnet-sdk,代码行数:9,代码来源:EWSProxies.Extensions.cs
示例10: CountToUntilReplace
/// <summary>
/// Counts to until replace. For recurrence pattern
/// </summary>
/// <param name="dtStart">The dt start.</param>
/// <param name="until">The until.</param>
/// <param name="rpattern">The rpattern.</param>
private static void CountToUntilReplace(iCalDateTime dtStart, iCalDateTime until, RecurrencePattern pattern)
{
//COUNT is specified
if (pattern.Count > 0)
{
List<iCalDateTime> occurs = pattern.Evaluate(dtStart, dtStart, until);
if (occurs.Count != 0 && occurs[occurs.Count - 1] >= until)
{
//Remove COUNT
pattern.Count = int.MinValue;
pattern.Until = until;
}
}
else
{
pattern.Until = until;
}
}
开发者ID:0anion0,项目名称:IBN,代码行数:24,代码来源:McEvent.cs
示例11: Test2
public void Test2()
{
IICalendar iCal = new iCalendar();
IEvent evt = iCal.Create<Event>();
evt.Summary = "Event summary";
evt.Start = new iCalDateTime(DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc));
IRecurrencePattern recur = new RecurrencePattern();
recur.Frequency = FrequencyType.Daily;
recur.Count = 3;
recur.ByDay.Add(new WeekDay(DayOfWeek.Monday));
recur.ByDay.Add(new WeekDay(DayOfWeek.Wednesday));
recur.ByDay.Add(new WeekDay(DayOfWeek.Friday));
evt.RecurrenceRules.Add(recur);
RecurrencePatternSerializer serializer = new RecurrencePatternSerializer();
Assert.IsTrue(string.Compare(serializer.SerializeToString(recur), "FREQ=DAILY;COUNT=3;BYDAY=MO,WE,FR") == 0,
"Serialized recurrence string is incorrect");
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:19,代码来源:RecurrenceTest.cs
示例12: Test4
public void Test4()
{
IRecurrencePattern rpattern = new RecurrencePattern();
rpattern.ByDay.Add(new WeekDay(DayOfWeek.Saturday));
rpattern.ByDay.Add(new WeekDay(DayOfWeek.Sunday));
rpattern.Frequency = FrequencyType.Weekly;
IDateTime evtStart = new iCalDateTime(2006, 12, 1);
IDateTime evtEnd = new iCalDateTime(2007, 1, 1);
IEvaluator evaluator = rpattern.GetService(typeof(IEvaluator)) as IEvaluator;
Assert.IsNotNull(evaluator);
// Add the exception dates
IList<IPeriod> periods = evaluator.Evaluate(
evtStart,
DateUtil.GetSimpleDateTimeData(evtStart),
DateUtil.SimpleDateTimeToMatch(evtEnd, evtStart),
false);
Assert.AreEqual(10, periods.Count);
Assert.AreEqual(2, periods[0].StartTime.Day);
Assert.AreEqual(3, periods[1].StartTime.Day);
Assert.AreEqual(9, periods[2].StartTime.Day);
Assert.AreEqual(10, periods[3].StartTime.Day);
Assert.AreEqual(16, periods[4].StartTime.Day);
Assert.AreEqual(17, periods[5].StartTime.Day);
Assert.AreEqual(23, periods[6].StartTime.Day);
Assert.AreEqual(24, periods[7].StartTime.Day);
Assert.AreEqual(30, periods[8].StartTime.Day);
Assert.AreEqual(31, periods[9].StartTime.Day);
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:32,代码来源:RecurrenceTest.cs
示例13: RecurrencePattern2
public void RecurrencePattern2()
{
// NOTE: evaluators are generally not meant to be used directly like this.
// However, this does make a good test to ensure they behave as they should.
RecurrencePattern pattern = new RecurrencePattern("FREQ=MINUTELY;INTERVAL=1");
CultureInfo us = CultureInfo.CreateSpecificCulture("en-US");
iCalDateTime startDate = new iCalDateTime(DateTime.Parse("3/31/2008 12:00:10 AM", us));
iCalDateTime fromDate = new iCalDateTime(DateTime.Parse("4/1/2008 10:08:10 AM", us));
iCalDateTime toDate = new iCalDateTime(DateTime.Parse("4/1/2008 10:43:23 AM", us));
IEvaluator evaluator = pattern.GetService(typeof(IEvaluator)) as IEvaluator;
Assert.IsNotNull(evaluator);
IList<IPeriod> occurrences = evaluator.Evaluate(
startDate,
DateUtil.SimpleDateTimeToMatch(fromDate, startDate),
DateUtil.SimpleDateTimeToMatch(toDate, startDate),
false);
Assert.AreNotEqual(0, occurrences.Count);
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:22,代码来源:RecurrenceTest.cs
示例14: Test1
public void Test1()
{
IICalendar iCal = new iCalendar();
IEvent evt = iCal.Create<Event>();
evt.Summary = "Event summary";
evt.Start = new iCalDateTime(DateTime.SpecifyKind(DateTime.Today, DateTimeKind.Utc));
IRecurrencePattern recur = new RecurrencePattern();
evt.RecurrenceRules.Add(recur);
try
{
IList<Occurrence> occurrences = evt.GetOccurrences(DateTime.Today.AddDays(1), DateTime.Today.AddDays(2));
Assert.Fail("An exception should be thrown when evaluating a recurrence with no specified FREQUENCY");
}
catch { }
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:17,代码来源:RecurrenceTest.cs
示例15: RecurrencePattern1
public void RecurrencePattern1()
{
// NOTE: evaluators are not generally meant to be used directly like this.
// However, this does make a good test to ensure they behave as they should.
IRecurrencePattern pattern = new RecurrencePattern("FREQ=SECONDLY;INTERVAL=10");
pattern.RestrictionType = RecurrenceRestrictionType.NoRestriction;
CultureInfo us = CultureInfo.CreateSpecificCulture("en-US");
iCalDateTime startDate = new iCalDateTime(DateTime.Parse("3/30/08 11:59:40 PM", us));
iCalDateTime fromDate = new iCalDateTime(DateTime.Parse("3/30/08 11:59:40 PM", us));
iCalDateTime toDate = new iCalDateTime(DateTime.Parse("3/31/08 12:00:11 AM", us));
IEvaluator evaluator = pattern.GetService(typeof(IEvaluator)) as IEvaluator;
Assert.IsNotNull(evaluator);
IList<IPeriod> occurrences = evaluator.Evaluate(
startDate,
DateUtil.SimpleDateTimeToMatch(fromDate, startDate),
DateUtil.SimpleDateTimeToMatch(toDate, startDate),
false);
Assert.AreEqual(4, occurrences.Count);
Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/30/08 11:59:40 PM", us)), occurrences[0].StartTime);
Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/30/08 11:59:50 PM", us)), occurrences[1].StartTime);
Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/31/08 12:00:00 AM", us)), occurrences[2].StartTime);
Assert.AreEqual(new iCalDateTime(DateTime.Parse("03/31/08 12:00:10 AM", us)), occurrences[3].StartTime);
}
开发者ID:MaitreDede,项目名称:dday-ical,代码行数:27,代码来源:RecurrenceTest.cs
示例16: SetRecurrencePattern
/// <summary>
/// Sets the pattern.
/// </summary>
/// <param name="pattern">The pattern.</param>
private void SetRecurrencePattern(RecurrencePattern pattern)
{
this.InitializeRecurrenceFrequency();
switch (pattern.Frequency)
{
case RecurrenceFrequency.Weekly:
this.SetupWeeklyRecurrence(pattern);
break;
case RecurrenceFrequency.Monthly:
this.SetupMonthlyRecurrence(pattern);
break;
case RecurrenceFrequency.Yearly:
this.SetupYearlyRecurrence(pattern);
break;
////case RecurrenceFrequency.Daily:
default:
this.SetupDailyRecurrence(pattern);
break;
}
}
开发者ID:JoshuaBradley,项目名称:Engage-Events,代码行数:25,代码来源:RecurrenceEditor.ascx.cs
示例17: SetupWeeklyRecurrence
/// <summary>
/// Sets up the controls in <see cref="RecurrencePatternWeeklyView"/>.
/// </summary>
/// <param name="pattern">The recurrence pattern.</param>
private void SetupWeeklyRecurrence(RecurrencePattern pattern)
{
this.RepeatFrequencyWeekly.Checked = true;
this.WeeklyRepeatIntervalTextBox.Text = pattern.Interval.ToString(CultureInfo.CurrentCulture);
this.WeeklyWeekdayMonday.Checked = (pattern.DaysOfWeekMask & RecurrenceDay.Monday) != 0;
this.WeeklyWeekdayTuesday.Checked = (pattern.DaysOfWeekMask & RecurrenceDay.Tuesday) != 0;
this.WeeklyWeekdayWednesday.Checked = (pattern.DaysOfWeekMask & RecurrenceDay.Wednesday) != 0;
this.WeeklyWeekdayThursday.Checked = (pattern.DaysOfWeekMask & RecurrenceDay.Thursday) != 0;
this.WeeklyWeekdayFriday.Checked = (pattern.DaysOfWeekMask & RecurrenceDay.Friday) != 0;
this.WeeklyWeekdaySaturday.Checked = (pattern.DaysOfWeekMask & RecurrenceDay.Saturday) != 0;
this.WeeklyWeekdaySunday.Checked = (pattern.DaysOfWeekMask & RecurrenceDay.Sunday) != 0;
}
开发者ID:JoshuaBradley,项目名称:Engage-Events,代码行数:17,代码来源:RecurrenceEditor.ascx.cs
示例18: GetCalendarContentFromControls
/// <summary>
/// Gets the calendar content from controls.
/// </summary>
/// <returns></returns>
internal string GetCalendarContentFromControls()
{
EnsureChildControls();
if ( _dpStartDateTime.SelectedDateTimeIsBlank )
{
return iCalendarContentEmptyEvent;
}
DDay.iCal.Event calendarEvent = new DDay.iCal.Event();
calendarEvent.DTStart = new DDay.iCal.iCalDateTime( _dpStartDateTime.SelectedDateTime.Value );
calendarEvent.DTStart.HasTime = true;
int durationHours = TextBoxToPositiveInteger( _tbDurationHours, 0 );
int durationMins = TextBoxToPositiveInteger( _tbDurationMinutes, 0 );
if ( (durationHours == 0 && durationMins == 0) || this.ShowDuration == false )
{
// make a one second duration since a zero duration won't be included in occurrences
calendarEvent.Duration = new TimeSpan( 0, 0, 1);
}
else
{
calendarEvent.Duration = new TimeSpan( durationHours, durationMins, 0 );
}
if ( _radRecurring.Checked )
{
if ( _radSpecificDates.Checked )
{
#region specific dates
PeriodList recurrenceDates = new PeriodList();
List<string> dateStringList = _hfSpecificDateListValues.Value.Split( new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries ).ToList();
foreach ( var dateString in dateStringList )
{
DateTime newDate;
if ( DateTime.TryParse( dateString, out newDate ) )
{
recurrenceDates.Add( new iCalDateTime( newDate.Date ) );
}
}
calendarEvent.RecurrenceDates.Add( recurrenceDates );
#endregion
}
else
{
if ( _radDaily.Checked )
{
#region daily
if ( _radDailyEveryXDays.Checked )
{
RecurrencePattern rruleDaily = new RecurrencePattern( FrequencyType.Daily );
rruleDaily.Interval = TextBoxToPositiveInteger( _tbDailyEveryXDays );
calendarEvent.RecurrenceRules.Add( rruleDaily );
}
else
{
// NOTE: Daily Every Weekday/Weekend Day is actually Weekly on Day(s)OfWeek in iCal
RecurrencePattern rruleWeekly = new RecurrencePattern( FrequencyType.Weekly );
if ( _radDailyEveryWeekday.Checked )
{
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Monday ) );
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Tuesday ) );
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Wednesday ) );
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Thursday ) );
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Friday ) );
}
else if ( _radDailyEveryWeekendDay.Checked )
{
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Saturday ) );
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Sunday ) );
}
calendarEvent.RecurrenceRules.Add( rruleWeekly );
}
#endregion
}
else if ( _radWeekly.Checked )
{
#region weekly
RecurrencePattern rruleWeekly = new RecurrencePattern( FrequencyType.Weekly );
rruleWeekly.Interval = TextBoxToPositiveInteger( _tbWeeklyEveryX );
if ( _cbWeeklySunday.Checked )
{
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Sunday ) );
}
if ( _cbWeeklyMonday.Checked )
{
rruleWeekly.ByDay.Add( new WeekDay( DayOfWeek.Monday ) );
}
if ( _cbWeeklyTuesday.Checked )
//.........这里部分代码省略.........
开发者ID:Ganon11,项目名称:Rock,代码行数:101,代码来源:ScheduleBuilder.cs
示例19: ProcessRecurrencePattern
private IRecurrencePattern ProcessRecurrencePattern(IDateTime referenceDate)
{
RecurrencePattern r = new RecurrencePattern();
r.CopyFrom(Pattern);
// Convert the UNTIL value to a local date/time based on the time zone information that
// is in the reference date
if (r.Until != DateTime.MinValue)
{
// Build an iCalDateTime with the correct time zone & calendar
var until = new iCalDateTime(r.Until, referenceDate.TZID);
until.AssociatedObject = referenceDate.AssociatedObject;
// Convert back to local time so time zone comparisons match
r.Until = until.Local;
}
if (r.Frequency > FrequencyType.Secondly &&
r.BySecond.Count == 0 &&
referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
r.BySecond.Add(referenceDate.Second);
if (r.Frequency > FrequencyType.Minutely &&
r.ByMinute.Count == 0 &&
referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
r.ByMinute.Add(referenceDate.Minute);
if (r.Frequency > FrequencyType.Hourly &&
r.ByHour.Count == 0 &&
referenceDate.HasTime /* NOTE: Fixes a bug where all-day events have BySecond/ByMinute/ByHour added incorrectly */)
r.ByHour.Add(referenceDate.Hour);
// If BYDAY, BYYEARDAY, or BYWEEKNO is specified, then
// we don't default BYDAY, BYMONTH or BYMONTHDAY
if (r.ByDay.Count == 0)
{
// If the frequency is weekly, use the original date's day of week.
// NOTE: fixes WeeklyCount1() and WeeklyUntil1() handling
// If BYWEEKNO is specified and BYMONTHDAY/BYYEARDAY is not specified,
// then let's add BYDAY to BYWEEKNO.
// NOTE: fixes YearlyByWeekNoX() handling
if (r.Frequency == FrequencyType.Weekly ||
(
r.ByWeekNo.Count > 0 &&
r.ByMonthDay.Count == 0 &&
r.ByYearDay.Count == 0
))
r.ByDay.Add(new WeekDay(referenceDate.DayOfWeek));
// If BYMONTHDAY is not specified,
// default to the current day of month.
// NOTE: fixes YearlyByMonth1() handling, added BYYEARDAY exclusion
// to fix YearlyCountByYearDay1() handling
if (r.Frequency > FrequencyType.Weekly &&
r.ByWeekNo.Count == 0 &&
r.ByYearDay.Count == 0 &&
r.ByMonthDay.Count == 0)
r.ByMonthDay.Add(referenceDate.Day);
// If BYMONTH is not specified, default to
// the current month.
// NOTE: fixes YearlyCountByYearDay1() handling
if (r.Frequency > FrequencyType.Monthly &&
r.ByWeekNo.Count == 0 &&
r.ByYearDay.Count == 0 &&
r.ByMonth.Count == 0)
r.ByMonth.Add(referenceDate.Month);
}
return r;
}
开发者ID:devcrafting,项目名称:DDay.iCal,代码行数:69,代码来源:RecurrencePatternEvaluator.cs
示例20: CreateFromSchedulerRecurrencePattern
public static RecurrencePatternBaseType CreateFromSchedulerRecurrencePattern(RecurrencePattern schedulerPattern)
{
if (schedulerPattern.Frequency == RecurrenceFrequency.Daily)
{
if (schedulerPattern.DaysOfWeekMask == RecurrenceDay.EveryDay)
{
DailyRecurrencePatternType pattern = new DailyRecurrencePatternType();
pattern.Interval = schedulerPattern.Interval;
return pattern;
}
else
{
WeeklyRecurrencePatternType pattern = new WeeklyRecurrencePatternType();
pattern.Interval = 1; // Interval is ignored in this case.
pattern.DaysOfWeek = DaysOfWeekStringConverter.ConvertFromRecurrenceDay(schedulerPattern.DaysOfWeekMask, false);
return pattern;
}
}
if (schedulerPattern.Frequency == RecurrenceFrequency.Weekly)
{
WeeklyRecurrencePatternType pattern = new WeeklyRecurrencePatternType();
pattern.Interval = schedulerPattern.Interval;
pattern.DaysOfWeek = DaysOfWeekStringConverter.ConvertFromRecurrenceDay(schedulerPattern.DaysOfWeekMask, false);
return pattern;
}
if (schedulerPattern.Frequency == RecurrenceFrequency.Monthly)
{
if (schedulerPattern.DayOfMonth > 0)
{
AbsoluteMonthlyRecurrencePatternType pattern = new AbsoluteMonthlyRecurrencePatternType();
pattern.Interval = schedulerPattern.Interval;
pattern.DayOfMonth = schedulerPattern.DayOfMonth;
return pattern;
}
else
{
RelativeMonthlyRecurrencePatternType pattern = new RelativeMonthlyRecurrencePatternType();
pattern.Interval = schedulerPattern.Interval;
pattern.DayOfWeekIndex = DayOfWeekIndexConverter.ConvertFromDayOrdinal(schedulerPattern.DayOrdinal);
pattern.DaysOfWeek = DayOfWeekConverter.ConvertFromRecurrenceDay(schedulerPattern.DaysOfWeekMask);
return pattern;
}
}
if (schedulerPattern.Frequency == RecurrenceFrequency.Yearly)
{
if (schedulerPattern.DayOfMonth > 0)
{
AbsoluteYearlyRecurrencePatternType pattern = new AbsoluteYearlyRecurrencePatternType();
pattern.Month = (MonthNamesType) Enum.Parse(typeof(MonthNamesType), schedulerPattern.Month.ToString());
pattern.DayOfMonth = schedulerPattern.DayOfMonth;
return pattern;
}
else
{
RelativeYearlyRecurrencePatternType pattern = new RelativeYearlyRecurrencePatternType();
pattern.Month = (MonthNamesType) Enum.Parse(typeof(MonthNamesType), schedulerPattern.Month.ToString());
pattern.DayOfWeekIndex = DayOfWeekIndexConverter.ConvertFromDayOrdinal(schedulerPattern.DayOrdinal);
pattern.DaysOfWeek = DaysOfWeekStringConverter.ConvertFromRecurrenceDay(schedulerPattern.DaysOfWeekMask, true);
return pattern;
}
}
return null;
}
开发者ID:angelpetrov90,项目名称:aspnet-sdk,代码行数:67,代码来源:EWSProxies.Extensions.cs
注:本文中的RecurrencePattern类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论