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.
|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using HighWayIot.Log4net;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Aucma.Scada.UI.viewModel
|
|
|
|
|
{
|
|
|
|
|
public class LogInfoViewModel : ViewModelBase
|
|
|
|
|
{
|
|
|
|
|
private LogHelper logHelper = LogHelper.Instance;
|
|
|
|
|
|
|
|
|
|
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
|
|
|
|
|
|
|
|
|
|
public LogInfoViewModel()
|
|
|
|
|
{
|
|
|
|
|
PrintMessageToListBox("打印日志");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 参数定义
|
|
|
|
|
private IEnumerable listBoxData;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// LisBox数据模板
|
|
|
|
|
/// </summary>
|
|
|
|
|
public IEnumerable ListBoxData
|
|
|
|
|
{
|
|
|
|
|
get { return listBoxData; }
|
|
|
|
|
set { listBoxData = value; RaisePropertyChanged(() => ListBoxData); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// listBox绑定日志
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="message"></param>
|
|
|
|
|
private void PrintMessageToListBox(string message)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
listItems.Add($"{DateTime.Now.ToString("HH:mm:ss")}==>{message}");
|
|
|
|
|
|
|
|
|
|
ListBoxData = listItems.OrderByDescending(x => x);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("日志数据绑定异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|