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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Get the events for today scheduler control

Thread ID:

Created:

Updated:

Platform:

Replies:

144147 Apr 22,2019 01:31 PM UTC Apr 24,2019 06:31 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: Scheduler
Marco Andrade
Asked On April 22, 2019 01:31 PM UTC

Hi,

I want to create a service to trigger notifications that are scheduled from scheduler events and stored in the database. Is there any way to get the events of the day on server side? My question is more about recursive events.

Thank you

Nevitha Ravi [Syncfusion]
Replied On April 24, 2019 06:31 AM UTC

Hi Marco, 

Greetings from Syncfusion Support. 

Yes we can get the events of a particular day on server side and we have prepared sample for your reference which can be downloaded from the following link. To get the recursive events of  a date, we need to parse the recurrence rule for that please refer this kb. 

        [HttpPost] 
        public List<ScheduleEvent> LoadData([FromBody]Params param) 
        { 
            var data = _context.ScheduleEvents.ToList(); 
 
            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) 
                { 
                    TimeSpan diff = app.EndTime.Subtract(app.StartTime); 
                    var recurrenceRule = data[i].RecurrenceRule; 
                    TimeSpan startDiff; 
                    var dateCollection = RecurrenceHelper.GetRecurrenceDateTimeCollection(recurrenceRule, DateTime.Now); 
                    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 
                { 
                    appCollection.Add(app); 
                } 
            } 
            // Here we filter the today appointment from the db 
            var todayAppointmentCollection = appCollection.Where(app => (app.StartTime >= startdate && app.StartTime <= enddate)).ToList(); 
            Console.WriteLine(todayAppointmentCollection); // Now the today appointment available in todayAppointemntCollection variable. 
            return data; 
        } 
 
 
        public class Params 
        { 
            public string StartDate { get; set; } 
            public string EndDate { get; set; } 
        } 

Please try the sample and revert us back if you need any further assistance. 

Regards, 
Nevitha 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon