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

127 lines
3.4 KiB
C#

using Aucma.Scada.Business;
using Aucma.Scada.Model.domain;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using System.Collections.ObjectModel;
namespace Aucma.Scada.UI.viewModel.TaskInfo
{
public class TaskInfoViewModel : ViewModelBase
{
private TaskInfoBusiness taskInfoBusiness = TaskInfoBusiness.Instance;
public TaskInfoViewModel()
{
TaskCommand = new RelayCommand<object>(obj => Task(obj));
this.InStoreTask();
}
#region 参数定义
/// <summary>
/// 任务列表DataGrid
/// </summary>
private ObservableCollection<RealTaskInfo> taskInfoDataGrid;
public ObservableCollection<RealTaskInfo> TaskInfoDataGrid
{
get { return taskInfoDataGrid; }
set { taskInfoDataGrid = value; RaisePropertyChanged(() => TaskInfoDataGrid); }
}
/// <summary>
/// 记录列表DataGrid
/// </summary>
private ObservableCollection<RealTaskInfo> recordInfoDataGrid;
public ObservableCollection<RealTaskInfo> 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 = taskInfoBusiness.GetTaskInfos(1);
TaskInfoDataGrid = new ObservableCollection<RealTaskInfo>();
RecordInfoDataGrid = new ObservableCollection<RealTaskInfo>();
if (models != null)
{
models.ForEach(
arg =>
{
if (arg.taskStatus == 3)
{
RecordInfoDataGrid.Add(arg);
}
else
{
TaskInfoDataGrid.Add(arg);
}
});
}
}
/// <summary>
/// 出库任务
/// </summary>
/// <param name="obj"></param>
private void OutStoreTask()
{
var models = taskInfoBusiness.GetTaskInfos(2);
TaskInfoDataGrid = new ObservableCollection<RealTaskInfo>();
RecordInfoDataGrid = new ObservableCollection<RealTaskInfo>();
if (models != null)
{
models.ForEach(
arg =>
{
if (arg.taskStatus == 3)
{
RecordInfoDataGrid.Add(arg);
}
else
{
TaskInfoDataGrid.Add(arg);
}
});
}
}
}
}