using Admin.Core.IService; using Admin.Core.Model; using Admin.Core.Model.Model_New; using Admin.Core.Model.ViewModels; using Admin.Core.Service; using Admin.Core.Tasks; using Aucma.Core.OldBoxFoam.Models; using CommunityToolkit.Mvvm.ComponentModel; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; /** * 老发泡线监控 * */ namespace Aucma.Core.OldBoxFoam.ViewModels { public partial class OldBoxFoamPageViewModel : ObservableObject { IOldBoxFoamDataServices? _oldBoxFoamDataServices; IOldBoxFoamTypeServices _oldBoxFoamTypeServices; public OldBoxFoamPageViewModel() { _oldBoxFoamDataServices = App.ServiceProvider.GetService(); _oldBoxFoamTypeServices = App.ServiceProvider.GetService(); Job_OldBoxFoam_Quartz.RefreshOldBoxFoamTypeDataDelegateEvent += OldBoxFoamTypeOnLoad3; Job_OldBoxFoam_Quartz.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3; Task.WaitAll(OldBoxFoamOnLoad(), OldBoxFoamTypeOnLoad()); } #region 初始化加载数据 public async Task OldBoxFoamOnLoad() { List list = await _oldBoxFoamDataServices.QueryAsync(); if (list == null) return; foreach (var item in list) { OldBoxFoamDataModel model = new OldBoxFoamDataModel(); model.ObjId = item.ObjId; model.Fixtureboxtype = item.Fixtureboxtype; model.Fixturestatus = item.Fixturestatus; model.Production = item.Production; model.CuringTimeSettingValue = item.CuringTimeSettingValue; model.ActualValue = item.ActualValue; _oldBoxFoamDataGrid.Add(model); } } public Task OldBoxFoamOnLoad3(List list) { if (list == null) return Task.CompletedTask; System.Windows.Application.Current.Dispatcher.Invoke((Action)( () => { OldBoxFoamDataGrid.Clear(); foreach (var item in list) { OldBoxFoamDataModel model = new OldBoxFoamDataModel(); model.ObjId = item.ObjId; model.Fixtureboxtype = item.Fixtureboxtype; model.Fixturestatus = item.Fixturestatus; model.Production = item.Production; model.CuringTimeSettingValue = item.CuringTimeSettingValue; model.ActualValue = item.ActualValue; OldBoxFoamDataGrid.Add(model); } })); return Task.CompletedTask; } public async Task OldBoxFoamTypeOnLoad() { var list =await _oldBoxFoamTypeServices.QueryAsync(); if (list == null) return; foreach (var item in list) { OldBoxFoamTypeModel model = new OldBoxFoamTypeModel(); model.ObjId = item.ObjId; model.Local = item.Local; model.Boxtype = item.Boxtype; model.Storeamount = item.Storeamount; _oldBoxFoamTypeDataGrid.Add(model); } } public Task OldBoxFoamTypeOnLoad3(List list) { if (list == null) return Task.CompletedTask; System.Windows.Application.Current.Dispatcher.Invoke((Action)(() => { OldBoxFoamTypeDataGrid.Clear(); foreach (var item in list) { OldBoxFoamTypeModel model = new OldBoxFoamTypeModel(); model.ObjId = item.ObjId; model.Local = item.Local; model.Boxtype = item.Boxtype; model.Storeamount = item.Storeamount; OldBoxFoamTypeDataGrid.Add(model); } })); return Task.CompletedTask; } #endregion #region 初始化发泡线 datagrid private ObservableCollection _oldBoxFoamDataGrid = new ObservableCollection(); public ObservableCollection OldBoxFoamDataGrid { get => _oldBoxFoamDataGrid; set => SetProperty(ref _oldBoxFoamDataGrid, value); } #endregion #region 初始化泡前库 datagrid private ObservableCollection _oldBoxFoamTypeDataGrid = new ObservableCollection(); public ObservableCollection OldBoxFoamTypeDataGrid { get => _oldBoxFoamTypeDataGrid; set => SetProperty(ref _oldBoxFoamTypeDataGrid, value); } #endregion } }