1
我正在使用C#Google API以編程方式從我的應用程序(asp.net mvc - C#)添加週期性事件。下面是它的代碼(我加入這開始於2012年12月1日和2012年12月3日結束的每日活動):使用C#API更新Google日曆週期性事件的事件
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日的活動標題更改爲「明年的計劃」。同樣,我需要爲All Following執行相同的操作,本系列中的所有事件也都會更新。我正在根據Google Event Id(在創建Recurring Event時的響應中)刪除所有事件,然後再次創建Events,這是雙重工作。
這是我如何刪除所有的重複活動,做好創建上面給出:
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);
}
}
什麼是剛剛更新僅根據所要求的條件的情況下的最佳方式(只有這種情況下,所有以下,本系列中的所有活動)?
只是想知道,你有沒有想出解決辦法?我有完全一樣的問題。 –
@MingSlogar,我仍然沒有得到任何解決方案。把它作爲我的應用程序的已知問題。 – Prasad