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

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

public GetTopicTimeline ( string topicId, System.DateTime since ) : IEnumerable
topicId string
since System.DateTime
Результат IEnumerable
        public IEnumerable<IEvent> GetTopicTimeline(string topicId, DateTime since)
        {
            try
            {
                var ctx = new EventFeedContext(_connectionString);
                var topic = ctx.Topics.Where(t => t.Id.Equals(topicId)).ToList().FirstOrDefault();
                if (topic == null) return new List<IEvent>();
                return topic.Events.Where(e => e.Occurred > since).OrderBy(e => e.Occurred);
            }
            catch (Exception ex)
            {
                throw new Exception("Error in GetTopicTimeline", ex);
            }
        }

Usage Example

Пример #1
0
        public void TestEventData()
        {
            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" },
                                    new Dictionary<string, object> { {"Type", "DocumentEvent"},{ "DocumentUrl", "http://sharepoint.brightstardb.com/file1.docx"}});

            var events = eventService.GetTopicTimeline("http://www.brightstardb.com/topics/34", DateTime.MinValue);
            Assert.AreEqual(1, events.Count());

            // get event
            var ev = events.ToList()[0];
            var eventData = eventService.GetEventData(ev);
            Assert.AreEqual("http://sharepoint.brightstardb.com/file1.docx", eventData.DocumentUrl.FirstOrDefault());
        }
All Usage Examples Of BrightstarDB.Models.EventFeed.EventFeedService::GetTopicTimeline