protected void btnCreateEvent_Click(object sender, EventArgs e)
        {
            Event event1 = new Event()
            {
                Summary = "當麻部落格測試",
                Start   = new EventDateTime()
                {
                    DateTime = DateTime.Now,
                    TimeZone = "Asia/Taipei"
                },
                End = new EventDateTime()
                {
                    DateTime = DateTime.Now.AddMinutes(1),
                    TimeZone = "Asia/Taipei"
                },
            };

            var             d             = JsonConvert.DeserializeObject <GoogleTokenModel>(File.ReadAllText(Gfolder + "Google.Apis.Auth.OAuth2.Responses.TokenResponse-" + UserId));
            CalendarService calService    = GetCalendarService(d);
            EventsResource  eventResource = new EventsResource(calService);


            var insertEntry = eventResource.Insert(event1, "primary").Execute();

            txtEventId.Text = insertEntry.Id;
        }
Example #2
0
        /// <summary>
        /// Client for making requests to the API.
        /// </summary>
        /// <param name="authHandler">The authentication handler.</param>
        /// <param name="ctx">The HTTP context to use for this session.</param>
        private Client(Func <CancellationToken, Task <string> > authHandler, HttpContext ctx)
        {
            // Setup resources.
            Assets              = new AssetsResource(authHandler, ctx);
            TimeSeries          = new TimeSeriesResource(authHandler, ctx);
            DataPoints          = new DataPointsResource(authHandler, ctx);
            Events              = new EventsResource(authHandler, ctx);
            Sequences           = new SequencesResource(authHandler, ctx);
            Raw                 = new RawResource(authHandler, ctx);
            Relationships       = new RelationshipResource(authHandler, ctx);
            DataSets            = new DataSetsResource(authHandler, ctx);
            ThreeDModels        = new ThreeDModelsResource(authHandler, ctx);
            ThreeDRevisions     = new ThreeDRevisionsResource(authHandler, ctx);
            ThreeDAssetMappings = new ThreeDAssetMappingsResource(authHandler, ctx);
            Files               = new FilesResource(authHandler, ctx);
            Login               = new LoginResource(authHandler, ctx);
            Token               = new TokenResource(authHandler, ctx);
            ExtPipes            = new ExtPipesResource(authHandler, ctx);
            Labels              = new LabelsResource(authHandler, ctx);
            Groups              = new GroupsResource(authHandler, ctx);

            // Playground features (experimental)
            Playground = new PlaygroundResource(authHandler, ctx);
            // Beta features (experimental)
            Beta = new BetaResource(authHandler, ctx);
        }
        protected void btnDelEvent_Click(object sender, EventArgs e)
        {
            var             d             = JsonConvert.DeserializeObject <GoogleTokenModel>(File.ReadAllText(Gfolder + "Google.Apis.Auth.OAuth2.Responses.TokenResponse-" + UserId));
            CalendarService calService    = GetCalendarService(d);
            EventsResource  eventResource = new EventsResource(calService);

            eventResource.Delete("primary", txtEventId.Text).Execute();
            Response.Write("成功刪除 :"   + txtEventId.Text);
        }
        /// <summary>
        /// This maps the default support for the event types.
        /// </summary>
        protected override void SupportLoadDefault()
        {
            SupportAdd(DataCollectionSupport.Boundary, (e) => EventsBoundary.Add(e));
            SupportAdd(DataCollectionSupport.Dispatcher, (e) => EventsDispatcher.Add(e));
            SupportAdd(DataCollectionSupport.EventSource, (e) => EventsEventSource.Add(e));
            SupportAdd(DataCollectionSupport.Logger, (e) => EventsLog.Add(e));
            SupportAdd(DataCollectionSupport.Statistics, (e) => EventsMicroservice.Add(e));
            SupportAdd(DataCollectionSupport.Telemetry, (e) => EventsMetric.Add(e));

            SupportAdd(DataCollectionSupport.Resource, (e) => EventsResource.Add(e));

            SupportAdd(DataCollectionSupport.Custom, (e) => EventsCustom.Add(e));

            SupportAdd(DataCollectionSupport.Security, (e) => EventsSecurity.Add(e));
        }
Example #5
0
        /// <summary>
        /// Inserts a game into a person's Google Calendar.
        /// </summary>
        private void AddCalendarEvent(CalendarService service, Schedule schedule, Game game)
        {
            int    gameId = game.Id;
            string user   = User.Identity.Name;

            // Get gamelogger calendar or make one if it doesn't exist
            IList <CalendarListEntry> calendars = service.CalendarList.List().Execute().Items;

            // Delete previous calendar and create a new one
            for (int i = 0; i < calendars.Count; i++)
            {
                if (calendars[i].Summary == "GameLogger")
                {
                    service.Calendars.Delete(calendars[i].Id).Execute();
                }
            }

            // Create new calendar
            Calendar calendar = new Calendar();

            calendar.Summary  = "GameLogger";
            calendar.TimeZone = "America/New_York";

            var    newCal = service.Calendars.Insert(calendar).Execute();
            string calId  = newCal.Id;

            // Insert event
            EventsResource eventRes = new EventsResource(service);

            Event calEvent = new Event();

            EventDateTime Start = new EventDateTime();
            EventDateTime End   = new EventDateTime();

            double gameLength = game.Main_Story_Length;

            int currPlayTime = 0;

            // If game does not have a length specified in the database then assume it will take 12 hours to beat.
            if (gameLength <= 0)
            {
                gameLength = 12;
            }

            // Get user's current playtime on the game and subtract the game's length from the playtime
            using (BacklogDataContext blDb = new BacklogDataContext())
            {
                Backlog bl = blDb.Backlogs.First(m => m.GameId == gameId && m.UserName == user);

                if (bl != null)
                {
                    currPlayTime = ((int)bl.PlayTime / 60);
                }
            }

            gameLength -= (currPlayTime);

            int daysToFinish = (int)Math.Ceiling(gameLength / 8);

            List <int> freeDays = new List <int>();

            // Get free days. TODO: make this less messy
            if (schedule.Monday == true)
            {
                freeDays.Add(1);
            }
            if (schedule.Tuesday == true)
            {
                freeDays.Add(2);
            }
            if (schedule.Wednesday == true)
            {
                freeDays.Add(3);
            }
            if (schedule.Thursday == true)
            {
                freeDays.Add(4);
            }
            if (schedule.Friday == true)
            {
                freeDays.Add(5);
            }
            if (schedule.Saturday == true)
            {
                freeDays.Add(6);
            }
            if (schedule.Sunday == true)
            {
                freeDays.Add(7);
            }

            int weekOffset = 0;

            // Find the next available day to play
            if (freeDays.Count > 0)
            {
                for (int x = 0; x < daysToFinish; x++)
                {
                    // Set start date. TODO: make this less messy
                    for (int i = 0; i < freeDays.Count; i++)
                    {
                        // Set event times
                        if (freeDays[i] == 1)
                        {
                            DateTime today         = DateTime.Today;
                            int      daysUntilNext = ((int)DayOfWeek.Monday - (int)today.DayOfWeek + 7) % 7;
                            DateTime next          = today.AddDays(daysUntilNext + (weekOffset * 7));
                            Start.Date = next.ToString("yyyy-MM-dd");
                            End.Date   = Start.Date;
                            daysToFinish--;
                        }
                        else if (freeDays[i] == 2)
                        {
                            DateTime today         = DateTime.Today;
                            int      daysUntilNext = ((int)DayOfWeek.Tuesday - (int)today.DayOfWeek + 7) % 7;
                            DateTime next          = today.AddDays(daysUntilNext + (weekOffset * 7));
                            Start.Date = next.ToString("yyyy-MM-dd");
                            End.Date   = Start.Date;
                            daysToFinish--;
                        }
                        else if (freeDays[i] == 3)
                        {
                            DateTime today         = DateTime.Today;
                            int      daysUntilNext = ((int)DayOfWeek.Wednesday - (int)today.DayOfWeek + 7) % 7;
                            DateTime next          = today.AddDays(daysUntilNext + (weekOffset * 7));
                            Start.Date = next.ToString("yyyy-MM-dd");
                            End.Date   = Start.Date;
                            daysToFinish--;
                        }
                        else if (freeDays[i] == 4)
                        {
                            DateTime today         = DateTime.Today;
                            int      daysUntilNext = ((int)DayOfWeek.Thursday - (int)today.DayOfWeek + 7) % 7;
                            DateTime next          = today.AddDays(daysUntilNext + (weekOffset * 7));
                            Start.Date = next.ToString("yyyy-MM-dd");
                            End.Date   = Start.Date;
                            daysToFinish--;
                        }
                        else if (freeDays[i] == 5)
                        {
                            DateTime today         = DateTime.Today;
                            int      daysUntilNext = ((int)DayOfWeek.Friday - (int)today.DayOfWeek + 7) % 7;
                            DateTime next          = today.AddDays(daysUntilNext + (weekOffset * 7));
                            Start.Date = next.ToString("yyyy-MM-dd");
                            End.Date   = Start.Date;
                            daysToFinish--;
                        }
                        else if (freeDays[i] == 6)
                        {
                            DateTime today         = DateTime.Today;
                            int      daysUntilNext = ((int)DayOfWeek.Saturday - (int)today.DayOfWeek + 7) % 7;
                            DateTime next          = today.AddDays(daysUntilNext + (weekOffset * 7));
                            Start.Date = next.ToString("yyyy-MM-dd");
                            End.Date   = Start.Date;
                            daysToFinish--;
                        }
                        else if (freeDays[i] == 7)
                        {
                            DateTime today         = DateTime.Today;
                            int      daysUntilNext = ((int)DayOfWeek.Sunday - (int)today.DayOfWeek + 7) % 7;
                            DateTime next          = today.AddDays(daysUntilNext + (weekOffset * 7));
                            Start.Date = next.ToString("yyyy-MM-dd");
                            End.Date   = Start.Date;
                            daysToFinish--;
                        }

                        // Set event information and insert
                        calEvent.Summary     = "GameLogger";
                        calEvent.Start       = Start;
                        calEvent.End         = End;
                        calEvent.ColorId     = "3";
                        calEvent.Description = "Playing " + game.Name;

                        // Insert event
                        eventRes.Insert(calEvent, calId).Execute();

                        if (daysToFinish <= 0)
                        {
                            break;
                        }
                    }

                    weekOffset++;
                }
            }
        }
Example #6
0
        public static bool AddUpdateDeleteEvent(List <GoogleCalendarAppointmentModel> GoogleCalendarAppointmentModelList, List <GoogleTokenModel> GoogleTokenModelList, double TimeOffset)
        {
            //Get the calendar service for a user to add/update/delete events
            CalendarService calService = GetCalendarService(GoogleTokenModelList[0]);

            if (GoogleCalendarAppointmentModelList != null && GoogleCalendarAppointmentModelList.Count > 0)
            {
                foreach (GoogleCalendarAppointmentModel GoogleCalendarAppointmentModelObj in GoogleCalendarAppointmentModelList)
                {
                    EventsResource er     = new EventsResource(calService);
                    string         ExpKey = "EventID";
                    string         ExpVal = GoogleCalendarAppointmentModelObj.EventID;

                    var queryEvent = er.List(calID);
                    queryEvent.SharedExtendedProperty = ExpKey + "=" + ExpVal; //"EventID=9999"
                    var EventsList = queryEvent.Execute();

                    //to restrict the appointment for specific staff only
                    //Delete this appointment from google calendar
                    if (GoogleCalendarAppointmentModelObj.DeleteAppointment == true)
                    {
                        string FoundEventID = String.Empty;
                        foreach (Event evItem in EventsList.Items)
                        {
                            FoundEventID = evItem.Id;
                            if (!String.IsNullOrEmpty(FoundEventID))
                            {
                                er.Delete(calID, FoundEventID).Execute();
                            }
                        }
                        return(true);
                    }
                    //Add if not found OR update if appointment already present on google calendar
                    else
                    {
                        Event eventEntry = new Event();

                        EventDateTime StartDate = new EventDateTime();
                        EventDateTime EndDate   = new EventDateTime();
                        StartDate.Date = GoogleCalendarAppointmentModelObj.EventStartTime.ToString("yyyy-MM-dd"); //"2014-11-17";
                        EndDate.Date   = StartDate.Date;                                                          //GoogleCalendarAppointmentModelObj.EventEndTime

                        //Always append Extended Property whether creating or updating event
                        Event.ExtendedPropertiesData exp = new Event.ExtendedPropertiesData();
                        exp.Shared = new Dictionary <string, string>();
                        exp.Shared.Add(ExpKey, ExpVal);

                        eventEntry.Summary            = GoogleCalendarAppointmentModelObj.EventTitle;
                        eventEntry.Start              = StartDate;
                        eventEntry.End                = EndDate;
                        eventEntry.Location           = GoogleCalendarAppointmentModelObj.EventLocation;
                        eventEntry.Description        = GoogleCalendarAppointmentModelObj.EventDetails;
                        eventEntry.ExtendedProperties = exp;

                        string FoundEventID = String.Empty;
                        foreach (var evItem in EventsList.Items)
                        {
                            FoundEventID = evItem.Id;
                            if (!String.IsNullOrEmpty(FoundEventID))
                            {
                                //Update the event
                                er.Update(eventEntry, calID, FoundEventID).Execute();
                            }
                        }

                        if (String.IsNullOrEmpty(FoundEventID))
                        {
                            //create the event
                            er.Insert(eventEntry, calID).Execute();
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }
Example #7
0
        /// <summary>
        /// This Function fetch Calendar detail from Gmail and insert in Appointment Table
        /// </summary>
        /// <param name="_calenderSer"></param>
        private void FetchCalender(CalendarService _calenderSer, Ctx ctx)
        {
            string sqlCategory       = "SELECT APPOINTMENTCATEGORY_ID FROM APPOINTMENTCATEGORY WHERE VALUE='Appointment' AND ISACTIVE='Y'";
            int    appointCategoryID = Util.GetValueOfInt(DB.ExecuteScalar(sqlCategory));

            try
            {
                Google.Apis.Calendar.v3.EventsResource ev = new EventsResource(_calenderSer, _authenticator);
                //ev.List(CalendarList.Id).SingleEvents = true;
                Events e = null;
                try
                {
                    e = ev.List("primary").Fetch(); //Fetch Calendar Events From Gmail which are Primary
                }
                catch (Exception ex)
                {
                    msg.Append(ex.Message);
                }

                if (e.Items == null)
                {
                    msg.Append("no Item Found");
                    return;
                }
                StringBuilder sql = new StringBuilder();

                if (e.Items.Count == 0)
                {
                    msg.Append("no Item Found");
                    return;
                }

                for (int i = 0; i < e.Items.Count; i++)
                {
                    try
                    {
                        VAdvantage.Model.MAppointmentsInfo ainfo = new VAdvantage.Model.MAppointmentsInfo(ctx, 0, null);

                        sql.Clear();
                        sql.Append("select  appointmentsinfo_id From APPOINTMENTSINFO ")
                        .Append(" where utaskid='" + e.Items[i].Id + "' and AD_User_ID=" + AD_User_ID);
                        DataSet ds = DB.ExecuteDataset(sql.ToString());
                        if (ds == null || ds.Tables[0].Rows.Count == 0)
                        {
                            ainfo.SetAD_Org_ID(AD_Org_ID);
                            ainfo.SetAD_Client_ID(AD_Client_ID);
                            ainfo.SetAD_User_ID(AD_User_ID);
                            ainfo.SetIsTask(false);
                            ainfo.SetUTaskID(e.Items[i].Id);
                            ainfo.SetAppointmentCategory_ID(appointCategoryID);
                            ainfo.SetStatus(3);

                            if (e.Items[i].Summary != null)
                            {
                                ainfo.SetSubject(e.Items[i].Summary);
                            }
                            if (e.Items[i].Description != null)
                            {
                                ainfo.SetDescription(e.Items[i].Description);
                            }
                            if (e.Items[i].Location != null)
                            {
                                ainfo.SetLocation(e.Items[i].Location);
                            }


                            if (e.Items[i].Visibility != null)
                            {
                                if (e.Items[i].Visibility.ToString().Equals("Private", StringComparison.OrdinalIgnoreCase))
                                {
                                    ainfo.SetIsPrivate(true);
                                }
                                else
                                {
                                    ainfo.SetIsPrivate(false);
                                }
                            }
                            else
                            {
                                ainfo.SetIsPrivate(false);
                            }

                            if (e.Items[i].Reminders != null)
                            {
                                Event.RemindersData rem = e.Items[i].Reminders;
                                if (rem != null)
                                {
                                    if (rem.Overrides != null)
                                    {
                                        IList <EventReminder> resmim = rem.Overrides;

                                        foreach (EventReminder r in resmim)
                                        {
                                            ainfo.SetReminderInfo(r.Minutes.ToString());
                                        }
                                    }
                                }
                            }
                            if (e.Items[i].Recurrence == null || e.Items[i].Recurrence.Count < 1)
                            {
                                EventDateTime dateStart = e.Items[i].Start;
                                if (dateStart.Date == null)
                                {
                                    DateTime startDate = Convert.ToDateTime(dateStart.DateTime);
                                    ainfo.SetStartDate(startDate.ToUniversalTime());
                                    ainfo.SetAllDay(false);
                                }
                                else
                                {
                                    ainfo.SetStartDate(Convert.ToDateTime(dateStart.Date).ToUniversalTime());
                                    ainfo.SetAllDay(true);
                                }

                                EventDateTime dateend = e.Items[i].End;
                                if (dateend.Date == null)
                                {
                                    DateTime endDate = Convert.ToDateTime(dateend.DateTime);
                                    ainfo.SetEndDate(endDate.ToUniversalTime());
                                    ainfo.SetAllDay(false);
                                }
                                else
                                {
                                    ainfo.SetEndDate(Convert.ToDateTime(dateend.Date).ToUniversalTime());
                                    ainfo.SetAllDay(true);
                                }
                            }
                            else
                            {
                                if (e.Items[i].Recurrence != null && e.Items[i].Recurrence.Count > 0)
                                {
                                    EventDateTime dateStart = e.Items[i].Start;
                                    EventDateTime dateend   = e.Items[i].End;

                                    if (e.Items[i].Start.Date == null)
                                    {
                                        DateTime sdate = Convert.ToDateTime(dateStart.DateTime);
                                        ainfo.SetStartDate(sdate.ToUniversalTime());
                                        ainfo.SetAllDay(false);
                                    }
                                    else
                                    {
                                        DateTime sdate = Convert.ToDateTime(dateStart.Date);
                                        ainfo.SetStartDate(sdate.ToUniversalTime());
                                        ainfo.SetAllDay(true);
                                    }

                                    if (e.Items[i].End.Date == null)
                                    {
                                        ainfo.SetEndDate(Convert.ToDateTime(dateend.DateTime).ToUniversalTime());
                                        ainfo.SetAllDay(false);
                                    }
                                    else
                                    {
                                        ainfo.SetEndDate(Convert.ToDateTime(dateend.Date).ToUniversalTime());
                                        ainfo.SetAllDay(true);
                                    }
                                    string recurenceRule = e.Items[i].Recurrence[0].Replace("RRULE:", "");
                                    ainfo.SetRecurrenceRule(recurenceRule);  //Save Recurrence rule
                                }
                            }
                            if (ainfo.Save())
                            {
                                sql.Clear();
                                sql.Append("Update APPOINTMENTSINFO set LastLocalUpdated=" + SetTime(ainfo.GetUpdated()) +
                                           " , Updated=" + SetTime(ainfo.GetUpdated()) + ", CreatedBY= " + AD_User_ID + ", UpdatedBy=" + AD_User_ID +
                                           ",LastGmailUpdated=" + GlobalVariable.TO_DATE(Convert.ToDateTime(e.Items[i].Updated), false) + " where APPOINTMENTSINFO_ID=" + ainfo.GetAppointmentsInfo_ID());
                                int result = DB.ExecuteQuery(sql.ToString());
                            }
                        }
                    }
                    catch (Exception exq)
                    {
                        msg.Append(exq.Message + " At no. " + i);
                    }
                }
            }
            catch (Exception ex)
            {
                msg.Append(ex.Message);
            }
        }
        /// <summary>
        /// Supprimer un Evénement GOOGLE CALENDAR
        /// </summary>
        /// <param name="infoEcole"></param>
        /// <param name="IdGoogleCalendar"></param>
        public void DeleteEvent(string IdGoogleCalendar, Event googleEvent)
        {
            Log.Debug("Suppression d'un évènement Google Calendar");

            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
                {
                    EventsResource er = new EventsResource(p_myService);
                    EventsResource.DeleteRequest _del = er.Delete(IdGoogleCalendar, googleEvent.Id);
                    _del.Execute();
                }
                catch (Exception _exc)
                {
                    Log.Error("Erreur lors de la suppression d'un événement Google", _exc);
                }
            }
        }
        /// <summary>
        /// Mettre à jour un Evénement GOOGLE CALENDAR
        /// </summary>
        /// <param name="infoEcole"></param>
        /// <param name="IdGoogleCalendar"></param>
        public void UpdateEvent(Ecole infoEcole, string IdGoogleCalendar, Event googleEvent)
        {
            Log.Debug("Mise à jour d'un évènement Google Calendar");

            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
                {
                    evnt = new Event();
                    StringBuilder _libelleEvent = new StringBuilder();
                    _libelleEvent.AppendFormat("{0} - {1}", infoEcole.Libelle, infoEcole.Ville);
                    if (infoEcole.Confirme) { _libelleEvent.AppendLine(" [Ecole confirmée]"); }
                    evnt.Summary = _libelleEvent.ToString();
                    evnt.Location = infoEcole.Adresse + " " + infoEcole.CodePostal + " " + infoEcole.Ville;
                    StringBuilder _description = new StringBuilder();
                    _description.AppendLine(infoEcole.IdEcole);
                    _description.AppendLine("Libelle : " + infoEcole.Libelle);
                    _description.AppendLine("Adresse : " + infoEcole.Adresse);
                    _description.AppendFormat("          {0} {1}\n", infoEcole.CodePostal, infoEcole.Ville);
                    _description.AppendLine("-------------------------------");
                    _description.AppendFormat("Contact :   {0} {1} ({2})\n", infoEcole.Contact.TitreCTC, infoEcole.Contact.NomCTC, infoEcole.Contact.FonctionCTC);
                    _description.AppendFormat("Téléphone : {0}\n", infoEcole.Contact.TelephoneCTC);
                    _description.AppendFormat("Portable  : {0}\n", infoEcole.Contact.PortableCTC);
                    _description.AppendFormat("EMail     : {0}\n", infoEcole.Contact.EmailCTC);
                    _description.AppendLine("-------------------------------");
                    _description.AppendLine("Compléments :");
                    _description.AppendLine(infoEcole.Contact.ComplementsCTC);
                    evnt.Description = _description.ToString();

                    EventDateTime startTime = new EventDateTime()
                    {
                        //DateTime = infoEcole._planifEnCours.StartDate.ToString("yyyy-MM-dd") + "T" + infoEcole._planifEnCours.StartDate.ToString("HH:mm:ss"),
                        DateTime = infoEcole._planifEnCours.StartDate,
                        TimeZone = "Europe/Paris"
                    };
                    EventDateTime endTime = new EventDateTime()
                    {
                        //DateTime = infoEcole._planifEnCours.EndDate.ToString("yyyy-MM-dd") + "T" + infoEcole._planifEnCours.EndDate.ToString("HH:mm:ss"),
                        DateTime = infoEcole._planifEnCours.EndDate,
                        TimeZone = "Europe/Paris"
                    };
                    evnt.Start = startTime;
                    evnt.End = endTime;

                    EventsResource er = new EventsResource(p_myService);
                    Event evntAfte = er.Patch(evnt, IdGoogleCalendar, googleEvent.Id).Execute();
                }
                catch (Exception _exc)
                {
                    Log.Error("Erreur lors de la mise à jour de l'événement Google {" + p_googleAccount + "} - {" + p_privateKey + "}", _exc);
                }
            }
        }
        // Just loops though getting all the rows.  
        private static Events ProcessResults(EventsResource.ListRequest request)
        {
            try
            {
                Events result = request.Execute();
                List<Event> allRows = new List<Event>();

                //// 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();

                }
                Events allData = result;
                allData.Items = (List<Event>)allRows;
                return allData;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
        }