BrightstarDB.Models.EventFeed.EventFeedService.GetSubscriberTimeline C# (CSharp) Метод

GetSubscriberTimeline() публичный Метод

Gets all the events on the subscriber timeline. Optional parameters are since and also how many
public GetSubscriberTimeline ( string userName, System.DateTime since ) : IEnumerable
userName string Gets timeline for user
since System.DateTime Events since this data should be included
Результат IEnumerable
        public IEnumerable<IEvent> GetSubscriberTimeline(string userName, DateTime since)
        {
            try
            {
                var ctx = new EventFeedContext(_connectionString);
                var sub = ctx.Subscribers.Where(s => s.UserName.Equals(userName)).ToList().FirstOrDefault();
                if (sub == null) throw new Exception("Subscriber does not exist");
                return sub.Events.Where(e => e.Occurred > since).OrderBy(e => e.Occurred);
            } catch (Exception ex){
                throw new Exception("Error in GetSubscriberTimeline", ex);
            }
        }

Usage Example

Пример #1
0
        public void TestSubscriberTimeline()
        {
            var storeId = Guid.NewGuid().ToString();
            var eventService = new EventFeedService(storeId);

            // create a topic first that can be subscribed to, this topic could have been 'found' by search or be
            // a well known topic.
            eventService.AssertTopic(new Uri("http://www.brightstardb.com/topics/34"), "Topic 34", "A very important topic");
            eventService.AssertSubscriber("domain\\bob", new List<Uri>() { new Uri("http://www.brightstardb.com/topics/34") });
            eventService.RaiseEvent("Bob created document Y", DateTime.UtcNow, new List<string>() { "http://www.brightstardb.com/topics/34" });

            var events = eventService.GetSubscriberTimeline("domain\\bob", DateTime.MinValue);
            Assert.AreEqual(1, events.Count());
        }