public List <FullCalendarEvent> GetFullCalendarEvents() { int _calendarID = DataHelper.GetIntFromQueryString("calendarID", 1); int _editMode = DataHelper.GetIntFromQueryString("editMode", 0); List <SueetieCalendarEvent> _sueetieCalendarEvents = SueetieCalendars.GetSueetieCalendarEventList(_calendarID); List <FullCalendarEvent> _fullCalendarEvents = new List <FullCalendarEvent>(); foreach (SueetieCalendarEvent _sueetieCalendarEvent in _sueetieCalendarEvents) { FullCalendarEvent _fullCalendarEvent = new FullCalendarEvent { id = _sueetieCalendarEvent.EventGuid, start = _sueetieCalendarEvent.StartDateTime.ToString("MM/dd/yyyy HH:mm:ss"), end = _sueetieCalendarEvent.EndDateTime.ToString("MM/dd/yyyy HH:mm:ss"), description = _sueetieCalendarEvent.EventDescription, moreMessage = SueetieLocalizer.GetString("click_for_more"), allDay = _sueetieCalendarEvent.AllDayEvent, title = _sueetieCalendarEvent.EventTitle, url = string.IsNullOrEmpty(_sueetieCalendarEvent.Url) || _editMode > 0 ? "na" : _sueetieCalendarEvent.Url, endRepeatDate = _sueetieCalendarEvent.RepeatEndDate.ToShortDateString(), sourceContentID = _sueetieCalendarEvent.SourceContentID }; _fullCalendarEvents.Add(_fullCalendarEvent); } return(_fullCalendarEvents); }
/// <summary> Converts to reservation row. </summary> /// <param name="row"> The row. </param> /// <returns> FullCalendarEvent. </returns> private static FullCalendarEvent ConvertToReservationRow(DataRow row) { var evt = new FullCalendarEvent { id = row.Field <int>("ItemID"), itemGuid = row.Field <Guid>("ItemGuid").ToString(), moduleId = row.Field <int>("ModuleID"), moduleGuid = row.Field <Guid>("ModuleGuid").ToString(), title = row.Field <string>("Title"), description = row.Field <string>("Description"), imageName = row.Field <string>("ImageName"), start = row.Field <DateTime>("StartDate").ToString("yyyy-MM-dd HH:mm:ss.fff"), end = row.Field <DateTime>("EndDate").ToString("yyyy-MM-dd HH:mm:ss.fff"), createdDate = row.Field <DateTime>("CreatedDate").ToString("yyyy-MM-dd"), userId = row.Field <int>("UserID"), userGuid = row.Field <Guid>("UserGuid").ToString(), location = row.Field <string>("Location"), latitude = row.Field <string>("Latitude"), longitude = row.Field <string>("Longitude"), lastModUserId = row.IsNull("LastModUserID") ? null : row.Field <int?>("LastModUserID"), lastModUserGuid = row.IsNull("LastModUserGuid") ? null : row.Field <Guid>("LastModUserGuid").ToString(), allDay = false //backgroundColor = "#a00", //textColor = "#fff" }; return(evt); }
public void ProcessICalRequest(Uri iCalUri, DateTime start, DateTime end, HttpContext context) { string backColor = PageUtils.getFromForm("backColour", "white"); string textColor = PageUtils.getFromForm("textColor", "black"); int cacheMinutes = HatCMS.Tools.cachingProxy.CacheDuration_Minutes; string cacheKey = iCalUri.ToString(); DDay.iCal.IICalendarCollection calCollection; if (cacheMinutes > 0 && context.Cache[cacheKey] != null) { calCollection = (DDay.iCal.IICalendarCollection)context.Cache[cacheKey]; } else { calCollection = DDay.iCal.iCalendar.LoadFromUri(iCalUri); // -- add the data to the cache if (cacheMinutes > 0) { context.Cache.Insert(cacheKey, calCollection, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(cacheMinutes), CacheItemPriority.Normal, null); } } List <FullCalendarEvent> eventsToOutput = new List <FullCalendarEvent>(); IList <DDay.iCal.Occurrence> occurrences = calCollection.GetOccurrences <DDay.iCal.IEvent>(start, end); foreach (DDay.iCal.Occurrence occurrence in occurrences) { if (occurrence.Source is DDay.iCal.IEvent) { DDay.iCal.IEvent ievent = occurrence.Source as DDay.iCal.IEvent; if (ievent.IsActive()) // make sure the event hasn't been cancelled. { FullCalendarEvent e = new FullCalendarEvent(ievent, backColor, textColor); eventsToOutput.Add(e); } } } // foreach string json = JsonWriter.Serialize(eventsToOutput.ToArray()); context.Response.Write(json); }
public static FullCalendarEvent FromEvent(Events evt) { var fullCalendarEvent = new FullCalendarEvent { title = evt.Subject, description = evt.Description, start = evt.Start, end = evt?.End, color = evt.ThemeColor, eventID = evt.EventID, allDay = evt.IsFullDay, mealID = evt.MealID, foodItemID = evt.FoodItemID, itemType = evt.itemType, itemId = evt.itemId }; return(fullCalendarEvent); }
public List <FullCalendarEvent> GetAll() { List <FullCalendarEvent> eventsToDisplay = new List <FullCalendarEvent>(); try { String serviceAccountEmail = "*****@*****.**"; var certificate = new X509Certificate2(@"ServiceAccountPrivateKey.p12", "notasecret", X509KeyStorageFlags.Exportable); ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { Scopes = new[] { CalendarService.Scope.Calendar, CalendarService.Scope.CalendarReadonly }, User = "******", }.FromCertificate(certificate)); HttpResponseMessage msg = new HttpResponseMessage(HttpStatusCode.OK); // Create the service. var service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Calendar API Sample", }); EventsResource.ListRequest listRequest = service.Events.List("*****@*****.**"); listRequest.SingleEvents = true; var calEvents = listRequest.Execute(); foreach (Event e in calEvents.Items) { FullCalendarEvent fcEvent = new FullCalendarEvent() { Id = e.Id, Title = e.Summary, Start = e.Start.DateTime, End = e.End.DateTime, AllDay = (e.End.DateTime == null) ? true : false }; eventsToDisplay.Add(fcEvent); } } catch (System.Net.Http.HttpRequestException) { for (int i = 0; i < 7; i++) { FullCalendarEvent fcEvent = new FullCalendarEvent() { Id = i.ToString(), Title = "No Internet " + i, Start = DateTime.Now.AddDays(i), End = DateTime.Now.AddDays(i), AllDay = false }; eventsToDisplay.Add(fcEvent); } } return(eventsToDisplay); }