private static void PostEvent(Lector l, CalendarService service, int year, DateTime startDay, string calendarId)
        {
            Console.WriteLine("Posting Event");
            var ev = new Event();

            var timeS = l.Start.Split(':');
            var timeE = l.End.Split(':');

            var date = startDay.AddDays(l.Day);

            // Format the date and time of the lector
            EventDateTime start = new EventDateTime();

            start.DateTime = new DateTime(year, date.Month, date.Day, int.Parse(timeS[0]), int.Parse(timeS[1]), 0);
            EventDateTime end = new EventDateTime();

            end.DateTime = new DateTime(year, date.Month, date.Day, int.Parse(timeE[0]), int.Parse(timeE[1]), 0);

            // Set event data
            ev.Start       = start;
            ev.End         = end;
            ev.Location    = l.Location;
            ev.Summary     = l.Class;
            ev.Description = l.Teacher + "\n" + l.Note;

            try
            {
                // Post event
                service.Events.Insert(ev, calendarId).Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine("You need to supply a valid CalendarID in the properties.txt file");
            }
        }
Beispiel #2
0
        private static List <Lector> GetLectors(List <HtmlNode> days)
        {
            var events = new List <Lector>();

            // Days
            for (int i = 0; i < days.Count; i++)
            {
                var es = days[i].Descendants("div")
                         .Where(node => node.GetAttributeValue("class", "")
                                .Equals("event")).ToList();

                // Events (Lectors)
                foreach (var e in es)
                {
                    var myEvent = new Lector();
                    myEvent.Class    = GetEventTitle(e);
                    myEvent.Teacher  = GetEventValue(e, "teacher");
                    myEvent.Location = GetEventValue(e, "location");
                    myEvent.Note     = GetEventValue(e, "note");
                    var time = GetEventValue(e, "time").Split(" - ");
                    myEvent.Start = time[0].Substring(5);
                    myEvent.End   = time[1];
                    myEvent.Day   = i;

                    events.Add(myEvent);
                }
            }

            return(events);
        }