change - 添加日志信息查询页面

master
wenjy 1 month ago
parent 11fead73dc
commit fcbdb97d1f

@ -0,0 +1,71 @@
using SlnMesnac.Common;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service.LogImpl;
using SlnMesnac.Repository.service.ScanLog;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* SlnMesnac.Business
* 9d48fdd1-4ce5-4944-9756-2a814bdd51ff
*
* WenJY
*
* 2024-10-09 9:53:19
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Business
{
public class LogInfoBusiness
{
private IBaseLogService logService;
public LogInfoBusiness(IBaseLogService _logService)
{
logService = _logService;
}
/// <summary>
/// 查询日志信息
/// </summary>
/// <param name="logLevel"></param>
/// <param name="beginTime"></param>
/// <param name="endTime"></param>
/// <param name="result"></param>
public void QueryLogInfo(string logLevel, DateTime beginTime, DateTime endTime, out List<BaseLog> result)
{
//var info = scanLogService.Query(x => x.CreateTime >= beginTime && x.CreateTime <= endTime);
Expression<Func<BaseLog, bool>> exp = s1 => true;
if (beginTime != null)
{
exp = exp.And(x => x.CreateTime >= beginTime.Date);
}
if (endTime != null)
{
exp = exp.And(x => x.CreateTime <= endTime.Date);
}
if (!string.IsNullOrEmpty(logLevel) && logLevel != "所有")
{
exp = exp.And(x => x.LogLevel == logLevel);
}
result = logService.Query(exp);
}
}
}

@ -123,12 +123,12 @@ namespace SlnMesnac.Business
Expression<Func<ScanLogModel, bool>> exp = s1 => true;
if(beginTime != null)
{
exp = exp.And(x => x.CreateTime >= beginTime);
exp = exp.And(x => x.CreateTime >= beginTime.Date);
}
if (endTime != null)
{
exp = exp.And(x => x.CreateTime <= endTime);
exp = exp.And(x => x.CreateTime <= endTime.Date);
}
if (!string.IsNullOrEmpty(rfidStr))

@ -14,7 +14,7 @@
<Border Grid.Row="0" BorderBrush="#EBF4FD" BorderThickness="2" CornerRadius="10" Background="#EBF4FD" Margin="10,10">
<StackPanel Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Left" Orientation="Horizontal">
<TextBlock Text="RFID" FontSize="18" Foreground="#31446E" Margin="10,3"/>
<TextBox Text="{Binding RfidCode}" FontSize="24" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5">
<TextBox Text="{Binding RfidCode}" FontSize="16" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5">
<TextBox.Template>
<ControlTemplate TargetType="TextBox">
<Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="5">
@ -25,9 +25,9 @@
</TextBox>
<TextBlock Text="扫描时间" FontSize="18" Foreground="#31446E" Margin="20,3,10,0"/>
<DatePicker x:Name="BeginTimeDatePicker" SelectedDate="{Binding BeginTime}" Width="120" VerticalAlignment="Center" Margin="0,0,5,0"/>
<DatePicker x:Name="BeginTimeDatePicker" SelectedDate="{Binding BeginTime}" FontSize="14" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5" Margin="0,0,5,0"/>
<TextBlock Text="-" FontSize="18" Foreground="#31446E" Margin="10,3"/>
<DatePicker x:Name="EndTimeDatePicker" SelectedDate="{Binding EndTime}" Width="120" VerticalAlignment="Center" Margin="0,0,5,0"/>
<DatePicker x:Name="EndTimeDatePicker" SelectedDate="{Binding EndTime}" FontSize="14" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5" Margin="0,0,5,0"/>
<Button Content="查 询" Command="{Binding QueryCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#5095F3" BorderBrush="#5095F3" Margin="10,0,10,0"/>
<Button Content="导 出" Command="{Binding ExportCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>

@ -24,24 +24,17 @@
</TextBox.Template>
</TextBox>-->
<ComboBox SelectedItem="{Binding LogType}" FontSize="16" Grid.Row="1" Width="180" Height="30">
<ComboBoxItem>INFO</ComboBoxItem>
<ComboBoxItem>WARN</ComboBoxItem>
<ComboBoxItem>ERROR</ComboBoxItem>
<ComboBox SelectedItem="{Binding LogLevel}" FontSize="16" Grid.Row="1" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5">
<ComboBoxItem>Info</ComboBoxItem>
<ComboBoxItem>Warn</ComboBoxItem>
<ComboBoxItem>Error</ComboBoxItem>
<ComboBoxItem>所有</ComboBoxItem>
<!--<ComboBox.Template>
<ControlTemplate TargetType="ComboBox">
<Border Background="White" BorderBrush="White" BorderThickness="1" CornerRadius="5">
<ScrollViewer x:Name="PART_ContentHost" />
</Border>
</ControlTemplate>
</ComboBox.Template>-->
</ComboBox>
<TextBlock Text="日志时间" FontSize="18" Foreground="#31446E" Margin="20,3,10,0"/>
<DatePicker x:Name="BeginTimeDatePicker" SelectedDate="{Binding BeginTime}" Width="120" VerticalAlignment="Center" Margin="0,0,5,0"/>
<DatePicker x:Name="BeginTimeDatePicker" SelectedDate="{Binding BeginTime}" FontSize="14" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5" Margin="0,0,5,0"/>
<TextBlock Text="-" FontSize="18" Foreground="#31446E" Margin="10,3"/>
<DatePicker x:Name="EndTimeDatePicker" SelectedDate="{Binding EndTime}" Width="120" VerticalAlignment="Center" Margin="0,0,5,0"/>
<DatePicker x:Name="EndTimeDatePicker" SelectedDate="{Binding EndTime}" FontSize="14" Width="180" Height="30" VerticalContentAlignment="Center" HorizontalAlignment="Center" Padding="5" Margin="0,0,5,0"/>
<Button Content="查 询" Command="{Binding QueryCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#5095F3" BorderBrush="#5095F3" Margin="10,0,10,0"/>
<Button Content="导 出" Command="{Binding ExportCommand}" Style="{StaticResource BUTTON_AGREE}" Width="100" Height="30" Background="#009999" BorderBrush="#FF36B5C1" Margin="0,0,10,0"/>
@ -51,17 +44,29 @@
<Border Grid.Row="1" BorderBrush="#EBF4FD" BorderThickness="2" CornerRadius="10" Background="#EBF4FD" Margin="10,10">
<DataGrid Grid.Row="0" ItemsSource="{Binding ScanItems}" Background="Transparent"
FontSize="18" ColumnHeaderHeight="35"
RowHeight="31" AutoGenerateColumns="False" RowHeaderWidth="0"
RowHeight="150" AutoGenerateColumns="False" RowHeaderWidth="0"
GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden" BorderThickness="0" CanUserAddRows="False" HorizontalAlignment="Center"
Foreground="#31446E" x:Name="dataGrid" Margin="0,10,0,0" >
<!--resourceStyle 399行修改选中字体颜色-->
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Id}" Header="序号" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding LogLevel}" Header="日志级别" Width="1*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Content}" Header="日志内容" Width="3*" IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding ErrMsg}" Header="异常日志" Width="3*" IsReadOnly="True">
<DataGridTextColumn.ElementStyle>
<Style TargetType="TextBlock">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
</DataGridTextColumn.ElementStyle>
</DataGridTextColumn>
<DataGridTextColumn Binding="{Binding CreateTime ,StringFormat=\{0:yyyy-MM-dd HH:mm:ss\}}" Header="记录时间" Width="1.5*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Rfid}" Header="RFID" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Code}" Header="ATR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Ocr}" Header="OCR" Width="2*" IsReadOnly="True"/>
<DataGridTextColumn Binding="{Binding Url}" Header="图像路径" Width="2*" IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
</Border>

@ -1,4 +1,5 @@
using System;
using SlnMesnac.WPF.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -23,6 +24,8 @@ namespace SlnMesnac.WPF.Page.LogInfo
public LogInfoControl()
{
InitializeComponent();
this.DataContext = new LogInfoViewModel();
}
}
}

@ -0,0 +1,85 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business;
using SlnMesnac.Model.domain;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* SlnMesnac.WPF.ViewModel
* 06dea146-4bed-4f74-9aac-01f8ea91d6bf
*
* WenJY
*
* 2024-10-09 8:50:06
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel
{
public partial class LogInfoViewModel: ObservableObject
{
private readonly LogInfoBusiness logInfoBusiness;
public LogInfoViewModel()
{
logInfoBusiness = App.ServiceProvider.GetService<LogInfoBusiness>();
}
public ComboBoxItem _logLevel = null;
public ComboBoxItem LogLevel
{
get => _logLevel;
set => SetProperty(ref _logLevel, value);
}
public DateTime _beginTime = DateTime.Now;
public DateTime BeginTime
{
get => _beginTime;
set => SetProperty(ref _beginTime, value);
}
public DateTime _endTime = DateTime.Now;
public DateTime EndTime
{
get => _endTime;
set => SetProperty(ref _endTime, value);
}
private ObservableCollection<BaseLog> _scanItems = new ObservableCollection<BaseLog>();
public ObservableCollection<BaseLog> ScanItems
{
get => _scanItems;
set => SetProperty(ref _scanItems, value);
}
[RelayCommand]
private void Query()
{
logInfoBusiness.QueryLogInfo(_logLevel.Content.ToString(), _beginTime, _endTime, out List<BaseLog> info);
ScanItems = new ObservableCollection<BaseLog>(info);
}
}
}
Loading…
Cancel
Save