Exemple #1
0
        public static Func <Log, bool> LogFilter(this Func <Log, bool> source, LogFilterViewModel filter)
        {
            if (filter == null)
            {
                return(p => true);
            }

            Func <Log, bool> predicateId          = p => true;
            Func <Log, bool> predicateTitle       = p => true;
            Func <Log, bool> predicateEvent       = p => true;
            Func <Log, bool> predicateLevel       = p => true;
            Func <Log, bool> predicateEnvironment = p => true;
            Func <Log, bool> predicateEnabled     = p => true;
            Func <Log, bool> predicateCreatedAt   = p => true;
            Func <Log, bool> predicateIp          = p => true;
            Func <Log, bool> predicateToken       = p => true;

            if (filter.Id != null)
            {
                predicateId = p => p.Id == filter.Id;
            }
            if (!string.IsNullOrEmpty(filter.Title))
            {
                predicateTitle = p => p.Title == filter.Title;
            }
            if (filter.Event.HasValue)
            {
                predicateEvent = p => p.Event == filter.Event;
            }
            if (!string.IsNullOrEmpty(filter.Level))
            {
                predicateLevel = p => p.Level == filter.Level;
            }
            if (!string.IsNullOrEmpty(filter.Environment))
            {
                predicateEnvironment = p => p.Environment == filter.Environment;
            }
            if (filter.Enabled.HasValue)
            {
                predicateEnabled = p => p.Enabled == filter.Enabled;
            }
            if (filter.CreatedAt.HasValue)
            {
                predicateCreatedAt = p => p.CreatedAt == filter.CreatedAt;
            }
            if (!string.IsNullOrEmpty(filter.Ip))
            {
                predicateIp = p => p.Ip == filter.Ip;
            }
            if (filter.Token.HasValue)
            {
                predicateToken = p => p.Token == filter.Token;
            }

            return(p => predicateId(p) && predicateTitle(p) &&
                   predicateLevel(p) && predicateEvent(p) &&
                   predicateEnvironment(p) && predicateEnabled(p) &&
                   predicateCreatedAt(p) && predicateIp(p) &&
                   predicateToken(p));
        }
Exemple #2
0
        public async Task <IActionResult> LogFilter(LogFilterViewModel model)
        {
            var logs = await unitOfWork
                       .LogsService
                       .GetFiltered(model.UserId, model.Date);

            return(PartialView("_Logs", ViewModelMapping.ConvertToViewModel(logs)));
        }
Exemple #3
0
        public ActionResult SystemHealthFilter()
        {
            LogFilterViewModel vm = new LogFilterViewModel();

            List <Person>             people   = new List <Person>();
            List <BGO.Common.LogType> logTypes = new List <BGO.Common.LogType>();

            people = cDal.GetPeople().OrderBy(x => x.Name).ToList();

            people.Add(new Person()
            {
                Id = -1, Fname = "NULL", Lname = "NULL"
            });
            logTypes = lookupDal.GetAllLogType();


            vm.People   = new SelectList(people, "Id", "Name");
            vm.LogTypes = new SelectList(logTypes, "Id", "Name");

            return(PartialView("_systemHealthFilter", vm));
        }
Exemple #4
0
        // GET: Logs
        public async Task <ActionResult> Index(LogFilterViewModel vm)
        {
            List <ListLogsViewModel> logs = new List <ListLogsViewModel>();
            var result = await _logService.FindAllLogs();

            if (result.Success)
            {
                if (result.Data.Count() > 0)
                {
                    foreach (var log in result.Data)
                    {
                        logs.Add(new ListLogsViewModel
                        {
                            Id              = log.Id,
                            Exception       = (log.Exception?.Length > 20) ? $"{log.Exception?.Substring(0, 20)} ..." : log.Exception,
                            LogEvent        = log.LogEvent,
                            Level           = log.Level,
                            Message         = (log.Message?.Length > 20) ? $"{log.Message?.Substring(0, 20)} ..." : log.Message,
                            MessageTemplate = (log.MessageTemplate?.Length > 20) ? $"{log.MessageTemplate?.Substring(0, 20)} ..." : log.MessageTemplate,
                            //Properties = log.Properties,
                            TimeStamp = log.TimeStamp
                        });
                    }
                }
                else
                {
                    Alert("No Logs Found", NotificationType.info, Int32.Parse(_appConfig.Value.NotificationDisplayTime));
                }

                return(View(logs));
            }
            else
            {
                Alert($"{result.Message}", NotificationType.error, Int32.Parse(_appConfig.Value.NotificationDisplayTime));

                return(View(logs));
            }
        }
Exemple #5
0
        public async Task <Pager <LogDto> > GetActivity([FromQuery] LogFilterViewModel model)
        {
            return(await _accountBusinessService.GetLogPager(_mapper.Map <LogFilterDto>(model)));

            //return new Pager<InvoiceListViewModel>(_mapper.Map<List<InvoiceListViewModel>>(result.Items), result.TotalItems, result.CurrentPage, result.PageSize);
        }