This is a migrated thread and some comments may be shown as answers.

ICS Exporting Descriptions

5 Answers 97 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Brian Mains
Top achievements
Rank 1
Brian Mains asked on 29 Dec 2008, 08:56 PM
Hello,

This is probably an ICS definition thing, but is it possible for the Scheduler to export a description for each appointment?  When you open up the appointment in excel, it has no description and it would be great to be able to export one.  Is this supported by the scheduler?  Is it even supported by ICS, and if it can be supported by ICS and is not currently by the Scheduler, do you plan on doing so in a future release?

Thanks.

5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 30 Dec 2008, 01:46 PM

Currently, the ExportToICalendar method of the RadScheduler class extracts only start time, end time and subject of the appointment. I will forward your inquiry to our development team to consider it and see if it is possible to extend the current functionality to include custom attributes as well. Thanks for asking this question.


Kind regards,
Peter
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Clyde
Top achievements
Rank 1
answered on 26 Jan 2009, 09:08 PM
I am also looking for this functionality and appreciate you forwarding it to the developers. You have my vote on implementing it, it would make the ICS export much more useful.

Thanks
Clyde
0
Charles
Top achievements
Rank 1
answered on 16 Apr 2009, 03:01 PM
Has there been any development on this topic? I really need a more flexible/robust means of exporting data.
0
Clyde
Top achievements
Rank 1
answered on 17 Apr 2009, 02:39 AM

Charles,

 

I went about creating a method that would work without the limitations. Here is my code taken from some of the samples I found as well as some back engineering of some existing iCalendar files I had. This is specific to my application but you should be able to modify it for your own. It loads custom content into the description field, sets the priority, the alarm, modifies the subject line and adds information into the location line.

One thing to note is that you need to replace all LF & CR characters in your description field as it considers it the end of the field when it hits a CR. See my example of the characters I replaced it with.

 

It all seems to be working pretty well, only did it this week so still want to enhance further. Need a variable for the PRIORITY as well as the TRIGGER minutes. For now it's set to High, 1 Day alarm in advance. This only exports one appointment, but it can be modified to do all.

Oh and it also takes into consideration the UTC offset which is a must if you want your times to be accurate.

Give it a try and let me know if you have any issues,

 

Clyde

 

    protected void RadScheduler1_AppointmentCommand(object sender, AppointmentCommandEventArgs e)  
    {  
        if (e.CommandName == "Export")  
        {  
            //DateTime aptStart = DateTime.SpecifyKind(e.Container.Appointment.Start, DateTimeKind.Local);  
            //TimeSpan currentOffset = TimeZone.CurrentTimeZone.GetUtcOffset(aptStart);  
            //WriteCalendar(RadScheduler.ExportToICalendar(e.Container.Appointment, currentOffset));    
 
            // Write out custom export to iCalendar - Telerik cannot include descriptions  
            WriteCalendar(CreateEventExport(e));  
 
        }  
    }  
 
    private void WriteCalendar(string data)  
    {  
        HttpResponse response = Page.Response;  
 
        response.Clear();  
        response.Buffer = true;  
 
        response.ContentType = "text/calendar";  
        response.ContentEncoding = Encoding.UTF8;  
        response.Charset = "utf-8";  
 
        response.AddHeader("Content-Disposition""attachment;filename=\"iCalendarExport.ics\"");  
 
        response.Write(data);  
        response.End();  
    }  
 
    protected string CreateEventExport(AppointmentCommandEventArgs e)  
    {  
        string data = "";  
        e.Container.Appointment.Subject = thisSite.CustomerName.Trim() + " - " + e.Container.Appointment.Subject;  
        DateTime aptStart = DateTime.SpecifyKind(e.Container.Appointment.Start, DateTimeKind.Local);  
        TimeSpan currentOffset = TimeZone.CurrentTimeZone.GetUtcOffset(aptStart);  
        e.Container.Appointment.Start = e.Container.Appointment.Start.Subtract(currentOffset);  
        e.Container.Appointment.End = e.Container.Appointment.End.Subtract(currentOffset);  
        COMWebDB.EventX thisEvent = new EventX(e.Container.Appointment.ID);  
        if (!thisEvent.IsNew)  
        {  
            string eventLocation = "";  
            if (thisEvent.LocationID > 0)  
            {  
                COMWebDB.EventsLocation thisEventsLocation = new EventsLocation(thisEvent.LocationID);  
                if (!thisEventsLocation.IsNew)  
                {  
                    eventLocation = thisEventsLocation.Name + " - " + thisEventsLocation.Address1 + ", " +  
                                    thisEventsLocation.City + ", " + thisEventsLocation.State + " " +  
                                    thisEventsLocation.Zip;  
                }  
            }  
            data = "BEGIN:VCALENDAR" + "\r\n";  
            //data += "PRODID:-//Microsoft Corporation//Outlook 11.0 MIMEDIR//EN" + "\r\n";  
            data += "PRODID:-//Telerik Inc.//NONSGML RadScheduler//EN\r\n";  
            data += "VERSION:2.0" + "\r\n";  
            data += "METHOD:PUBLISH" + "\r\n";  
            data += "BEGIN:VEVENT" + "\r\n";  
            data += "DTSTAMP:" + e.Container.Appointment.Start.Year + "" + e.Container.Appointment.Start.Month.ToString("D2") + "" +  
                    e.Container.Appointment.Start.Day.ToString("D2") + "T" + e.Container.Appointment.Start.Hour.ToString("D2") + "" +  
                    e.Container.Appointment.Start.Minute.ToString("D2") + "" + e.Container.Appointment.Start.Second.ToString("D2") + "Z\r\n";  
            data += "DTSTART:" + e.Container.Appointment.Start.Year + "" + e.Container.Appointment.Start.Month.ToString("D2") + "" +  
                    e.Container.Appointment.Start.Day.ToString("D2") + "T" + e.Container.Appointment.Start.Hour.ToString("D2") + "" +  
                    e.Container.Appointment.Start.Minute.ToString("D2") + "" + e.Container.Appointment.Start.Second.ToString("D2") + "Z\r\n";  
            data += "DTEND:" + e.Container.Appointment.End.Year + "" + e.Container.Appointment.End.Month.ToString("D2") + "" + e.Container.Appointment.End.Day.ToString("D2") +  
                    "T" + e.Container.Appointment.End.Hour.ToString("D2") + "" + e.Container.Appointment.End.Minute.ToString("D2") + "" +  
                    e.Container.Appointment.End.Second.ToString("D2") + "Z\r\n";  
            data +=  
                "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + thisEvent.Description.Replace(System.Environment.NewLine, "=0D=0A") + "\r\n";  
            data += "LOCATION;ENCODING=QUOTED-PRINTABLE:" + eventLocation + "\r\n";  
            data += "SUMMARY;ENCODING=QUOTED-PRINTABLE:" + e.Container.Appointment.Subject + "\r\n";  
            data += "PRIORITY:1" + "\r\n";  
            data += "UID: " + e.Container.Appointment.ID + "\r\n";  
            data += "SEQUENCE:0" + "\r\n";  
            data += "BEGIN:VALARM" + "\r\n";  
            data += "TRIGGER:-PT1440M" + "\r\n";  
            data += "ACTION:DISPLAY" + "\r\n";  
            data += "DESCRIPTION:Reminder" + "\r\n";  
            data += "END:VALARM" + "\r\n";  
            data += "STATUS:CONFIRMED" + "\r\n";  
            data += "END:VEVENT" + "\r\n";  
        }  
        return data;  
    } 
0
bad nick
Top achievements
Rank 1
answered on 07 Jan 2010, 02:21 PM
I used a very simple approach by "overloading" ExportToICalendar method:

/// <summary> 
/// Extends telerik's ExportToICalendar to include Location and Notes 
/// </summary> 
/// <param name="app">Telerik Appointment object</param> 
/// <returns>iCalendar 2.0 formatted data string</returns> 
public string ExportToICalendar(Appointment app) 
    // Call Telerik's method to get the iCalendar data 
    string data = RadScheduler.ExportToICalendar(app); 
    string extraData = string.Empty; 
    // Add Location and Description attributes 
    if (!string.IsNullOrEmpty(app.Attributes["Location"])) 
    { 
        extraData += string.Format("LOCATION:{0}\r\n", app.Attributes["Location"]); 
    } 
    if (!string.IsNullOrEmpty(app.Description)) 
    { 
        extraData += string.Format("DESCRIPTION:{0}\r\n", app.Description); 
    } 
 
    if (extraData.Length > 0) 
    { 
        // "Insert" the additional data 
        data = data.Replace("BEGIN:VEVENT\r\n""BEGIN:VEVENT\r\n" + extraData); 
    } 
 
    return data; 

Description comes out from Appointment's property and
Location , or any other custom data can be stored in Telerik's Appointment entity's attributes. In fact, you can write a proper Extension Method if you use .NET 3.0 or higher.

Hope this helps.
Tags
Scheduler
Asked by
Brian Mains
Top achievements
Rank 1
Answers by
Peter
Telerik team
Clyde
Top achievements
Rank 1
Charles
Top achievements
Rank 1
bad nick
Top achievements
Rank 1
Share this question
or