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


C# CalendarService.Query方法代码示例

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


在下文中一共展示了CalendarService.Query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Delete

 public bool Delete(Task task)
 {
     ErrorMessage = String.Empty;
     CalendarService service = new CalendarService("googleCalendar");
     service.setUserCredentials(task.AccountInfo.Username, task.AccountInfo.Password);
     Log.InfoFormat("Fetching google account : [{0}]", task.AccountInfo.ToString());
     string queryUri = String.Format(CultureInfo.InvariantCulture,
                                     "http://www.google.com/calendar/feeds/{0}/private/full",
                                     service.Credentials.Username);
     Log.DebugFormat("Query='{0}'", queryUri);
     EventQuery eventQuery = new EventQuery(queryUri);
     try
     {
         EventFeed eventFeed = service.Query(eventQuery);
         foreach (EventEntry eventEntry in eventFeed.Entries.Cast<EventEntry>())
         {
             if (eventEntry.Times.Count > 0)
             {
                 if (eventEntry.EventId == task.Id)
                 {
                     Log.InfoFormat("Deleting : [{0}]-[{1}]", eventEntry.EventId, eventEntry.Title);
                     eventEntry.Delete();
                     return true;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         Log.ErrorFormat(exception.Message);
         Log.ErrorFormat(exception.ToString());
         ErrorMessage = exception.Message;
     }
     return false;
 }
开发者ID:trippleflux,项目名称:jezatools,代码行数:35,代码来源:GoogleTaskManager.cs

示例3: PrintAllEvents

        /// <summary>
        /// Prints the titles of all events on the specified calendar.
        /// </summary>
        /// <param name="service">The authenticated CalendarService object.</param>
        static void PrintAllEvents(CalendarService service)
        {
            EventQuery myQuery = new EventQuery(feedUri);
            EventFeed myResultsFeed = service.Query(myQuery) as EventFeed;

            Console.WriteLine("All events on your calendar:");
            Console.WriteLine();
            for (int i = 0; i < myResultsFeed.Entries.Count; i++)
            {
                Console.WriteLine(myResultsFeed.Entries[i].Title.Text);
            }
            Console.WriteLine();
        }
开发者ID:mintwans,项目名称:cpsc483,代码行数:17,代码来源:CalendarDemo.cs

示例4: Main

        static void Main(string[] args)
        {
            try
            {
                // create an OAuth factory to use
                GOAuthRequestFactory requestFactory = new GOAuthRequestFactory("cl", "MyApp");
                requestFactory.ConsumerKey = "CONSUMER_KEY";
                requestFactory.ConsumerSecret = "CONSUMER_SECRET";

                // example of performing a query (use OAuthUri or query.OAuthRequestorId)
                Uri calendarUri = new OAuthUri("http://www.google.com/calendar/feeds/default/owncalendars/full", "USER", "DOMAIN");
                // can use plain Uri if setting OAuthRequestorId in the query
                // Uri calendarUri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full");

                CalendarQuery query = new CalendarQuery();
                query.Uri = calendarUri;
                query.OAuthRequestorId = "[email protected]"; // can do this instead of using OAuthUri for queries

                CalendarService service = new CalendarService("MyApp");
                service.RequestFactory = requestFactory;
                service.Query(query);
                Console.WriteLine("Query Success!");

                // example with insert (must use OAuthUri)
                Uri contactsUri = new OAuthUri("http://www.google.com/m8/feeds/contacts/default/full", "USER", "DOMAIN");

                ContactEntry entry = new ContactEntry();
                EMail primaryEmail = new EMail("[email protected]");
                primaryEmail.Primary = true;
                primaryEmail.Rel = ContactsRelationships.IsHome;
                entry.Emails.Add(primaryEmail);

                ContactsService contactsService = new ContactsService("MyApp");
                contactsService.RequestFactory = requestFactory;
                contactsService.Insert(contactsUri, entry); // this could throw if contact exists

                Console.WriteLine("Insert Success!");

                // to perform a batch use
                // service.Batch(batchFeed, new OAuthUri(atomFeed.Batch, userName, domain));

                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Fail!");
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.ReadKey();
            }
        }
开发者ID:Zelxin,项目名称:RPiKeg,代码行数:51,代码来源:Program.cs

示例5: FullTextQuery

        /// <summary>
        /// Prints the titles of all events matching a full-text query.
        /// </summary>
        /// <param name="service">The authenticated CalendarService object.</param>
        /// <param name="queryString">The text for which to query.</param>
        static void FullTextQuery(CalendarService service, String queryString)
        {
            EventQuery myQuery = new EventQuery(feedUri);
            myQuery.Query = queryString;

            EventFeed myResultsFeed = service.Query(myQuery) as EventFeed;

            Console.WriteLine("Events matching \"{0}\":", queryString);
            Console.WriteLine();
            for (int i = 0; i < myResultsFeed.Entries.Count; i++)
            {
                Console.WriteLine(myResultsFeed.Entries[i].Title.Text);
            }
            Console.WriteLine();
        }
开发者ID:mintwans,项目名称:cpsc483,代码行数:20,代码来源:CalendarDemo.cs

示例6: PrintUserCalendars

        /// <summary>
        /// Prints a list of the user's calendars.
        /// </summary>
        /// <param name="service">The authenticated CalendarService object.</param>
        static void PrintUserCalendars(CalendarService service)
        {
            FeedQuery query = new FeedQuery();
            query.Uri = new Uri("http://www.google.com/calendar/feeds/default");

            // Tell the service to query:
            AtomFeed calFeed = service.Query(query);

            Console.WriteLine("Your calendars:");
            Console.WriteLine();
            for (int i = 0; i < calFeed.Entries.Count; i++)
            {
                Console.WriteLine(calFeed.Entries[i].Title.Text);
            }
            Console.WriteLine();
        }
开发者ID:mintwans,项目名称:cpsc483,代码行数:20,代码来源:CalendarDemo.cs

示例7: deleteCalendar

        private void deleteCalendar(CalendarService service,string calendarTitle)
        {
            //assume title is non-empty for now
            CalendarQuery query = new CalendarQuery();
            query.Uri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
            CalendarFeed resultFeed = (CalendarFeed)service.Query(query);

            foreach (CalendarEntry entry in resultFeed.Entries)
            {
                if (entry.Title.Text == calendarTitle)
                {
                    try
                    {
                        entry.Delete();
                    }
                    catch (GDataRequestException)
                    {
                        MessageBox.Show("Unable to delete primary calendar.\n");
                    }
                }
            }
        }
开发者ID:creativepsyco,项目名称:SampleGData,代码行数:22,代码来源:Form1.cs

示例8: GetItems

        public EventDto[] GetItems()
        {
            EventQuery query = new EventQuery();
            CalendarService service = new CalendarService("Virtual ALT.NET calendar");

            query.Uri = new Uri(@"http://www.google.com/calendar/feeds/[email protected]/public/full");
            query.StartTime = DateTime.Now;
            query.EndTime = DateTime.Now.AddMonths(3);
            query.SingleEvents = true;
            query.ExtraParameters = "orderby=starttime&sortorder=ascending";

            try
            {
                EventFeed calFeed = service.Query(query);

                return this.GetEventDtos(calFeed.Entries.OfType<EventEntry>());
            }
            catch (Exception)
            {
                return new EventDto[0];
            }
        }
开发者ID:zachariahyoung,项目名称:virtualaltnet,代码行数:22,代码来源:GoogleEventProvider.cs

示例9: Main

        static void Main(string[] args)
        {
            //
            // TODO: Add code to start application here
            //
            if (args.Length < 3)
            {
                Console.WriteLine("Not enough parameters. Usage is Sample <uri> <username> <password>");
                return;
            }

            string calendarURI = args[0];
            string userName = args[1];
            string passWord = args[2];

            EventQuery query = new EventQuery();
            CalendarService service = new CalendarService(ApplicationName);

            if (userName != null)
            {
                service.setUserCredentials(userName, passWord);
            }

            query.Uri = new Uri(calendarURI);
            EventFeed calFeed = service.Query(query);

            EventEntry insertedEntry = InsertEvent(calFeed, "Conference www2006",
                "Frank Mantek", DateTime.Now, 
                                DateTime.Now.AddDays(1), 
                                true,
                                "Edinburgh");

            if (insertedEntry != null) 
            {
                DumpEventEntry(insertedEntry);
            }
        }
开发者ID:mintwans,项目名称:cpsc483,代码行数:37,代码来源:insert.cs

示例10: Main

        static void Main(string[] args)
        {
            //
            // TODO: Add code to start application here
            //
            if (args.Length != 1 && args.Length != 3)
            {
                Console.WriteLine("Not enough parameters. Usage is Sample <uri> <username> <password>");
                return;
            }

            string calendarURI = args[0];

            string userName = args.Length == 3 ? args[1] : null;
            string passWord = args.Length == 3 ? args[2] : null;

            EventQuery query = new EventQuery();
            CalendarService service = new CalendarService(ApplicationName);

            if (userName != null)
            {
                service.setUserCredentials(userName, passWord);
            }

            query.Uri = new Uri(calendarURI);
            EventFeed calFeed = service.Query(query) as EventFeed;

            Console.WriteLine("");
            Console.WriteLine("Query Feed Test " + query.Uri);

            Console.WriteLine("Post URI is:  " + calFeed.Post); 

            foreach (EventEntry feedEntry in calFeed.Entries)
            {
                DumpEventEntry(feedEntry);
            }
        }
开发者ID:mintwans,项目名称:cpsc483,代码行数:37,代码来源:main.cs

示例11: Main

        static void Main(string[] args)
        {
            //
            // TODO: Add code to start application here
            //
            if (args.Length < 3)
            {
                Console.WriteLine("Not enough parameters. Usage is Sample <uri> <username> <password>");
                return;
            }

            string calendarURI = args[0];
            string userName = args[1];
            string passWord = args[2];

            EventQuery query = new EventQuery();
            CalendarService service = new CalendarService(ApplicationName);

            if (userName != null)
            {
                service.setUserCredentials(userName, passWord);
            }

            query.Uri = new Uri(calendarURI);
            EventFeed calFeed = service.Query(query) as EventFeed;

 			foreach (EventEntry entry in calFeed.Entries)
            {
            	if (entry.Title.Text == "Conference www2006") 
            	{
                	entry.Content.Content = "The conference was fun... ";
                	entry.Update();
                	Console.WriteLine("Updated the Conference entry"); 
                }
            }
        }
开发者ID:mintwans,项目名称:cpsc483,代码行数:36,代码来源:update.cs

示例12: CalendarQuickAddTest

        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarQuickAddTest()
        {
            Tracing.TraceMsg("Entering CalendarQuickAddTest");

            EventQuery query = new EventQuery();
            CalendarService service = new CalendarService(this.ApplicationName);

            if (this.defaultCalendarUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.defaultCalendarUri);
                EventFeed calFeed = service.Query(query) as EventFeed;

                if (calFeed != null)
                {
                    // get the first entry
                    EventEntry entry  = new EventEntry();
                    entry.Content.Content = "Dinner with Sabine, Oct 1st, 10pm";
                    entry.Content.Type = "html";
                    entry.QuickAdd = true;


                    EventEntry newEntry = (EventEntry) calFeed.Insert(entry); 

                    Assert.IsTrue(newEntry.Title.Text.StartsWith("Dinner with Sabine"), "both titles should be identical" + newEntry.Title.Text); 

                }
                service.Credentials = null; 
            }
        }
开发者ID:david-mitchell,项目名称:MonoMac-Demo,代码行数:42,代码来源:caltest.cs

示例13: CalendarExtensionTest

        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarExtensionTest()
        {
            Tracing.TraceMsg("Entering CalendarExtensionTest");

            EventQuery query = new EventQuery();
            CalendarService service = new CalendarService(this.ApplicationName);

            int iCount; 

            if (this.defaultCalendarUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.defaultCalendarUri);
                EventFeed calFeed = service.Query(query) as EventFeed;

                if (calFeed.TimeZone != null)
                {
                    Tracing.TraceMsg(calFeed.TimeZone.Value); 
                }

                iCount = calFeed.Entries.Count; 

               String strTitle = "Dinner & time" + Guid.NewGuid().ToString(); 

                if (calFeed != null)
                {
                    // get the first entry
                    EventEntry entry  = ObjectModelHelper.CreateEventEntry(1); 
                    entry.Title.Text = strTitle;

                    EventEntry newEntry = (EventEntry) calFeed.Insert(entry); 

                    iCount++; 
                    Tracing.TraceMsg("Created calendar entry");

                    Reminder rNew = null;
                    Reminder rOld = null;
                    if (newEntry.Reminders.Count > 0)
                    {
                        rNew = newEntry.Reminders[0] as Reminder;
                    }
                    if (entry.Reminders.Count > 0)
                    {
                        rOld = entry.Reminders[0] as Reminder;
                    }

                    Assert.IsTrue(rNew != null, "Reminder should not be NULL);");
                    Assert.IsTrue(rOld != null, "Original Reminder should not be NULL);");
                    Assert.AreEqual(rNew.Minutes, rOld.Minutes, "Reminder time should be identical"); 

                    Where wOldOne, wOldTwo;
                    Where wNewOne;

                    Assert.IsTrue(entry.Locations.Count == 2, "entry should have 2 locations");
                    // calendar ignores sending more than one location
                    Assert.IsTrue(newEntry.Locations.Count == 1, "new entry should have 1 location");


                    if (entry.Locations.Count > 1)
                    {
                        wOldOne = entry.Locations[0];
                        wOldTwo = entry.Locations[1];
                    
                        if (newEntry.Locations.Count == 1)
                        {
                            wNewOne = newEntry.Locations[0];
                            Assert.IsTrue(wOldOne != null, "Where oldOne should not be NULL);");
                            Assert.IsTrue(wOldTwo != null, "Where oldTwo should not be NULL);");
                            Assert.IsTrue(wNewOne != null, "Where newOne should not be NULL);");
                            Assert.IsTrue(wOldOne.ValueString == wNewOne.ValueString, "location one should be identical");
                        }
                    }

                    newEntry.Content.Content = "Updated..";
                    newEntry.Update();

                    // try to get just that guy.....
                    FeedQuery singleQuery = new FeedQuery();
                    singleQuery.Uri = new Uri(newEntry.SelfUri.ToString()); 

                    EventFeed newFeed = service.Query(query) as EventFeed;
                    EventEntry sameGuy = newFeed.Entries[0] as EventEntry; 

                    sameGuy.Content.Content = "Updated again..."; 
                    When x = sameGuy.Times[0]; 
                    sameGuy.Times.Clear();
                    x.StartTime = DateTime.Now; 
                    sameGuy.Times.Add(x); 
//.........这里部分代码省略.........
开发者ID:david-mitchell,项目名称:MonoMac-Demo,代码行数:101,代码来源:caltest.cs

示例14: CalendarOriginalEventTest

        //////////////////////////////////////////////////////////////////////
        /// <summary>tests the original event </summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarOriginalEventTest()
        {
            Tracing.TraceMsg("Entering CalendarOriginalEventTest");

            FeedQuery query = new FeedQuery();

            CalendarService service = new CalendarService(this.ApplicationName);

            if (this.defaultCalendarUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                GDataLoggingRequestFactory factory = (GDataLoggingRequestFactory) this.factory;
                factory.MethodOverride = true;
                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.defaultCalendarUri);

                EventFeed calFeed = service.Query(query) as EventFeed;

                string recur  = 
                    "DTSTART;TZID=America/Los_Angeles:20060314T060000\n" +
                    "DURATION:PT3600S\n" + 
                    "RRULE:FREQ=DAILY;UNTIL=20060321T220000Z\n" +
                    "BEGIN:VTIMEZONE\n" + 
                    "TZID:America/Los_Angeles\n" +
                    "X-LIC-LOCATION:America/Los_Angeles\n" +
                    "BEGIN:STANDARD\n" +
                    "TZOFFSETFROM:-0700\n" +
                    "TZOFFSETTO:-0800\n" +
                    "TZNAME:PST\n" +
                    "DTSTART:19671029T020000\n" +
                    "RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\n" +
                    "END:STANDARD\n" +
                    "BEGIN:DAYLIGHT\n" +
                    "TZOFFSETFROM:-0800\n" +
                    "TZOFFSETTO:-0700\n" +
                    "TZNAME:PDT\n" +
                    "DTSTART:19870405T020000\n" +
                    "RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU\n" +
                    "END:DAYLIGHT\n" +
                    "END:VTIMEZONE\n"; 

                EventEntry entry  =  ObjectModelHelper.CreateEventEntry(1); 
                entry.Title.Text = "New recurring event" + Guid.NewGuid().ToString();  

                // get rid of the when entry
                entry.Times.Clear(); 

                entry.Recurrence = new Recurrence();
                entry.Recurrence.Value = recur; 

                EventEntry recEntry = calFeed.Insert(entry) as EventEntry;

                entry = ObjectModelHelper.CreateEventEntry(1); 
                entry.Title.Text = "whateverfancy"; 

                OriginalEvent originalEvent = new OriginalEvent();
                When start = new When();
                start.StartTime = new DateTime(2006, 03, 14, 15, 0,0); 
                originalEvent.OriginalStartTime = start;
                originalEvent.Href = recEntry.SelfUri.ToString();
                originalEvent.IdOriginal = recEntry.EventId;
                entry.OriginalEvent = originalEvent;
                entry.Times.Add(new When(new DateTime(2006, 03, 14, 9,0,0),
                                         new DateTime(2006, 03, 14, 10,0,0)));
                calFeed.Insert(entry);

                service.Credentials = null; 
                factory.MethodOverride = false;
            }
        }
开发者ID:david-mitchell,项目名称:MonoMac-Demo,代码行数:78,代码来源:caltest.cs

示例15: CalendarDefaultReminderTest

        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>tests that a default reminder get's created if none is set</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarDefaultReminderTest()
        {
            Tracing.TraceMsg("Entering CalendarDefaultReminderTest");

            FeedQuery query = new FeedQuery();

            CalendarService service = new CalendarService(this.ApplicationName);

            if (this.defaultCalendarUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                GDataLoggingRequestFactory factory = (GDataLoggingRequestFactory) this.factory;
                factory.MethodOverride = true;
                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.defaultCalendarUri);

                EventFeed calFeed = service.Query(query) as EventFeed;

                EventEntry entry  =  ObjectModelHelper.CreateEventEntry(1); 
                entry.Title.Text = "New event with default reminder" + Guid.NewGuid().ToString();  

                entry.Reminder = new Reminder();
                entry.Reminder.Method = Reminder.ReminderMethod.unspecified;

                EventEntry newEntry = calFeed.Insert(entry) as EventEntry;
                Reminder reminder = newEntry.Reminder;
                Assert.IsTrue(reminder != null, "reminder should not be null - this only works if the calendar HAS default remidners set"); 
                Assert.IsTrue(reminder.Method != Reminder.ReminderMethod.unspecified, "reminder should not be unspecified - this only works if the calendar HAS default remidners set"); 

                service.Credentials = null; 
                factory.MethodOverride = false;
            }
        }
开发者ID:david-mitchell,项目名称:MonoMac-Demo,代码行数:43,代码来源:caltest.cs


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