Scheduler does not save custom backgrounds when exporting to iCal format.

1 Answer 42 Views
Scheduler and Reminder
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Troy asked on 29 Dec 2021, 01:07 AM

For some reason, it seems to keep saving the original items that were in the background list, such as "BUSY" or "BUSINESS", even though I've cleared the list, and added new backgrounds (with different IDs).  

So its not that the iCal export doesn't save backgrounds, it just that it doesn't seem to recognize custom backgrounds and then saves with the wrong background instead.

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 29 Dec 2021, 01:20 AM

It appears the same issue exists with custom status labels as well. 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Dec 2021, 11:28 AM
Hello, Troy,

I would like to provide some information about the default export logic that the SchedulerICalendarExporter class offers:
        protected virtual void WriteAdditionalDataForAppointment(IEvent appointment, CalObject calObject)
        {
            if (appointment == null)
            {
                return;
            }

            if (appointment.Description != null)
            {
                calObject.AddProperty(CalendarConstants.Description, CalHelper.CalTextEncode(appointment.Description));
            }

            object idObject = appointment.UniqueId.KeyValue;
            string idString = (idObject != null) ? idObject.ToString() : string.Empty;
            calObject.ReplaceProperty(CalendarConstants.UniqueId, idString);

            if (appointment.Location != null)
            {
                calObject.AddProperty(CalendarConstants.Location, appointment.Location);
            }

            calObject.AddProperty(CalendarConstants.MSStatus, CalHelper.GetAppointmentStatusName((AppointmentStatus)appointment.StatusId));

            calObject.AddProperty(CalendarConstants.Background, CalHelper.GetAppointmentBackgroundName((AppointmentBackground)appointment.BackgroundId));

            IRemindObject remindObject = appointment as IRemindObject;
            if (remindObject != null && remindObject.Reminder.HasValue && !remindObject.Dismissed)
            {
                CalObject alarmObject = new CalObject(CalendarConstants.Alarm);
                alarmObject.AddProperty(CalendarConstants.Action, CalendarConstants.DisplayValue);
                alarmObject.AddProperty(CalendarConstants.Description, "Reminder");
                alarmObject.AddProperty(CalendarConstants.Trigger, CalHelper.GetReminderString(remindObject.Reminder.Value));
                calObject.Children.Add(alarmObject);
            }
        }
        public static string GetAppointmentStatusName(AppointmentStatus status)
        {
            string name = "BUSY";
            switch (status)
            {
                case AppointmentStatus.Free:
                    name = "FREE";
                    break;
                case AppointmentStatus.Tentative:
                    name = "TENTATIVE";
                    break;
                case AppointmentStatus.Unavailable:
                    name = "UNAVAILABLE";
                    break;
            }

            return name;
        }
        public static string GetAppointmentBackgroundName(AppointmentBackground background)
        {
            string name = "BUSY";
            switch (background)
            {
                case AppointmentBackground.Anniversary:
                    name = "ANNIVERSARY";
                    break;
                case AppointmentBackground.Birthday:
                    name = "BIRTHDAY";
                    break;
                case AppointmentBackground.Business:
                    name = "BUSINESS";
                    break;
                case AppointmentBackground.Important:
                    name = "IMPORTANT";
                    break;
                case AppointmentBackground.MustAttend:
                    name = "MUSTATTEND";
                    break;
                case AppointmentBackground.NeedsPreparation:
                    name = "NEEDSPREPARATION";
                    break;
                case AppointmentBackground.Personal:
                    name = "PERSONAL";
                    break;
                case AppointmentBackground.PhoneCall:
                    name = "PHONECALL";
                    break;
                case AppointmentBackground.TravelRequired:
                    name = "TRAVELREQUIRED";
                    break;
                case AppointmentBackground.Vacation:
                    name = "VACATION";
                    break;
            }

            return name;
        }
	public enum AppointmentBackground
	{
        /// <summary>
        /// Specifies that no background fill is drawn
        /// </summary>
		None = 1,
        /// <summary>
        /// Specifies that the important type of background fill should be drawn
        /// </summary>
		Important,
        /// <summary>
        /// Specifies that the business type background fill should be drawn
        /// </summary>
		Business,
        /// <summary>
        /// Specifies that the personal type of background fill should be drawn
        /// </summary>
		Personal,
        /// <summary>
        /// Specifies that vacation type of background fill should be drawn
        /// </summary>
		Vacation,
        /// <summary>
        /// Specifies that the MustAttend type of background fill should be drawn
        /// </summary>
		MustAttend,
        /// <summary>
        /// Specifies that the TravelRequired type of background fill should be drawn
        /// </summary>
		TravelRequired,
        /// <summary>
        /// Specifies that the NeedsPreparation type of background fill should be drawn
        /// </summary>
		NeedsPreparation,
        /// <summary>
        /// Specifies that the Birthday type of background fill should be drawn
        /// </summary>
		Birthday,
        /// <summary>
        /// Specifies that the Anniversary type of background fill should be drawn
        /// </summary>
		Anniversary,
        /// <summary>
        /// Specifies that the PhoneCall type of background fill should be drawn
        /// </summary>
		PhoneCall
	}
	public enum AppointmentStatus
	{
        /// <summary>
        /// Specifies that the status of an appointment is Free
        /// </summary>
		Free = 1,
        /// <summary>
        ///  Specifies that the status of an appointment is Busy
        /// </summary>
		Busy,
        /// <summary>
        ///  Specifies that the status of an appointment is Unavailable
        /// </summary>
		Unavailable,
        /// <summary>
        ///  Specifies that the status of an appointment is Tentative
        /// </summary>
		Tentative
	}

In the WriteAdditionalDataForAppointment method both, StatusId and BackgroundId are converted to AppointmentStatus and AppointmentBackground respectively. If you use a custom status/background, the ID wouldn't be available in the respective enum. Hence, the default value will be exported. This behavior is expected.

If you want to export the custom status/background, it would be necessary to create a derivative of the SchedulerICalendarExporter class and override its WriteAdditionalDataForAppointment method. You can refer to the above default logic and adjust this part of the method that adds the status/background to the cal object according to the custom requirement you have.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Troy
Top achievements
Rank 3
Bronze
Iron
Iron
commented on 29 Dec 2021, 06:31 PM

Dess,

Thanks for the reply. I've already done as you mentioned with overriding the WriteAdditionalDataForAppointment method and have what I want working. 

It just seems broken that you allow native methods for overwriting the collections, but then don't use those new values when you export.  Seems as though you could change to use the new collection data as all of the information you need is in those collections, instead of using the static values used now.  

Anyway, I see it as a bug, but maybe you can see it as a requested enhancement? =)

 

Dess | Tech Support Engineer, Principal
Telerik team
commented on 30 Dec 2021, 07:48 AM

Hi, Troy,

I am glad that the previously suggested approach helped you for achieving the custom requirement that you have.

Indeed, the SchedulerICalendarExporter is purposed to export these statuses and backgrounds that are available by default. For any custom added statuses/backgrounds, it is necessary to adopt the SchedulerICalendarExporter and cover these cases. To be honest, this is the first time we have such a request for the export functionality in RadScheduler. If we have similar requests from other customers, we will consider it in the future improvement of the control.
Tags
Scheduler and Reminder
Asked by
Troy
Top achievements
Rank 3
Bronze
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or