public static CalendarListResource.PatchRequest SetColor(this CalendarListResource calendarList, string calendarId, string color) { var calListEntry = new CalendarListEntry { BackgroundColor = color }; var setColourRequest = calendarList.Patch(calListEntry, calendarId); setColourRequest.ColorRgbFormat = true; return(setColourRequest); }
/// <summary> /// Mise à jour des caractéristiques des calendriers /// </summary> public void UpdateGoogleCalendars() { Log.Debug("Mise à jour des Calendriers Google"); if (!p_isActivated) { return; } // Si la fonction n'est pas activée, on sort de la fonction bool _returnGoogle = true; if (p_myService == null) { _returnGoogle = this.InitCnx(); } if (_returnGoogle) { try { CalendarListResource.ListRequest _lstCalendar = p_myService.CalendarList.List(); CalendarList _lst = _lstCalendar.Execute(); foreach (CalendarListEntry _entry in _lst.Items) { Photographe _myPhoto = p_applClass.Param.GetPhotographeFromIdGoogle(_entry.Id); if (_myPhoto != null) { _entry.BackgroundColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(_myPhoto.ARGB)); _entry.SummaryOverride = _myPhoto.Nom; CalendarListResource _cal = new CalendarListResource(p_myService); _cal.Update(_entry, _entry.Id).Execute(); } } } catch (Exception _exc) { Log.Error("Erreur lors de la mise à jour des calendriers Google {" + p_googleAccount + "} - {" + p_privateKey + "}", _exc); } } }
// 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; } }
public static CalendarListResource.PatchRequest SetColor(this CalendarListResource calendarList, string calendarId, string colorId) => calendarList.Patch(new CalendarListEntry { ColorId = colorId }, calendarId);