public ActionResult Filter(LoggerSettings loggerSetting)
 {
     LogSettingAndEvents logSettingAndEvents = new LogSettingAndEvents();
     logSettingAndEvents.IsStarted = _memoryAppender != null ? _memoryAppender.IsStarted : false;
     logSettingAndEvents.LoggingEvents = GetFilteredEvents(loggerSetting);
     logSettingAndEvents.LoggerSetting = loggerSetting;
     return View("Show", logSettingAndEvents);
 }
        public ActionResult Filter(LoggerSettings loggerSetting)
        {
            var logSettingAndEvents = new LogSettingAndEvents
            {
                IsStarted = _memoryAppender?.IsStarted ?? false,
                LoggingEvents = GetFilteredEvents(loggerSetting),
                LoggerSetting = loggerSetting
            };

            return View("Show", logSettingAndEvents);
        }
 public LogSettingAndEvents()
 {
     LoggingEvents = Enumerable.Empty <LoggingEvent>();
     LoggerSetting = new LoggerSettings();
 }
        private IEnumerable<LoggingEvent> GetFilteredEvents(LoggerSettings loggerSetting)
        {
            if(_memoryAppender == null)
            {
                return Enumerable.Empty<LoggingEvent>();
            }

            IEnumerable<LoggingEvent> res = _memoryAppender.GetEvents().Distinct().Where(l => l.Level >= loggerSetting.Level).OrderBy(l => l.TimeStamp);

            if(res.Any() && !string.IsNullOrEmpty(loggerSetting.LoggerName))
            {
                res = res.Where(l => l.LoggerName.Contains(loggerSetting.LoggerName));
            }

            if(res.Any() && !string.IsNullOrEmpty(loggerSetting.ThreadName))
            {
                res = res.Where(l => l.ThreadName == loggerSetting.ThreadName);
            }

            if(res.Any() && !string.IsNullOrEmpty(loggerSetting.UserName))
            {
                res = res.Where(l => l.UserName == loggerSetting.UserName);
            }

            if(res.Any())
            {
                res = res.Where(l => ((l.TimeStamp.Ticks >= loggerSetting.StartDate.Ticks) && (l.TimeStamp.Ticks <= loggerSetting.EndDate.Ticks)));
            }

            return res;
        }
 public LogSettingAndEvents()
 {
     LoggingEvents = Enumerable.Empty<LoggingEvent>();
     LoggerSetting = new LoggerSettings();
 }