Exemple #1
0
        /// <summary>
        /// Gets all the events of a certain type from the DB
        /// </summary>
        /// <returns>List of events, empty if no such event exists</returns>
        private IEnumerable <IMessage> GetEventsByType(ExecutionEventId eventTypeID)
        {
            Contract.Requires(Accessor != null, "XldbStore must be initialized via OpenDatastore first");

            var storedEvents = new List <IMessage>();
            var eventQuery   = new EventTypeQuery
            {
                EventTypeID = eventTypeID,
            };

            if (!m_eventParserDictionary.TryGetValue(eventTypeID, out var parser))
            {
                return(storedEvents);
            }

            var maybeFound = Accessor.Use(database =>
            {
                foreach (var kvp in database.PrefixSearch(eventQuery.ToByteArray(), EventColumnFamilyName))
                {
                    storedEvents.Add(parser.ParseFrom(kvp.Value));
                }
            });

            if (!maybeFound.Succeeded)
            {
                maybeFound.Failure.Throw();
            }

            return(storedEvents);
        }
Exemple #2
0
        /// <summary>
        /// Gets all the events of a certain type from the DB
        /// </summary>
        private IEnumerable <string> GetEventsByType(ExecutionEventId eventTypeID)
        {
            Contract.Assert(Accessor != null, "XldbStore must be initialized via OpenDatastore first");

            var storedEvents = new List <string>();
            var eventQuery   = new EventTypeQuery
            {
                EventTypeID = eventTypeID,
            };

            var maybeFound = Accessor.Use(database =>
            {
                foreach (var kvp in database.PrefixSearch(eventQuery.ToByteArray()))
                {
                    if (m_eventParserDictionary.TryGetValue(eventTypeID, out var parser))
                    {
                        storedEvents.Add(parser.ParseFrom(kvp.Value).ToString());
                    }
                    else
                    {
                        // We will never reach here since this is a private method and we explicitly control which ExecutionEventIDs are passed in (ie. the public facing helper methods below)
                        _ = Contract.AssertFailure("Invalid Execution Event ID passed in. Exiting");
                    }
                }
            });

            if (!maybeFound.Succeeded)
            {
                maybeFound.Failure.Throw();
            }

            return(storedEvents);
        }
Exemple #3
0
        public IMessage GetEventByKey(ExecutionEventId eventTypeID, uint pipID)
        {
            Contract.Requires(Accessor != null, "XldbStore must be initialized via OpenDatastore first");

            var eventQuery = new EventTypeQuery
            {
                EventTypeID = eventTypeID,
                PipId       = pipID
            };

            if (!m_eventParserDictionary.TryGetValue(eventTypeID, out var parser))
            {
                return(null);
            }

            var maybeFound = Accessor.Use(database =>
            {
                foreach (var kvp in database.PrefixSearch(eventQuery.ToByteArray(), EventColumnFamilyName))
                {
                    return(parser.ParseFrom(kvp.Value));
                }
                return(null);
            });

            if (!maybeFound.Succeeded)
            {
                maybeFound.Failure.Throw();
            }

            return(maybeFound.Result);
        }