예제 #1
0
        /// <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);
        }
예제 #2
0
        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();
        }
예제 #3
0
        /// <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;
        }
예제 #4
0
        /// <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);
        }
예제 #5
0
        public void SaveEvent(TableEvent eventToSave)
        {
            this.BeginHttpRequest(Address.CombineServerAddress(eventToSave.Url));

            ContentTypeCalendar();
            SetMethod("PUT");


            Request.BeginGetRequestStream(SaveEventWriteRequest, eventToSave);
        }