简体   繁体   English

使用.Net API读取Google日历重复事件

[英]Reading Google Calendar recurring events using .Net API

I am doing some sync across different calendar formats and one of the Calendar providers is Google, Other providers expose this data in an object oriented approach through their API but in Google it is exposed via Events.Recurrence as this: 我正在不同的日历格式之间进行一些同步,并且Google的日历提供程序之一是其他提供程序,其他提供程序通过其API以面向对象的方式公开此数据,但在Google中是通过Events。暴露的。

"DTSTART;TZID=Pacific/Auckland:20110629T100000\r\n
DTEND;TZID=Pacific/Auckland:20110629T110000\r\n
RRULE:FREQ=DAILY;COUNT=10;INTERVAL=3\r\n
BEGIN:VTIMEZONE\r\n
TZID:Pacific/Auckland\r\n
X-LIC-LOCATION:Pacific/Auckland\r\n
BEGIN:DAYLIGHT\r\n
TZOFFSETFROM:+1200\r\n
TZOFFSETTO:+1300\r\n
TZNAME:NZDT\r\n
DTSTART:19700927T020000\r\n
RRULE:FREQ=YEARLY;BYMONTH=9;BYDAY=-1SU\r\n
END:DAYLIGHT\r\n
BEGIN:STANDARD\r\n
TZOFFSETFROM:+1300\r\n
TZOFFSETTO:+1200\r\n
TZNAME:NZST\r\n
DTSTART:19700405T030000\r\n
RRULE:FREQ=YEARLY;BYMONTH=4;BYDAY=1SU\r\n
END:STANDARD\r\n
END:VTIMEZONE"

Is there any way of parsing this to an object oriented format? 有什么办法可以将其解析为面向对象的格式吗? ie a Recurrence object? 即重复对象? All of the samples I saw online are setting those values which is easier rather than reading it. 我在网上看到的所有样本都在设置这些值,这比读取值更容易。 Any samples of reading and writing to it are welcome. 欢迎阅读和阅读它的任何样本。

EventEntry.Times is a collection, so you have to parse it into an ExtensionCollection object, which you can then iterate through. EventEntry.Times是一个集合,因此您必须将其解析为ExtensionCollection对象,然后可以对其进行迭代。

foreach (Google.GData.Calendar.EventEntry ev in calFeed.Entries)
    {
        CalendarEvents ce = new CalendarEvents();

        ce.Title = ev.Title.Text;
        ExtensionCollection<When> v = ev.Times;
        ce.Date = v[0].StartTime;
        ce.Content = ev.Content.Content;
    }

Iterating wasn't necessary in my project, but i think you get the idea. 在我的项目中没有必要进行迭代,但是我认为您可以理解。

试试这个库: http : //icalparser.sourceforge.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM