109 lines
3.6 KiB
C#
109 lines
3.6 KiB
C#
|
|
using Cowain.Bake.BLL;
|
|||
|
|
using Cowain.Bake.Common;
|
|||
|
|
using Cowain.Bake.Common.Core;
|
|||
|
|
using Cowain.Bake.Common.Enums;
|
|||
|
|
using Cowain.Bake.Model;
|
|||
|
|
using HandyControl.Controls;
|
|||
|
|
using Prism.Commands;
|
|||
|
|
using Prism.Regions;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Collections.ObjectModel;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
using Unity;
|
|||
|
|
|
|||
|
|
namespace Cowain.Bake.UI.ProductManagement.ViewModels
|
|||
|
|
{
|
|||
|
|
public class DBLogViewModel: ViewModelBase
|
|||
|
|
{
|
|||
|
|
public DBLogViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager)
|
|||
|
|
{
|
|||
|
|
this.PageTitle = "日志查询";
|
|||
|
|
SetCombox();
|
|||
|
|
}
|
|||
|
|
private ObservableCollection<TLog> logList;
|
|||
|
|
public ObservableCollection<TLog> LogList
|
|||
|
|
{
|
|||
|
|
get => logList ?? (logList = new ObservableCollection<TLog>());
|
|||
|
|
set { SetProperty(ref logList, value); }
|
|||
|
|
}
|
|||
|
|
private DateTime _startTime = DateTime.Now.AddHours(-4);
|
|||
|
|
public DateTime StartDatetime
|
|||
|
|
{
|
|||
|
|
get { return _startTime; }
|
|||
|
|
set { SetProperty(ref _startTime, DateTime.Parse(value.ToString("yyyy-MM-dd HH:mm:ss"))); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private DateTime _endTime = DateTime.Now.AddHours(4);
|
|||
|
|
public DateTime EndDatetime
|
|||
|
|
{
|
|||
|
|
get { return _endTime; }
|
|||
|
|
set { SetProperty(ref _endTime, DateTime.Parse(value.ToString("yyyy-MM-dd HH:mm:ss"))); }
|
|||
|
|
}
|
|||
|
|
private string _logText=string.Empty;
|
|||
|
|
public string LogText
|
|||
|
|
{
|
|||
|
|
get { return _logText; }
|
|||
|
|
set { SetProperty(ref _logText, value); }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string selectLogLevel;
|
|||
|
|
public string SelectLogLevel
|
|||
|
|
{
|
|||
|
|
get => selectLogLevel;
|
|||
|
|
set => SetProperty(ref selectLogLevel, value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private List<string> listLogLevel;
|
|||
|
|
public List<string> ListLogLevel
|
|||
|
|
{
|
|||
|
|
get => listLogLevel;
|
|||
|
|
set => SetProperty(ref listLogLevel, value);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetCombox()
|
|||
|
|
{
|
|||
|
|
ListLogLevel = new List<string>();
|
|||
|
|
|
|||
|
|
foreach (E_LogType level in System.Enum.GetValues(typeof(E_LogType)))
|
|||
|
|
{
|
|||
|
|
ListLogLevel.Add(level.GetDescription());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SelectLogLevel = E_LogType.Operate.GetDescription();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public DelegateCommand<object> QueryCommand => new DelegateCommand<object>((x) =>
|
|||
|
|
{
|
|||
|
|
logList.Clear();
|
|||
|
|
E_LogType logType = EnumHelper.GetValueByDescription<E_LogType>(SelectLogLevel);
|
|||
|
|
//var list = EnumHelper.GetEnumList<E_LogType>().Where(item => item.EnumDesc == SelectLogLevel);
|
|||
|
|
//string level = list.FirstOrDefault().EnumString;
|
|||
|
|
var logService = _unityContainer.Resolve<LogService>();
|
|||
|
|
List<Model.TLog> logListTemporary;
|
|||
|
|
//if (string.IsNullOrEmpty(level))
|
|||
|
|
//{
|
|||
|
|
// //logListTemporary = logService.QueryByTime(StartDatetime, EndDatetime);
|
|||
|
|
// LogHelper.Instance.Warn("日志级别不能为空",null, true);
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
{
|
|||
|
|
logListTemporary = logService.QueryByTimeAndText(StartDatetime, EndDatetime, logType);
|
|||
|
|
}
|
|||
|
|
if (logListTemporary.Count != 0)
|
|||
|
|
{
|
|||
|
|
logListTemporary.ForEach(item => logList.Add(item));
|
|||
|
|
Growl.Success("查询完成!");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Growl.Success("没有数据!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|