Hi,
I wanted to know if it was possible to save past occurences of recurring event in a separate db.
Let me explain further:
If I create a weekly recurring event starting 1/10/2021, I want to make it so when each event time has passed, the event and associated invoice fields are saved in a separate invoice db table. This means for 1/10/2021 until todays date 8 occurrences will be saved in a separate db and then in the future any event will be saved to that separate db on the date of the event date.
Hi,
I have tried the above sample and one thing that I could not see is the action of saving of parsed occurances or action that helps the binding of parsed occurances to the db.
In another way, is there a way to send event data/fields to separate db table at event time or when event time has passed.
Thanks
Hi
Abdurrhmanzaki,
Thanks for the update.
We have validated your required scenario at our
end and suspect that your need is to see the action of parsed occurrences
saving to the Db and also need to send event details to the separate DB. We
have prepared a sample with service for your reference, in this sample, we have
maintained the event details in the separate DB like the below screenshot.
And also you can see the event processing the LoadData and UpdateData method of the HomeController.cs file. The sample can be viewed from the below attachment.
Kindly refer to the above solution and let us know if you need further
assistance.
Regards,
Balasubramanian S
Hi,
Thanks for previous response.
However, how is the action completed? automatically at the time of the occurrence?
Would you be able to let us know if the scheduler has a feature that generates action at occurrence time.
Hi Abdurrhmanzaki,
Thanks for the update.
Can you please check by binding the actionBegin an actionComplete event at your sample and check whether you have enough detail in their arguments?
Code snippet:
|
@using Syncfusion.EJ2.Schedule
<ejs-schedule id="schedule" height="550" actionBegin="onActionBegin" actionComplete="onActionComplete" selectedDate="new DateTime(2018, 1, 28) "> <e-schedule-eventsettings dataSource="@ViewBag.datasource"> </e-schedule-eventsettings> </ejs-schedule>
<script type="text/javascript"> function onActionBegin(args) { console.log(args); } function onActionComplete(args) { console.log(args); } </script>
|
Kindly try the above solution and let us know if you need further assistance.
Regards,
Balasubramanian S
Thanks
Balasubramanian,
Thanks your previous answer. I am aware of OnAction/actionComplete.
However, I was looking for something similar to what signalr does maybe.
or maybe reminders that are auto-triggered and show up at certain time before the appointment.
In my case I wanted to know if you have a trigger that completes my request of saving occurance data to the db in the background.
Example: Next event is 2021-12-24 11:30. and exactly on the appointment time, occurance data is saved to the db in the background.
Thanks
Just as a further info see below calendar... I want the occurances in the recurrence to automatically saved to the db...
Example below: 21-Dec @ 1:PM the occurace is triggered and is saved to the db in the background
22-Dec @1 PM the second occurance is triggered and saved to a db
in the background
and so on for all remaining occurances.
All occurances are saved automatically at the event time. This is similar to reminder but action is different.
Hi Abdurrahmanzaki,
Thanks for the details.
Currently, we are checking the possibility to prepare the sample at our end and will update the further details on December 28, 2021. We would appreciate your valuable patience.
Regards,
Balasubramanian S
Hi Abdurrahmanzaki,
Thanks for your patience.
We have prepared a sample to save the appointment occurrence in the separate DB
when the reminder popped up using the below code snippets.
Index.cshtml:
|
function refreshEventReminder() { var scheduleObj = document.querySelector('.e-schedule').ej2_instances[0]; var toastObjReminder = document.querySelector('.e-toast').ej2_instances[0]; var eventCollection = scheduleObj.getCurrentViewEvents(); eventCollection.forEach(function (event, i) { var dateFormat = function (date) { return new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds()); } var startTime = dateFormat(event[scheduleObj.eventFields.startTime]); var currentTime = dateFormat(new Date(new Date().toUTCString().slice(0, -3))); var difference = currentTime.getTime() - startTime.getTime() ; if (difference >= 0 && difference <= 10000) { console.log(event); // The reminder will be popuped based on the appointment's start time. $.ajax({ url: '/Home/UpdateReminderData', data: JSON.stringify(event), type: 'POST', async: false, traditional: true, contentType: 'application/json', success: function (data) { alert("Success") }, failure: function (data) { alert("Failure occurred") }, error: function (data) { alert("Error Occurred") } }); toastObjReminder.show({ template: (ej.base.compile(document.getElementById("reminder-template").innerHTML.trim())(event)[0]).outerHTML }); } }); } |
HomeController.cs:
|
[HttpPost] public List<ScheduleEvent> UpdateReminderData([FromBody] AppointmentData data) { DateTime startTime = Convert.ToDateTime(data.StartTime); DateTime endTime = Convert.ToDateTime(data.EndTime); ScheduleEvent appointment = new ScheduleEvent() { StartTime = startTime.ToLocalTime(), EndTime = endTime.ToLocalTime(), Subject = data.Subject, StartTimezone = data.StartTimezone, EndTimezone = data.EndTimezone, RecurrenceRule = data.RecurrenceRule }; // The occurrences of the 'Daily recurrence event' will be stored to the DB when the reminder is popup. _context.ScheduleEvents.Add(appointment); _context.SaveChanges(); return _context.ScheduleEvents.ToList(); } |
Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Schedule_with_ajax1743896789.zip
Kindly try the above solution and let us know if this is helpful.
Regards,
Balasubramanian S
Hi,
Thanks for the latest response. It is by far the closest i could get and it works with calendar page open.
I wanted to check with you oe thing. As you can see from the attached image, the notification works and it will generate the db. However, it will ONLY be done if you are on the calendar page or when you return to the page. It will not work otherwise. Is that the best option or there could be an option to make this work without having the calendar page open.
Hi,
Furthermore, further tests showed that if calendar page is not open, this action will not work and I will not get a reminder and hence nothing will be triggrered to update the db. I would greatly appreciate if we could work around to allow this fuction to work even when the calendar/scheduler is not running.
Thanks