private EventBookmark SetBookmarkForLatestFailureItem()
        {
            EventBookmark eventBookmark = null;
            EventLogQuery eventLogQuery = FailureItemWatcher.CreateEventLogQueryByDatabaseGuid(this.m_database.Guid);

            eventLogQuery.ReverseDirection = true;
            using (EventLogReader eventLogReader = new EventLogReader(eventLogQuery))
            {
                using (EventRecord eventRecord = eventLogReader.ReadEvent())
                {
                    if (eventRecord != null)
                    {
                        DatabaseFailureItem databaseFailureItem = DatabaseFailureItem.Parse(eventRecord);
                        eventBookmark = databaseFailureItem.Bookmark;
                        this.Bookmarker.Write(eventBookmark);
                    }
                }
            }
            return(eventBookmark);
        }
        internal static DatabaseFailureItem FindMostRecentIdenticalFailureItem(DatabaseFailureItem referenceDbfi, out int countDupliateItems, out EventRecord latestRecord)
        {
            EventLogQuery       eventQuery = FailureItemWatcher.CreateEventLogQueryByDatabaseGuid(referenceDbfi.Guid);
            DatabaseFailureItem result;

            using (EventLogReader eventLogReader = new EventLogReader(eventQuery, referenceDbfi.Bookmark))
            {
                latestRecord = null;
                DatabaseFailureItem databaseFailureItem = null;
                countDupliateItems = 0;
                for (;;)
                {
                    EventRecord eventRecord2;
                    EventRecord eventRecord = eventRecord2 = eventLogReader.ReadEvent();
                    try
                    {
                        if (eventRecord != null)
                        {
                            DatabaseFailureItem databaseFailureItem2 = DatabaseFailureItem.Parse(eventRecord);
                            if (referenceDbfi.Equals(databaseFailureItem2))
                            {
                                databaseFailureItem = databaseFailureItem2;
                                latestRecord        = eventRecord;
                                countDupliateItems++;
                                continue;
                            }
                        }
                    }
                    finally
                    {
                        if (eventRecord2 != null)
                        {
                            ((IDisposable)eventRecord2).Dispose();
                        }
                    }
                    break;
                }
                result = databaseFailureItem;
            }
            return(result);
        }
        private bool ProcessRecord(EventRecord rec)
        {
            bool          flag = false;
            int           num  = 0;
            EventRecord   suppressUntilRecord = null;
            EventBookmark bookmark            = null;
            TagHandler    tagHandler          = null;

            this.m_suppressUntilRecord = null;
            try
            {
                this.Trace("Processing Record# {0}", new object[]
                {
                    rec.RecordId
                });
                bookmark = rec.Bookmark;
                DatabaseFailureItem databaseFailureItem = DatabaseFailureItem.Parse(rec);
                if (databaseFailureItem != null)
                {
                    if (databaseFailureItem.Tag == FailureTag.Remount)
                    {
                        DatabaseFailureItem databaseFailureItem2 = FailureItemWatcher.FindMostRecentIdenticalFailureItem(databaseFailureItem, out num, out suppressUntilRecord);
                        if (num > 0)
                        {
                            this.Trace("Skipped {0} identical failure items of tag {1}", new object[]
                            {
                                num,
                                databaseFailureItem.Tag
                            });
                            databaseFailureItem = databaseFailureItem2;
                        }
                    }
                    bookmark = databaseFailureItem.Bookmark;
                    this.Trace("Starting to process failure item: {0}", new object[]
                    {
                        databaseFailureItem
                    });
                    tagHandler = TagHandler.GetInstance(this, databaseFailureItem);
                    if (tagHandler != null)
                    {
                        ExTraceGlobals.FaultInjectionTracer.TraceTest(2640719165U);
                        flag = tagHandler.Execute();
                        if (flag)
                        {
                            this.Trace("Finished processing failure item for database '{0}'", new object[]
                            {
                                this.m_database.Name
                            });
                        }
                        else
                        {
                            this.Trace("Could not process failure item for database '{0}'", new object[]
                            {
                                this.m_database.Name
                            });
                        }
                    }
                    else
                    {
                        this.Trace("Failed to process failure item since there is no handler found (failureitem:{0})", new object[]
                        {
                            databaseFailureItem
                        });
                        flag = true;
                    }
                    this.Trace("Finished processing failure item", new object[0]);
                }
            }
            catch (InvalidFailureItemException ex)
            {
                this.Trace("Ignoring the invalid failure item. (error={0}, eventxml={1})", new object[]
                {
                    ex,
                    rec.ToXml()
                });
                flag = true;
            }
            if (flag)
            {
                this.Bookmarker.Write(bookmark);
                if (num > 0)
                {
                    this.m_suppressUntilRecord = suppressUntilRecord;
                }
                if (tagHandler != null && tagHandler.PostProcessingAction != null)
                {
                    tagHandler.PostProcessingAction();
                }
            }
            return(flag);
        }