public void LoadCalendar(string path) { var wrapper = new ICSCalendar(); var calendar = wrapper.Get(path); Parse(calendar); }
public ActionResult icsCalendar(int eventId, string user, string cal) { ICSCalendar calInfo = CreateEventICSInfo(eventId, user, cal); string iCal = WebDev.Common.Utils.CalendarUtils.CreateICalendar(calInfo); byte[] calendarBytes = System.Text.Encoding.UTF8.GetBytes(iCal); //iCal is the calendar string return(File(calendarBytes, "text/calendar", "event.ics")); }
private ICSCalendar CreateEventICSInfo(int eventId, string user, string cal) { ICSCalendar calInfo = new ICSCalendar(); CalendarEventInfo eventInfo = GetCalendarEventInfo(eventId, user); calInfo.EventStartDateTime = eventInfo.StartTime ?? DateTime.UtcNow; calInfo.EventEndDateTime = eventInfo.EndTime ?? DateTime.UtcNow; calInfo.OrganizerName = "Rich See"; calInfo.OrganizerEmail = "*****@*****.**"; calInfo.EventDescription = eventInfo.Description; //Text to display in event info calInfo.EventSummary = eventInfo.Title; calInfo.AlarmTrigger = 30; calInfo.AlarmRepeat = 2; calInfo.AlarmDuration = 15; calInfo.AlarmDescription = eventInfo.Title; return(calInfo); }
private void Parse(ICSCalendar calendar) { Calendar.Clear(); //2017.09.01 je prvni den pocitani supportu var validCalendar = calendar.Events.Where(e => e.StartDate > new DateTime(2017, 8, 31)).OrderBy(e => e.StartDate.Year).ThenBy(e => e.StartDate.Month); foreach (ICSEvent icsEvent in validCalendar) { var supportEvent = new SupportEvent(icsEvent, Holidays.IsHoliday(icsEvent.StartDate)); var key = $"{supportEvent.Date.Year}/{supportEvent.Date.Month}"; if (!Calendar.ContainsKey(key)) { Calendar[key] = new List <SupportEvent>(); } Calendar[key].Add(supportEvent); } CalendarDefinitions = calendar.Definition; }
public static string CreateAddToCalendarUrl(ICSCalendar calendarInfo, string calendar) { StringBuilder urlBuilder = new StringBuilder(); if (calendar == "google") { //return "http://www.google.com/calendar/event?action=TEMPLATE&text=[event-title]&dates=[start-custom format='Ymd\\THi00\\Z']/[end-custom format='Ymd\\THi00\\Z']&details=[description]&location=[location]&trp=false&sprop=&sprop=name:" urlBuilder.Append("http://www.google.com/calendar/event?action=TEMPLATE&"); //urlBuilder.Append("https://calendar.google.com/calendar/r/eventedit?"); urlBuilder.Append($"text={ System.Web.HttpUtility.UrlEncode(calendarInfo.EventSummary)}"); urlBuilder.Append($"&dates={ConvertToUniversalTime(calendarInfo.EventStartDateTime)}/{ConvertToUniversalTime(calendarInfo.EventEndDateTime)}"); urlBuilder.Append($"&details={System.Web.HttpUtility.UrlEncode(calendarInfo.EventDescription)}"); urlBuilder.Append($"&location={System.Web.HttpUtility.UrlEncode(calendarInfo.EventLocation)}"); } else if (calendar == "outlook") { urlBuilder.Append(""); } return(urlBuilder.ToString()); }