We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

MySQL View or stored procedure for getting list of recurring events

Hello,

is there a MySQL script for View or for a Stored Procedure to get the list of events, that were added as recurring events, between 2 dates just like we get in the Schedule control so that we can use this data in other places, like grid control or in reports?


3 Replies

RM Ruksar Moosa Sait Syncfusion Team October 12, 2022 07:41 AM UTC

Hi Davor,


We have checked on your query and let you know that currently we do not have MYSQL view or stored procedure to get the recurring events between the two dates. We only have parser in Typescript and C#.


https://www.syncfusion.com/kb/13184/how-to-parse-the-recurrence-rule-rrule-in-server-side

https://www.syncfusion.com/kb/10009/how-to-parse-the-recurrencerule-at-server-side

https://www.syncfusion.com/kb/5391/how-to-parse-the-recurrencerule-in-server-side


Kindly refer to the shared Knowledge base links for more information on parsing the Recurrence Rule.


Regards,

Ruksar Moosa Sait




DA Davor October 12, 2022 10:07 PM UTC

Thank you Ruksar for your response.

In this case, this control is useless and a waste of time if we cannot use the data saved from that control in other parts of the application?



VD Vinitha Devi Murugan Syncfusion Team October 14, 2022 01:23 PM UTC

Hi Daver,


Sorry for the inconvenience.


We have validated your reported query “to get the list of events, that were added as recurring events, between 2 dates just like we get in the Schedule control so that we can use this data in other places, like grid control or in reports” at our end. To get the recurrence events of a date range, we need to parse the recurrence rule using recurrence helper file like below. Please refer this kb to know more about how to parse recurrence rule at server end.


       [HttpPost] 

        public List<ScheduleEvent> LoadData([FromBody]Params param) 

        { 

            var data = _context.ScheduleEvents.ToList(); // get events from database

 

            DateTime startdate = DateTime.Today; 

            DateTime enddate = startdate.AddDays(1); 

            List<ScheduleEvent> appCollection = new List<ScheduleEvent>(); 

            for (var i = 0; i < data.Count; i++) 

            { 

                var app = data[i]; 

                if (data[i].RecurrenceRule != null)  // If recurrene event generate occurrence from parent

                { 

                    TimeSpan diff = app.EndTime.Subtract(app.StartTime); 

                    var recurrenceRule = data[i].RecurrenceRule; 

                    TimeSpan startDiff; 

                    var dateCollection = RecurrenceHelper.GetRecurrenceDateTimeCollection(recurrenceRule, DateTime.Now); // Here we generated occurrence from recurrence using recurrence helper file

                    foreach (var date in dateCollection) 

                    { 

                        startDiff = app.StartTime.Subtract(date); 

                        break; 

                    } 

                    foreach (var date in dateCollection) 

                    { 

                        var start = date.Add(startDiff); 

                        var end = start.Add(diff); 

                        appCollection.Add(new ScheduleEvent { Subject = app.Subject, StartTime = start, EndTime = end, CategoryId = app.CategoryId, Description = app.Description, IsAllDay = app.IsAllDay, RecurrenceRule = app.RecurrenceRule, Location = app.Location, ProjectId = app.ProjectId, StartTimezone = app.StartTimezone, EndTimezone = app.EndTimezone, Id = app.Id }); 

                    } 

                } 

                else // If normal events directly add it in to app collection

                { 

                    appCollection.Add(app); 

                } 

            } 

            // Here we filter the today appointment from the appCollection

            var todayAppointmentCollection = appCollection.Where(app => (app.StartTime >= startdate && app.StartTime <= enddate)).ToList(); 

            Console.WriteLine(todayAppointmentCollection); // Now the today appointment available in todayAppointemntCollection variable. You can assign this as datasource in other places

            return data; 

        } 

 

 

        public class Params 

        { 

            public string StartDate { getset; } 

            public string EndDate { getset; } 

        } 

 


Also, we already discussed the same query in below forum. Please refer it.


https://www.syncfusion.com/forums/144147/get-the-events-for-today-scheduler-control


To know more about how to perform CRUD actions on Scheduler with Db, we suggest you to refer below UG and forum links.


https://ej2.syncfusion.com/documentation/schedule/data-binding/#scheduler-crud-actions

https://www.syncfusion.com/forums/159099/connect-schedule-with-mysql


Kindly try with the above solution and get back to us if you need any further assistance


Regards,

Vinitha


Loader.
Live Chat Icon For mobile
Up arrow icon