示例#1
0
 public void setEvents(params Entry[] eventsArray)
 {
     events.Clear();
     foreach (Entry e in eventsArray)
     {
         events.Add(e);
     }
     eventsUpdated();
 }
示例#2
0
        /// <summary>
        /// Gets the app events from the DTO objects. Returns an empty collection if no events.
        /// </summary>
        /// <param name="eventDtos">An enumerable object containing the app event data transfer objects.</param>
        /// <returns>Returns an <see cref="IEventCollection" />.</returns>
        private static IEventCollection GetEventsFromDtos(IEnumerable<EventDto> eventDtos)
        {
            var events = new EventCollection();

            try
            {
                foreach (var ev in eventDtos)
                {
                    events.Add(new Event(ev.EventId,
                        ev.EventType,
                        ev.FKGalleryId,
                        ev.TimeStampUtc,
                        ev.ExType,
                        ev.Message,
                        Deserialize(ev.EventData),
                        ev.ExSource,
                        ev.ExTargetSite,
                        ev.ExStackTrace,
                        ev.InnerExType,
                        ev.InnerExMessage,
                        ev.InnerExSource,
                        ev.InnerExTargetSite,
                        ev.InnerExStackTrace,
                        Deserialize(ev.InnerExData),
                        ev.Url,
                        Deserialize(ev.FormVariables), Deserialize(ev.Cookies), Deserialize(ev.SessionVariables), Deserialize(ev.ServerVariables)));
                }
            }
            catch (InvalidOperationException ex)
            {
                if (ex.Source.Equals("System.Data.SqlServerCe"))
                {
                    // We hit the SQL CE bug described here: http://connect.microsoft.com/SQLServer/feedback/details/606152
                    // Clear the table.
                    var sqlCeController = new SqlCeController(GetConnectionStringSettings().ConnectionString);

                    sqlCeController.ClearEventLog();

                    events.Clear();
                }
                else throw;
            }

            return events;
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bypassCache"></param>
        /// <returns></returns>
        public virtual EventCollection <T> LoadEvents(bool bypassCache)
        {
            var events = new EventCollection <T>();

            if (_events != null)
            {
                _events.ForEach(t => events.Add(t));
            }

            if ((bypassCache) || (events.Count == 0))
            {
                events = new EventCollection <T>();
            }


            _eventData = LoadEventList(false) as EventData; // CAST HERE from base type class

            if (_eventData != null)
            {
                var eventTable = _eventData.EVENT;
            }

            if (_eventData != null)
            {
                _eventArray = new T[_eventData.Tables["EVENT"].Rows.Count];
            }
            var i = 0;

            if (_eventData != null)
            {
                foreach (EventData.EVENTRow eventRow in _eventData.Tables["EVENT"].Rows)
                {
                    // _event = Activator.CreateInstance<T>();

                    _event = events.Contains(events[eventRow.TITLE]) ? events[eventRow.TITLE] : new T();

                    if (!eventRow.IsDATENull())
                    {
                        DateTime date;
                        _event.EventDate = DateTime.TryParse(eventRow.DATE, out date) ? date : DateTime.Now;
                        _event.Day       = _event.EventDate.DayOfWeek;
                    }

                    if (!eventRow.IsTITLENull())
                    {
                        _event.Title = eventRow.TITLE;
                    }

                    if (!eventRow.Is_TITLE_SECONDARYNull())
                    {
                        _event.Subtitle = eventRow._TITLE_SECONDARY;
                    }

                    // if (!eventRow.Is_GMT_TIMENull)
                    // _event.GmtTime = WORK ON THIS
                    // _event.GmtTime =
                    if (!eventRow.Is_START_TIMENull())
                    {
                        DateTime startTime;
                        _event.StartTime = DateTime.TryParse(eventRow._START_TIME, out startTime)
                                               ? startTime
                                               : DateTime.Now;
                    }

                    if (!eventRow.Is_END_TIMENull())
                    {
                        DateTime endTime;
                        _event.EndTime = DateTime.TryParse(eventRow._END_TIME, out endTime) ? endTime : DateTime.Now;
                    }
                    // _event.EndTime = DateTime.Parse(eventRow._END_TIME);

                    if (!eventRow.IsWHERENull())
                    {
                        _event.Channel = eventRow.WHERE; // won't be an exact match, work on routine to match them.
                    }
                    // _event.Channel = new ChannelCollection<IChannel>()[eventRow.WHERE] as IChannel;

                    if (!eventRow.IsCALENDAR_URLNull())
                    {
                        if (Uri.IsWellFormedUriString(eventRow.CALENDAR_URL, UriKind.Absolute))
                        {
                            _event.EventUrl = new Uri(eventRow.CALENDAR_URL);
                        }
                    }

                    _eventArray[i] = _event;
                    i++;

                    //_events.Add(_event);
                }
            }

            events.Clear();
            events.AddRange(_eventArray);

            if (_events == null)
            {
                _events = new EventCollection <T>();
            }

            _events.Clear();
            events.Clone(_events);

            return(events);
        }