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

Recurrence and Sharepoint Recurrence

5 Answers 367 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Chad
Top achievements
Rank 1
Chad asked on 19 Sep 2008, 09:25 PM
Is there an easy way to map the recurrence list values from sharepoint to the scheduler? I've looked around and the object model for messing with sharepoint recurrence is pretty lackluster...

Was just wondering if you've come across this in your development and created a nice and easy SPRecurrence = RADRecurrence type tool?

Please? lol

5 Answers, 1 is accepted

Sort by
0
Dimitar Milushev
Telerik team
answered on 22 Sep 2008, 01:30 PM
Hello Chad,

If you need to do this 'translation' once, you may try exporting the SharePoint's calendar to iCal format and then importing the iCal data through RadScheduler.

Also, if you are having troubles with the Recurrence only, you may use the iCal Exporter mentioned in the linked blog post to base your code on. Specifically, there is a ParseRecurrence method in the iCal Exporter that translates SP's RecurrenceData XML into iCalendar recurrence string. RadScheduler uses iCal strings to store recurrence rules so this code may be very helpful in your case.

If you create a reusable tool for converting SharePoint's recurrences into RadScheduler recurrences, we'll gladly post it as Code Library so others can benefit from it and you'll be awarded a good amount of Telerik points.

Greetings,
Dimitar Milushev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Aroh Shukla
Top achievements
Rank 1
answered on 09 Feb 2009, 02:07 AM
Hi Chad and Dimitar,

Greetings from Singapore!
Well, I have the same issue. I am using RADScheduler and its backed by SharePoint calendar list as database.
Everything works except the recurrence. I looked at the Dimitar's solution:

1) SharePoint calendar list to iCal format. (its using feature and lot of coding to export to iCal format)
2) Importing to the iCal data into RadScheduler.

Problem with the solution:
1) Its fairly complex and we have to add one more feature.
 2) My Calendar application is infact complex too and it uses 2 features. Adding one feature just for recurrence will make the application more complex.

My solution:
Well, I solved it using CAML queries and its much more simpler and easy to code rather than creating one more feature. Here is my approach: 

1) For calendar items (for e.g. Team members in my case), I am filtering out all recurrent events. 
2) For recurrent items, I am filtering other calendar items. 

Thus, RADScheduler will display both: individual calendar items (for e.g. team members) and recurrent events (for e.g. Team meeting on every monday).
Creating 2 CAML queries: one for calendar items (not recurrent) and second is for recurrent items (not selecting other calendar items which are not recurrent)

My application worked perfect and with no additional feature just for recurrence.

There is my code and it will be useful for other SharePoint Developers who are RADScheduler.
Cheers,
Aroh Shukla

private SPCalendarItemCollection GetCalendarItems()  
        {  
            // Create a new collection for the calendar items    
            // This is an item with a start and end date.    
            SPCalendarItemCollection items = new SPCalendarItemCollection();  
 
            oWeb = SPControl.GetContextWeb(Context);  
            SPList oCalendarList = oWeb.Lists["Calendar"];  
            SPView oView = oCalendarList.Views["Calendar"];  
 
            SPQuery query = new SPQuery();  
            query.Query = "<OrderBy><FieldRef Name='ID' /></OrderBy>";  
 
 
            if (allUsers.SelectedItem.Value == "0"//Show All    
            {  
                query.Query = "<Where><Eq><FieldRef Name='fRecurrence' /><Value Type='Recurrence'>0</Value></Eq></Where><OrderBy><FieldRef Name='ID' /></OrderBy>";  
            }  
            else 
            {  
                query.Query = "<OrderBy><FieldRef Name='ID' /></OrderBy><Where><And><Eq><FieldRef Name='Absentee' /><Value Type='User'>" + allUsers.SelectedItem.Text + "</Value></Eq><Eq><FieldRef Name='fRecurrence' /><Value Type='Recurrence'>0</Value></Eq></And></Where>";  
            }  
 
            //For Team members (not for recurrent events)  
            foreach (SPListItem listItem in oCalendarList.GetItems(query))  
            {  
                SPCalendarItem calItem = new SPCalendarItem();  
                calItem.ItemID = listItem["ID"].ToString();  
                calItem.Title = listItem["Title"].ToString();  
                calItem.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);  
                calItem.StartDate = (DateTime)listItem["Start Time"];  
                calItem.ItemID = listItem.ID.ToString();  
 
                if (listItem["End Time"] != null)  
                {  
                    calItem.hasEndDate = true;  
                    calItem.EndDate = (DateTime)listItem["End Time"];  
                }  
                else 
                    calItem.hasEndDate = false;  
 
                if (listItem["Description"] != null)  
                    calItem.Description = listItem["Description"].ToString();  
 
                if (listItem["Location"] != null)  
                    calItem.Location = listItem["Location"].ToString();  
 
                calItem.IsRecurrence = Convert.ToBoolean(listItem["Recurrence"]);  
 
                 
                items.Add(calItem);  
 
            }  
 
            //Only for Reccurent events (like weekley meetings)  
            SPQuery queryRecurrence = new SPQuery();  
            queryRecurrence.ExpandRecurrence = true;  
            queryRecurrence.Query = "<Where>" +   
                                       "<And>" +    
                                          "<Eq>"+   
                                             "<FieldRef Name='fRecurrence' />" +  
                                             "<Value Type='Recurrence'>1</Value>" +  
                                          "</Eq>" +   
                                          "<DateRangesOverlap>" +  
                                             "<FieldRef Name='EventDate' />"+  
                                             "<FieldRef Name='EndDate' />"+  
                                             "<FieldRef Name='RecurrenceID' />" +  
                                                 "<Value Type='DateTime'>"+  
                                                    "<Month />"+  
                                                 "</Value>" +  
                                          "</DateRangesOverlap>"+  
                                       "</And>" +  
                                    "</Where>"+  
                                    "<ViewFields>"+  
                                       "<FieldRef Name='Title' />"+  
                                       "<FieldRef Name='EventDate' />"+  
                                       "FieldRef Name='EndDate' />"+   
                                       "<FieldRef Name='fRecurrence' />"+  
                                       "<FieldRef Name='Absentee' />"+  
                                    "</ViewFields>";  
              
            // Look forward from the beginning of the current month  
            queryRecurrence.CalendarDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);  
 
            // Returns all items (including recurrence instances) that  
            // would appear in the calendar view for the current month  
 
            SPListItemCollection calendarItems = oCalendarList.GetItems(queryRecurrence);  
 
            foreach (SPListItem listItem in oCalendarList.GetItems(queryRecurrence))  
            {  
                SPCalendarItem calItem = new SPCalendarItem();  
                calItem.ItemID = listItem["ID"].ToString();  
                calItem.Title = listItem["Title"].ToString();  
                calItem.CalendarType = Convert.ToInt32(SPCalendarType.Gregorian);  
                calItem.StartDate = (DateTime)listItem["Start Time"];  
                calItem.ItemID = listItem.ID.ToString();  
 
                if (listItem["End Time"] != null)  
                {  
                    calItem.hasEndDate = true;  
                    calItem.EndDate = (DateTime)listItem["End Time"];  
                }  
                else 
                    calItem.hasEndDate = false;  
 
                if (listItem["Description"] != null)  
                    calItem.Description = listItem["Description"].ToString();  
 
                if (listItem["Location"] != null)  
                    calItem.Location = listItem["Location"].ToString();  
 
                items.Add(calItem);  
            }  
 
 
            // return the collection    
            return items;  
        } 


0
Aroh Shukla
Top achievements
Rank 1
answered on 09 Feb 2009, 02:17 AM
Hi Telerik support,

I want to send a code example from SharePoint Recurrence.
I looked at the "Send a code example" but there no facility to send my code?

Could someone please guide about this?

Best regards,
Aroh Shukla
0
Dimitar Milushev
Telerik team
answered on 11 Feb 2009, 10:08 AM
Hi Aroh Shukla,

You can submit a Code Library with you code sample. Simply go to http://www.telerik.com/community/code-library/aspnet-ajax/scheduler.aspx and click the New Thread button. On the new thread page, near the bottom, you will find an 'attach files' option that you can use to attach .zip or .rar files.

I hope this helps.

Best wishes,
Dimitar Milushev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Eliza Sahoo
Top achievements
Rank 1
answered on 06 May 2010, 02:00 PM

For instance, let us take a State List which holds all the states of India. States are grouped under different zones i.e. North, South, East & West. If I need to retrieve all the States for North zone then my SP Query would look somewhat like,

SPQuery stateQuery = new SPQuery();
stateQuery.Query =
"<Where><Eq><FieldRef Name=\"Zone\"/><Value Type=\"Text\">North</Value></Eq></Where>"; 
SPListItemCollection stateCol = StateList.GetItems(stateQuery);



For more information refer

Tags
Scheduler
Asked by
Chad
Top achievements
Rank 1
Answers by
Dimitar Milushev
Telerik team
Aroh Shukla
Top achievements
Rank 1
Eliza Sahoo
Top achievements
Rank 1
Share this question
or