protected virtual void OnLoadCalendarDataComplete(LoadCalendarDataCompleteArgs e)
 {
     if (LoadCalendarDataComplete != null)
     {
         LoadCalendarDataComplete(e); //Method not found exception
     }
 }
        private void CalendarDataGetResponse(IAsyncResult ar)
        {
            try
            {
                var response = Request.EndGetResponse(ar);

                EndHttpRequest();
                var param = new LoadCalendarDataCompleteArgs
                {
                    Success = true,
                    Events  = MultistateParser.ParseCalendarEvents(response.GetResponseStream())
                };
                try
                {
                    OnLoadCalendarDataComplete(param);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
            catch (Exception)
            {
                EndHttpRequest();
                OnLoadCalendarDataComplete(new LoadCalendarDataCompleteArgs {
                    Success = false
                });
            }
        }
 protected virtual void OnLoadCalendarDataComplete(LoadCalendarDataCompleteArgs e)
 {
     if (LoadCalendarDataComplete != null)
     {
         LoadCalendarDataComplete(e);
     }
 }
        void LoadEventInfoComplete(LoadCalendarDataCompleteArgs e)
        {
            _ocClient.LoadCalendarDataComplete -= LoadEventInfoComplete;

            if (!e.Success)
            {
                OnSyncComplete(false);
                return;
            }

            //Herrausfinden, welche Termine aktualisiert werden müssen
            foreach (var unparsedEvent in e.Events)
            {
                var dbEvent = _context.Events.SingleOrDefault(o => o.Url == unparsedEvent.EventInfo.Url);

                if (dbEvent == null || dbEvent.GetETag != unparsedEvent.EventInfo.GetETag)
                {
                    _eventToUpdate.Add(unparsedEvent);
                }
            }

            //Herrausfinden, welche Termine gelöscht werden müssen
            var dbCalendar = _context.Calendars.SingleOrDefault(o => o.Url == _currentUpdatingCalendar.Url);

            if (dbCalendar != null)
            {
                var dbEvents = _context.Events.Where(o => o.CalendarId == dbCalendar.Id);
                foreach (var dbEvent in dbEvents)
                {
                    if (e.Events.SingleOrDefault(o => o.EventInfo.Url == dbEvent.Url) == null)
                    {
                        _context.Events.DeleteOnSubmit(dbEvent);
                    }
                }
            }
            _context.SubmitChanges();

            if (_eventToUpdate.Count == 0)
            {
                EndDownloadCalendar();
            }
            else
            {
                LoadEventDetails();
            }
        }
Beispiel #5
0
        private void LoadServerEventDetailsComplete(LoadCalendarDataCompleteArgs e)
        {
            App.Current.RootFrame.Dispatcher.BeginInvoke(() =>
            {
                if (!e.Success)
                {
                    OnSyncComplete(false);
                    return;
                }

                var serverCalendar = _context.Calendars.Single(o => o.Url == _currentUpdatingCalendar.Url);

                foreach (var serverEvent in e.Events)
                {
                    try
                    {
                        var dbEvent = _context.Events.SingleOrDefault(o => o.Url == serverEvent.EventInfo.Url) ??
                                      new TableEvent
                        {
                            CalendarId = serverCalendar.Id,
                            Url        = serverEvent.EventInfo.Url
                        };

                        dbEvent.GetETag      = serverEvent.EventInfo.GetETag;
                        dbEvent.CalendarData = serverEvent.RawEventData;
                        //dbEvent.Calendar = serverCalendar;

                        EventMetaUpdater.UpdateEventMetadata(dbEvent);

                        if (dbEvent.EventId == 0)
                        {
                            _context.Events.InsertOnSubmit(dbEvent);
                        }
                    }
                    catch (Exception ex)
                    {
                        //Do nothing
                    }
                }

                _context.SubmitChanges();

                EndDownloadCalendar();
            });
        }
        public void LoadEventDetailsComplete(LoadCalendarDataCompleteArgs e)
        {
            _ocClient.LoadCalendarDataComplete -= LoadEventDetailsComplete;

            if (!e.Success)
            {
                OnSyncComplete(false);
                return;
            }

            var serverCalendar = _context.Calendars.Single(o => o.Url == _currentUpdatingCalendar.Url);

            foreach (var serverEvent in e.Events)
            {
                var dbEvent = _context.Events.SingleOrDefault(o => o.Url == serverEvent.EventInfo.Url) ??
                              new TableEvent {
                    CalendarId = serverCalendar.Id, Url = serverEvent.EventInfo.Url
                };

                dbEvent.GetETag      = serverEvent.EventInfo.GetETag;
                dbEvent.CalendarData = serverEvent.RawEventData;

                EventMetaUpdater.UpdateEventMetadata(dbEvent);

                if (dbEvent.EventId == 0)
                {
                    _context.Events.InsertOnSubmit(dbEvent);
                }
            }



            _context.SubmitChanges();

            EndDownloadCalendar();
        }
 protected virtual void OnLoadCalendarDataComplete(LoadCalendarDataCompleteArgs e)
 {
     if (LoadCalendarDataComplete != null)
         LoadCalendarDataComplete(e);
 }
        private void CalendarDataGetResponse(IAsyncResult ar)
        {
            try
            {
                var response = Request.EndGetResponse(ar);

                EndHttpRequest();
                var param = new LoadCalendarDataCompleteArgs
                    {
                        Success = true,
                        Events = MultistateParser.ParseCalendarEvents(response.GetResponseStream())
                    };
                try
                {
                    OnLoadCalendarDataComplete(param);
                }
                catch (Exception ex)
                {
                    throw;
                }
                
            }
            catch (Exception)
            {
                EndHttpRequest();
                OnLoadCalendarDataComplete(new LoadCalendarDataCompleteArgs {Success = false});
            }
        }