当前位置: 首页>>代码示例>>C#>>正文


C# CalendarService.SetAuthenticationToken方法代码示例

本文整理汇总了C#中Google.GData.Calendar.CalendarService.SetAuthenticationToken方法的典型用法代码示例。如果您正苦于以下问题:C# CalendarService.SetAuthenticationToken方法的具体用法?C# CalendarService.SetAuthenticationToken怎么用?C# CalendarService.SetAuthenticationToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Google.GData.Calendar.CalendarService的用法示例。


在下文中一共展示了CalendarService.SetAuthenticationToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCalendarEvents

        public static List<CalendarEvent> GetCalendarEvents(Calendar calendar)
        {
            List<CalendarEvent> eventList = new List<CalendarEvent>();

            EventQuery query = new EventQuery();
            CalendarService service = new CalendarService("GoogleCalendarReminder");
            service.SetAuthenticationToken(GetAuthToken());

            //service.setUserCredentials(Account.Default.Username
            //                            , SecureStringUtility.SecureStringToString(Account.Default.Password));

            query.Uri = new Uri(calendar.CalendarUri);
            query.SingleEvents = true;
            query.StartTime = DateTime.Now;
            query.EndTime = DateTime.Today.AddDays(Settings.Default.DayRange);

            EventFeed calFeed;
            try
            {
                calFeed = service.Query(query) as EventFeed;
            }
            catch (Exception)
            {
                return null;
            }

            // now populate the calendar
            while (calFeed != null && calFeed.Entries.Count > 0)
            {
                foreach (EventEntry entry in calFeed.Entries)
                {
                    eventList.Add(new CalendarEvent(entry)
                                        {
                                            Color = calendar.Color
                                        });
                }

                // just query the same query again.
                if (calFeed.NextChunk != null)
                {
                    query.Uri = new Uri(calFeed.NextChunk);

                    try
                    {
                        calFeed = service.Query(query) as EventFeed;
                    }
                    catch (Exception ex)
                    {
                        return null;
                    }
                }
                else
                {
                    calFeed = null;
                }
            }

            return eventList;
        }
开发者ID:cyndilou,项目名称:CalendarReminderApp,代码行数:59,代码来源:GoogleCalendarService.cs

示例2: GetCalendarList

        public static List<Calendar> GetCalendarList()
        {
            // Create a CalenderService and authenticate
            var service = new CalendarService("GoogleCalendarReminder");
            service.SetAuthenticationToken(GetAuthToken());

            //service.setUserCredentials(Account.Default.Username, SecureStringUtility.SecureStringToString(Account.Default.Password));

            var query = new CalendarQuery
                            {
                                Uri = new Uri("https://www.google.com/calendar/feeds/default/allcalendars/full")
                            };

            CalendarFeed resultFeed;

            try
            {
                resultFeed = service.Query(query) as CalendarFeed;
            }
            catch (CaptchaRequiredException ex)
            {
                // TODO: CDA - http://code.google.com/googleapps/faq.html
                MessageBox.Show(ex.Message, ex.GetType().ToString());

                //https://www.google.com/accounts/UnlockCaptcha
                return null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().ToString());
                return null;
            }

            return (from CalendarEntry entry in resultFeed.Entries where !entry.Hidden select new Calendar(entry)).ToList();
        }
开发者ID:cyndilou,项目名称:CalendarReminderApp,代码行数:35,代码来源:GoogleCalendarService.cs


注:本文中的Google.GData.Calendar.CalendarService.SetAuthenticationToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。