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


C# CalendarService.Batch方法代码示例

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


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

示例1: CalendarBatchTest

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


        //////////////////////////////////////////////////////////////////////
        /// <summary>runs a test of batch support on the events feed</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void CalendarBatchTest()
        {
            Tracing.TraceMsg("Entering CalendarBatchTest");

            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;

                EventQuery query = new EventQuery(this.defaultCalendarUri);

                EventFeed feed = service.Query(query);
                AtomFeed batchFeed = new AtomFeed(feed);

                string newEntry1Title = "new event" + Guid.NewGuid().ToString();
                EventEntry newEntry1 = new EventEntry(newEntry1Title);
                newEntry1.BatchData = new GDataBatchEntryData("1", GDataBatchOperationType.insert);
                batchFeed.Entries.Add(newEntry1);

                string newEntry2Title = "new event" + Guid.NewGuid().ToString();
                EventEntry newEntry2 = new EventEntry(newEntry2Title);
                newEntry2.BatchData = new GDataBatchEntryData("2", GDataBatchOperationType.insert);
                batchFeed.Entries.Add(newEntry2);

                string newEntry3Title = "new event" + Guid.NewGuid().ToString();
                EventEntry newEntry3 = new EventEntry(newEntry3Title);
                newEntry3.BatchData = new GDataBatchEntryData("3", GDataBatchOperationType.insert);
                batchFeed.Entries.Add(newEntry3);

                Tracing.TraceMsg("Creating batch items");

                EventFeed batchResultFeed = (EventFeed)service.Batch(batchFeed, new Uri(feed.Batch));

                foreach (EventEntry evt in batchResultFeed.Entries)
                {
                    Assert.IsNotNull(evt.BatchData, "Result should contain batch information.");
                    Assert.IsNotNull(evt.BatchData.Id, "Result should have a Batch ID.");
                    Assert.AreEqual(201, evt.BatchData.Status.Code, "Created entries should return 201");
 
                    switch (evt.BatchData.Id)
                    {
                        case "1":
                            Assert.AreEqual(newEntry1Title, evt.Title.Text, "titles should be equal.");
                            break;
                        case "2":
                            Assert.AreEqual(newEntry2Title, evt.Title.Text, "titles should be equal.");
                            break;
                        case "3":
                            Assert.AreEqual(newEntry3Title, evt.Title.Text, "titles should be equal.");
                            break;
                        default:
                            Assert.Fail("Unrecognized entry in result of batch insert feed");
                            break;
                    }

                }

                Tracing.TraceMsg("Updating created entries.");

                batchFeed = new AtomFeed(feed);
                foreach (EventEntry evt in batchResultFeed.Entries)
                {
                    evt.BatchData = new GDataBatchEntryData(evt.BatchData.Id, GDataBatchOperationType.update);
                    evt.Title.Text = evt.Title.Text + "update";
                    batchFeed.Entries.Add(evt);
                }

                batchResultFeed = (EventFeed) service.Batch(batchFeed, new Uri(feed.Batch));

                foreach (EventEntry evt in batchResultFeed.Entries)
                {
                    Assert.IsNotNull(evt.BatchData, "Result should contain batch information.");
                    Assert.IsNotNull(evt.BatchData.Id, "Result should have a Batch ID.");
                    Assert.AreEqual(200, evt.BatchData.Status.Code, "Updated entries should return 200");

                    switch (evt.BatchData.Id)
                    {
                        case "1":
                            Assert.AreEqual(newEntry1Title + "update", evt.Title.Text, "titles should be equal.");
                            break;
                        case "2":
                            Assert.AreEqual(newEntry2Title + "update", evt.Title.Text, "titles should be equal.");
                            break;
                        case "3":
                            Assert.AreEqual(newEntry3Title + "update", evt.Title.Text, "titles should be equal.");
                            break;
                        default:
                            Assert.Fail("Unrecognized entry in result of batch update feed");
//.........这里部分代码省略.........
开发者ID:david-mitchell,项目名称:MonoMac-Demo,代码行数:101,代码来源:caltest.cs

示例2: addEvent

        private static string addEvent(string calID)
        {
            string result = "";
            #region 新增Event
            {
                CalendarService myService = new CalendarService("ischool.CourseCalendar");
                myService.setUserCredentials(googleAcc, googlePWD);
                EventFeed feed = myService.Query(new EventQuery("https://www.google.com/calendar/feeds/" + calID + "/private/full"));
                AtomFeed batchFeed = new AtomFeed(feed);
                Google.GData.Calendar.EventEntry eventEntry = new Google.GData.Calendar.EventEntry();

                eventEntry.Title.Text = "TEST";
                //eventEntry
                Where eventLocation = new Where();
                eventLocation.ValueString = "地點";
                eventEntry.Locations.Add(eventLocation);
                eventEntry.Notifications = true;
                eventEntry.Times.Add(new When(DateTime.Parse("2012/4/5 15:00"), DateTime.Parse("2012/4/5 17:00")));
                eventEntry.Participants.Add(new Who()
                {
                    ValueString = googleAcc,
                    Attendee_Type = new Who.AttendeeType() { Value = Who.AttendeeType.EVENT_REQUIRED },
                    Attendee_Status = new Who.AttendeeStatus() { Value = Who.AttendeeStatus.EVENT_ACCEPTED },
                    Rel = Who.RelType.EVENT_ATTENDEE
                });
                eventEntry.BatchData = new GDataBatchEntryData("TEST", GDataBatchOperationType.insert);
                batchFeed.Entries.Add(eventEntry);
                EventFeed batchResultFeed = (EventFeed)myService.Batch(batchFeed, new Uri(feed.Batch));
                foreach (EventEntry entry in batchResultFeed.Entries)
                {
                    if (entry.BatchData.Status.Code == 201)
                    {
                        result = entry.EventId;
                        break;

                    }
                }
            }
            #endregion
            return result;
        }
开发者ID:jungfengpaulwang,项目名称:EMBACourseCalender,代码行数:41,代码来源:ResetCalendar.cs

示例3: deleteEvent

        private static void deleteEvent(string calID, string[] args)
        {
            #region Delete
            {
                CalendarService myService = new CalendarService("ischool.CourseCalendar");
                myService.setUserCredentials(googleAcc, googlePWD);
                EventFeed feed = myService.Query(new EventQuery("https://www.google.com/calendar/feeds/" + calID + "/private/full"));
                AtomFeed batchFeed = new AtomFeed(feed);
                foreach (string id in args)
                {
                    EventEntry toDelete = (EventEntry)feed.Entries.FindById(new AtomId(feed.Id.AbsoluteUri + "/" + id));
                    if (toDelete != null)
                    {
                        toDelete.Id = new AtomId(toDelete.EditUri.ToString());
                        toDelete.BatchData = new GDataBatchEntryData("C", GDataBatchOperationType.delete);
                        batchFeed.Entries.Add(toDelete);
                    }
                }

                EventFeed batchResultFeed = (EventFeed)myService.Batch(batchFeed, new Uri(feed.Batch));
                foreach (EventEntry entry in batchResultFeed.Entries)
                {
                    if (entry.BatchData.Status.Code == 200)
                    {
                        break;
                    }
                }
            }
            #endregion
        }
开发者ID:jungfengpaulwang,项目名称:EMBACourseCalender,代码行数:30,代码来源:ResetCalendar.cs

示例4: AddMenuButton


//.........这里部分代码省略.........
                                    targetCal.ACLList = "";
                                    foreach (string acc in aclList)
                                    {
                                        targetCal.ACLList += (targetCal.ACLList == "" ? "" : "%") + acc;
                                    }
                                }
                                #endregion
                                #region Events
                                if (publishItems.ContainsKey(course.ID))
                                {
                                    EventFeed feed = myService.Query(new EventQuery("https://www.google.com/calendar/feeds/" + targetCal.GoogleCalanderID + "/private/full"));
                                    AtomFeed batchFeed = new AtomFeed(feed);
                                    foreach (Section section in publishItems[course.ID])
                                    {
                                        if (!section.Removed)
                                        {
                                            #region 新增Event
                                            Google.GData.Calendar.EventEntry eventEntry = new Google.GData.Calendar.EventEntry();

                                            eventEntry.Title.Text = course.Name;
                                            //eventEntry
                                            Where eventLocation = new Where();
                                            eventLocation.ValueString = section.Place;
                                            eventEntry.Locations.Add(eventLocation);
                                            eventEntry.Notifications = true;
                                            eventEntry.Times.Add(new When(section.StartTime, section.EndTime));
                                            eventEntry.Participants.Add(new Who()
                                            {
                                                ValueString = googleAcc,
                                                Attendee_Type = new Who.AttendeeType() { Value = Who.AttendeeType.EVENT_REQUIRED },
                                                Attendee_Status = new Who.AttendeeStatus() { Value = Who.AttendeeStatus.EVENT_ACCEPTED },
                                                Rel = Who.RelType.EVENT_ATTENDEE
                                            });
                                            eventEntry.BatchData = new GDataBatchEntryData(section.UID, GDataBatchOperationType.insert);
                                            batchFeed.Entries.Add(eventEntry);
                                            #endregion
                                        }
                                        else
                                        {
                                            #region 刪除Event

                                            EventEntry toDelete = (EventEntry)feed.Entries.FindById(new AtomId(feed.Id.AbsoluteUri + "/" + section.EventID));
                                            if (toDelete != null)
                                            {
                                                toDelete.Id = new AtomId(toDelete.EditUri.ToString());
                                                toDelete.BatchData = new GDataBatchEntryData(section.UID, GDataBatchOperationType.delete);
                                                batchFeed.Entries.Add(toDelete);
                                            }
                                            else
                                            {
                                                section.Deleted = true;
                                                syncedSections.Add(section);
                                            }
                                            #endregion
                                        }
                                        int p = syncedSections.Count * 80 / count + 20;
                                        if (p > 100) p = 100;
                                        if (p < 0) p = 0;
                                        bkw.ReportProgress(p);
                                    }
                                    EventFeed batchResultFeed = (EventFeed)myService.Batch(batchFeed, new Uri(feed.Batch));
                                    foreach (Section section in publishItems[course.ID])
                                    {
                                        if (syncedSections.Contains(section)) continue;
                                        #region 儲存Section狀態
                                        bool match = false;
开发者ID:jungfengpaulwang,项目名称:EMBACourseCalender,代码行数:67,代码来源:SyncSection.cs


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