public ActionResult Index() { var logSearchModel = new LogSearchModel(); // add all type of log levels logSearchModel.AvailableLogLevels = LogLevel.Debug.ToSelectList(false).ToList(); logSearchModel.AvailableLogLevels.Insert(0, new SelectListItem() { Text = localizationService.GetResource("Common.All"), Value = "0" }); return View(logSearchModel); }
public ActionResult List(LogSearchModel model) { if (!Request.IsAjaxRequest()) return RedirectToAction(SystemRouteNames.Index); DateTime? startDateValue = (model.CreatedOnFrom == null) ? null : (DateTime?)dateTimeHelper.ConvertToUtcTime(model.CreatedOnFrom.Value, dateTimeHelper.CurrentTimeZone); DateTime? endDateValue = (model.CreatedOnTo == null) ? null : (DateTime?)dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, dateTimeHelper.CurrentTimeZone).AddDays(1); LogLevel? logLevel = model.LogLevelId > 0 ? (LogLevel?)(model.LogLevelId) : null; var logs = logger.GetAll(startDateValue, endDateValue, model.Message, logLevel, CommonHelper.To<int>(Request[StateKeyManager.DataTable.DISPLAY_START]) / CommonHelper.To<int>(Request[StateKeyManager.DataTable.DISPLAY_LENGTH]), CommonHelper.To<int>(Request[StateKeyManager.DataTable.DISPLAY_LENGTH])); var pagedModel = new PagedModel<LogModel> { Data = logs.Select(x => { return new LogModel() { RowId = x.RowId, LogLevel = x.LogLevel.GetLocalizedEnum(localizationService, workContext), ShortMessage = x.ShortMessage, FullMessage = x.FullMessage, IpAddress = x.IpAddress, UserId = x.UserId, UserName = x.User != null ? x.User.Username : null, PageUrl = x.PageUrl, ReferrerUrl = x.ReferrerUrl, CreatedOn = x.CreatedOn.ToString(StateKeyManager.DateTimeFormat) }; }), TotalCount = logs.TotalCount }; return Json(new DataTablesPagedParser<LogModel>(Request, pagedModel).Parse()); }