using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; 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.TaskInfo { public class TaskInfoViewModel : ViewModelBase { private ISysUserInfoService sysUserInfoService = new SysUserInfoServiceImpl(); public TaskInfoViewModel() { TaskCommand = new RelayCommand(obj => Task(obj)); this.InStoreTask(); } #region 参数定义 /// /// 任务列表DataGrid /// private ObservableCollection taskInfoDataGrid; public ObservableCollection TaskInfoDataGrid { get { return taskInfoDataGrid; } set { taskInfoDataGrid = value; RaisePropertyChanged(() => TaskInfoDataGrid); } } /// /// 记录列表DataGrid /// private ObservableCollection recordInfoDataGrid; public ObservableCollection RecordInfoDataGrid { get { return recordInfoDataGrid; } set { recordInfoDataGrid = value; RaisePropertyChanged(() => RecordInfoDataGrid); } } #endregion #region 事件定义 /// /// 出入库任务按钮事件 /// public RelayCommand TaskCommand { get; set; } #endregion private void Task(object obj) { string info = obj as string; switch (info) { case "inStore": InStoreTask(); break; case "outStore": OutStoreTask(); break; default: break; } } /// /// 入库任务 /// /// private void InStoreTask() { var models = sysUserInfoService.GetUserInfos(); TaskInfoDataGrid = new ObservableCollection(); RecordInfoDataGrid = new ObservableCollection(); if (models != null) { models.ForEach( arg => { arg.userName = "入库任务"; TaskInfoDataGrid.Add(arg); RecordInfoDataGrid.Add(arg); }); } } /// /// 出库任务 /// /// private void OutStoreTask() { var models = sysUserInfoService.GetUserInfos(); TaskInfoDataGrid = new ObservableCollection(); RecordInfoDataGrid = new ObservableCollection(); if (models != null) { models.ForEach( arg => { arg.userName = "出库任务"; TaskInfoDataGrid.Add(arg); RecordInfoDataGrid.Add(arg); }); } } } }