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/TaskInfo/TaskInfoViewModel.cs

120 lines
3.3 KiB
C#

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<object>(obj => Task(obj));
this.InStoreTask();
}
#region 参数定义
/// <summary>
/// 任务列表DataGrid
/// </summary>
private ObservableCollection<SysUserInfo> taskInfoDataGrid;
public ObservableCollection<SysUserInfo> TaskInfoDataGrid
{
get { return taskInfoDataGrid; }
set { taskInfoDataGrid = value; RaisePropertyChanged(() => TaskInfoDataGrid); }
}
/// <summary>
/// 记录列表DataGrid
/// </summary>
private ObservableCollection<SysUserInfo> recordInfoDataGrid;
public ObservableCollection<SysUserInfo> RecordInfoDataGrid
{
get { return recordInfoDataGrid; }
set { recordInfoDataGrid = value; RaisePropertyChanged(() => RecordInfoDataGrid); }
}
#endregion
#region 事件定义
/// <summary>
/// 出入库任务按钮事件
/// </summary>
public RelayCommand<object> 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;
}
}
/// <summary>
/// 入库任务
/// </summary>
/// <param name="obj"></param>
private void InStoreTask()
{
var models = sysUserInfoService.GetUserInfos();
TaskInfoDataGrid = new ObservableCollection<SysUserInfo>();
RecordInfoDataGrid = new ObservableCollection<SysUserInfo>();
if (models != null)
{
models.ForEach(
arg =>
{
arg.userName = "入库任务";
TaskInfoDataGrid.Add(arg);
RecordInfoDataGrid.Add(arg);
});
}
}
/// <summary>
/// 出库任务
/// </summary>
/// <param name="obj"></param>
private void OutStoreTask()
{
var models = sysUserInfoService.GetUserInfos();
TaskInfoDataGrid = new ObservableCollection<SysUserInfo>();
RecordInfoDataGrid = new ObservableCollection<SysUserInfo>();
if (models != null)
{
models.ForEach(
arg =>
{
arg.userName = "出库任务";
TaskInfoDataGrid.Add(arg);
RecordInfoDataGrid.Add(arg);
});
}
}
}
}