Esempio n. 1
0
        private bool MatchEntry(EventLogEntryEx entry)
        {
            bool match = true;

            if (!EventEntryTypeMatch(entry))
            {
                match = false;
            }
            else if (Sources.Count > 0 && !Sources.Contains(entry.Source))
            {
                match = false;
            }
            else if (EventIds.Count > 0 && !EventIds.Contains(entry.EventId))
            {
                match = false;
            }
            else if (TextFilter.Length > 0 && ContainsText && (!entry.Message.ToLower().Contains(TextFilter.ToLower())))
            {
                match = false;
            }
            else if (TextFilter.Length > 0 && !ContainsText && (!entry.Message.StartsWith(TextFilter, StringComparison.CurrentCultureIgnoreCase)))
            {
                match = false;
            }
            return(match);
        }
Esempio n. 2
0
        //internal List<EventLogEntryEx> GetMatchingEventLogEntries()
        //{
        //    List<EventLogEntryEx> list = new List<EventLogEntryEx>();
        //    using (diag.EventLog log = new diag.EventLog(EventLog, Computer))
        //    {
        //        DateTime currentTime = DateTime.Now;
        //        int counter = 0;
        //        int listSize = log.Entries.Count - 1;

        //        for (int i = listSize; i >= 0; i--)
        //        {
        //            try
        //            {
        //                diag.EventLogEntry entry = log.Entries[i];
        //                if (WithInLastXEntries > 0 && WithInLastXEntries <= counter)
        //                    break;
        //                if (WithInLastXMinutes > 0 && entry.TimeGenerated.AddMinutes(WithInLastXMinutes) < currentTime)
        //                    break;

        //                EventLogEntryEx newentry = new EventLogEntryEx();
        //                newentry.Category = entry.Category;
        //                newentry.EntryType = entry.EntryType;
        //                newentry.EventId = (int)(entry.InstanceId & 65535);
        //                newentry.MachineName = entry.MachineName;
        //                newentry.LogName = EventLog;
        //                newentry.Message = entry.Message;
        //                newentry.MessageSummary = newentry.Message.Length > 80 ? newentry.Message.Substring(0, 80) : newentry.Message;
        //                newentry.Source = entry.Source;
        //                newentry.TimeGenerated = entry.TimeGenerated;
        //                newentry.UserName = entry.UserName;

        //                if (MatchEntry(newentry))
        //                    list.Add(newentry);
        //                counter++;
        //            }
        //            catch (Exception ex)
        //            {
        //                if (!ex.ToString().Contains("is out of bounds"))
        //                {
        //                    throw;
        //                }
        //            }
        //        }
        //    }
        //    return list;
        //}
        private bool MatchEntry(EventLogEntryEx entry)
        {
            bool match = true;

            if (!EventEntryTypeMatch(entry))
            {
                match = false;
            }
            else if (Sources.Count > 0 && !Sources.Contains(entry.Source))
            {
                match = false;
            }
            else if (EventIds.Count > 0 && !EventIds.Contains(entry.EventId))
            {
                match = false;
            }
            else if (TextFilter.Length > 0 && UseRegEx)
            {
                System.Text.RegularExpressions.Match regMatch = System.Text.RegularExpressions.Regex.Match(entry.Message, TextFilter, System.Text.RegularExpressions.RegexOptions.Multiline);
                match = regMatch.Success;
            }
            else if (TextFilter.Length > 0 && !ContainsText && (!entry.Message.StartsWith(TextFilter, StringComparison.CurrentCultureIgnoreCase)))
            {
                match = false;
            }
            else if (TextFilter.Length > 0 && ContainsText && (!entry.Message.ToLower().Contains(TextFilter.ToLower())))
            {
                match = false;
            }
            return(match);
        }
Esempio n. 3
0
        void PublishEvent()
        {
            if (AttachEvents.Count > 0)
            {
                try
                {
                    using (XuHos.EventBus.MQChannel mqChannel = new EventBus.MQChannel())
                    {
                        var dict = AttachEvents.ToDictionary(a => a.EventID, a => new Dictionary <string, string>()
                        {
                            { "Body", a.EventObject },
                            { "EventTypeName", a.RouteKey }
                        });

                        mqChannel.Publish(dict, (EventIds) =>
                        {
                            this.SysEvents.Where(a => !a.Enqueued && EventIds.Contains(a.EventID)).Update(a => new SysEvent()
                            {
                                Enqueued = true
                            });
                        }, (EventIds) =>
                        {
                            this.SysEvents.Where(a => !a.Enqueued && EventIds.Contains(a.EventID)).Update(a => new SysEvent()
                            {
                                Enqueued = false
                            });
                        }, (EventIds) =>
                        {
                            this.SysEvents.Where(a => !a.Enqueued && EventIds.Contains(a.EventID)).Update(a => new SysEvent()
                            {
                                Enqueued = false
                            });
                        });
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Esempio n. 4
0
        private async Task HandleEventLogEntry(EventLogEntry entry, string logName)
        {
            // Don't send the entry to Seq if it doesn't match the filtered log levels, event IDs, or sources
            if (LogLevels != null && LogLevels.Count > 0 && !LogLevels.Contains(entry.EntryType))
            {
                return;
            }

            // EventID is obsolete
#pragma warning disable 618
            if (EventIds != null && EventIds.Count > 0 && !EventIds.Contains(entry.EventID))
#pragma warning restore 618
            {
                return;
            }

            if (Sources != null && Sources.Count > 0 && !Sources.Contains(entry.Source))
            {
                return;
            }

            await SeqApi.PostRawEvents(entry.ToDto(logName));
        }
Esempio n. 5
0
        public override IEnumerable <FeedItem> Execute()
        {
            if (BuildErrorTypeId <= 0)
            {
                return(new List <FeedItem>());
            }

            var query = from error in _db.BuildErrors
                        join log in _db.EventLogs on error.LogId equals log.Id
                        join be in _db.BuildEvents on log.Id equals be.EventLogId
                        join comm in _db.LogCommentEvents on log.Id equals comm.SourceEventLogId into logComments
                        where log.DateReceived >= StartDate &&
                        log.DateReceived <= EndDate &&
                        log.Id > MinLogId &&
                        error.BuildErrorTypeId == BuildErrorTypeId
                        orderby log.DateReceived descending
                        select new
            {
                Log          = log,
                BuildEvent   = be,
                Comments     = logComments,
                HelpfulMarks = (from helpful in _db.HelpfulMarkGivenEvents
                                where logComments.Select(l => l.Id).Contains(helpful.LogCommentEventId)
                                select helpful).Count()
            };

            //were we supplied with a maximum ID number?
            if (MaxLogId > 0)
            {
                query = from q in query
                        where q.Log.Id < MaxLogId
                        select q;
            }

            //if we were asked to retrieve a certain list of events, add that into the query
            if (EventIds.Count > 0)
            {
                query = from q in query
                        where EventIds.Contains(q.Log.Id)
                        select q;
            }

            //get list of subscription ids
            var subjectIds = SubscriptionSubjects.Select(s => s.Id).ToArray();

            if (subjectIds.Length > 0)
            {
                query = from q in query
                        where subjectIds.Contains(q.Log.SenderId)
                        select q;
            }

            //did we only want a certain number of results returned?
            if (MaxQuerySize > 0)
            {
                query = query.Take(MaxQuerySize);
            }

            //finally, loop through the query and build our results
            return(query.Select(row => new FeedItem
            {
                LogId = row.Log.Id,
                Log = row.Log,
                Comments = row.Comments.ToList(),
                HelpfulComments = row.HelpfulMarks,
                EventId = row.BuildEvent.Id,
                Event = row.BuildEvent
            })
                   .ToList());
        }
Esempio n. 6
0
        private List <EventModel> InitEventCollection()
        {
            var collection = collectionInitializer.Initialize <Event, EventModel>(e => e.MeetId == MeetId && EventIds.Contains(e.Id));

            var sorted = collection
                         .Select(e => new { Event = e, Rank = EventIds.IndexOf(e.Id) })
                         .OrderBy(a => a.Rank)
                         .Select(a => a.Event)
                         .ToList();

            return(sorted);
        }