OnRecurrenceExceptionCreated doesn't supply new Recurrencerule

10 posts, 0 answers
  1. Larevenge
    Larevenge avatar
    38 posts
    Member since:
    Jul 2009

    Posted 12 Jan 2011 Link to this post

    Hello,

    At the moment i have my scheduler working, all from the server side. Recurrence is working fine as well, but i also want to "edit this occurence only" option working.

    To do this, i wanted to use the "OnRecurrenceExceptionCreated" to get it working.

    However, it seems that i cannot retrieve the updated RecurrenceRule with the Exception in it.

    I tried to make it work in the RadScheduler_AppointmentUpdate(the recurrencerule with exception) however, i cant determine in this void if there is an Recurrence exception created.

    Beneath the three classes i use in combination with customized advanced templates accorinding to youre example in the following link:
    advancedformtemplate

    I supply them all, so someone else who wants to do it all server side, can find it a bit easier then i could :)

    My Code at the moment

    Scheduler.
    <telerik:RadScheduler runat="server" ID="RadScheduler1" Width="100%" Height="100%" Enabled="false"
        DayStartTime="08:00:00" DayEndTime="22:00:00" WorkDayStartTime="08:00:00" WorkDayEndTime="22:00:00"
        FirstDayOfWeek="Monday" LastDayOfWeek="Friday" HoursPanelTimeFormat="HH:mm" ShowViewTabs="true"
        StartInsertingInAdvancedForm="true" StartEditingInAdvancedForm="true" ShowAllDayRow="false"
        Culture="nl-NL" OnDataBinding="RadScheduler1_DataBinding" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound"
        OnClientFormCreated="schedulerFormCreated" CustomAttributeNames="intSelectedProspectID,intSelectedLocID,RecurrenceRule,id_prospect,strLine1, strLine2, strLine3, strCSS, strBezichtingPand, strTelefoon1, strTelefoon2"
        EnableDescriptionField="true" AppointmentStyleMode="Default" OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" OnRecurrenceExceptionCreated="RadScheduler1_OnRecurrenceExceptionCreated"
        OnAppointmentInsert="RadScheduler1_AppointmentInsert" OnAppointmentCreated="RadScheduler1_AppointmentCreated" OnFormCreated="RadScheduler1_FormCreated">
        <AdvancedForm Modal="false" />
        <Reminders Enabled="false" />
        <AdvancedEditTemplate>
            <scheduler:AdvancedForm runat="server" ID="AdvancedEditForm1" Mode="Edit" Subject='<%# Bind("Subject") %>'
                Description='<%# Bind("Description") %>' Start='<%# Bind("Start") %>' End='<%# Bind("End") %>'
                RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' UserID='<%# Bind("intPersoneelID") %>'
                RoomID='<%# Bind("intKamerID") %>' AfspraakType='<%# Bind("intAfspraakTypeID") %>'
                ProspectID='<%# Bind("id_prospect") %>' Locatie='<%# Bind("intLocatieID") %>' />
        </AdvancedEditTemplate>
        <AdvancedInsertTemplate>
            <scheduler:AdvancedForm runat="server" ID="AdvancedInsertForm1" Mode="Insert" Subject='<%# Bind("Subject") %>'
                Start='<%# Bind("Start") %>' End='<%# Bind("End") %>' Description='<%# Bind("Description") %>'
                RecurrenceRuleText='<%# Bind("RecurrenceRule") %>' UserID='<%# Bind("intPersoneelID") %>'
                RoomID='<%# Bind("intKamerID") %>' AfspraakType='<%# Bind("intAfspraakTypeID") %>'
                ProspectID='<%# Bind("id_prospect") %>' Locatie='<%# Bind("intLocatieID") %>' />
        </AdvancedInsertTemplate>
        <AppointmentTemplate>
            <div class="rsAptSubject">
                <%# Eval("strLine1") %></div>
            <div>
                <%# Eval("strLine2") %></div>
            <div>
                <%# Eval("strLine3") %></div>
        </AppointmentTemplate>
        <TimelineView UserSelectable="false" />
        <TimeSlotContextMenuSettings EnableDefault="true" />
        <AppointmentContextMenuSettings EnableDefault="true" />
    </telerik:RadScheduler>

    Insert
    protected void RadScheduler1_AppointmentInsert(object sender, Telerik.Web.UI.SchedulerCancelEventArgs e)
    {
        try
        {
            ArrayList paramList = new ArrayList();
            paramList.Add(new SqlParameter("@afspraakdatum", Convert.ToDateTime(e.Appointment.Start.ToShortDateString() + " " + e.Appointment.Start.ToShortTimeString())));
            paramList.Add(new SqlParameter("@afspraakdatumEind", Convert.ToDateTime(e.Appointment.End.ToShortDateString() + " " + e.Appointment.End.ToShortTimeString())));
            paramList.Add(new SqlParameter("@intAfspraakTypeID", Supervisor.convInt32DBNULL(e.Appointment.Attributes["intAfspraakTypeID"])));
            paramList.Add(new SqlParameter("@strAfspraakOnderwerp", Supervisor.convStringDBNULL(e.Appointment.Subject)));
            paramList.Add(new SqlParameter("@afspraakopmerkingen", Supervisor.convStringDBNULL(e.Appointment.Description)));
            paramList.Add(new SqlParameter("@adviseur_id", Supervisor.convInt32DBNULL(e.Appointment.Attributes["intPersoneelID"])));
            paramList.Add(new SqlParameter("@fiat", fiat));
            paramList.Add(new SqlParameter("@intKamerID", Supervisor.convInt32DBNULL(e.Appointment.Attributes["intKamerID"])));
            paramList.Add(new SqlParameter("@intLocatie", Supervisor.convInt32DBNULL(e.Appointment.Attributes["intLocatieID"])));
            paramList.Add(new SqlParameter("@id_prospect", Supervisor.convInt32DBNULL(e.Appointment.Attributes["id_prospect"])));
            paramList.Add(new SqlParameter("@RecurrenceRule", Supervisor.convStringDBNULL(e.Appointment.RecurrenceRule)));
            paramList.Add(new SqlParameter("@RecurrenceParentKeyField", Supervisor.convStringDBNULL(e.Appointment.RecurrenceParentID)));
            string strSQL = "exec sp_insAfspraakFromPlan4 @afspraakdatum, @afspraakdatumEind, @intAfspraakTypeID, @strAfspraakOnderwerp, @afspraakopmerkingen, @id_prospect, @adviseur_id, @fiat, @intKamerID, @intLocatie,@RecurrenceRule,@RecurrenceParentKeyField";
            string foutmelding = MSSQL_Comm.ExecuteNonQuery(strSQL, paramList, "ConnWB");
            if (foutmelding.Length > 0)
            {
                e.Cancel = true;
                Label Label1 = new Label();
                Label1.Text = foutmelding;
                //NOT WORKING YET!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "LabelUpdated",
                    "$telerik.$('.lblError').show().animate({ opacity: 0.9 }, 2000).fadeOut('slow');", true);
            }
        }
        catch (Exception ex)
        {
            e.Cancel = true;
            Label Label1 = new Label();
            Label1.Text = ex.Message;
            //NOT WORKING YET!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "LabelUpdated",
                "$telerik.$('.lblError').show().animate({ opacity: 0.9 }, 2000).fadeOut('slow');", true);
        }
    }

    Update
    protected void RadScheduler1_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)
    {
        try
        {
            ArrayList paramList = new ArrayList();
            paramList.Add(new SqlParameter("@afspraakdatum", Convert.ToDateTime(e.ModifiedAppointment.Start.ToShortDateString() + " " + e.ModifiedAppointment.Start.ToShortTimeString())));
            paramList.Add(new SqlParameter("@afspraakdatumEind", Convert.ToDateTime(e.ModifiedAppointment.End.ToShortDateString() + " " + e.ModifiedAppointment.End.ToShortTimeString())));
            paramList.Add(new SqlParameter("@intAfspraakTypeID", Supervisor.convInt32DBNULL(e.ModifiedAppointment.Attributes["intAfspraakTypeID"])));
            paramList.Add(new SqlParameter("@strAfspraakOnderwerp", Supervisor.convStringDBNULL(e.ModifiedAppointment.Subject)));
            paramList.Add(new SqlParameter("@afspraakopmerkingen", Supervisor.convStringDBNULL(e.ModifiedAppointment.Description)));
            paramList.Add(new SqlParameter("@adviseur_id", Supervisor.convInt32DBNULL(e.ModifiedAppointment.Attributes["intPersoneelID"])));
            paramList.Add(new SqlParameter("@fiat", 1));
            paramList.Add(new SqlParameter("@intKamerID", Supervisor.convInt32DBNULL(e.ModifiedAppointment.Attributes["intKamerID"])));
            paramList.Add(new SqlParameter("@intLocatie", Supervisor.convInt32DBNULL(e.ModifiedAppointment.Attributes["intLocatieID"])));
            paramList.Add(new SqlParameter("@id_prospect", Supervisor.convInt32DBNULL(e.ModifiedAppointment.Attributes["id_prospect"])));
            paramList.Add(new SqlParameter("@id", e.ModifiedAppointment.ID));
            paramList.Add(new SqlParameter("@RecurrenceRule", Supervisor.convStringDBNULL(e.ModifiedAppointment.RecurrenceRule)));
            paramList.Add(new SqlParameter("@RecurrenceParentKeyField", Supervisor.convStringDBNULL(e.ModifiedAppointment.RecurrenceParentID)));
            string strSQL = "exec sp_updAfspraakFromPlan3 @afspraakdatum, @afspraakdatumEind, @intAfspraakTypeID, @strAfspraakOnderwerp, @afspraakopmerkingen, @id_prospect, @adviseur_id, @fiat, @intKamerID, @id, @RecurrenceRule, @RecurrenceParentKeyField";
            string foutmelding = MSSQL_Comm.ExecuteNonQuery(strSQL, paramList, "ConnWB");
            if (foutmelding.Length > 0)
            {
                e.Cancel = true;
                Label Label1 = new Label();
                Label1.Text = foutmelding;
                ScriptManager.RegisterClientScriptBlock(this, GetType(), "LabelUpdated",
                    "$telerik.$('.lblError').show().animate({ opacity: 0.9 }, 2000).fadeOut('slow');", true);
            }
        }
        catch (Exception ex)
        {
            e.Cancel = true;
            Label Label1 = new Label();
            Label1.Text = ex.Message;
            ScriptManager.RegisterClientScriptBlock(this, GetType(), "LabelUpdated",
                "$telerik.$('.lblError').show().animate({ opacity: 0.9 }, 2000).fadeOut('slow');", true);
        }
    }

    OnRecurrenceException
    protected void RadScheduler1_OnRecurrenceExceptionCreated(object sender, Telerik.Web.UI.RecurrenceExceptionCreatedEventArgs e)
    {
        int intMasterOccurrenceID = Convert.ToInt32(e.OccurrenceAppointment.ID);
        string RecurrenceRule = e.Appointment.RecurrenceRule;
        string newRecurrenceRule = "?????????????????????????????????????????????????????";
          
        e.Cancel = true;
    }

    How to make this work asap?
  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 14 Jan 2011 Link to this post

    Hi Larevenge,

    You need to handle AppointmentUpdate to get the updated recurrence rule:

    protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
       {
           //e.ModifiedAppointment.RecurrenceRule
       }


    Greetings,
    Peter
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Larevenge
    Larevenge avatar
    38 posts
    Member since:
    Jul 2009

    Posted 14 Jan 2011 Link to this post

    Yes i figured that i could do that, however, how can i determine which is an appointment that is updated from an recurrence exception because my attributes are empty in update.
  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 17 Jan 2011 Link to this post

    Hello Larevenge,

    Can you elaborate why you need the modified recurrence rule with the exceptions in OnRecurrenceExceptionCreated? Maybe we will be able to find some workaround if we know what the final goal is.

    Regards,
    Peter
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  5. Larevenge
    Larevenge avatar
    38 posts
    Member since:
    Jul 2009

    Posted 10 Mar 2011 Link to this post

    Sorry, my reaction is late, i really didnt have time in the project to keep asking about this matter.

    I want the modified recurrence rule in OnRecurrenceExceptionCreated because of this:

    When i use 'OnRecurrenceExceptionCreated', the update method is not called.
    When i dont update my appointment with the new recurrence rule, i still see the recurrence appointment next to the exception appointment.

    I just want to edit a recurrence only, i tried to use OnRecurrenceExceptionCreated to get the job done, but this doesn't supply me enough parameters, so the real question will be, is the method OnRecurrenceExceptionCreated the right one to use in this matter and even more does it has any use at all if it does not supply the new recurrence rule?
  6. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 16 Mar 2011 Link to this post

    Hello Larevenge,

    Creating exceptions is automatically handled by RadScheduler. The way this works is when you try to edit a recurring appointment, a popup dialog shows up asking the user if he wants to edit just this occurrence or the entire series. Then based on the user selection, either an exception is created or the entire series is updated.

    Can you explain what exactly you need to change of this built-in functionality?

    Regards,
    Peter
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  7. Larevenge
    Larevenge avatar
    38 posts
    Member since:
    Jul 2009

    Posted 23 Mar 2011 Link to this post

    Let me describe it one last time.

    I want to edit just this occurence and not the series.

    I catch the update in the onrecurrenceexception created.

    When i want to update, i got three appointments to get my recurrencerule with exception from:
    e.Appointment.RecurrenceRule (has the old recurrencerule, but not the new)
    e.ExceptionAppointment.RecurrenceRule (is empty)
    e.OccurrenceAppointment.RecurrenceRule (is empty)

    So what is it what i want to achieve?

    I want to INSERT a new appointment in my database, i have enough data to do this, including the recurrenceparentid, so i don't need help on this insert, it works fine!

    I want to UPDATE the recurrence appointment, and preferable the recurrencerule because it needs an 'EXC' or smth like that at the end. However i only have the normal recurrencerule without exception wich is not enough to make the series dissapear in my scheduler and to show the exception only.
  8. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 28 Mar 2011 Link to this post

    Hello Corné,
     
    I am still not sure why you cannot use AppointmentUpdate. Can you send us a code sample of your implementation?

    Kind regards,
    Peter
    the Telerik team
  9. Mike
    Mike avatar
    7 posts
    Member since:
    May 2012

    Posted 16 May 2012 Link to this post

    I have a couple issues similiar to the ones mentioned in this forum.  My Application  has a custom Object that have same fields that appointment would have.  When working with Recurrence if it has a recurrencestate.occurrence the appointment is collapsed in the scheduler.

    Also I have a seperate .aspx page that I use to insert and edit appointments I need to change the edit series to go to the page.
  10. Mike
    Mike avatar
    7 posts
    Member since:
    May 2012

    Posted 17 May 2012 Link to this post

    I've figured out the first issue it was the startdate time that was being set on the recurrenceEditor. 

    My second question is still outstanding this might be a bit clearer then what was originally posted:

    I'm using a custom aspx page and it's forward there through the OnAppointmentClick with recurrence I'm unable to tell if the event is coming from edit series or edit occurence.
Back to Top