/// <summary> /// Creates a new Event with Calendar data. The meta info properties (Like from and to) /// are not set correctly. They dont match with the calendar data /// </summary> /// <returns></returns> public static TableEvent CreateNew() { var newEvent = new TableEvent { IsFullDayEvent = true, From = DateTime.Now.Date, To = DateTime.Now.Date.AddDays(1) }; using (var icalStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Ocwp.Assets.NewCalendar.ics")) { if (icalStream != null) { var reader = new StreamReader(icalStream); newEvent.CalendarData = reader.ReadToEnd(); } else { throw new Exception("New calendar not found"); } } return(newEvent); }
private async Task SaveTableEvent(TableEvent dbEvent) { dbEvent.From = (DpFrom.Value ?? DateTime.Now).CombineWithTime(TpFrom.Value ?? DateTime.Now); dbEvent.To = (DpTo.Value ?? DateTime.Now).CombineWithTime(TpTo.Value ?? DateTime.Now); dbEvent.Title = TbTitle.Text; dbEvent.IsFullDayEvent = CbFullDayEvent.IsChecked ?? false; if (dbEvent.IsFullDayEvent) { dbEvent.From = dbEvent.From.Date; dbEvent.To = dbEvent.To.Date.AddDays(1); } if (dbEvent.To < dbEvent.From) { MessageBox.Show(Resource.Localization.AppResources.AppointmentPage_WrongDate); UnlockPage(); return; } CalendarDataUpdater.UpdateCalendarData(dbEvent, TbDescription.Text, false); var ocCLient = await LoadOcCalendarClient(); ocCLient.SaveEventComplete += ocCLient_SaveEventComplete; ocCLient.SaveEvent(dbEvent); Context.SubmitChanges(); }
/// <summary> /// Creates a new Event with Calendar data. The meta info properties (Like from and to) /// are not set correctly. They dont match with the calendar data /// </summary> /// <returns></returns> public static TableEvent CreateNew() { var newEvent = new TableEvent { IsFullDayEvent = true, From = DateTime.Now.Date, To = DateTime.Now.Date.AddDays(1) }; using (var icalStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Ocwp.Assets.NewCalendar.ics")) { if (icalStream != null) { var reader = new StreamReader(icalStream); newEvent.CalendarData = reader.ReadToEnd(); } else throw new Exception("New calendar not found"); } return newEvent; }
/// <summary> /// Aktualisiert die Termine für den Kalendar im angegebenen Monat /// </summary> public void RefreshAppointments() { var calendarEvents = Context.Calendars.Where(o => o._accountId == AccountID).Select(o => o.Events.Where(q => q.To > _firstDayOfCalendarMonth && q.From < _lastDayOfCalendarMonth)); //merge all calendar events IEnumerable<TableEvent> events = new TableEvent[0]; foreach (var calendar in calendarEvents) events = events.Concat(calendar); events = events .OrderByDescending(o => o.To - o.From) //Längere Event sollen oben angezeigt werden .ToArray(); //Refresh events to get the changes, if a sync was completed // ReSharper disable CoVariantArrayConversion Context.Refresh(RefreshMode.OverwriteCurrentValues, events); // ReSharper restore CoVariantArrayConversion //Delete displayed events GrdAppointments.Children.Clear(); _dayPanels.Clear(); //INsert new events PutEvent(events); }
public void SaveEvent(TableEvent eventToSave) { this.BeginHttpRequest(Address.CombineServerAddress(eventToSave.Url)); ContentTypeCalendar(); SetMethod("PUT"); Request.BeginGetRequestStream(SaveEventWriteRequest, eventToSave); }