public static UnparsedEvent[] ParseCalendarEvents(Stream stream)
        {
            var rootItem = LoadRootItem(stream);

            var responses = rootItem.Elements();

            var calendars = new List<UnparsedEvent>();

            foreach (var response in responses)
            {
                var curEvent = new UnparsedEvent
                    {
                        EventInfo = new EventCalDavInfo {Url = response.GetIfExists(XName.Get("href", XmlNamespaces.NsDav))}
                    };

                var propstats = response.Elements(XName.Get("propstat", XmlNamespaces.NsDav));

                foreach (var propstat in propstats)
                {
                    if (propstat.GetIfExists(XName.Get("status", XmlNamespaces.NsDav)) == "HTTP/1.1 200 OK")
                    {
                        var prop = propstat.Element(XName.Get("prop", XmlNamespaces.NsDav));

                        foreach (var propValue in prop.Elements())
                        {
                            switch (propValue.Name.LocalName)
                            {
                                case "getetag":
                                    curEvent.EventInfo.GetETag = propValue.Value;
                                    break;
                                case "calendar-data":
                                    curEvent.RawEventData = propValue.Value;
                                    break;
                            }
                        }
                    }
                }

                calendars.Add(curEvent);

            }

            return calendars.ToArray();
        }
Exemple #2
0
 /// <summary>
 /// Erstellt ein Event für die Datenbank von einem Ungepasden Kalendar
 /// </summary>
 /// <param name="unparsedEvent"></param>
 /// <returns></returns>
 public static TableEvent FromUnparsedEvent(UnparsedEvent unparsedEvent)
 {
     return new TableEvent
         {
             CalendarData = unparsedEvent.RawEventData
             , Url = unparsedEvent.EventInfo.Url
             , GetETag = unparsedEvent.EventInfo.GetETag
         };
 }