2012-12-04 62 views
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); 
    } 
} 

什么是刚刚更新仅根据所要求的条件的情况下的最佳方式(只有这种情况下,所有以下,本系列中的所有活动)?

+0

只是想知道,你有没有想出解决办法?我有完全一样的问题。 –

+0

@MingSlogar,我仍然没有得到任何解决方案。把它作为我的应用程序的已知问题。 – Prasad

回答

0

10分钟前就明白了这一点。

要在某一日期访问定期事件的单个实例使用下列作为事件网址:

https://www.google.com/calendar/feeds/default/private/full/" 
    + googleEventId + "_" + dateTime.ToString("yyyyMMdd"); 
相关问题