225 lines
8.8 KiB
Plaintext
225 lines
8.8 KiB
Plaintext
@using TIAM.Entities.Products
|
|
@using TIAM.Entities.Transfers
|
|
@using TIAM.Entities.Drivers
|
|
@using TIAM.Entities.Users
|
|
@using TIAM.Models.Dtos.Users
|
|
@using TIAM.Services
|
|
@using TIAMSharedUI.Shared.Components.Grids
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI
|
|
@using TIAMWebApp.Shared.Application.Services
|
|
@using TIAMWebApp.Shared.Application.Utility
|
|
@using TIAM.Core.Loggers
|
|
@using AyCode.Core.Loggers
|
|
@using AyCode.Services.Loggers
|
|
@using AyCode.Core
|
|
@using AyCode.Core.Extensions
|
|
@using AyCode.Core.Helpers
|
|
@using Castle.Components.DictionaryAdapter
|
|
@using DevExpress.Data.Filtering
|
|
@using DevExpress.DirectX.Common.Direct2D
|
|
@using TIAM.Core.Enums
|
|
@inject IServiceProviderDataService ServiceProviderDataService
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
@inject AdminSignalRClient AdminSignalRClient
|
|
@inject IWizardProcessor WizardProcessor
|
|
@inject IUserDataService UserDataService
|
|
|
|
|
|
@* VirtualScrollingEnabled="true" *@
|
|
<LogViewerGrid Logger="_logger"
|
|
@ref="_logViewerGrid"
|
|
ContextIds="_contextParams"
|
|
SignalRClient="AdminSignalRClient"
|
|
FilterText="@_filterText"
|
|
ShowGroupPanel="true"
|
|
PageSize="20"
|
|
PagerPosition="GridPagerPosition.TopAndBottom"
|
|
PageSizeSelectorVisible="true"
|
|
PageSizeSelectorItems="@(new int[] { 20, 50, 100, 200, 300, 400, 500 })"
|
|
PageSizeSelectorAllRowsItemVisible="true"
|
|
ValidationEnabled="false"
|
|
CustomizeElement="Grid_CustomizeElement"
|
|
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
|
DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto"
|
|
ShowFilterRow="true">
|
|
<Columns>
|
|
<DxGridDataColumn FieldName="TimeStampUtc" Caption="TimeStampUtc" SortIndex="0" SortOrder="GridColumnSortOrder.Descending" DisplayFormat="g" Width="130" />
|
|
<DxGridDataColumn FieldName="AppType" Caption="AppType" Width="80px" />
|
|
<DxGridDataColumn FieldName="LogLevel" Caption="LogLevel" Width="80px" />
|
|
<DxGridDataColumn FieldName="ThreadId" Caption="ThId" Width="55px" />
|
|
<DxGridDataColumn FieldName="CategoryName" Width="170" />
|
|
<DxGridDataColumn FieldName="CallerName" Width="200" />
|
|
<DxGridDataColumn FieldName="Text" />
|
|
<DxGridDataColumn FieldName="Exception" Width="200" />
|
|
<DxGridDataColumn FieldName="ErrorType" Visible="false" />
|
|
</Columns>
|
|
<DetailRowTemplate>
|
|
@{
|
|
var a = ((LogItemViewerModel)context.DataItem);
|
|
}
|
|
<div><p>@($"{a.CategoryName}->{a.CallerName}")</p></div>
|
|
<div><p>@($"{a.Text}")</p></div>
|
|
<div style="font-weight: bold;">Exception:</div>
|
|
<div><p style="text-wrap: wrap;">@a.Exception</p></div>
|
|
</DetailRowTemplate>
|
|
<ToolbarTemplate>
|
|
<DxGridLayout>
|
|
<Rows>
|
|
<DxGridLayoutRow />
|
|
</Rows>
|
|
<Columns>
|
|
<DxGridLayoutColumn />
|
|
<DxGridLayoutColumn Width="130" />
|
|
<DxGridLayoutColumn Width="130" />
|
|
<DxGridLayoutColumn Width="100" />
|
|
<DxGridLayoutColumn Width="auto" />
|
|
</Columns>
|
|
<Items>
|
|
<DxGridLayoutItem Row="0" Column="0">
|
|
<Template>
|
|
<DxTagBox Data="@(Enum.GetValues<LogLevel>().ToList())" Values="@_selectedLogLevels"
|
|
NullText="Select status type..." ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Auto" aria-label="Select status type"
|
|
ValuesChanged="(IEnumerable<LogLevel> values) => TagBox_ValuesChanged(values)" />
|
|
</Template>
|
|
</DxGridLayoutItem>
|
|
<DxGridLayoutItem Row="0" Column="1">
|
|
<Template>
|
|
<DxDateEdit Date="@_fromDate"
|
|
NullText="Select fromDate..."
|
|
DisplayFormat="d"
|
|
DateChanged="@((DateTime fromDate) => OnValueChangedStartDate(fromDate))"
|
|
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Never">
|
|
</DxDateEdit>
|
|
</Template>
|
|
</DxGridLayoutItem>
|
|
<DxGridLayoutItem Row="0" Column="2">
|
|
<Template>
|
|
<DxDateEdit Date="@_toDate"
|
|
NullText="select toDate..."
|
|
DisplayFormat="d"
|
|
DateChanged="@((DateTime toDate) => OnValueChangedEndDate(toDate))"
|
|
ClearButtonDisplayMode="DataEditorClearButtonDisplayMode.Never">
|
|
</DxDateEdit>
|
|
</Template>
|
|
</DxGridLayoutItem>
|
|
<DxGridLayoutItem Row="0" Column="3">
|
|
<Template>
|
|
<DxSpinEdit Value="@_takeCount" CssClass="dx-demo-editor-width" MinValue="0" Increment="500" BindValueMode="BindValueMode.OnDelayedInput" InputDelay="1500"
|
|
ValueChanged="@((int newValue) => OnValueChangedTakeCount(newValue))">
|
|
</DxSpinEdit>
|
|
</Template>
|
|
</DxGridLayoutItem>
|
|
|
|
</Items>
|
|
</DxGridLayout>
|
|
</ToolbarTemplate>
|
|
</LogViewerGrid>
|
|
|
|
@code {
|
|
[Parameter] public GridDetailExpandButtonDisplayMode DetailExpandButtonDisplayMode { get; set; } = GridDetailExpandButtonDisplayMode.Never;
|
|
|
|
private LogViewerGrid _logViewerGrid;
|
|
|
|
private static DateTime _fromDate = DateTime.Today.AddDays(-2);
|
|
private static DateTime _toDate = DateTime.Today;
|
|
|
|
private static int _takeCount = 250;
|
|
private object[] _contextParams = new object[3] { _takeCount, _fromDate, _toDate };
|
|
|
|
private LoggerClient<LogViewerGridComponent> _logger;
|
|
private static List<LogLevel> _selectedLogLevels = [LogLevel.Error, LogLevel.Warning, LogLevel.Suggest];
|
|
private static string _filterText = GetFilterText(_selectedLogLevels);
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
_logger = new LoggerClient<LogViewerGridComponent>(LogWriters.ToArray());
|
|
|
|
base.OnInitialized();
|
|
}
|
|
|
|
private static string GetFilterText(ICollection<LogLevel> selectedLogLevels)
|
|
=> selectedLogLevels.Count == 0 ? string.Empty : CriteriaOperator.FromLambda<LogItemViewerModel>(t => selectedLogLevels.Contains(t.LogLevel)).ToString();
|
|
|
|
void TagBox_ValuesChanged(IEnumerable<LogLevel> newSelectedLogLevels)
|
|
{
|
|
var filterText = string.Empty;
|
|
InOperator? filterCriteria = null;
|
|
|
|
_selectedLogLevels = newSelectedLogLevels.ToList();
|
|
|
|
if (_selectedLogLevels.Count > 0)
|
|
{
|
|
filterCriteria = new InOperator(nameof(LogLevel), _selectedLogLevels);
|
|
filterText = GetFilterText(_selectedLogLevels);
|
|
}
|
|
|
|
_filterText = filterText;
|
|
_logViewerGrid.SetFieldFilterCriteria(nameof(LogLevel), filterCriteria);
|
|
}
|
|
|
|
private async Task OnValueChangedTakeCount(int value)
|
|
{
|
|
if (_takeCount == value) return;
|
|
|
|
_takeCount = value;
|
|
_contextParams[0] = _takeCount;
|
|
await _logViewerGrid.LoadDataSourceAsync();
|
|
}
|
|
|
|
private async Task OnValueChangedStartDate(DateTime value)
|
|
{
|
|
if (_fromDate == value) return;
|
|
|
|
_fromDate = value;
|
|
if (_fromDate.Date > DateTime.Today.Date) _fromDate = DateTime.Today;
|
|
|
|
_contextParams[1] = _fromDate;
|
|
|
|
if (_fromDate.Date > _toDate.Date) return;
|
|
await _logViewerGrid.LoadDataSourceAsync();
|
|
}
|
|
|
|
private async Task OnValueChangedEndDate(DateTime value)
|
|
{
|
|
if (_toDate == value) return;
|
|
|
|
_toDate = value;
|
|
_contextParams[2] = _toDate;
|
|
|
|
if (_fromDate.Date > _toDate.Date) return;
|
|
await _logViewerGrid.LoadDataSourceAsync();
|
|
}
|
|
|
|
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
|
|
{
|
|
if (e.ElementType != GridElementType.DataRow) return;
|
|
|
|
var logLevelObject = e.Grid?.GetRowValue(e.VisibleIndex, nameof(LogLevel));
|
|
if (logLevelObject == null) return;
|
|
|
|
var levelObject = (LogLevel)logLevelObject;
|
|
|
|
switch (levelObject)
|
|
{
|
|
case LogLevel.Detail:
|
|
break;
|
|
case LogLevel.Trace:
|
|
break;
|
|
case LogLevel.Debug:
|
|
break;
|
|
case LogLevel.Info:
|
|
break;
|
|
case LogLevel.Suggest:
|
|
break;
|
|
case LogLevel.Warning:
|
|
e.CssClass = "bg-attention";
|
|
break;
|
|
case LogLevel.Error:
|
|
e.CssClass = "bg-important";
|
|
break;
|
|
case LogLevel.Disabled:
|
|
break;
|
|
}
|
|
}
|
|
} |