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

6 posts, 0 answers
  1. Tamkeen
    Tamkeen avatar
    6 posts
    Member since:
    Jun 2011

    Posted 14 Oct 2011 Link to this post

     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

       
  2. George
    Admin
    George avatar
    1332 posts

    Posted 20 Oct 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Tamkeen
    Tamkeen avatar
    6 posts
    Member since:
    Jun 2011

    Posted 20 Oct 2011 Link to this post

    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
     
  5. Muhammad
    Muhammad avatar
    2 posts
    Member since:
    Sep 2012

    Posted 10 Apr 2013 Link to this post

    Hello, 

    I am trying to do similar thing. If you have already did that can you please share the code? Thanks. 
  6. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 12 Apr 2013 Link to this post

    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.

  7. Peter
    Peter avatar
    1 posts
    Member since:
    Feb 2014

    Posted 28 Aug 2014 Link to this post

    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
Back to Top
DevCraft banner