Esempio n. 1
0
        public List <GCalendarEventItem> EventsForCalendar(GCalendarItem calendar)
        {
            List <GCalendarEventItem> calEvents;

            events.TryGetValue(calendar, out calEvents);
            return(calEvents);
        }
Esempio n. 2
0
        public void UpdateCalendars()
        {
            CalendarQuery query;
            CalendarFeed  calendarFeed;
            GCalendarItem allEventsCal;
            Dictionary <GCalendarItem, List <GCalendarEventItem> > cals;

            query        = new CalendarQuery(FeedUri);
            cals         = new Dictionary <GCalendarItem, List <GCalendarEventItem> > ();
            allEventsCal = new GCalendarItem(AllEventsCalName, CalendarUiUrl);

            // we add this default meta-calendar which contains all events
            cals [allEventsCal] = new List <GCalendarEventItem> ();

            try {
                calendarFeed = service.Query(query);

                foreach (CalendarEntry calendar in calendarFeed.Entries)
                {
                    GCalendarItem gcal;

                    gcal        = new GCalendarItem(calendar.Title.Text, calendar.Content.AbsoluteUri);
                    cals [gcal] = UpdateEvents(gcal);
                    // append the previous calendar's events to the All Calendars calendar
                    cals [allEventsCal].AddRange(cals [gcal]);
                }
            } catch (Exception e) {
                Log.Error(ErrorInMethod, "UpdateCalendars", e.Message);
                Log.Debug(e.StackTrace);
            }

            events = new Dictionary <GCalendarItem, List <GCalendarEventItem> > (cals);
        }
Esempio n. 3
0
        public override IEnumerable <Item> Perform(IEnumerable <Item> items, IEnumerable <Item> modifierItems)
        {
            GCalendarItem cal       = modifierItems.First() as GCalendarItem;
            string        eventData = (items.First() as ITextItem).Text;

            yield return(GCalendarEventItem.NewEvent(cal, eventData));
        }
Esempio n. 4
0
        EventQuery BuildSearchQuery(GCalendarItem calendar, string needle)
        {
            EventQuery query;

            query = new EventQuery(calendar.Url);
            DateTime [] dates = ParseEventDates(needle);
            query.StartTime = dates [0];
            query.EndTime   = dates [1];
            query.Query     = ParseSearchString(needle);

            return(query);
        }
Esempio n. 5
0
        List <GCalendarEventItem> UpdateEvents(GCalendarItem calendar)
        {
            EventQuery query;
            EventFeed  eventFeed;
            List <GCalendarEventItem> events;

            query           = new EventQuery(calendar.Url);
            query.StartTime = DateTime.UtcNow;
            query.EndTime   = DateTime.Now.AddMonths(MonthsToIndex);

            events = new List <GCalendarEventItem> ();

            try {
                eventFeed = service.Query(query);

                foreach (EventEntry entry in eventFeed.Entries)
                {
                    string eventTitle, eventUrl, eventDesc, start;

                    eventTitle = entry.Title.Text;
                    eventDesc  = entry.Content.Content;
                    eventUrl   = entry.AlternateUri.Content;

                    // check if the event has associated dates
                    if (entry.Times.Any())
                    {
                        start     = entry.Times [0].StartTime.ToShortDateString();
                        eventDesc = start + " - " + eventDesc;
                    }

                    events.Add(new GCalendarEventItem(eventTitle, eventUrl, eventDesc));
                }
            } catch (Exception e) {
                Log.Error(ErrorInMethod, "UpdateEvents", e.Message);
                Log.Debug(e.StackTrace);
            }

            return(events);
        }
Esempio n. 6
0
        public GCalendarEventItem NewEvent(GCalendarItem calendar, string data)
        {
            EventEntry         entry;
            GCalendarEventItem newEvent;
            string             url, desc, title, start;

            url = desc = title = start = "";

            entry                 = new EventEntry();
            entry.QuickAdd        = true;
            entry.Content.Content = data;

            try {
                entry = service.Insert(new Uri(calendar.Url), entry);

                title = entry.Title.Text;
                desc  = entry.Content.Content;
                url   = entry.AlternateUri.Content;

                if (entry.Times.Any())
                {
                    start = entry.Times[0].StartTime.ToShortDateString();
                    desc  = start + " - " + desc;
                }
            } catch (WebException e) {
                Log.Error(ErrorInMethod, "NewEvent", e.Message);
                Log.Debug(e.StackTrace);

                return(null);
            }

            newEvent = new GCalendarEventItem(title, url, desc);
            events [calendar].Add(newEvent);

            return(newEvent);
        }
Esempio n. 7
0
 public static GCalendarEventItem NewEvent(GCalendarItem calendar, string data)
 {
     return(client.NewEvent(calendar, data));
 }
Esempio n. 8
0
 public static IEnumerable <GCalendarEventItem> EventsForCalendar(GCalendarItem calendar)
 {
     return(client.EventsForCalendar(calendar));
 }