public void FetchCalendarLists(CalendarService cal, Ctx ctx) { try { this._calenderService = cal; // Fetch all CalenderLists of the user asynchronously. CalendarList response = _calenderService.CalendarList.List().Fetch(); //foreach (CalendarListEntry list in response.Items) //{ // if (list.AccessRole == "owner") // { // FetchCalender(_calenderService, list); // } //} FetchCalender(_calenderService, ctx); } catch (ThreadAbortException) { // User was not yet authenticated and is being forwarded to the authorization page. throw; } catch (Exception) { } }
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(); }
public List <MyCalendarListEntry> getCalendars() { CalendarList request = null; try { request = service.CalendarList.List().Execute(); } catch (System.Exception ex) { //MainForm.Instance.HandleException(ex); throw ex; } if (request != null) { List <MyCalendarListEntry> result = new List <MyCalendarListEntry>(); foreach (CalendarListEntry cle in request.Items) { result.Add(new MyCalendarListEntry(((Google.Apis.Auth.OAuth2.UserCredential)service.HttpClientInitializer).UderId, cle)); } return(result); } return(null); }
private void SettingsForm_Load(object sender, EventArgs e) { if (GoogleSync.Syncer.PerformAuthentication()) { // Get the list of Google Calendars and load them into googleCal_CB m_googleFolders = GoogleSync.Syncer.PullCalendars(); foreach (var calendarListEntry in m_googleFolders.Items) { GoogleCal_CB.Items.Add(calendarListEntry.Summary); } // Get the list of Outlook Calendars and load them into the outlookCal_CB m_outlookFolders = OutlookSync.Syncer.PullCalendars(); foreach (var folder in m_outlookFolders) { OutlookCal_CB.Items.Add(folder.Name); } } m_scheduler = Scheduler.Instance; foreach (var task in m_scheduler) { Calendars_LB.Items.Add(task.ToString()); } }
private async void Calendar_DateClicked(object sender, XamForms.Controls.DateTimeEventArgs e) { lbl.Text = calendar.SelectedDate.Value.ToShortDateString(); bool datePresent = false; CalendarList calendarList = null; foreach (CalendarList cl in mvm.CalendarLists) { if (cl.Date == calendar.SelectedDate.Value) { datePresent = true; calendarList = cl; break; } } if (!datePresent) { calendarList = new CalendarList { Date = calendar.SelectedDate.Value, Tasks = new ObservableCollection <TaskViewModel>() }; mvm.CalendarLists.Add(calendarList); } await Navigation.PushAsync(new TasksListPage(calendarList.Tasks)); //await Navigation.PushAsync(new TasksListPage(calendar.SelectedDate.Value)); }
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); }
private List <Event> GetCalendarItems(DateTime tLimitFrom, DateTime tLimitTo) { lock (_lockOutlook) { log.LogEverything(t.GetMethodName("OutlookOnlineController"), "OutlookOnlineController.GetCalendarItems called"); string filter = "GetCalendarItems [After] '" + tLimitTo.ToString("g") + "' AND [before] <= '" + tLimitFrom.ToString("g") + "'"; log.LogVariable(t.GetMethodName("OutlookOnlineController"), nameof(filter), filter.ToString()); calendarName = GetCalendarName(); userEmailAddess = GetUserEmailAddress(); CalendarList calendarList = outlookExchangeOnlineAPIClient.GetCalendarList(userEmailAddess, calendarName); if (calendarList != null) { foreach (Calendar cal in calendarList.value) { log.LogEverything(t.GetMethodName("OutlookOnlineController"), "GetCalendarItems comparing cal.Name " + cal.Name + " with calendarName " + calendarName); if (cal.Name.Equals(calendarName, StringComparison.OrdinalIgnoreCase)) { EventList outlookCalendarItems = outlookExchangeOnlineAPIClient.GetCalendarItems(userEmailAddess, cal.Id, tLimitFrom, tLimitTo); //log.LogVariable(t.GetMethodName("OutlookOnlineController"), "outlookCalendarItems.Count", outlookCalendarItems.value.Count); return(outlookCalendarItems.value); } } } return(null); } }
protected void Page_Load(object sender, EventArgs e) { _CalendarAbsPath = MapPath("~/Calendars"); if (!IsPostBack) { // Load our list of available calendars CalendarList.DataSource = LoadCalendarList(); CalendarList.DataBind(); // Select all calendars in the list by default foreach (ListItem li in CalendarList.Items) { li.Selected = true; } } // Get a list of todays events and upcoming events List <Occurrence> todaysEvents = GetTodaysEvents(); List <Occurrence> upcomingEvents = GetUpcomingEvents(); // Bind our list to the repeater that will display the events. TodaysEvents.DataSource = todaysEvents; TodaysEvents.DataBind(); // Bind our list to the repeater that will display the events. UpcomingEvents.DataSource = upcomingEvents; UpcomingEvents.DataBind(); }
/// <summary> /// Pulls the list of calendars. /// </summary> /// <returns>A list of the user's Google calendars</returns> public CalendarList PullCalendars() { try { // Force the list to be updated initially and then every 30 minutes. if (m_lastUpdate == DateTime.MinValue || m_lastUpdate < DateTime.Now.Subtract(TimeSpan.FromMinutes(30))) { PerformAuthentication(); m_calendarList = m_service.CalendarList.List().Execute(); m_lastUpdate = DateTime.Now; } Log.Write("Pulled the list of Google calendars."); return(m_calendarList); } catch (GoogleApiException ex) { Log.Write(ex); HandleException(ex, "There was an error when trying to pull a list of calendars from google."); return(null); } catch (TokenResponseException ex) { Log.Write(ex); return(null); } }
/// <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); } }
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(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["credential"] == null) { return; } service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = Session["credential"] as UserCredential, ApplicationName = "GoogleCalendarAPI" }); UpdateTimeRulers(); if (service == null) { return; } if (!IsPostBack) { CalendarList calendarList = this.service.CalendarList.List().Execute(); foreach (var calendarItem in calendarList.Items) { lbCalendars.Items.Add(new ListItem(calendarItem.Summary, calendarItem.Id)); } lbCalendars.SelectedIndex = 0; } this.calendarId = lbCalendars.SelectedValue; ShowAndBindScheduler(); }
/// <summary> /// The default constructor for GoogleSync. This should never be called directly. You should always use GoogleSync.Syncer /// </summary> public GoogleSync() { m_currentCalendar = "primary"; m_lastUpdate = DateTime.MinValue; m_calendarList = null; m_fileDataStore = new FileDataStore(m_workingDirectory, true); }
public ActionResult List(DateTime bDate, DateTime eDate, int codeID = 0, string SearchCode = "", string Requestor = "") { ViewBag.MinistryID = codeID; ViewBag.Requestor = Requestor; IEnumerable <calendar> CalendarList; if (SearchCode == "Ministry") { CalendarList = CalendarRepository.GetCalendarByMinistryDate(codeID, bDate.Date, eDate.Date); } else { CalendarList = CalendarRepository.GetCalendarByDateRangeActive(bDate.Date, eDate.Date); } foreach (calendar c in CalendarList) { c.EventTypeDesc = ConstantRepository.GetConstantID(c.EventType).Value1; if (c.ministryID != 0) { c.ministry = MinistryRepository.GetMinistryByID(c.ministryID); } } ViewBag.RecordCount = CalendarList.Count(); return(PartialView(CalendarList)); }
/// <summary> /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event. /// </summary> /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); CalendarView.SelectionChanged += new EventHandler(CalendarView_SelectionChanged); CalendarView.DayRender += new DayRenderEventHandler(CalendarView_DayRender); CalendarView.VisibleMonthChanged += new MonthChangedEventHandler(CalendarView_VisibleMonthChanged); if (!IsPostBack) { // Default begin date is todays date. CalendarList.BeginDate = DateTime.Now; CalendarList.DataBind(); // MonthlyItems is a hidden calendar list used to calculate what days to highlight in CalenderView. // We use the first of current month as begin date but substract 6 days since CalendarView can show up to 6 days of previous month. MonthlyItems.BeginDate = new DateTime(CalendarView.TodaysDate.Year, CalendarView.TodaysDate.Month, 1).AddDays(-6); // NumberOfDaysToRender is calculated to 6 + 31 + 13 = 50. // 6 = CalendarView can show up to 6 days of previous month. // 31 = Maximum number of days in a month. // 13 = CalendarView can show up to 13 days of next month. MonthlyItems.NumberOfDaysToRender = 50; MonthlyItems.DataBind(); } }
public CalendarList GetGoogleCalendars(string account) { CalendarListResource.ListRequest request = GetService(account).CalendarList.List(); CalendarList x = request.Execute(); return(x); }
public ActionResult Calendar() { SessionContext.Current.ActiveUser.MenuId = "-1"; CalendarList model = new CalendarList(); //model.CalendarHiddenData = GetCalendarDataShow(); return(View(model)); }
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); }
// This method will fetch all the changed calendars public static IList <CalendarListEntry> syncCalendars(out string syncToken) { // Init request for the calendar list, fetch the token (id) from the uuid master identified by uuid = static uuid token (gsync-calendar-sync-token) // If the token is not present, then preform a full sync var req = GService.service.CalendarList.List(); req.ShowDeleted = true; try { var obj = JsonConvert.DeserializeObject <IdOutput>(uuidMaster.GetIdBy(calendarSyncTokenUUID, 7)); req.SyncToken = obj.id; } catch (Exception e) { //req.SyncToken = ""; } // Setup placeholder vars for storage CalendarList calendars = null; string pageToken = ""; IList <CalendarListEntry> response = new List <CalendarListEntry>(); // Execute this loop until all requests (seperated in pages) are processed & fetched do { req.PageToken = pageToken; try { calendars = req.Execute(); IList <CalendarListEntry> items = calendars.Items; // Add every event to the response list foreach (var item in items) { if (!item.Id.Equals(calIgnore)) { response.Add(item); } } pageToken = calendars.NextPageToken; } catch (Exception e) { // Do a dance } }while (!String.IsNullOrEmpty(pageToken)); // Update the uuid master with the latest sync token syncToken = calendars != null ? calendars.NextSyncToken : ""; //uuidMaster.PutUpdateUUID(calendarSyncTokenUUID, calendars.NextSyncToken, Calendarss.getversion(calendarSyncTokenUUID) + 1); return(response); }
public static void GetCalendars() { CalendarList results = cal.CalendarList.List().Execute(); int i = 0; foreach (CalendarListEntry item in results.Items) { i++; } }
public async Task ExecuteCalendersCommand() { if (IsBusy) { return; } IsBusy = true; GetDateCommand?.ChangeCanExecute(); try { CalendarList.Clear(); var Event = await dataStore.GetCalendarAsync(); CalendarList.ReplaceRange(Event.Select(s => { DateTime result = DateTime.MinValue; if (DateTime.TryParse(s.start, out result)) { return(new SpecialDate(result.Date) { FontSize = 30, TextColor = Color.Blue, Selectable = true }); } return(new SpecialDate(DateTime.MinValue)); }).ToList()); //foreach (var e in Event.ToList()) //{ // DateTime result = DateTime.MinValue; // if (DateTime.TryParse(e.start, out result)) // { // var Children = new List<EntityClass>(); // Children.Add(new EntityClass { Title = string.IsNullOrEmpty(e.description)? string.Empty: e.description}); // Entity.Add(new EntityClass // { // Title = String.Format("{0}: {1}", result.ToString("t"), e.summary), // Description = result.Date.ToString(), // ChildItems = Children // }); // } //} } catch (Exception ex) { //await page.DisplayAlert("Uh Oh :(", "Unable to gather Event.", "OK"); } finally { IsBusy = false; GetDateCommand?.ChangeCanExecute(); } //await page.Navigation.PopAsync(); }
private void GetUserCalendarsFromGoogle() { CalendarList calendarList = service.CalendarList.List().Execute(); foreach (var calendar in calendarList.Items) { bool isPrimary = calendar.Primary == false || calendar.Primary == null ? false : true; var userCalendar = new UserCalendar(calendar.Id, calendar.Summary, isPrimary); userCalendars.Add(userCalendar); } }
public void FetchingCalendar(CalendarList result, CalendarService service, Ctx ctx) { //foreach (CalendarListEntry calendar in result.Items) //{ // if (calendar.AccessRole == "owner") // { // FetchCalender(service, calendar); // } //} FetchCalender(service, ctx); }
/// <summary> /// get all user calendars /// </summary> /// <param name="user"></param> /// <param name="path">path of directory where user is token</param> /// <returns></returns> public static List <GoogleCalendarInfo> GetCalendars(User user, string path) { var service = GetCalendarService(GetCredentials(user, path)); CalendarList calendars = service.CalendarList.List().Execute(); var calendarsList = new List <GoogleCalendarInfo>(); foreach (var calendar in calendars.Items) { calendarsList.Add(new GoogleCalendarInfo(calendar)); } return(calendarsList); }
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'"; }
protected void grdData_RowDataBound(object sender, GridRowEventArgs e) { CalendarList row = (CalendarList)e.DataItem; int val = row.i_CalendarStatusId; if (val == 4) { highlightRows.Text += e.RowIndex.ToString() + ","; } }
/** * get calendars events * * @return */ public List <GCal> GetCalendars() { List <GCal> calendars = new List <GCal>(); CalendarList list = cs.CalendarList.List().Execute(); foreach (CalendarListEntry o in list.Items) { calendars.Add(Convert(o)); } return(calendars); }
public ActionResult ListAdmin(DateTime bDate, DateTime eDate, string SearchType = "", int codeID = 0, string codeName = "", string CallerType = "") { GetData(); ViewBag.ReturnBeginDate = bDate; //.ToShortDateString(); ViewBag.ReturnEndDate = eDate; //.ToShortDateString(); ViewBag.ReturnSearchType = SearchType; ViewBag.ReturnCodeID = codeID; ViewBag.ReturnCodeName = codeName; ViewBag.ReturnCallerType = CallerType; ViewBag.Heading = "Ministry Calendar"; IEnumerable <calendar> CalendarList; if (SearchType == "MinistrySearch") { GetData(codeID); CalendarList = CalendarRepository.GetCalendarByMinistryDate(codeID, bDate, eDate); string ministryName = MinistryRepository.GetMinistryByID(codeID).MinistryName; ViewBag.Heading = string.Format("{0} Calendar", ministryName); } else if (SearchType == "StatusSearch") { CalendarList = CalendarRepository.GetCalendarByStatus(codeName, bDate, eDate); } else if (SearchType == "EventTypeSearch") { CalendarList = CalendarRepository.GetCalendarByEvent(codeID, bDate, eDate); ViewBag.Heading = "Event Calendar"; } else if (SearchType == "LocationTypeSearch") { CalendarList = CalendarRepository.GetCalendarByLocation(codeName, bDate, eDate); ViewBag.Heading = "Event Calendar"; } else { CalendarList = CalendarRepository.GetCalendarByDateRange(bDate.Date, eDate.Date); } ViewBag.RecordCount = CalendarList.Count(); foreach (calendar c in CalendarList) { c.ministry = MinistryRepository.GetMinistryByID(c.ministryID); } return(PartialView(CalendarList.OrderBy(e => e.CalendarDate))); }
public string getPrimaryCalendarId() { CalendarList cl = getCalendars(); string id = ""; for (int i = 0; i < cl.Items.Count; i++) { if ((bool)cl.Items[i].Primary) { id = cl.Items[i].Id; break; } } return(id); }
private async Task Run() { UserCredential credential; FileStream stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read); credential = await GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, new[] { CalendarService.Scope.Calendar }, "user", CancellationToken.None); mService = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Calendar API Sample", }); mCalendarList = mService.CalendarList.List().Execute(); foreach (CalendarListEntry entry in mCalendarList.Items) { CalenderCombo.Items.Add(entry); } }
public List<string> Main() { UserCredential credential; using (var stream = new FileStream(@"C:\Users\AngelFelipe\Documents\Visual Studio 2015\Projects\Reservas.Api\Reservas.ApiService\Json\client_secret.json", FileMode.Open, FileAccess.Read)) { string credPath = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Personal); credPath = Path.Combine(credPath, ".credentials"); 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, }); // Define parameters of request. EventsResource.ListRequest request = service.Events.List("primary"); request.TimeMin = DateTime.Now; request.ShowDeleted = false; request.SingleEvents = true; request.MaxResults = 10; request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; CalendarList listaCalendarios = new CalendarList(); Calendar calendario = new Calendar(); var t = service.CalendarList.List(); var des = t.Execute(); // List events. Events events = request.Execute(); List<string> response = new List<string>(); Console.WriteLine("Upcoming events:"); 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; } response.Add(string.Format("{0} ({1})", eventItem.Summary, when)); } } else { response.Add("No upcoming events found."); } return response; }