I'm trying to give a client url, to add his and everyone elses event in a scheduled site.
The site works with fullcalendar.io, the client gets his url from the site.
Example URL:
http://scheduleme.catom.com/Ical/Ical.ashx?GUID=&ID=6
I Can't add .ical file by url to Google calander, but the importing works on Outlook
The .ashx looks like:
public class Ical : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
int I_ID = 0;
int user = 0;
string filename = "";
//string username = "";
string UD_GUID = context.Request.QueryString["GUID"];
if (Int32.TryParse(context.Request.QueryString["ID"], out I_ID))
{
I_ID = Convert.ToInt32(context.Request.QueryString["ID"]);
}
if (Int32.TryParse(context.Request.QueryString["user"], out user))
{
user = Convert.ToInt32(context.Request.QueryString["user"]);
}
List<IcalClass> events = new List<IcalClass>();
if (user == 1)
{
events.FillData(UD_GUID,I_ID);
filename = "my_orders_" + (events.Count > 0 ? events.First().I_Title : "");
}
else
{
events.FillData(I_ID);
filename = "all_orders_" + (events.Count > 0 ? events.First().I_Title : "");
}
//username = events.First().UD_UserName;
StringBuilder r = new StringBuilder();
r.AppendLine("BEGIN:VCALENDAR");
r.AppendLine("VERSION:2.0");
r.AppendLine("PRODID:-//Google Inc//Google Calendar 70.9054//EN");
r.AppendLine("CALSCALE:GREGORIAN");
r.AppendLine("METHOD:PUBLISH");
r.AppendLine("X-WR-CALNAME:" + filename);
foreach (IcalClass item in events)
{
r.AppendLine("BEGIN:VEVENT");
DateTime start = TimeZoneInfo.ConvertTimeToUtc(item.OD_StartDate);
DateTime end = TimeZoneInfo.ConvertTimeToUtc(item.OD_EndDate);
r.AppendLine("DTSTART:" + start.Year + start.Month.ToString().PadLeft(2, '0') + start.Day.ToString().PadLeft(2, '0') + "T" + start.Hour.ToString().PadLeft(2, '0') + start.Minute.ToString().PadLeft(2, '0') + start.Second.ToString().PadLeft(2, '0') + "Z");
r.AppendLine("DTEND:" + end.Year + end.Month.ToString().PadLeft(2, '0') + end.Day.ToString().PadLeft(2, '0') + "T" + end.Hour.ToString().PadLeft(2, '0') + end.Minute.ToString().PadLeft(2, '0') + end.Second.ToString().PadLeft(2, '0') + "Z");
string row = "SUMMARY:" + item.I_Title + "[" + item.UD_UserName + " " + item.OT_Title;
if (item.UD_UserNameService.Length > 0)
{
row += "-" + item.UD_UserNameService + "]";
}
else
{
row += "]";
}
r.AppendLine(row);
r.AppendLine("END:VEVENT");
}
r.AppendLine("END:VCALENDAR");
//context.Response.ContentType = "text/calendar; charset=utf-8";
context.Response.AddHeader("Content-type", "text/calendar; charset=utf-8");
context.Response.AddHeader("Content-Disposition", "attachment; filename=" + filename + ".ics");
context.Response.Write(r.ToString());
}
public bool IsReusable
{
get
{
return false;
}
}
}
Any suggestions?