Hello!
Is there possibility to expand RecurrenceRule in C# instead of using SQL UDF (provided here: http://www.telerik.com/community/forums/aspnet-ajax/scheduler/sql-reporting-display-all-recurring-appointments.aspx)?
For example I have List of type Appointment and I want to expand Recurrences in elements which have RecurrencyRule != null so the result will be List of upcoming events ordered by Start attribute.
Is this possible?
Thanks in advance
EDIT:
I've opened ExpandRecurrence_UDF zip file from post about SQL UDF and I've found function which returns occurences for RecurrenceRule string but when I try to parse my RecurrenceRules which are being parsed by SQL UDF function I can't get this make to work under C#.
Function:
Occurences class:
Sample RecurrenceRule string which I'm tryign to parse:
I've tryed to use Replace function to convert \n to Environment.NewLine but it was returning false too.
EDIT2: I've found bug in my RecurrencyRule string. Month in DTSTART and DTEND was in X format (for months 1-9) instead of XX
Is there possibility to expand RecurrenceRule in C# instead of using SQL UDF (provided here: http://www.telerik.com/community/forums/aspnet-ajax/scheduler/sql-reporting-display-all-recurring-appointments.aspx)?
For example I have List of type Appointment and I want to expand Recurrences in elements which have RecurrencyRule != null so the result will be List of upcoming events ordered by Start attribute.
Is this possible?
Thanks in advance
EDIT:
I've opened ExpandRecurrence_UDF zip file from post about SQL UDF and I've found function which returns occurences for RecurrenceRule string but when I try to parse my RecurrenceRules which are being parsed by SQL UDF function I can't get this make to work under C#.
Function:
public static IEnumerable ExpandRecurrence(string recurrenceRule, DateTime rangeStart, DateTime rangeEnd) |
{ |
List<OccurrenceInfo> occurrences = new List<OccurrenceInfo>(); |
RecurrenceRule rrule; |
if (RecurrenceRule.TryParse(recurrenceRule, out rrule)) |
{ |
rrule.SetEffectiveRange(rangeStart, rangeEnd); |
foreach (DateTime occStart in rrule.Occurrences) |
{ |
OccurrenceInfo info = new OccurrenceInfo(occStart, occStart.Add(rrule.Range.EventDuration)); |
occurrences.Add(info); |
} |
} |
return occurrences; |
} |
Occurences class:
public class OccurrenceInfo |
{ |
private DateTime start; |
private DateTime end; |
public OccurrenceInfo(DateTime start, DateTime end) |
{ |
this.start = start; |
this.end = end; |
} |
public DateTime Start |
{ |
get { return start; } |
set { start = value; } |
} |
public DateTime End |
{ |
get { return end; } |
set { end = value; } |
} |
} |
Sample RecurrenceRule string which I'm tryign to parse:
RecurrenceRule.TryParse("DTSTART:2008422T000000Z\nDTEND:2008423T000000Z\nRRULE:FREQ=YEARLY;INTERVAL=1;BYMONTHDAY=22;BYDAY=MO,TU,WE,TH,FR,SA,SU;BYMONTH=04\n", out rrule) |
I've tryed to use Replace function to convert \n to Environment.NewLine but it was returning false too.
EDIT2: I've found bug in my RecurrencyRule string. Month in DTSTART and DTEND was in X format (for months 1-9) instead of XX