예제 #1
0
        public static CalendarCalDavInfo[] ParseCalendarCalDavInfo(Stream stream)
        {
            var rootItem = LoadRootItem(stream);

            var responses = rootItem.Elements();

            var calendars = new List<CalendarCalDavInfo>();

            foreach (var res in responses)
            {
                var info = new CalendarCalDavInfo
                    {
                        Url = res.Elements(XName.Get("href", XmlNamespaces.NsDav)).Single().Value
                    };

                var propstat = res.Element(XName.Get("propstat", XmlNamespaces.NsDav));
                if (propstat != null)
                {
                    var status = propstat.GetIfExists(XName.Get("status", XmlNamespaces.NsDav));
                    if (status != "HTTP/1.1 200 OK") continue;
                }
                else continue;

                foreach (var prop in propstat.Elements(XName.Get("prop", XmlNamespaces.NsDav)))
                {
                    info.DisplayName = prop.GetIfExists(XName.Get("displayname", XmlNamespaces.NsDav));
                    info.GetCTag = prop.GetIfExists(XName.Get("getctag", XmlNamespaces.NsCalenderServer));
                }

                calendars.Add(info);
            }

            return calendars.ToArray();
        }
예제 #2
0
 /// <summary>
 /// Erstellt einen Kalendar zum speichern in der Datenbank aus
 /// </summary>
 /// <param name="calendar">Die Kalendarinformationen</param>
 /// <returns></returns>
 public static TableCalendar FromCalDavCalendarInfo(Calendar.ParsedCalendar.CalendarCalDavInfo calendar)
 {
     return(new TableCalendar()
     {
         Url = calendar.Url
         , GetCTag = calendar.GetCTag
         , DisplayName = calendar.DisplayName
     });
 }
예제 #3
0
        public void DisableCalendar(CalendarCalDavInfo calendar) {
            using (var context = new OwnCloudDataContext()) {
                var entity = (from o in context.Calendars where o.Url == calendar.Url select o).SingleOrDefault();

                if (entity != null)
                    context.Calendars.DeleteOnSubmit(entity);

                var eventsToDelete = context.Events.Where(o => o.CalendarId == entity.Id).ToArray();

                context.Events.DeleteAllOnSubmit(eventsToDelete);

                context.SubmitChanges();
            }
        }
예제 #4
0
        /// <summary>
        /// Lädt die Termine eines Kalendars
        /// </summary>
        /// <param name="cInfo">Die Information über den Kalendar</param>
        /// <param name="request">The request</param>
        public void LoadCalendarData(CalendarCalDavInfo cInfo, CalendarEventRequest request = null)
        {
            this.BeginHttpRequest(Address.CombineServerAddress(cInfo.Url));

            ContentTypeXml();
            this.SetMethod("REPORT");

            Request.Headers["Depth"] = "1";
            Request.Headers["Prefer"] = "return-minimal";

            if (request == null)
                request = new CalendarEventRequest();

            Request.BeginGetRequestStream(CalendarDataWriteRequest, request);
        }
예제 #5
0
        public void EnableCalendar(CalendarCalDavInfo calendar) {
            using (var context = new OwnCloudDataContext()) {
                var existingEntity =
                    (from o in context.Calendars where o.Url == calendar.Url select o).SingleOrDefault();

                if (existingEntity != null)
                    return;

                var entity = TableCalendar.FromCalDavCalendarInfo(calendar);
                entity.GetCTag = "";

                entity._accountId = this._accountId;

                context.Calendars.InsertOnSubmit(entity);
                context.SubmitChanges();
            }
        }