コード例 #1
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();
            });
        }
コード例 #2
0
        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();
        }