public static void fetchFromGoogle(DateTime minTime) { Debug.Print("" + minTime); MeetingNode meeting = new MeetingNode(); FileNode file = new FileNode(); // Create Google Calendar API service. var service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); // Define parameters of request. EventsResource.ListRequest request = service.Events.List("primary"); request.TimeMin = minTime; request.TimeMax = DateTime.Now; request.ShowDeleted = false; request.SingleEvents = true; // List events. try { Events events = request.Execute(); if (events.Items != null && events.Items.Count > 0) { foreach (var eventItem in events.Items) { meeting = new MeetingNode(); string attendee = ""; string when = eventItem.Start.DateTime.ToString(); if (eventItem.Attendees != null) { EventAttendee[] attendeeData = new EventAttendee[eventItem.Attendees.Count]; eventItem.Attendees.CopyTo(attendeeData, 0); List <String> attendeelist = new List <String>(); for (int i = 0; i < eventItem.Attendees.Count; i++) { if ((attendeeData[i].DisplayName != null) && (attendeeData[i].DisplayName != "")) { attendeelist.Add(attendeeData[i].DisplayName); } } if (attendeelist.Count >= 2) { for (int i = 0; i < attendeelist.Count; i++) { attendee = attendee + attendeelist[i]; if (i != attendeelist.Count - 1) { attendee = attendee + ";"; } } } else { attendee = "N/A"; } } else { attendee = "N/A"; } meeting.SetAttendents(attendee); meeting.SetMeetingID(eventItem.Id); meeting.SetParentID(eventItem.ICalUID.ToString()); meeting.SetStartTime(when); meeting.SetEndTime(eventItem.End.DateTime.ToString()); meeting.SetMeetingTitle(eventItem.Summary); if (DateTime.Compare(meeting.GetEndTime(), DateTime.Now) <= 0) { meetingList.AddLast(meeting); } if (eventItem.Attachments != null) { for (int i = 0; i < eventItem.Attachments.Count; i++) { file = new FileNode(); file.SetModifiedTime(eventItem.Start.DateTime.ToString()); file.SetFileID(" "); file.SetExtension("GoogleDrive"); file.SetFileName(eventItem.Attachments[i].Title); file.SetFilePath(eventItem.Attachments[i].FileUrl); file.AddMeetings(eventItem.Id); file.SetMissing("No"); fileList.AddLast(file); } } } } }catch (Exception e) { MessageBox.Show("Network connection lost"); } }