public async Task <IEnumerable <Event> > GetEvents() { // Define parameters of request. CalendarListResource.ListRequest calendarRequest = service.CalendarList.List(); var calendars = await calendarRequest.ExecuteAsync(); List <Event> allEvents = new List <Event>(); foreach (var calendar in calendars.Items.Where(item => item.Selected ?? false)) { EventsResource.ListRequest request = service.Events.List(calendar.Id); request.TimeMin = DateTime.Now.Date; request.TimeMax = DateTime.Now.Date.AddDays(1); request.ShowDeleted = false; request.SingleEvents = true; request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; Events events = await request.ExecuteAsync(); if (events.Items != null) { allEvents.AddRange(events.Items); } } return(allEvents); }
async Task UpdateCalendarListUI() { CalendarListResource.ListRequest listRequest = this.service.CalendarList.List(); this.calendarList = await listRequest.ExecuteAsync(); this.ricbCalendarList.Items.Clear(); foreach (CalendarListEntry item in this.calendarList.Items) { this.ricbCalendarList.Items.Add(item.Summary); } if (!String.IsNullOrEmpty(this.activeCalendarId)) { CalendarListEntry itemToSelect = this.calendarList.Items.FirstOrDefault(x => x.Id == this.activeCalendarId); this.dxGoogleCalendarSync.CalendarId = this.activeCalendarId; if (this.ricbCalendarList.Items.Contains(itemToSelect.Summary)) { this.beiCalendarList.EditValue = itemToSelect.Summary; } else { this.activeCalendarId = String.Empty; } } UpdateBbiAvailability(); }
// Just loops though getting all the rows. private CalendarList ProcessResults(CalendarListResource.ListRequest request) { var result = request.Execute(); var allRows = new List <CalendarListEntry>(); //// Loop through until we arrive at an empty page while (result.Items != null) { //Add the rows to the final list allRows.AddRange(result.Items); // We will know we are on the last page when the next page token is // null. // If this is the case, break. if (result.NextPageToken == null) { break; } // Prepare the next page of results request.PageToken = result.NextPageToken; // Execute and process the next page request result = request.Execute(); } var allData = result; allData.Items = allRows; return(allData); }
public async Task <Calendar[]> GetCalendarsAsync() { if (service == null) { return(new Calendar[0]); } CalendarListResource.ListRequest req = service.CalendarList.List(); req.ShowDeleted = false; CalendarList src = await req.ExecuteAsync(); var dst = new Calendar[src.Items.Count]; for (int i = 0; i < src.Items.Count; i++) { var calendar = src.Items[i]; Color col; col.A = 255; col.R = Convert.ToByte(calendar.BackgroundColor.Substring(1, 2), 16); col.G = Convert.ToByte(calendar.BackgroundColor.Substring(3, 2), 16); col.B = Convert.ToByte(calendar.BackgroundColor.Substring(5, 2), 16); dst[i] = new Calendar() { color = col, id = calendar.Id, name = String.IsNullOrEmpty(calendar.SummaryOverride) ? calendar.Summary : calendar.SummaryOverride, isHidden = false }; } return(dst); }
public static void CreateGoogleCalendarEvent(string title, DateTime startTime, DateTime endTime, string calendar) { AuthorizeGoogleCalendar(); CalendarListResource.ListRequest calRequest = calendarService.CalendarList.List(); calRequest.MinAccessRole = CalendarListResource.ListRequest.MinAccessRoleEnum.Owner; CalendarList calendars = calRequest.Execute(); CalendarListEntry reminderCalendar = calendars.Items.Where(p => p.Summary == calendar).FirstOrDefault(); Event newReminderEvent = new Event() { Summary = title }; newReminderEvent.Start = new EventDateTime() { DateTime = startTime }; newReminderEvent.End = new EventDateTime() { DateTime = endTime }; EventsResource.InsertRequest createRequest = calendarService.Events.Insert(newReminderEvent, reminderCalendar.Id); createRequest.Execute(); }
/// <summary> /// Retorna Todos os Calendarios Disponiveis para Sua Conta /// </summary> /// <returns>Lista de Calendarios</returns> public List <Calendario> ListarCalendarios() { try { List <Calendario> retorno = new List <Calendario>(); Calendario calendario; CalendarService service = _Autenticacao.Autenticar(); CalendarListResource.ListRequest lista = service.CalendarList.List(); CalendarList clist = lista.Execute(); for (int i = 0; i < clist.Items.Count; i++) { calendario = new Calendario(); calendario.Id = clist.Items[i].Id; calendario.Nome = clist.Items[i].Summary; calendario.Descricao = clist.Items[i].Description; retorno.Add(calendario); } return(retorno); } catch (Exception ex) { throw new Exception(ex.Message); } }
public CalendarList GetGoogleCalendars(string account) { CalendarListResource.ListRequest request = GetService(account).CalendarList.List(); CalendarList x = request.Execute(); return(x); }
private static string GetMainCalendarId(CalendarService service) { var calendarListRequest = new CalendarListResource.ListRequest(service); var calendars = calendarListRequest.Execute(); var result = calendars.Items.First().Id; return(result); }
public static string GetCalendarIdForName(this CalendarService service, string name) { CalendarListResource.ListRequest listRequest = service.CalendarList.List(); CalendarList calendarList = listRequest.Execute(); CalendarListEntry entry = calendarList.Items?.FirstOrDefault(e => e.Summary == name); return(entry?.Id); }
private static CalendarListEntry GetCalendarListEntry(CalendarService service) { CalendarListResource.ListRequest calendarListRequest = service.CalendarList.List(); CalendarList calendarList = calendarListRequest.Execute(); CalendarListEntry dienstplan = calendarList.Items.FirstOrDefault(x => x.Summary == _calendarName); return(dienstplan); }
public void Delete(int id) { using (var context = new DbGoogleContext()) { var credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = "491606904456-nr7nscjo3l75na40kq939t35fd55i9o7.apps.googleusercontent.com", ClientSecret = "xhc5pCiEoW54ch7aF_J8Ah69", }, new[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None).Result; try { var service = new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = "Calendar API Realtor", }); CalendarListResource.ListRequest cal = service.CalendarList.List(); cal.MaxResults = 100; var calresult = cal.Execute().Items; foreach (CalendarListEntry entry in calresult) { EventsResource.ListRequest request = service.Events.List(entry.Id); request.TimeMin = Convert.ToDateTime("03/01/2019"); request.ShowDeleted = false; request.SingleEvents = true; request.MaxResults = 200; request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; Events eventss = request.Execute(); } var eid = new DbGoogleContext().Content.Where(d => d.Id == id).FirstOrDefault().EventId; String calendarId = "*****@*****.**"; String eventId = eid; var delCal = service.Events.Delete(calendarId, eventId); delCal.SendNotifications = true; delCal.Execute(); var removes = context.Content.Where(s => s.Id == id).FirstOrDefault(); context.Content.Remove(removes); context.SaveChanges(); } catch (Exception e) { throw e; } } }
public override object GetCalendarList() { try { CalendarListResource.ListRequest req = CalendarService.CalendarList.List(); return(req.Execute()); } catch (Exception ex) { return(ex); } }
private void btnGetCalendars_Click(object sender, EventArgs e) { CalendarListResource.ListRequest callist = CalendarService.CalendarList.List(); CalendarList list = callist.Execute(); dgvFromCalendars.AutoGenerateColumns = true; dgvFromCalendars.DataSource = list.Items.Select(o => new { o.Id, o.Summary, o.Description }).ToList(); dgvToCalendars.DataSource = list.Items.Select(o => new { o.Id, o.Summary, o.Description }).ToList(); btnCopyEvents.Enabled = tbSearchFilter.Enabled = tbReplace.Enabled = startDate.Enabled = endDate.Enabled = true; lblInfo.Text = "Double click calendar to preview events with filters. Select Source (left) and Destination (right) calendar and click 'Copy Events'"; }
private static string getLifeCoachCalendarId(CalendarService service, string calendarName) { CalendarListResource.ListRequest listRequest = service.CalendarList.List(); var calendarList = listRequest.Execute(); foreach (var calendar in calendarList.Items) { if (calendar.Summary == calendarName) { return(calendar.Id); } } return(null); }
async protected override void OnLoad(EventArgs e) { base.OnLoad(e); CalendarListResource.ListRequest listRequest = Service.CalendarList.List(); var calendarList = await listRequest.ExecuteAsync(); this.lookUpEdit1.Properties.DataSource = calendarList.Items; this.lookUpEdit1.Properties.DisplayMember = "Summary"; this.lookUpEdit1.Properties.ValueMember = "Id"; this.lookUpEdit1.Properties.Columns.Clear(); this.lookUpEdit1.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("Summary")); this.lookUpEdit1.EditValue = CalendarId; this.lookUpEdit1.EditValueChanged += OnLookUpEdit1EditValueChanged; }
public async Task <CalendarList> GetCalendarList() { var service = new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = ServiceAccount.Instance.Credential, ApplicationName = "Calendar API Sample" }); CalendarListResource.ListRequest request = service.CalendarList.List(); request.MaxResults = 100; request.ShowDeleted = false; request.ShowHidden = false; return(ProcessListResults(request)); }
private void StartUpdatingCalendarList() { SharedCalendarEntryList.Clear(); if (ApplicationName.Length == 0) { return; } if (CredentialToken == null) { ObtainCredentialToken(false); } if (CredentialToken == null) { return; } try { // Create Google Calendar API service. using CalendarService service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = CredentialToken, ApplicationName = ApplicationName }); // Define parameters of requestCalendarList. CalendarListResource.ListRequest requestCalendarList = service.CalendarList.List(); requestCalendarList.ShowDeleted = false; requestCalendarList.MaxResults = 10; // List events. ListTaskCancellation = new CancellationTokenSource(); ListTask = requestCalendarList.ExecuteAsync(ListTaskCancellation.Token); IsListing = true; IsListingCancelable = true; ListTimer.Change(ListTimerStart, ListTimerInterval); } catch { } }
public CalendarList getCalendars() { CalendarList cl = new CalendarList(); CalendarList clr = new CalendarList(); clr.Items = new List <CalendarListEntry>(); CalendarListResource.ListRequest request = service.CalendarList.List(); try { cl = request.Execute(); } catch (Exception e) { } for (int i = 0; i < cl.Items.Count; i++) { if (cl.Items[i].AccessRole == "owner" || cl.Items[i].AccessRole == "writer") { clr.Items.Add(cl.Items[i]); } } return(clr); }
// Just loops though getting all the rows. private static CalendarList ProcessResults(CalendarListResource.ListRequest request) { try { CalendarList result = request.Execute(); List <CalendarListEntry> allRows = new List <CalendarListEntry>(); //// Loop through until we arrive at an empty page while (result.Items != null) { //Add the rows to the final list allRows.AddRange(result.Items); // We will know we are on the last page when the next page token is // null. // If this is the case, break. if (result.NextPageToken == null) { break; } // Prepare the next page of results request.PageToken = result.NextPageToken; // Execute and process the next page request result = request.Execute(); } CalendarList allData = result; allData.Items = (List <CalendarListEntry>)allRows; return(allData); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
/// <summary> /// Get the list of calendars in the Google account /// </summary> /// <param name="owner">Accoutn to return list of calendars for</param> /// <returns>List of google calendar names and id's associated with the Google account</returns> public static CalendarListItem[] GetCalendars(string owner) { log.Info("Starting Retrieval of Google Calendars for " + owner); CalendarListItem[] lstCalendars = new CalendarListItem[0]; CalendarListResource.ListRequest request = GetCalendarService(owner).CalendarList.List(); request.ShowDeleted = false; request.ShowHidden = false; request.MaxResults = 20; CalendarList calendars = request.Execute(); if (calendars.Items != null && calendars.Items.Count > 0) { lstCalendars = new CalendarListItem[calendars.Items.Count]; int count = 0; foreach (var calItem in calendars.Items) { string calId = calItem.Id.ToString(); string calName = calItem.Summary.ToString(); CalendarListItem item = new CalendarListItem(); item.Text = calName; item.Value = calId; lstCalendars[count] = item; count++; } } log.Info("Finished Retrieval of Google Calendars for " + owner); return(lstCalendars); }
public static async Task <int> GetNumberOfCalendars() { int numberOfCalendars = 0; UserCredential credential; using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read)) { // The file token.json stores the user's access and refresh tokens, and is created // automatically when the authorization flow completes for the first time. string credPath = "token.json"; credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; Console.WriteLine("Credential file saved to: " + credPath); } // Create Google Calendar API service. var service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); //var service = new DiscoveryService(new BaseClientService.Initializer() //{ //ApplicationName = ApplicationName, //HttpClientInitializer = credential //}); // Define parameters of request. //EventsResource.ListRequest request = service.Events.List("primary"); CalendarListResource.ListRequest request = service.CalendarList.List(); //var request = service.Apis.List().Execute(); //request.TimeMin = DateTime.Now; //request.ShowDeleted = false; //request.SingleEvents = true; //request.MaxResults = 10; //request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; // List events. //Events events = request.Execute(); //Console.WriteLine("Upcoming events:"); var calendars = await request.ExecuteAsync(); Console.WriteLine("Calendar Names"); if (calendars.Items != null) { numberOfCalendars = calendars.Items.Count; foreach (var item in calendars.Items) { Console.WriteLine($"{item.Id} - {item.Summary}"); } } //if (events.Items != null && events.Items.Count > 0) //{ //foreach (var eventItem in events.Items) //{ //string when = eventItem.Start.DateTime.ToString(); //if (String.IsNullOrEmpty(when)) //{ //when = eventItem.Start.Date; //} //Console.WriteLine("{0} ({1})", eventItem.Summary, when); //} //} //else //{ //Console.WriteLine("No upcoming events found."); //} //Console.Read(); return(numberOfCalendars); }
public bool Post([FromBody] Content val) { bool state = false; using (var context = new DbGoogleContext()) { var credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = "491606904456-nr7nscjo3l75na40kq939t35fd55i9o7.apps.googleusercontent.com", ClientSecret = "xhc5pCiEoW54ch7aF_J8Ah69", }, new[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None).Result; try { var service = new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = "Calendar API Realtor", }); CalendarListResource.ListRequest cal = service.CalendarList.List(); cal.MaxResults = 100; var calresult = cal.Execute().Items; foreach (CalendarListEntry entry in calresult) { EventsResource.ListRequest request = service.Events.List(entry.Id); request.TimeMin = Convert.ToDateTime("03/01/2015"); request.ShowDeleted = false; request.SingleEvents = true; request.MaxResults = 200; request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; Events events = request.Execute(); } DateTime sDate = val.Start; DateTime eDate = val.End; var myEvent = new Event { Id = val.EventId, Summary = val.Title, Description = val.Description, Location = "Thailand", Start = new EventDateTime() { DateTime = sDate, TimeZone = "Asia/Colombo", }, End = new EventDateTime() { DateTime = eDate, TimeZone = "Asia/Colombo", }, Attendees = new EventAttendee[] { new EventAttendee() { Email = "*****@*****.**" }, new EventAttendee() { Email = "*****@*****.**" }, }, Reminders = new Event.RemindersData() { UseDefault = false, Overrides = new EventReminder[] { new EventReminder() { Method = "email", Minutes = 24 * 60 }, new EventReminder() { Method = "popup", Minutes = 10 }, } } }; String calendarId = "*****@*****.**"; EventsResource.InsertRequest singleEvent = service.Events.Insert(myEvent, calendarId); singleEvent.SendNotifications = true; singleEvent.Execute(); } catch (Exception e) { Console.WriteLine(e); } context.Content.Add(val); context.SaveChanges(); state = true; } return(state); }
public async Task <IActionResult> PutValues(int id, Content vals) { using (var context = new DbGoogleContext()) { var credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = "491606904456-nr7nscjo3l75na40kq939t35fd55i9o7.apps.googleusercontent.com", ClientSecret = "xhc5pCiEoW54ch7aF_J8Ah69", }, new[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None).Result; try { var service = new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = credential, ApplicationName = "Calendar API Realtor", }); CalendarListResource.ListRequest cal = service.CalendarList.List(); cal.MaxResults = 100; var calresult = cal.Execute().Items; // List<EventDetails> ed = new List<EventDetails>(); foreach (CalendarListEntry entry in calresult) { EventsResource.ListRequest request = service.Events.List(entry.Id); request.TimeMin = Convert.ToDateTime("03/01/2019"); request.ShowDeleted = false; request.SingleEvents = true; request.MaxResults = 200; request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; // List events. Events eventss = request.Execute(); } var eid = new DbGoogleContext().Content.Where(d => d.Id == id).FirstOrDefault().EventId; String calendarId = "*****@*****.**"; String eventId = eid; // var eventslist = service.Events.List(calendarId); var events = service.Events.Get(calendarId, eventId).Execute(); DateTime ssDate = vals.Start; DateTime esDate = vals.End; Event ev = new Event { Summary = vals.Title, Id = vals.EventId, Description = vals.Description, Start = new EventDateTime() { DateTime = ssDate, TimeZone = "Asia/Colombo", }, End = new EventDateTime() { DateTime = esDate, TimeZone = "Asia/Colombo", } }; //string FoundEventID = events.Id; var updateCal = service.Events.Patch(ev, calendarId, eventId); updateCal.SendNotifications = true; updateCal.Execute(); context.Entry(vals).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Content(id)) { return(NotFound()); } else { throw; } } } catch (Exception e) { throw e; } if (id != vals.Id) { return(BadRequest()); } } return(NoContent()); }
public async Task <ActionResult> GoogleCalendarAsync(CancellationToken cancellationToken) { var result = await new AuthorizationCodeMvcApp(this, new Showcase.Util.ZenoFlowMetadata()). AuthorizeAsync(cancellationToken); if (result.Credential != null) { var service = new CalendarService(new BaseClientService.Initializer { HttpClientInitializer = result.Credential, ApplicationName = "ASP.NET MVC Sample" }); if (String.IsNullOrEmpty(Request.Form["CalendarID"])) { CalendarListResource.ListRequest request0 = service.CalendarList.List(); request0.MaxResults = 10; // List events. CalendarList calendars = request0.Execute(); string desc = string.Empty; Dictionary <string, string> calendarList = new Dictionary <string, string>(); if (calendars.Items != null && calendars.Items.Count > 0) { foreach (var calendarItem in calendars.Items) { calendarList.Add(calendarItem.Id, calendarItem.Summary); } } ViewBag.Message = "Please select which calendar you want to add."; return(View(calendarList)); } else { DateTime tomorrow = DateTime.Today.AddDays(1); string chineseDate = ChineseCalendar.GetChineseDate(tomorrow); var newEvent = new Google.Apis.Calendar.v3.Data.Event() { Summary = chineseDate, Start = new EventDateTime() { Date = tomorrow.ToString("yyyy-MM-dd"), }, End = new EventDateTime() { Date = tomorrow.ToString("yyyy-MM-dd"), }, Transparency = "transparent" }; EventsResource.InsertRequest request = service.Events.Insert(newEvent, Request.Form["CalendarID"]); Event createdEvent = request.Execute(); ViewBag.Message = "Google Calendar Event Added: URL = " + createdEvent.HtmlLink; return(View()); } /* * Showcase.ZenoService.ZenoServiceClient zeno = new Showcase.ZenoService.ZenoServiceClient(); * GoogleRequest request = new GoogleRequest(); * request.Type = ShowcaseService.Contract.GoogleRequestType.CalendarPush; * request.User = new ShowcaseService.Contract.GoogleUser(){ AccessToken = result.Credential.Token.AccessToken, RefreshToken = result.Credential.Token.RefreshToken}; * GoogleResponse response = zeno.InvokeGoogleService(request); * ViewBag.Message = response.Message; */ } else { return(new RedirectResult(result.RedirectUri)); } }
public static CalendarList getCalendar() { CalendarListResource.ListRequest request = s.CalendarList.List(); request.MaxResults = 20; return(request.Execute()); }
public static Dictionary <Event, string> GetGoogleCalendarEvents(List <string> calendarNames, DateTime startDate, DateTime endDate, int returnAmount) { Dictionary <Event, string> eventDictionary = new Dictionary <Event, string>(); AuthorizeGoogleCalendar(); CalendarListResource.ListRequest calRequest = calendarService.CalendarList.List(); calRequest.MinAccessRole = CalendarListResource.ListRequest.MinAccessRoleEnum.Owner; CalendarList calendars = calRequest.Execute(); if (calendarNames == null || calendarNames.Count == 0) { foreach (CalendarListEntry calendar in calendars.Items) { EventsResource.ListRequest eventRequest = calendarService.Events.List(calendar.Id); eventRequest.TimeMin = startDate.Date + new TimeSpan(0, 0, 0); //Force the start to the bottom of the date eventRequest.TimeMax = endDate.Date + new TimeSpan(23, 59, 59); //Make the "endDate" inclusive eventRequest.ShowDeleted = false; eventRequest.SingleEvents = true; eventRequest.MaxResults = returnAmount; eventRequest.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; Events events = eventRequest.Execute(); List <string> eventDisplay = new List <string>(); for (var i = 0; i < events.Items.Count; i++) { string eventSummary = events.Items[i].Summary + " (" + events.Items[i].Start.DateTime.Value.ToString("HH:mm") + " - " + events.Items[i].End.DateTime.Value.ToString("HH:mm") + ")"; eventDictionary.Add(events.Items[i], eventSummary); } } } else if (calendarNames.Count == 1) { CalendarListEntry calendar = calendars.Items.Where(p => p.Summary == "*****@*****.**").FirstOrDefault(); //Todo: get the user's personal calendar from the Google Calendar API? https://developers.google.com/gmail/api/v1/reference/users/getProfile EventsResource.ListRequest eventRequest = calendarService.Events.List(calendar.Id); eventRequest.TimeMin = startDate.Date + new TimeSpan(0, 0, 0); //Force the start to the bottom of the date eventRequest.TimeMax = endDate.Date + new TimeSpan(23, 59, 59); //Make the "endDate" inclusive eventRequest.ShowDeleted = false; eventRequest.SingleEvents = true; eventRequest.MaxResults = returnAmount; eventRequest.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; Events events = eventRequest.Execute(); List <string> eventDisplay = new List <string>(); for (var i = 0; i < events.Items.Count; i++) { string eventSummary = events.Items[i].Summary + " (" + events.Items[i].Start.DateTime.Value.ToString("HH:mm") + " - " + events.Items[i].End.DateTime.Value.ToString("HH:mm") + ")"; eventDictionary.Add(events.Items[i], eventSummary); } } else { foreach (string calendarString in calendarNames) { CalendarListEntry calendar = calendars.Items.Where(p => p.Summary == calendarString).FirstOrDefault(); EventsResource.ListRequest eventRequest = calendarService.Events.List(calendar.Id); eventRequest.TimeMin = startDate.Date + new TimeSpan(0, 0, 0); //Force the start to the bottom of the date eventRequest.TimeMax = endDate.Date + new TimeSpan(23, 59, 59); //Make the "endDate" inclusive eventRequest.ShowDeleted = false; eventRequest.SingleEvents = true; eventRequest.MaxResults = returnAmount; eventRequest.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; Events events = eventRequest.Execute(); List <string> eventDisplay = new List <string>(); for (var i = 0; i < events.Items.Count; i++) { string eventSummary = events.Items[i].Summary + " (" + events.Items[i].Start.DateTime.Value.ToString("HH:mm") + " - " + events.Items[i].End.DateTime.Value.ToString("HH:mm") + ")"; eventDictionary.Add(events.Items[i], eventSummary); } } } //Reorganize the dictionary by startDate eventDictionary = eventDictionary.OrderBy(p => p.Key.Start.DateTime.Value).ToDictionary(pair => pair.Key, pair => pair.Value); return(eventDictionary); }
public CalendarList ListCalendars(string accessRole) { CalendarListResource.ListRequest calendarListRequest = service.CalendarList.List(); calendarListRequest.MinAccessRole = (MinAccessRoleEnum)Enum.Parse(typeof(MinAccessRoleEnum), accessRole); return(DoActionWithExponentialBackoff(calendarListRequest)); }