1

我正在使用 C# Google API 从我的应用程序(asp.net mvc - C#)中以编程方式添加重复事件。以下是它的代码(我添加了一个从 2012 年 12 月 1 日开始到 2012 年 12 月 3 日结束的每日活动):

GOAuthRequestFactory authFactory = new GOAuthRequestFactory("cl", "MyApp");
authFactory.ConsumerKey = "xxxx";
authFactory.ConsumerSecret = "yyyy";
authFactory.Token = "zzzz";
authFactory.TokenSecret = "ssss";
Google.GData.Calendar.CalendarService service = new Google.GData.Calendar.CalendarService(authFactory.ApplicationName);
service.RequestFactory = authFactory;

EventEntry entry = new EventEntry();
entry.Title.Text = "Year End Meeting";

Recurrence recur = new Recurrence();
recur.Value = "DTSTART;VALUE=DATE:20121201\r\nDTEND;VALUE=DATE:20121201\r\nRRULE:FREQ=DAILY;UNTIL=20121203;INTERVAL=1";
entry.Recurrence = recur;

Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
EventEntry insertedEntry = service.Insert(postUri, entry);
if (insertedEntry != null && !string.IsNullOrEmpty(insertedEntry.EventId))
{
   //Update the Google Event Id to the Event Table
    this.UpdateGoogleEventId(_userId, _eventId, insertedEntry.EventId);
}

直到这一切顺利。现在我需要从重复事件中更新特定事件(仅此实例)。例如;我需要将 2012 年 12 月 2 日活动的标题更改为“明年计划”。同样,我需要对所有关注做同样的事情,这个系列中的所有事件也更新操作。我正在根据 Google 事件 ID(在创建重复事件时的响应中)删除所有事件,然后再次创建事件,这是一种双重工作。

这就是我删除所有重复事件并按照上面给出的创建的方式:

Uri delteUri = new Uri("https://www.google.com/calendar/feeds/default/private/full/" + googleeventid);
EventQuery deleteQuery = new EventQuery(delteUri.ToString());
EventFeed deleteFeed = service.Query(deleteQuery);
if (deleteFeed.Entries.Count > 0)
{
   AtomEntry eve = deleteFeed.Entries[0];
   if (eve != null)
   {
       service.Delete(eve);
   }
}

根据所需条件仅更新实例的最佳方法是什么(仅此实例、所有以下、本系列中的所有事件)?

4

1 回答 1

0

10分钟前才发现这个。

要在特定日期访问重复事件的单个实例,请使用以下作为事件 url:

https://www.google.com/calendar/feeds/default/private/full/" 
    + googleEventId + "_" + dateTime.ToString("yyyyMMdd");
于 2013-11-29T16:04:18.603 回答