public static JaevnerEntry GetJaevnerEntry(EventEntry eventEntry) { var entry = new JaevnerEntry(); entry.Title = eventEntry.Title.Text; entry.Description = eventEntry.Content.Content; if (eventEntry.Locations.Count > 0) { entry.Location = eventEntry.Locations[0].ValueString; } else { entry.Location = string.Empty; } entry.StartDateTime = eventEntry.Times[0].StartTime; entry.EndDateTime = eventEntry.Times[0].EndTime; var property = eventEntry.ExtensionElements .OfType <ExtendedProperty>() .FirstOrDefault(e => e.Name.Equals("UniqueId")); if (property != default(ExtendedProperty)) { entry.UniqueId = property.Value; } return(entry); }
public List <JaevnerEntry> Parse(string data) { string[] lines = data.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); var entries = new List <JaevnerEntry>(); foreach (string line in lines) { string[] lineData = line.Split(new[] { "\",\"" }, StringSplitOptions.None); if (lineData.Length < 9) { throw new ArgumentOutOfRangeException("data"); } var entry = new JaevnerEntry(); entry.Title = lineData[0].TrimStart(new[] { '"' }); entry.StartDateTime = GetDateFromDateTimeStrings(lineData[1], lineData[2]); entry.EndDateTime = GetDateFromDateTimeStrings(lineData[3], lineData[4]); entry.AllDayEvent = Convert.ToBoolean(lineData[5]); entry.Location = lineData[6]; entry.Description = lineData[7]; entry.UniqueId = lineData[8].TrimEnd(new[] { '"' }); entries.Add(entry); } return(entries); }
public List <JaevnerEntry> ListEntries() { CalendarService calendarService = GetCalendarService(); var eventQuery = new EventQuery(_settings.CalendarUrl); EventFeed eventFeed = calendarService.Query(eventQuery); var jaevnerEntries = new List <JaevnerEntry>(); var entries = eventFeed.Entries; if (entries.Count > 0) { foreach (object entry in entries) { var feedEntry = (EventEntry)entry; JaevnerEntry jaevnerEntry = EntryConverter.GetJaevnerEntry(feedEntry); jaevnerEntries.Add(jaevnerEntry); } } return(jaevnerEntries); }
public void Insert(JaevnerEntry entry) { CalendarService calendarService = GetCalendarService(); EventEntry eventEntry = EntryConverter.GetEventEntry(entry); var uri = new Uri(_settings.CalendarUrl); calendarService.Insert(uri, eventEntry); }
public void Remove(JaevnerEntry entry) { CalendarService calendarService = GetCalendarService(); if (entry.UniqueId != null) { EventEntry eventEntry = FindByUniqueId(entry.UniqueId); calendarService.Delete(eventEntry); } }
public void Update(JaevnerEntry entry) { CalendarService calendarService = GetCalendarService(); EventEntry eventEntry = FindByUniqueId(entry.UniqueId); eventEntry.Title.Text = entry.Title; eventEntry.Times[0].StartTime = entry.StartDateTime; eventEntry.Times[0].EndTime = entry.EndDateTime; eventEntry.Times[0].AllDay = entry.AllDayEvent; eventEntry.Locations[0].ValueString = entry.Location; calendarService.Update(eventEntry); }
public static EventEntry GetEventEntry(JaevnerEntry entry) { var eventEntry = new EventEntry(entry.Title, entry.Description, entry.Location); var eventTimes = new When(entry.StartDateTime, entry.EndDateTime); eventTimes.AllDay = entry.AllDayEvent; eventEntry.Times.Add(eventTimes); var extended = new ExtendedProperty(); extended.Name = "UniqueId"; extended.Value = entry.UniqueId; eventEntry.ExtensionElements.Add(extended); return(eventEntry); }
private void InsertEntry(JaevnerEntry entry) { try { _repository.Insert(entry); OnEntryAction(new JaevnerEventArgs { Entry = entry, Action = EntryActionType.Inserted }); } catch (Exception ex) { OnEntryException(new JaevnerExceptionEventArgs { Entry = entry, Action = EntryActionType.Inserted, Exception = ex }); } }