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.
Aucma.Scada/Aucma.Scada.UI/viewModel/RecordViewModel.cs

93 lines
2.3 KiB
C#

using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using HighWayIot.Repository.service;
using HighWayIot.Repository.service.Impl;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Aucma.Scada.UI.viewModel
{
public class RecordViewModel: ViewModelBase
{
private LogHelper logHelper = LogHelper.Instance;
private ISysUserInfoService sysUserInfoService = new SysUserInfoServiceImpl();
public RecordViewModel()
{
QueryCommand = new RelayCommand(Query);
ResetCommand = new RelayCommand(Reset);
}
#region 参数定义
private String search = String.Empty;
public String Search
{
get { return search; }
set { search = value; RaisePropertyChanged(); }
}
private ObservableCollection<SysUserInfo> gridModelList;
//前端使用的属性
public ObservableCollection<SysUserInfo> GridModelList
{
get { return gridModelList; }
set { gridModelList = value; RaisePropertyChanged(); }
}
#endregion
#region 事件定义
/// <summary>
/// 查询事件
/// </summary>
public RelayCommand QueryCommand { get; set; }
/// <summary>
/// 重置
/// </summary>
public RelayCommand ResetCommand { get; set; }
#endregion
/// <summary>
/// 查询
/// </summary>
public void Query()
{
var models = sysUserInfoService.GetUserInfos();
if (!string.IsNullOrEmpty(Search))
{
models = models.Where(x => x.userName.Contains(Search)).ToList();
}
GridModelList = new ObservableCollection<SysUserInfo>();
if (models != null)
{
models.ForEach(
arg =>
{
GridModelList.Add(arg);
}
);
}
}
/// <summary>
/// 重置
/// </summary>
public void Reset()
{
Search = String.Empty;
this.Query();
}
}
}