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

how to covert the sharepoint RecurrenceData field(xml) to RecurrencePattern in rad SchedlerView

5 Answers 166 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Tamkeen
Top achievements
Rank 2
Tamkeen asked on 14 Oct 2011, 03:42 PM
 Hi sir,

i need pass the RecurrencePattern   from SchedlerView   to sharepoint  RecurrenceData field
 the problem is :
1) i ll get RecurrencePattern from  rad SchedlerView  ll be in string format ie "FREQ=DAILY;UNTIL=20111216T040000Z;INTERVAL=2;BYDAY=SU,MO,TU,WE,TH,FR,SA" i need to convert to xml  to store  it in sharepoint RecurrenceData field
2)sharepoint RecurrenceData field takes only xml ie
                  //"<recurrence>
                //           <rule>
                //           <firstDayOfWeek>
                //            su
                //          </firstDayOfWeek>
                //        <repeat>
                //        <weekly su='TRUE' mo='TRUE' tu='TRUE' weekFrequency='1' />
                //         </repeat>
                //      <repeatForever>FALSE"
                //     </repeatForever>
                //         </rule>
                //      </recurrence>";
how to convert this  xml into RecurrencePattern string ie (" FREQ=DAILY;UNTIL=20111216T040000Z;INTERVAL=2;BYDAY=SU,MO,TU,WE,TH,FR,SA" ) and  (vis versa) is there any way i can do it ?
now i am doing this manual like this only for " WEEKLY"  Recurrence
var serializedPattern = RecurrencePatternHelper.RecurrencePatternToString(e.Appointment.RecurrenceRule.Pattern);
              
              XDocument doc = new XDocument();
 
              XElement recurrence =  new XElement("recurrence");
              XElement rule  = new XElement("rule");
 
              recurrence.Add(rule);
              XElement repeat = new XElement("repeat");
             
              // xelements of the  weekly
              XElement weekly = null;
 
              XElement DAILY = null;
              XElement MONTHL = null;
               
           
              XElement UNTIL = null;
              
              string[] value1 = serializedPattern.Split(';');
         
              foreach (string str in value1)
              {
 
                  if (str == "FREQ=WEEKLY")
                  {
                      
                    rule.Add(repeat);
                    weekly = new XElement("weekly");
                    repeat.Add (weekly);
                      
 
                  }
                  else if (str == "FREQ=DAILY")
                  {
                      rule.Add(repeat);
                      DAILY = new XElement("DAILY");
                      repeat.Add(DAILY);
 
 
                  }
                  else if (str == "FREQ=MONTHL")
                  {
                      rule.Add(repeat);
                      MONTHL = new XElement("MONTHL");
                      repeat.Add(MONTHL);
 
                  }
                  string mystr = str.Substring(0, 5);
 
                  if (mystr == "COUNT")
                  {
                  }
                  else if (mystr == "UNTIL")
                  {
                      StringBuilder dataformate = new StringBuilder();
                   
                      dataformate.Append(str.Substring(6, 16));
                      dataformate.Insert(4, "-");
                      dataformate.Insert(7, "-");
                      dataformate.Insert(13, ":");
                      dataformate.Insert(16, ":");
                   
                      UNTIL = new XElement("windowEnd", dataformate);
                      rule.Add(UNTIL);
                  }
 
                  else if (mystr == "INTER")
                  {
 
                      
                  weekly.Add(new XAttribute("weekFrequency", "1"));
                  }
                  else if (mystr == "WKST=")
                  {
                  }
                  else if (mystr == "BYDAY")
                  {
                      string day = str.Substring(6);
                      string[] days = day.Split(',');
                      foreach (string strin in days)
                      {
                          if (value1[0].ToString() == "FREQ=WEEKLY")
                          {
                              if (strin == "SU")
                              {
 
                                  weekly.Add(new XAttribute("su", "TRUE"));
 
 
                              }
                              else if (strin == "MO")
                              {
 
                                  weekly.Add(new XAttribute("mo", "TRUE"));
                              }
                              else if (strin == "TU")
                              {
 
                                  weekly.Add(new XAttribute("tu", "TRUE"));
                              }
                              else if (strin == "WE")
                              {
 
                                  weekly.Add(new XAttribute("we", "TRUE"));
 
                              }
                              else if (strin == "TH")
                              {
 
                                  weekly.Add(new XAttribute("th", "TRUE"));
                              }
                              else if (strin == "FR")
                              {
 
                                  weekly.Add(new XAttribute("fr", "TRUE"));
                              }
                              else if (strin == "SA")
                              {
                                  weekly.Add(new XAttribute("sa", "TRUE"));
                              }
                          }
                          else if (value1[0].ToString() == "FREQ=WEEKLY")
                          {
                              if (strin == "SU")
                              {
 
                                  weekly.Add(new XAttribute("su", "TRUE"));
 
 
                              }
                              else if (strin == "MO")
                              {
 
                                  weekly.Add(new XAttribute("mo", "TRUE"));
                              }
                              else if (strin == "TU")
                              {
 
                                  weekly.Add(new XAttribute("tu", "TRUE"));
                              }
                              else if (strin == "WE")
                              {
 
                                  weekly.Add(new XAttribute("we", "TRUE"));
 
                              }
                              else if (strin == "TH")
                              {
 
                                  weekly.Add(new XAttribute("th", "TRUE"));
                              }
                              else if (strin == "FR")
                              {
 
                                  weekly.Add(new XAttribute("fr", "TRUE"));
                              }
                              else if (strin == "SA")
                              {
                                             weekly.Add(new XAttribute("sa", "TRUE"));
                              }
                          }
                       }
                  }
              }
              doc.Add(recurrence);
          }


plz help me.


thank u
Tamkeen

   

5 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 20 Oct 2011, 08:54 AM
Hi Tamkeen,

 
You need to handle this scenario manually. The RadScheduleView exposes helper classes that convert the recurrence pattern to iCal format and back, but not the sharepoint recurrence data. We will consider implementing such feature for the RadScheduleView control. You can vote for the feature here - http://www.telerik.com/support/pits.aspx#/public/silverlight/8237


All the best,
George
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Tamkeen
Top achievements
Rank 2
answered on 20 Oct 2011, 03:57 PM
Hi  George,

  thank you for  you are response but i think it will be vary complex
  i need to handle both  end , it's ok i will try it at my end ,at present  i am working on that.


 thank u
Tamkeen
 
0
Muhammad
Top achievements
Rank 1
answered on 10 Apr 2013, 09:12 AM
Hello, 

I am trying to do similar thing. If you have already did that can you please share the code? Thanks. 
0
Vladi
Telerik team
answered on 12 Apr 2013, 06:58 AM
Hi,

This feature hasn't been planed to be implemented in the ScheduleView control yet and currently we don't have an examples demonstrating how it could be achieved in the current version of the control that we can share with you. As George mentioned in order to achieve the desired behavior you will need to handle this scenario manually.

You can read this help article that goes through the RecurrencePatternHelper class.

All the best,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Peter
Top achievements
Rank 1
answered on 28 Aug 2014, 08:44 PM
Hi Tamkeen and Muhammad

Did you ever manager to create a robust method to do this conversion (both ways)? I am in the same situation and looking for a good way to do this.

Regards

Peter
Tags
ScheduleView
Asked by
Tamkeen
Top achievements
Rank 2
Answers by
George
Telerik team
Tamkeen
Top achievements
Rank 2
Muhammad
Top achievements
Rank 1
Vladi
Telerik team
Peter
Top achievements
Rank 1
Share this question
or