using Cowain.Bake.BLL; using Cowain.Bake.Model.Entity; using Cowain.Bake.Common; using Cowain.Bake.Model; 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; using Prism.Commands; using System.Windows; using HandyControl.Controls; using Cowain.Bake.Common.Core; namespace Cowain.Bake.UI.DataQuery.ViewModels { public class ProductionsInfoViewModel:ViewModelBase { public ProductionsInfoViewModel(IUnityContainer unityContainer, IRegionManager regionManager) : base(unityContainer, regionManager) { this.PageTitle = "产量查询"; } private ObservableCollection productionList; public ObservableCollection ProductionList { get => productionList ?? (productionList = new ObservableCollection()); set { SetProperty(ref productionList, value); } } void ExecuteQuery() { List query = null; var cellService = _unityContainer.Resolve(); if (5 < (EndDateTime - StartDateTime).Days) { Growl.Fatal("查询日期间隔不能大于5天!"); return; } var task = System.Threading.Tasks.Task.Factory.StartNew(() => { query = cellService.GetProductionOutPut(StartDateTime, EndDateTime); }); task.Wait(); if (null == query) { Growl.Fatal("查询失败,请重新查询!"); return; } productionList.Clear(); if (0 != query.Count) { query.ForEach(item => ProductionList.Add(item)); Growl.Success("查询完成!"); } else { Growl.Success("没有数据!"); } } public DelegateCommand QueryCommand => new DelegateCommand((x) => { ExecuteQuery(); }); } }