Bug while editing recurring appointment (webservices & advanced form)

5 posts, 0 answers
  1. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 12 Aug 2009 Link to this post

    Hi,

    It seems that i ran into a bug in de scheduler control.
    We are using the schedulat control with webservices and with the advanced form.

    When i create a new recurring appointment the image which indicate that the appointment is recurring is not visible on the first appointment in the recurrence serie. This also means that when i double click the first appointment to edit, i won't get the message that i'm editing a recurring appointment. The same happens when i'm deleting the first appointment.

    Please let me know if this is a bug and if you can fix it?
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 14 Aug 2009 Link to this post

    Hello Datamex,

    We cannot replicate the problem in our local tests or online demo:
    http://demos.telerik.com/aspnet-ajax/scheduler/examples/webservice/defaultcs.aspx

    Is there anything specific we need to take into consideration to observe the issue?


    Regards,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 14 Aug 2009 Link to this post

    Hi,

    We are using a custom LinqSchedulerProvider that inherits your SchedulerProviderBase where i override the GetAppointments method:

    public class LinqSchedulerProvider : SchedulerProviderBase  
      {  
        private DALDataContext _database = new DALDataContext();  
     
        public override IEnumerable<Telerik.Web.UI.Appointment> GetAppointments(RadScheduler owner)  
        {  
          List<Telerik.Web.UI.Appointment> appointments = new List<Telerik.Web.UI.Appointment>();  
     
     
          var appointmentSource = (from d in _database.Appointments  
                                   where   
                                   d.EmployeeID != null  
                                   && (  d.EndedOn > owner.VisibleRangeStart  
                                   &&    d.StartedOn < owner.VisibleRangeEnd 
                                   ) || (  
                                    d.RecurrenceString != null && d.RecurrenceString != ""  
                                   )  
                                   select d);  
            
          if(appointmentSource != null)  
          {  
            foreach (Datamex.Projects.Saturnus.DataAccess.Appointment app in appointmentSource)  
            {  
              Telerik.Web.UI.Appointment curAppointment = new Telerik.Web.UI.Appointment();  
              curAppointment.ID = app.AppointmentID;  
              curAppointment.Start = (DateTime)app.StartedOn;  
              curAppointment.End = (DateTime)app.EndedOn;  
              curAppointment.RecurrenceRule = app.RecurrenceString;  
              curAppointment.RecurrenceParentID = app.RecurrenceParentAppointmentID;  
              curAppointment.Subject = app.Subject;  
              if (app.EmployeeID != null && app.EmployeeID != 0)  
                curAppointment.Resources.Add(new Resource("Employee", app.EmployeeID, app.Employee.Name));  
              if (app.AppointmentStateID != 0 && app.AppointmentStateID != 0)  
                curAppointment.Resources.Add(new Resource("State", app.AppointmentStateID, app.AppointmentState.IconName));  
              if ( app.AppointmentSubStateID != 0 && app.AppointmentSubStateID != 0 )  
                curAppointment.Resources.Add(new Resource("SubState", app.AppointmentSubStateID, app.AppointmentState.IconName));  
              if (app.AppointmentTypeID != null && app.AppointmentTypeID != 0)  
                curAppointment.Resources.Add(new Resource("Type", app.AppointmentTypeID, app.AppointmentType.Color));  
              if ( app.CustomerID != null && app.CustomerID != 0 )  
                curAppointment.Resources.Add(new Resource("Customer", app.CustomerID, app.Customer.Name));  
     
              if (app.AppointmentState != null)  
                curAppointment.Attributes.Add("StateIconName", app.AppointmentState.IconName);  
              if ( app.AppointmentSubState != null )  
                curAppointment.Attributes.Add("SubStateIconName", app.AppointmentSubState.IconName);  
              if (app.AppointmentType != null)  
                curAppointment.Attributes.Add("Color", app.AppointmentType.Color);  
              if ( app.Customer != null )  
                curAppointment.Attributes.Add("CustomerName", app.Customer.Name);  
     
              //// Add all attributes of the appointment.  
              //Type t = app.GetType();  
              //PropertyInfo[] props = t.GetProperties();  
              //foreach (PropertyInfo prop in props)  
              //  if (prop.GetValue(app, null) != null)  
              //    curAppointment.Attributes.Add(prop.Name, prop.GetValue(app, null).ToString());  
     
              //if (app.AppointmentState != null)  
              //  curAppointment.Attributes.Add("IconName", app.AppointmentState.IconName);  
              //if ( app.AppointmentSubState != null )  
              //  curAppointment.Attributes.Add("IconName2", app.AppointmentSubState.IconName);  
              //if (app.AppointmentType != null)  
              //  curAppointment.Attributes.Add("Color", app.AppointmentType.Color);  
     
              appointments.Add(curAppointment);  
            }  
          } 
        }
    }

    The following SchedulerWebService is being used to call the method from the controller

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]  
      [WebService(Namespace = "http://localhost/webservices")]  
      [ScriptService]  
      public class SchedulerWebService : WebService  
      {  
        private WebServiceAppointmentController _controller;  
     
        /// <summary> 
        /// The WebServiceAppointmentController class is used as a facade to the SchedulerProvider.  
        /// </summary> 
        private WebServiceAppointmentController Controller  
        {  
          get  
          {  
            if (_controller == null)  
            {  
              this._controller = new WebServiceAppointmentController(new LinqSchedulerProvider());  
            }  
     
            return _controller;  
          }  
        }  
          
        [WebMethod]  
        public IEnumerable<AppointmentData> GetAppointments(SchedulerInfo schedulerInfo)  
        {  
          return Controller.GetAppointments(schedulerInfo);  
        }  
     

    Then i use the following javascript to display the Appointments

    /// <summary> 
          /// Occurs when a timeslot is created.  
          /// Sets the AppointmentType image, as well as the AppointmentState catagory color.  
          /// </summary> 
          /// <param name="sender">telerik:RadScheduler</param> 
          /// <param name="e">telerik:TimeSlot</param> 
          /// <returns>null</returns> 
          function TimeSlotCreated(sender, e) {  
            var app = e.get_appointment();  
            var element = e.get_appointment().get_element();  
            var attributeCollection = app.get_attributes();  
            var StateIconName = attributeCollection.getAttribute("StateIconName");  
            var SubStateIconName = attributeCollection.getAttribute("SubStateIconName");  
            var RsCategory = RgbStringToRadStyleString(attributeCollection.getAttribute("Color"));  
            var customerName = attributeCollection.getAttribute("CustomerName");  
            var startTime = app.get_start().format("MMM dd, yyyy HH:mm:ss");  
            attributeCollection.setAttribute("OriginalStartTime", startTime);  
              
            // Set the tooltip of the appointment  
            app.set_toolTip("Afspraak: " + app.get_toolTip() + "\n" + "Klant:       " + customerName);  
     
            // Set the stateimage  
            var image = document.createElement("img");  
            image.setAttribute("src", '<%= System.Configuration.ConfigurationManager.AppSettings["IconDirectory"].Replace("~","") %>' + StateIconName);  
            image.setAttribute("alt", 'IconImage');  
     
            // If the appointment has a substate then show the substateimage  
            if (SubStateIconName != null) {  
              var image2 = document.createElement("img");  
              image2.setAttribute("src", '<%= System.Configuration.ConfigurationManager.AppSettings["IconDirectory"].Replace("~","") %>' + SubStateIconName);  
              image2.setAttribute("alt", 'IconImage');  
            }  
     
            element.setAttribute("class", element.className + " rsCategory" + RsCategory);  
     
            // All appointments with ID 0 are script generated, they are not actually appointments within the database, thus must not be allowed to  
            // be edited/moved or resized in any way shape or form.  
            if (app.get_id() == 0) {  
              app.set_allowDelete(false);  
              app.set_allowEdit(false);  
            }  
     
            var divs = element.getElementsByTagName('div');  
            var result;  
            var innerHTML;  
            for (i = 0; i < divs.length; i++) {  
              // IE and its eternal spacing issues *sigh*  
              if ($telerik.$(divs[i]).is("div.rsAptContent")) {  
                result = divs[i];  
                innerHTML = result.innerHTML;  
                result.innerHTML = '';  
                result.appendChild(image);  
     
                // If the appointment has a substate then show the substateimage  
                if (SubStateIconName != null) { result.appendChild(image2); }  
     
                resultresult.innerHTML = result.innerHTML + innerHTML;  
                resultresult.innerHTML = result.innerHTML + "<br />";  
     
                if (customerName != null) {  
                  resultresult.innerHTML = result.innerHTML + customerName;  
                }  
                return;  
              }  
            }  
     
          } 

    I hope u can find the problem with this information.
  5. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 15 Aug 2009 Link to this post

    Hi,

    I thick i found the problem.

    When the start and the end of the appointment are equal to the DTSTART and the DTEND from the recurrenceString, then the image that indicates recurrence is not visible in first appointment.

    When i remove the begin and end time from the appoinment, than everything seems to work fine.

    Is it true that if you use a recurrenceString in an telerik appointment, you don't have to give the appointment a start and end time?

    Let me know if this is the right conclusion?

    Greetings Datamex

  6. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 20 Aug 2009 Link to this post

    Hello,

    I am not sure how this works at your end. When using a custom provider, you need to make sure that you set the RecurrenceState (this is done by our sample providers):
    RecurrenceState initialState = RecurrenceState.NotRecurring;  
    if (recurrenceParentKey != null)  
    {  
      initialState = RecurrenceState.Exception;  
    }  
    else 
    if (recurrenceRule != string.Empty)  
    {  
      initialState = RecurrenceState.Master;  
    }  
     


    Greetings,
    Peter
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017