Ejemplo n.º 1
0
        public SerializedEvent[] FindEventsForConsumer(long from, long to, Guid streamId, int quantity, string consumer)
        {
            using (var context = this.contextFactory(true))
            {
                var events = context
                             .Events
                             .Where(e => e.StreamType == this.streamType &&
                                    e.EventCollectionVersion > from &&
                                    e.EventCollectionVersion <= to &&
                                    e.StreamId == streamId)
                             .OrderBy(e => e.EventCollectionVersion)
                             .Take(quantity)
                             .ToArray()
                             .Select(e =>
                                     EventStoreFuncs.ApplyConsumerFilter(
                                         new SerializedEvent(e.EventCollectionVersion, e.Payload),
                                         consumer,
                                         this.serializer,
                                         this.consumerFilter))
                             .ToArray();

                return(events.Length > 0
                ? events
                : new SerializedEvent[] { new SerializedEvent(to, this.serializer.Serialize(new CloakedEvent(to, this.streamType))) });
            }
        }
 /// <summary>
 /// FindEvents
 /// </summary>
 /// <returns>Events if found, otherwise return empty list.</returns>
 public SerializedEvent[] FindEventsForConsumer(long from, long to, int quantity, string consumer)
 {
     return(this.sql.ExecuteReader(this.findEventsQuery,
                                   r => new SerializedEvent(r.GetInt64("EventCollectionVersion"), r.GetString("Payload")),
                                   new SqlParameter("@Quantity", SqlDbType.Int)
     {
         Value = quantity
     },
                                   new SqlParameter("@StreamType", SqlDbType.NVarChar, 40)
     {
         Value = this.streamType
     },
                                   new SqlParameter("@LastReceivedVersion", SqlDbType.BigInt)
     {
         Value = from
     },
                                   new SqlParameter("@MaxVersion", SqlDbType.BigInt)
     {
         Value = to
     })
            .Select(e =>
                    EventStoreFuncs.ApplyConsumerFilter(
                        new SerializedEvent(e.EventCollectionVersion, e.Payload),
                        consumer,
                        this.serializer,
                        this.consumerFilter))
            .ToArray());
 }
Ejemplo n.º 3
0
 public SerializedEvent[] FindEventsForConsumer(long from, long to, int quantity, string consumer)
 {
     return(this.events
            .Where(e => e.Key > from &&
                   e.Key <= to)
            .OrderBy(e => e.Key)
            .Take(quantity)
            .Select(e =>
                    EventStoreFuncs.ApplyConsumerFilter(
                        new SerializedEvent(e.Key, e.Value.Payload),
                        consumer,
                        this.serializer,
                        this.consumerFilter))
            .ToArray());
 }
Ejemplo n.º 4
0
 public SerializedEvent[] FindEventsForConsumer(long from, long to, int quantity, string consumer)
 {
     using (var context = this.contextFactory(true))
     {
         return(context
                .Events
                .Where(e => e.StreamType == this.streamType && e.EventCollectionVersion > from && e.EventCollectionVersion <= to)
                .OrderBy(e => e.EventCollectionVersion)
                .Take(quantity)
                .ToArray()
                .Select(e =>
                        EventStoreFuncs.ApplyConsumerFilter(
                            new SerializedEvent(e.EventCollectionVersion, e.Payload),
                            consumer,
                            this.serializer,
                            this.consumerFilter))
                .ToArray());
     }
 }
Ejemplo n.º 5
0
        public SerializedEvent[] FindEventsForConsumer(long from, long to, Guid streamId, int quantity, string consumer)
        {
            var events = this.events
                         .Where(e => e.Key > from &&
                                e.Key <= to &&
                                e.Value.StreamId == streamId)
                         .OrderBy(e => e.Key)
                         .Take(quantity)
                         .Select(e =>
                                 EventStoreFuncs.ApplyConsumerFilter(
                                     new SerializedEvent(e.Key, e.Value.Payload),
                                     consumer,
                                     this.serializer,
                                     this.consumerFilter))
                         .ToArray();

            return(events.Length > 0
                ? events
                : new SerializedEvent[] { new SerializedEvent(to, this.serializer.Serialize(new CloakedEvent(to, this.streamType))) });
        }
        public SerializedEvent[] FindEventsForConsumer(long from, long to, Guid streamId, int quantity, string consumer)
        {
            var events = this.sql.ExecuteReader(this.findEventsWithStreamIdQuery,
                                                r => new SerializedEvent(r.GetInt64("EventCollectionVersion"), r.GetString("Payload")),
                                                new SqlParameter("@Quantity", SqlDbType.Int)
            {
                Value = quantity
            },
                                                new SqlParameter("@StreamType", SqlDbType.NVarChar, 40)
            {
                Value = this.streamType
            },
                                                new SqlParameter("@LastReceivedVersion", SqlDbType.BigInt)
            {
                Value = from
            },
                                                new SqlParameter("@MaxVersion", SqlDbType.BigInt)
            {
                Value = to
            },
                                                new SqlParameter("@StreamId", SqlDbType.UniqueIdentifier)
            {
                Value = streamId
            })
                         .Select(e =>
                                 EventStoreFuncs.ApplyConsumerFilter(
                                     new SerializedEvent(e.EventCollectionVersion, e.Payload),
                                     consumer,
                                     this.serializer,
                                     this.consumerFilter))
                         .ToArray();

            return(events.Length > 0
                ? events
                : new SerializedEvent[] { new SerializedEvent(to, this.serializer.Serialize(new CloakedEvent(to, this.streamType))) });
        }