Esempio n. 1
0
        public static FeedElement ToAllEventsBackwardFeed(ReadAllResult result,
                                                          Func <EventRecord, string, EntryElement> itemToEntry,
                                                          string userHostName)
        {
            var self = HostName.Combine(userHostName, "/streams/$all");
            var feed = new FeedElement();

            feed.SetTitle(String.Format("All events"));
            feed.SetId(self);

            var items = result.Records.Select(rer => rer.Event).ToList();

            feed.SetUpdated(items.Any() ? items.First().TimeStamp : DateTime.MinValue.ToUniversalTime());
            feed.SetAuthor(AtomSpecs.Author);

            feed.AddLink(self, "self", null);
            feed.AddLink(HostName.Combine(userHostName,
                                          "/streams/$all/{0}",
                                          result.MaxCount),
                         "first",
                         null);
            feed.AddLink(HostName.Combine(userHostName,
                                          "/streams/$all/after/{0}/{1}",
                                          new TFPos(0, 0).AsString(),
                                          result.MaxCount),
                         "last",
                         null);
            feed.AddLink(HostName.Combine(userHostName,
                                          "/streams/$all/after/{0}/{1}",
                                          result.PrevPos.AsString(),
                                          result.MaxCount),
                         "prev",
                         null);
            feed.AddLink(HostName.Combine(userHostName,
                                          "/streams/$all/before/{0}/{1}",
                                          result.NextPos.AsString(),
                                          result.MaxCount),
                         "next",
                         null);

            foreach (var item in items)
            {
                feed.AddEntry(itemToEntry(item, userHostName));
            }
            return(feed);
        }
Esempio n. 2
0
        public static FeedElement ToAllEventsBackwardFeed(ReadAllResult result,
                                                          Func<EventRecord, string, EntryElement> itemToEntry,
                                                          string userHostName)
        {
            var self = HostName.Combine(userHostName, "/streams/$all");
            var feed = new FeedElement();
            feed.SetTitle(String.Format("All events"));
            feed.SetId(self);

            var items = result.Records.Select(rer => rer.Event).ToList();

            feed.SetUpdated(items.Any() ? items.First().TimeStamp : DateTime.MinValue.ToUniversalTime());
            feed.SetAuthor(AtomSpecs.Author);

            feed.AddLink(self, "self", null);
            feed.AddLink(HostName.Combine(userHostName,
                                          "/streams/$all/{0}",
                                          result.MaxCount),
                         "first",
                         null);
            feed.AddLink(HostName.Combine(userHostName,
                                          "/streams/$all/after/{0}/{1}",
                                          new TFPos(0, 0).AsString(),
                                          result.MaxCount),
                         "last",
                         null);
            feed.AddLink(HostName.Combine(userHostName,
                                          "/streams/$all/after/{0}/{1}",
                                          result.PrevPos.AsString(),
                                          result.MaxCount),
                         "prev",
                         null);
            feed.AddLink(HostName.Combine(userHostName,
                                          "/streams/$all/before/{0}/{1}",
                                          result.NextPos.AsString(),
                                          result.MaxCount),
                         "next",
                         null);

            foreach (var item in items)
            {
                feed.AddEntry(itemToEntry(item, userHostName));
            }
            return feed;
        }
Esempio n. 3
0
            public ReadAllEventsBackwardCompleted(Guid correlationId, ReadAllResult result, string error, ResolvedEvent[] events,
                                                  StreamMetadata streamMetadata, bool isCachePublic, int maxCount,
                                                  TFPos currentPos, TFPos nextPos, TFPos prevPos, long tfLastCommitPosition)
            {
                Ensure.NotNull(events, "events");

                CorrelationId        = correlationId;
                Result               = result;
                Error                = error;
                Events               = events;
                StreamMetadata       = streamMetadata;
                IsCachePublic        = isCachePublic;
                MaxCount             = maxCount;
                CurrentPos           = currentPos;
                NextPos              = nextPos;
                PrevPos              = prevPos;
                TfLastCommitPosition = tfLastCommitPosition;
            }
Esempio n. 4
0
 private ClientMessage.ReadAllEventsBackwardCompleted NoData(ClientMessage.ReadAllEventsBackward msg, ReadAllResult result, TFPos pos, long lastCommitPosition, string error = null)
 {
     return(new ClientMessage.ReadAllEventsBackwardCompleted(
                msg.CorrelationId, result, error, ResolvedEvent.EmptyArray, null, false,
                msg.MaxCount, pos, TFPos.Invalid, TFPos.Invalid, lastCommitPosition));
 }
Esempio n. 5
0
 private ClientMessage.ReadAllEventsForwardCompleted NoData(ClientMessage.ReadAllEventsForward msg, ReadAllResult result, TFPos pos, string error = null)
 {
     return(new ClientMessage.ReadAllEventsForwardCompleted(
                msg.CorrelationId, result, error, ResolvedEvent.EmptyArray, null, false,
                msg.MaxCount, pos, TFPos.Invalid, TFPos.Invalid, _writerCheckpoint.Read()));
 }
Esempio n. 6
0
        public static FeedElement ToAllEventsBackwardFeed(ReadAllResult result, string userHostName, EmbedLevel embedContent)
        {
            var self = HostName.Combine(userHostName, "/streams/{0}", AllEscaped);
            var feed = new FeedElement();
            feed.SetTitle(string.Format("All events"));
            feed.SetId(self);

            feed.SetUpdated(result.Events.Length > 0 ? result.Events[0].Event.TimeStamp : DateTime.MinValue.ToUniversalTime());
            feed.SetAuthor(AtomSpecs.Author);

            feed.AddLink("self", self);
            feed.AddLink("first", HostName.Combine(userHostName, "/streams/{0}/{1}", AllEscaped, result.MaxCount));
            feed.AddLink("last", HostName.Combine(userHostName, "/streams/{0}/after/{1}/{2}", AllEscaped, new TFPos(0, 0).AsString(), result.MaxCount));
            feed.AddLink("previous", HostName.Combine(userHostName, "/streams/{0}/after/{1}/{2}", AllEscaped, result.PrevPos.AsString(), result.MaxCount));
            feed.AddLink("next", HostName.Combine(userHostName, "/streams/{0}/before/{1}/{2}", AllEscaped, result.NextPos.AsString(), result.MaxCount));

            for (int i = 0; i < result.Events.Length; ++i)
            {
                feed.AddEntry(ToEntry(new ResolvedEvent(result.Events[i].Event, result.Events[i].Link), userHostName, embedContent));
            }
            return feed;
        }
Esempio n. 7
0
 public ReadAllEventsForwardCompleted(Guid correlationId, ReadAllResult result)
 {
     CorrelationId = correlationId;
     Result = result;
 }
 public ReadAllEventsBackwardCompleted(Guid correlationId, ReadAllResult result, bool notModified)
 {
     CorrelationId = correlationId;
     NotModified = notModified;
     Result = result;
 }
Esempio n. 9
0
 public ReadAllEventsBackwardCompleted(Guid correlationId, ReadAllResult result)
 {
     CorrelationId = correlationId;
     Result        = result;
 }