• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CalendarService类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CalendarService的典型用法代码示例。如果您正苦于以下问题:C# CalendarService类的具体用法?C# CalendarService怎么用?C# CalendarService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: CreateService

        public CalendarService CreateService(string applicationName)
        {
            UserCredential credential;
            string[] scopes = { CalendarService.Scope.CalendarReadonly };

            using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
            {
                var credPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

                credPath = Path.Combine(credPath, ".credentials");

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
            }

            var service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = applicationName,
            });

            return service;
        }
开发者ID:raganm,项目名称:GoogleCalendarTest,代码行数:27,代码来源:CalendarUtils.cs


示例2: GoogleMain

        public void GoogleMain()
        {
            UserCredential credential;

            using (FileStream stream =
                new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
            {
                string credPath = System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.Personal);
                credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart");

                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;
                Console.WriteLine("Credential file saved to: " + credPath);
            }

          
            CalendarService service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = ApplicationName,
            });
            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;

            
            Events events = request.Execute();

           
            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;
                    }
                   
                    gcevents.Add(eventItem.Summary);
                    dates.Add(when);
                }
            }
            else
            {
                
            }
            



        }
开发者ID:KongXiong,项目名称:Airline-Proj2,代码行数:60,代码来源:CalendarReader.cs


示例3: AuthenticateCalendarOauth

        /// <summary>
        ///     <see cref="Authenticate" /> to Google Using Oauth2 Documentation
        ///     https://developers.google.com/accounts/docs/OAuth2
        /// </summary>
        /// <param name="clientId">
        ///     From Google Developer console https://console.developers.google.com
        /// </param>
        /// <param name="clientSecret">
        ///     From Google Developer console https://console.developers.google.com
        /// </param>
        /// <param name="userName">
        ///     A string used to identify a user (locally).
        /// </param>
        /// <param name="fileDataStorePath">
        ///     Name/Path where the Auth Token and refresh token are stored (usually
        ///     in %APPDATA%)
        /// </param>
        /// <param name="applicationName">Applicaiton Name</param>
        /// <param name="isFullPath">
        ///     <paramref name="fileDataStorePath" /> is completePath or Directory
        ///     Name
        /// </param>
        /// <returns>
        /// </returns>
        public CalendarService AuthenticateCalendarOauth(string clientId, string clientSecret, string userName,
            string fileDataStorePath, string applicationName, bool isFullPath = false)
        {
            try
            {
                var authTask = Authenticate(clientId, clientSecret, userName, fileDataStorePath, isFullPath);

                authTask.Wait(30000);

                if (authTask.Status == TaskStatus.WaitingForActivation)
                {
                    return null;
                }

                var service = new CalendarService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = authTask.Result,
                    ApplicationName = applicationName
                });

                return service;
            }
            catch (AggregateException exception)
            {
                Logger.Error(exception);
                return null;
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
                return null;
            }
        }
开发者ID:flyeven,项目名称:PCoMD,代码行数:57,代码来源:AccountAuthenticationService.cs


示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            // Ensure we have at least one calendar. If not, let's move them back to the calendar and explain that this feature is not yet ready.
            var service = new CalendarService();
            var calendars = service.GetCalendars();
            if(calendars.First().CalendarID == 0)
            {
                Response.Redirect(URL_CALENDAR + "?status=0");
            }

            // Ensure that, if we are editing an event, it is the backoffice owner's event.
            if(CalendarItemID != 0)
            {
                if(!service.ValidateCalendarItem(CalendarItemID))
                {
                    Response.Redirect(URL_CALENDARDETAILS + "?id=" + CalendarItemID);
                }
            }

            PopulateCalendarOptions();
            PopulateCalendarItemRepeatTypeOptions();
            PopulateCalendarItemTypeOptions();
            PopulateDefaultFormOptions();
            PopulateTimeZones();
            PopulateExistingData();
        }
    }
开发者ID:BakerWebDev,项目名称:strongbrook.me,代码行数:29,代码来源:ManageEvent.aspx.cs


示例5: addEvent

        public static void addEvent(CalendarService service, string email, string summary, string[] participants, TimePeriod timePeriod)
        {
            Event myEvent = new Event
            {
                Summary = summary,
                //Location = "Somewhere",
                Start = new EventDateTime()
                {
                    DateTime = timePeriod.Start.Value,
                    TimeZone = "Europe/London"
                },
                End = new EventDateTime()
                {
                    DateTime = timePeriod.End.Value,
                    TimeZone = "Europe/London"
                },
                /*Recurrence = new String[] {
                            "RRULE:FREQ=WEEKLY;BYDAY=MO"
                },*/

                //Attendees = getAttendees(participants)
            };

            //or Insert(myEvent, "primary")
            Event recurringEvent = service.Events.Insert(myEvent, email).Execute();
        }
开发者ID:tonyxfox,项目名称:SScheduler,代码行数:26,代码来源:GoogleCalendarUtils.cs


示例6: ApiMethods

        public ApiMethods()
        {
            using (var stream =
                new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
            {
                string credPath = System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.Personal);
                credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart");

                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.
            service = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = applicationName,
            });
        }
开发者ID:Alexsus87,项目名称:GAPI,代码行数:25,代码来源:ApiMethods.cs


示例7: AddCalendarEventClick

        private void AddCalendarEventClick(object sender, RoutedEventArgs e)
        {
            const string calendarEventDescription = "Test event for DrZob";
            var timeFrom = DateTime.Today.AddHours(4);
            var timeTo = DateTime.Today.AddHours(6);
            var calendarEvent = CreateCalendarEvent(calendarEventDescription, timeFrom, timeTo);

            try
            {
                var credentials = GetCredentials(new[] { CalendarService.Scope.Calendar }, User.Text);

                var calendarService = new CalendarService(new BaseClientService.Initializer
                                                  {
                                                      HttpClientInitializer = credentials,
                                                      ApplicationName = ApplicationName
                                                  });

                var calendars = calendarService.CalendarList.List().Execute();
                var calendar = calendars.Items.SingleOrDefault(x => x.Summary == "DrZob");

                if (calendar == null)
                {
                    MessageBox.Show("The calendar 'DrZob' does not exist!");
                    return;
                }

                var calendarEventResponse = calendarService.Events.Insert(calendarEvent, calendar.Id).Execute();
            }
            catch (Exception ex)
            {
                Console.WriteLine("A Google Apps error occurred:");
                Console.WriteLine(ex.Message);
            }
        }
开发者ID:LogicInc,项目名称:GoogleCalendarTest,代码行数:34,代码来源:MainWindow.xaml.cs


示例8: Render

    protected override void Render(HtmlTextWriter writer)
    {
        if(Request.QueryString["action"] != null)
        {
            var start = Request.QueryString["start"];
            var end = Request.QueryString["end"];
            var filter = Request.QueryString["filter"];

            var service = new CalendarService();
            var json = service.GetDataAsJson(start, end, filter);

            // Write the JSON
            Response.Clear();
            writer.Write(json);
            Response.End();

            // Write the JSON
            Response.Clear();
            writer.Write(json);
            Response.End();
        }
        else
        {
            base.Render(writer);
        }
    }
开发者ID:BakerWebDev,项目名称:strongbrook.me,代码行数:26,代码来源:Calendar.aspx.cs


示例9: InitCnx

        /// <summary>
        /// Initialise la connexion avec Google Calendar
        /// </summary>
        /// <param name="privateKey"></param>
        /// <param name="googleAccount"></param>
        /// <returns></returns>
        public bool InitCnx()
        {
            Log.Debug("Initialisation de la connexion avec Google ...");
            // Si la fonction n'est pas activée, on passe tout de suite
            if (!p_isActivated) { return false; }

            try
            {
                string[] scopes = new string[] {
                    CalendarService.Scope.Calendar, // Manage your calendars
 	                CalendarService.Scope.CalendarReadonly // View your Calendars
            };
                var certificate = new X509Certificate2(p_privateKey, "notasecret", X509KeyStorageFlags.Exportable);

                ServiceAccountCredential credential = new ServiceAccountCredential(
                         new ServiceAccountCredential.Initializer(p_googleAccount)
                         {
                             Scopes = scopes
                         }.FromCertificate(certificate));
                // Create Google Calendar API service.
                p_myService = new CalendarService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName = "PlanningLAB",
                });
            }
            catch (Exception err) { Log.Error("Erreur Authentification Google {" + p_googleAccount + "} - {" + p_privateKey + "} :", err); return false; }
            return true;
        }/// <summary>
开发者ID:StephOfPixVert,项目名称:PlanningLab,代码行数:35,代码来源:GoogleUtilities.cs


示例10: AuthenticateOauth

        /// <summary>
        /// Authenticate to Google Using Oauth2
        /// Documentation https://developers.google.com/accounts/docs/OAuth2
        /// </summary>
        /// <param name="clientId">From Google Developer console https://console.developers.google.com</param>
        /// <param name="clientSecret">From Google Developer console https://console.developers.google.com</param>
        /// <param name="userName">A string used to identify a user.</param>
        /// <returns></returns>
        public static CalendarService AuthenticateOauth(string clientId, string clientSecret, string userName)
        {

            string[] scopes = new string[] {
        CalendarService.Scope.Calendar  ,  // Manage your calendars
        CalendarService.Scope.CalendarReadonly    // View your Calendars
            };

            try
            {
                // here is where we Request the user to give us access, or use the Refresh Token that was previously stored in %AppData%
                UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets { ClientId = clientId, ClientSecret = clientSecret }
                                                                    , scopes
                                                                    , userName
                                                                    , CancellationToken.None
                                                                    , new FileDataStore("Daimto.GoogleCalendar.Auth.Store")).Result;



                CalendarService service = new CalendarService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName = "Calendar API Sample",
                });
                return service;
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.InnerException);
                return null;

            }

        }
开发者ID:anhct,项目名称:Google-Dotnet-Samples,代码行数:43,代码来源:Authentication.cs


示例11: GoogleCalendar

        public GoogleCalendar()
        {
            //UserCredential credential;
            //using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
            //{

            //    //var clientSecrets = GoogleClientSecrets.Load(stream).Secrets;
            //     credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
            //        stream,
            //        new[] { CalendarService.Scope.Calendar },
            //        "user", CancellationToken.None, new FileDataStore("Calendar.ListMyLibrary")).Result;

            //    service = new CalendarService(new BaseClientService.Initializer()
            //    {
            //        HttpClientInitializer = credential,
            //        ApplicationName = "Outlook Google Sync" ,

            //    });
            //    //credential = authorizeAsync.Result;
            //}

            var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
            provider.ClientIdentifier = "646754649922-g2p0157e4q3d5qv25ia3ur09vrc455k6.apps.googleusercontent.com";
            provider.ClientSecret = "ZyPfCdrOFb6y-VWrdVZ65_8M";

            service = new CalendarService(new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthentication));
            service.Key = "AIzaSyCg7QtvUT6V3Hh3ZG7M5KfDiFScRkaYix0";
        }
开发者ID:rantsi,项目名称:outlookgooglesync,代码行数:28,代码来源:GoogleCalendar.cs


示例12: UpcomingEvents

        // GET: /Calendar/UpcomingEvents
        public async Task<ActionResult> UpcomingEvents()
        {
            const int MaxEventsPerCalendar = 20;
            const int MaxEventsOverall = 50;

            var model = new UpcomingEventsViewModel();

            var credential = await GetCredentialForApiAsync();

            var initializer = new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "ASP.NET MVC5 Calendar Sample",
            };
            var service = new CalendarService(initializer);

            // Fetch the list of calendars.
            var calendars = await service.CalendarList.List().ExecuteAsync();

            // Fetch some events from each calendar.
            var fetchTasks = new List<Task<Google.Apis.Calendar.v3.Data.Events>>(calendars.Items.Count);
            foreach (var calendar in calendars.Items)
            {
                var request = service.Events.List(calendar.Id);
                request.MaxResults = MaxEventsPerCalendar;
                request.SingleEvents = true;
                request.TimeMin = DateTime.Now;
                fetchTasks.Add(request.ExecuteAsync());
            }
            var fetchResults = await Task.WhenAll(fetchTasks);

            // Sort the events and put them in the model.
            var upcomingEvents = from result in fetchResults
                                 from evt in result.Items
                                 where evt.Start != null
                                 let date = evt.Start.DateTime.HasValue ?
                                     evt.Start.DateTime.Value.Date :
                                     DateTime.ParseExact(evt.Start.Date, "yyyy-MM-dd", null)
                                 let sortKey = evt.Start.DateTimeRaw ?? evt.Start.Date
                                 orderby sortKey
                                 select new { evt, date };
            var eventsByDate = from result in upcomingEvents.Take(MaxEventsOverall)
                               group result.evt by result.date into g
                               orderby g.Key
                               select g;

            var eventGroups = new List<CalendarEventGroup>();
            foreach (var grouping in eventsByDate)
            {
                eventGroups.Add(new CalendarEventGroup
                {
                    GroupTitle = grouping.Key.ToLongDateString(),
                    Events = grouping,
                });
            }

            model.EventGroups = eventGroups;
            return View(model);
        }
开发者ID:Cyril12740,项目名称:google-api-dotnet-client-samples,代码行数:60,代码来源:CalendarController.cs


示例13: AddEvent

        public void AddEvent()
        {
            UserCredential credential;

            using (var stream =
                new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
            {
                string credPath = System.Environment.GetFolderPath(
                    System.Environment.SpecialFolder.Personal);
                credPath = Path.Combine(credPath, ".credentials/calendar-dotnet-quickstart");

                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,
            });
            Console.WriteLine("Enter sumary");
            string sum = Console.ReadLine();

            Console.WriteLine("Enter Location");
            string location = Console.ReadLine();

            Event myEvent = new Event
            {

                Summary = sum,
                Location = location,
                Start = new EventDateTime()
                {
                    DateTime = new DateTime(2016,03,06),
                    TimeZone = "America/Chicago"
                },
                End = new EventDateTime()
                {
                    DateTime = new DateTime(2016,03,07),
                    TimeZone = "America/Chicago"
                },
                Recurrence = new String[] {
      "RRULE:FREQ=WEEKLY;BYDAY=MO"
  },
                Attendees = new List<EventAttendee>()
      {
        new EventAttendee() { Email = "[email protected]" }
      }
            };

            Event recurringEvent = service.Events.Insert(myEvent, "primary").Execute();
        }
开发者ID:KongXiong,项目名称:Airline-Proj2,代码行数:58,代码来源:GoogleCalendar.cs


示例14: Main

        public static void Main(string[] args)
        {
            Console.WriteLine("Google Calender API v3");

            var clientId = ConfigurationManager.AppSettings["ClientId"];
            var clientSecret = ConfigurationManager.AppSettings["ClientSecret"];
            var calendarId = ConfigurationManager.AppSettings["CalendarId"];

            try
            {
                var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    new ClientSecrets
                    {
                        ClientId = clientId,
                        ClientSecret = clientSecret,
                    },
                    new[] { CalendarService.Scope.Calendar },
                    "user",
                    CancellationToken.None).Result;

                var service = new CalendarService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = credential,
                    ApplicationName = "Google Calender API v3",
                });

                var queryStart = DateTime.Now;
                var queryEnd = queryStart.AddYears(1);

                var query = service.Events.List(calendarId);
                // query.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime; - not supported :(
                query.TimeMin = queryStart;
                query.TimeMax = queryEnd;

                var events = query.Execute().Items;

                var eventList = events.Select(e => new Tuple<DateTime, string>(DateTime.Parse(e.Start.Date), e.Summary)).ToList();
                eventList.Sort((e1, e2) => e1.Item1.CompareTo(e2.Item1));

                Console.WriteLine("Query from {0} to {1} returned {2} results", queryStart, queryEnd, eventList.Count);

                foreach (var item in eventList)
                {
                    Console.WriteLine("{0}\t{1}", item.Item1, item.Item2);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception encountered: {0}", e.Message);
            }

            Console.WriteLine("Press any key to continue...");

            while (!Console.KeyAvailable)
            {
            }
        }
开发者ID:zhouhao15917,项目名称:Google-Calendar-API-v3-Simple-Console-Demo,代码行数:57,代码来源:Program.cs


示例15: Main

        static void Main(string[] args)
        {
            UserCredential credential;

            using (var stream = new FileStream("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.AddYears(-1);//DateTime.Now.AddYears(-7);
            request.TimeMax = DateTime.Now;
            request.ShowDeleted = false;
            request.SingleEvents = true;
            request.MaxResults = 1000;//{Default:25, Max:2500}
            request.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;

            // List events.
            Events events = request.Execute();
            Console.WriteLine(String.Format("Event Count: {0}", events.Items.Count));
            if (events.Items != null && events.Items.Count > 0)
            {
                foreach (var eventItem in events.Items)
                {
                    Thread.Sleep(200);
                    eventItem.Visibility = "private";
                    eventItem.Transparency = "transparent";
                    EventsResource.UpdateRequest updateReq = service.Events.Update(eventItem, "primary", eventItem.Id);
                    Event updatedEvent = updateReq.Execute();
                    Console.WriteLine("Event Updated: " + updatedEvent.Id + " " + updatedEvent.Visibility + " " + updatedEvent.Description);
                }
            }
            else
            {
                Console.WriteLine("No events found.");
            }
            Console.Read();
            Console.Read();
        }
开发者ID:danielevora,项目名称:CalUndoer,代码行数:57,代码来源:Program.cs


示例16: Main

        static void Main(string[] args)
        {
            UserCredential credential;

            using (var stream = new FileStream(@"Components\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 Calendar 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;

            Console.WriteLine("Upcoming events:");
            Events events = request.Execute();
            if (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();
        }
开发者ID:OskarKlintrot,项目名称:1dv430-individuellt-mjukvaruutvecklingsprojekt,代码行数:56,代码来源:Program.cs


示例17: GetData

        /// <summary>
        /// Loads calendar events
        /// </summary>
        /// <returns>Awaitable task of Events in list form</returns>
        public List<Cal.Event> GetData()
        {
            string serviceAccount = "[email protected]nt.com";
            string fileName = System.Web.HttpContext.Current.Server.MapPath("..\\") + "MagicMirror.p12";

            var certificate = new X509Certificate2(fileName, "notasecret", X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable);

            ServiceAccountCredential credential = new ServiceAccountCredential(
               new ServiceAccountCredential.Initializer(serviceAccount)
               {
                   Scopes = new[] { CalendarService.Scope.CalendarReadonly },
                   User = serviceAccount
               }.FromCertificate(certificate));


            var calendarService = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "MagicMirror"
            });

            var calendarListResource = calendarService.CalendarList.List().Execute(); //await calendarService.CalendarList.List().ExecuteAsync(); //calendarService.CalendarList.List().Execute().Items; 

            var myCalendar = calendarListResource.Items[0];

            string pageToken = null;
            Events = new List<Cal.Event>();

            //do
            //{
            //TODO: Make configuration items
            var activeCalendarList = calendarService.Events.List(calendarOwner);
            activeCalendarList.PageToken = pageToken;
            activeCalendarList.MaxResults = 3;
            activeCalendarList.TimeMax = DateTime.Now.AddMonths(3);
            activeCalendarList.TimeMin = DateTime.Now;
            activeCalendarList.SingleEvents = true;
            activeCalendarList.OrderBy = EventsResource.ListRequest.OrderByEnum.StartTime;

            var calEvents = activeCalendarList.Execute();

            var items = calEvents.Items;
            foreach (var item in items)
            {
                Events.Add(new Cal.Event()
                {
                    Summary = item.Summary,
                    StartTimeStr = (item.Start.DateTime.HasValue ? item.Start.DateTime.Value : DateTime.Parse(item.Start.Date)).ToString(),
                    EndTimeStr = (item.End.DateTime.HasValue ? item.End.DateTime.Value : DateTime.Parse(item.End.Date)).ToString()
                });
            }

            return Events;
        }
开发者ID:scottroot2,项目名称:MagicMirror,代码行数:58,代码来源:CalendarManager.cs


示例18: push_event

 public void push_event()
 {
     CalendarService service = new CalendarService(new BaseClientService.Initializer()
     {
         HttpClientInitializer = credential,
         ApplicationName = ApplicationName,
     });
     EventsResource.InsertRequest newevent =  service.Events.Insert(googleevent, "primary");
     newevent.SendNotifications = true;
     newevent.Execute();
 }
开发者ID:zhtmike,项目名称:seminar,代码行数:11,代码来源:calendarevent.cs


示例19: get

 /// <summary>
 /// Returns metadata for a calendar. 
 /// Documentation:https://developers.google.com/google-apps/calendar/v3/reference/calendars/get
 /// </summary>
 /// <param name="service">Valid Autenticated Calendar service</param>
 /// <param name="id">Calendar identifier.</param>
 /// <returns>Calendar resorce: https://developers.google.com/google-apps/calendar/v3/reference/calendars#resource </returns>
 public static Calendar get(CalendarService service, string id)
 {
     try
     {
        return service.Calendars.Get(id).Execute();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return null;
     }
 }
开发者ID:anhct,项目名称:Google-Dotnet-Samples,代码行数:19,代码来源:DaimtoCalendarHelper.cs


示例20: get

 /// <summary>
 /// Imports an event. This operation is used to add a private copy of an existing event to a calendar. 
 /// Documentation:https://developers.google.com/google-apps/calendar/v3/reference/events/import
 /// </summary>
 /// <param name="service">Valid Autenticated Calendar service</param>
 /// <param name="id">Calendar identifier.</param>
 /// <param name="body">an event</param>
 /// <returns>Events resorce: https://developers.google.com/google-apps/calendar/v3/reference/events#resource </returns>
 public static Event get(CalendarService service, string id,Event body)
 {
     try
     {
         return service.Events.Import(body,id).Execute();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         return null;
     }
 }
开发者ID:anhct,项目名称:Google-Dotnet-Samples,代码行数:20,代码来源:DaimtoEventHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CalendarWeekRule类代码示例发布时间:2022-05-24
下一篇:
C# CalendarId类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap