@namespace Oqtane.Modules.Admin.Logs @using System.Globalization @inherits ModuleBase @inject NavigationManager NavigationManager @inject ILogService LogService @inject IPageService PageService @inject IPageModuleService PageModuleService @inject IUserService UserService @if (_pageName != string.Empty) { } @if (_moduleTitle != string.Empty) { } @if (_username != string.Empty) { } @if (!string.IsNullOrEmpty(_exception)) { }
Cancel @code { private int _logId; private string _logDate = string.Empty; private string _level = string.Empty; private string _feature = string.Empty; private string _function = string.Empty; private string _category = string.Empty; private string _pageName = string.Empty; private string _moduleTitle = string.Empty; private string _username = string.Empty; private string _url = string.Empty; private string _template = string.Empty; private string _message = string.Empty; private string _exception = string.Empty; private string _properties = string.Empty; private string _server = string.Empty; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Host; protected override async Task OnInitializedAsync() { try { _logId = Int32.Parse(PageState.QueryString["id"]); var log = await LogService.GetLogAsync(_logId); if (log != null) { _logDate = log.LogDate.ToString(CultureInfo.CurrentCulture); _level = log.Level; _feature = log.Feature; _function = log.Function; _category = log.Category; if (log.PageId != null) { var page = await PageService.GetPageAsync(log.PageId.Value); if (page != null) { _pageName = page.Name; } } if (log.PageId != null && log.ModuleId != null) { var pagemodule = await PageModuleService.GetPageModuleAsync(log.PageId.Value, log.ModuleId.Value); if (pagemodule != null) { _moduleTitle = pagemodule.Title; } } if (log.UserId != null) { var user = await UserService.GetUserAsync(log.UserId.Value, PageState.Site.SiteId); if (user != null) { _username = user.Username; } } _url = log.Url; _template = log.MessageTemplate; _message = log.Message; _exception = log.Exception; _properties = log.Properties; _server = log.Server; } } catch (Exception ex) { await logger.LogError(ex, "Error Loading Log {LogId} {Error}", _logId, ex.Message); AddModuleMessage("Error Loading Log", MessageType.Error); } } }