You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.6 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using log4net;
using Microsoft.IdentityModel.Logging;
using Polly;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using Admin.Core.Tasks;
namespace Aucma.Core.SheetMetal.ViewModels
{
public class LogPageViewModel : ObservableObject
{
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(LogPageViewModel));
public LogPageViewModel()
{
//Job_Admin_Quartz.LogDelegateEvent += PrintMessageToListBox;
}
/// <summary>
/// LisBox数据模板
/// </summary>
private IEnumerable logInfoListBox;
public IEnumerable LogInfoListBox
{
get => logInfoListBox;
set => SetProperty(ref logInfoListBox, value);
}
/// <summary>
/// listBox绑定日志
/// </summary>
/// <param name="message"></param>
private void PrintMessageToListBox(string message)
{
try
{
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss")}==>{message}");
LogInfoListBox = listItems.OrderByDescending(x => x);
}
catch (Exception ex)
{
log.Error("日志数据绑定异常", ex);
}
}
}
}