This is a migrated thread and some comments may be shown as answers.

xml datasource for appointments

1 Answer 85 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Tanuj
Top achievements
Rank 1
Tanuj asked on 18 Oct 2010, 07:42 PM

i am trying to load the appointments thru an xml file, the xml file is generated dynamically and its displaying all the appointments. however the recurrence and the enddate time does not seem to work correctly, i have attached the xml for your reference please take a look and let me know what am i missing?
The Problem: 
if the start time is 10:00AM and the end time is 11:00AM and the start date is 10/25/2010 and the end date is 10/30/2010, the recurrence rule is not stopping on the end date, but continues infinetely. if i want an event to span 6 days continously from say 10/25 - 10/30 at 10:00AM to 11:00AM
what should be value of
<Start> tag?
<End> tag?
<RecurrenceRule>DTSTART:?
<RecurrenceRule>DTEND:?
<RecurrenceRule>UNTIL:?



<?

 

xml version="1.0" encoding="utf-8"?><Appointments><Resources><Resource><Key>1</Key><Text>Classes</Text></Resource><Resource><Key>2</Key><Text>Workshops</Text></Resource><Resource><Key>3</Key><Text>Salon Series</Text></Resource><Resource><Key>4</Key><Text>Teachers Symposium</Text></Resource><Resource><Key>5</Key><Text>Kids Art Camp</Text></Resource><Resource><Key>6</Key><Text>Teen Art Camp</Text></Resource><Resource><Key>7</Key><Text>Portfolio Development</Text></Resource><Resource><Key>8</Key><Text>Spring Break Art Camp</Text></Resource><Resource><Key>9</Key><Text>Summer Saturday Art Camp</Text></Resource><Resource><Key>10</Key><Text>Exhibitions</Text></Resource><Resource><Key>11</Key><Text>Events</Text></Resource><Resource><Key>12</Key><Text>Alerts</Text></Resource></Resources><Appointment><ID>1</ID><Subject>Test Event</Subject><Description>some Description&lt;br/&gt;&lt;a href='http://www.google.com'&gt;Click here for more details&lt;/a&gt;</Description><Start>2010-09-25T11:30Z</Start><End>2010-09-26T14:00Z</End><RecurrenceRule>

 

&lt;

 

![CDATA[

 

DTSTART:20100925T113000Z

DTEND:20100925T140000Z

RRULE:FREQ=DAILY;UNTIL:20100926T140000Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU]]

&gt;

 

</

 

RecurrenceRule><Resources><Resource Key="4" /></Resources></Appointment><Appointment><ID>2</ID><Subject>Sunday Event</Subject><Description>sample event</Description><Start>2010-09-26T10:00Z</Start><End>2010-09-26T11:00Z</End><RecurrenceRule>

 

&lt;

 

![CDATA[

 

DTSTART:20100926T100000Z

DTEND:20100926T110000Z

RRULE:FREQ=DAILY;UNTIL:20100926T110000Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU]]

&gt;

 

</

 

RecurrenceRule><Resources><Resource Key="12" /></Resources></Appointment><Appointment><ID>3</ID><Subject>Special Event</Subject><Description>some description</Description><Start>2010-09-28T15:00Z</Start><End>2010-09-28T19:30Z</End><RecurrenceRule>

 

&lt;

 

![CDATA[

 

DTSTART:20100928T150000Z

DTEND:20100928T193000Z

RRULE:FREQ=DAILY;UNTIL:20100928T193000Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU]]

&gt;

 

</

 

RecurrenceRule><Resources><Resource Key="10" /></Resources></Appointment><Appointment><ID>4</ID><Subject>testing recurrence</Subject><Description>testing recurrence</Description><Start>2010-10-18T10:30Z</Start><End>2010-10-30T12:45Z</End><RecurrenceRule>

 

&lt;

 

![CDATA[

 

DTSTART:20101018T103000Z

DTEND:20101018T124500Z

RRULE:FREQ=DAILY;UNTIL:20101030T124500Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU]]

&gt;

 

</

 

RecurrenceRule><Resources><Resource Key="12" /></Resources></Appointment><Appointment><ID>5</ID><Subject>second event</Subject><Description>second event</Description><Start>2010-10-25T10:00Z</Start><End>2010-10-29T11:15Z</End><RecurrenceRule>

 

&lt;

 

![CDATA[

 

DTSTART:20101025T100000Z

DTEND:20101025T111500Z

RRULE:FREQ=DAILY;UNTIL:20101029T111500Z;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU]]

&gt;

 

</

 

RecurrenceRule><Resources><Resource Key="11" /></Resources></Appointment></Appointments>

 


here is the function that builds the recurrence string

 

public static string GetRecurranceString(DateTime StartDate, DateTime EndDate, string StartTime,string EndTime)

 

{

 

StringBuilder sb = new StringBuilder();

 

 

StringBuilder RecStr = new StringBuilder();

 

RecStr.Append(

"\r\n<![CDATA[");

 

sb.Append(StartDate.Month.ToString()).Append(

"/");

 

sb.Append(StartDate.Day.ToString()).Append(

"/");

 

sb.Append(StartDate.Year.ToString()).Append(

" ");

 

sb.Append(StartTime.Replace(

"AM", ":00 AM").Replace("PM", ":00 PM"));

 

 

DateTime mystartdate = Convert.ToDateTime(sb.ToString());

 

RecStr.Append(

"\r\nDTSTART:" + mystartdate.ToString("yyyyMMddTHHmm00Z"));

 

 

StringBuilder eb = new StringBuilder();

 

eb.Append(StartDate.Month.ToString()).Append(

"/");

 

eb.Append(StartDate.Day.ToString()).Append(

"/");

 

eb.Append(StartDate.Year.ToString()).Append(

" ");

 

eb.Append(EndTime.Replace(

"AM", ":00 AM").Replace("PM", ":00 PM"));

 

 

DateTime myenddate = Convert.ToDateTime(eb.ToString());

 

 

StringBuilder until = new StringBuilder();

 

until.Append(EndDate.Month.ToString()).Append(

"/");

 

until.Append(EndDate.Day.ToString()).Append(

"/");

 

until.Append(EndDate.Year.ToString()).Append(

" ");

 

until.Append(EndTime.Replace(

"AM", ":00 AM").Replace("PM", ":00 PM"));

 

 

DateTime myuntildate = Convert.ToDateTime(until.ToString());

 

RecStr.Append(

"\r\nDTEND:" + myenddate.ToString("yyyyMMddTHHmm00Z"));

 

RecStr.Append(

"\r\nRRULE:FREQ=DAILY;").Append("UNTIL:" + myuntildate.ToString("yyyyMMddTHHmm00Z")).Append(";INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU");

 

RecStr.Append(

"]]>\r\n");

 

 

return RecStr.ToString();

 

}

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 22 Oct 2010, 12:41 PM
Hi Tanuj,

I recommend you use the built-in XmlSchedulerProvider as shown in this demo. The provider will take care of recurrence, resources and custom attributes automatically.

Greetings,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Scheduler
Asked by
Tanuj
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or