using Admin.Core.Common; using Admin.Core.IService; using Admin.Core.Model.ViewModels; using Admin.Core.Service; using Aucma.Core.BoxFoam.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.BoxFoam.ViewModels { public partial class FoamMachinesPageViewModel : ObservableObject { IBoxLastShotRecordServices _boxLastShotRecordServices; public FoamMachinesPageViewModel() { _boxLastShotRecordServices = App.ServiceProvider.GetService(); //Task.WaitAll(LoadData()); } #region 加载DataGrid数据 private async Task LoadData() { System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () => { LastShotRecordDataGrid.Clear(); int i = 1; var list = await _boxLastShotRecordServices.QueryAsync(); if (list == null) return; list.OrderByDescending(d => d.LastTime); foreach (var item in list.Take(50)) { string system = string.Empty; if (item.System == "1") { system = "1系统"; } if (item.System == "2") { system = "2系统"; } LastShotRecordDataGrid.Add(new LastShotRecordModel() { No = i, System = system, GunHead=item.GunHead, StationNumber=item.StationNumber, PolInjectionpressure = item.PolInjectionpressure, IsoInjectionpressure = item.IsoInjectionpressure, PolInjectiontemperature = item.PolInjectiontemperature, IsoInjectiontemperature = item.IsoInjectiontemperature, LastTime = item.LastTime, Createtime = item.Createtime }); i++; }; //Datalist.Insert(0, Datalist[Datalist.Count - 1]); //Datalist.RemoveAt(Datalist.Count - 1); })); } #endregion #region 初始化datagrid private ObservableCollection _lastShotRecordDataGrid = new ObservableCollection(); public ObservableCollection LastShotRecordDataGrid { get { return _lastShotRecordDataGrid; } set { _lastShotRecordDataGrid = value; OnPropertyChanged();//属性通知 } } #endregion #region 1系统属性 /// /// POL输入压力 /// private string _PolInputPressure = "0.00"; public string PolInputPressure1 { get => _PolInputPressure; set => SetProperty(ref _PolInputPressure, value); } /// /// ISO输入压力 /// private string _IsoInputPressure = "0.00"; public string IsoInputPressure1 { get => _IsoInputPressure; set => SetProperty(ref _IsoInputPressure, value); } /// /// POL输出压力 /// private string _polOutputPressure = "0.0"; public string PolOutputPressure1 { get => _polOutputPressure; set => SetProperty(ref _polOutputPressure, value); } /// /// ISO输出压力 /// private string _isoOutputPressure1 = "0.0"; public string IsoOutputPressure1 { get => _isoOutputPressure1; set => SetProperty(ref _isoOutputPressure1, value); } /// /// Pol流量 /// private string _Polflow1 = "0"; public string PolFlow1 { get => _Polflow1; set => SetProperty(ref _Polflow1, value); } /// /// Iso流量 /// private string _isoflow1 = "0"; public string IsoFlow1 { get => _isoflow1; set => SetProperty(ref _isoflow1, value); } /// /// Pol温度 /// private string _PoleTmperature = "0"; public string PoleTmperature1 { get => _PoleTmperature; set => SetProperty(ref _PoleTmperature, value); } /// /// Iso温度 /// private string _isoTemperature = "0"; public string IsoTemperature1 { get => _isoTemperature; set => SetProperty(ref _isoTemperature, value); } /// /// 料位 /// private string _PolMaterialLevel1 = "0"; public string PolMaterialLevel1 { get => _PolMaterialLevel1; set => SetProperty(ref _PolMaterialLevel1, value); } /// /// Iso温度 /// private string _IsoMaterialLevel1 = "0"; public string IsoMaterialLevel1 { get => _IsoMaterialLevel1; set => SetProperty(ref _IsoMaterialLevel1, value); } /// /// 压力 /// private string _pressure1 = "0.00"; public string Pressure1 { get => _pressure1; set => SetProperty(ref _pressure1, value); } /// /// 温度 /// private string _temperature1 = "0.00"; public string Temperature1 { get => _temperature1; set => SetProperty(ref _temperature1, value); } /// /// A枪状态 /// private string _status1; public string Status1 { get => _status1; set => SetProperty(ref _status1, value); } /// /// B枪状态 /// private string _status11; public string Status11 { get => _status11; set => SetProperty(ref _status11, value); } /// /// 压力 /// private string _POLPressure1 = "0.00"; public string POLPressure1 { get => _POLPressure1; set => SetProperty(ref _POLPressure1, value); } /// /// A枪POL温度 /// private string _POLTemperature1 = "0.00"; public string POLTemperature1 { get => _POLTemperature1; set => SetProperty(ref _POLTemperature1, value); } /// /// B枪POL温度 /// private string _POLTemperature11 = "0.0"; public string POLTemperature11 { get => _POLTemperature11; set => SetProperty(ref _POLTemperature11, value); } /// /// 压力 /// private string _ISOPressure1 = "0.00"; public string ISOPressure1 { get => _ISOPressure1; set => SetProperty(ref _ISOPressure1, value); } /// /// 压力 /// private string _ISOPressure11 = "0.00"; public string ISOPressure11 { get => _ISOPressure11; set => SetProperty(ref _ISOPressure11, value); } /// /// 温度 /// private string _ISOTemperature11 = "0.0"; public string ISOTemperature11 { get => _ISOTemperature11; set => SetProperty(ref _ISOTemperature11, value); } #endregion #region 2系统属性 /// /// POL输入压力 /// private string _PolInputPressure2 = "0.00"; public string PolInputPressure2 { get => _PolInputPressure2; set => SetProperty(ref _PolInputPressure2, value); } /// /// ISO输入压力 /// private string _IsoInputPressure2 = "0.00"; public string IsoInputPressure2 { get => _IsoInputPressure2; set => SetProperty(ref _IsoInputPressure2, value); } /// /// POL输出压力 /// private string _polOutputPressure2 = "0.00"; public string PolOutputPressure2 { get => _polOutputPressure2; set => SetProperty(ref _polOutputPressure2, value); } /// /// ISO输出压力 /// private string _isoOutputPressure2 = "0.00"; public string IsoOutputPressure2 { get => _isoOutputPressure2; set => SetProperty(ref _isoOutputPressure2, value); } /// /// Pol流量 /// private string _Polflow2 = "0"; public string PolFlow2 { get => _Polflow2; set => SetProperty(ref _Polflow2, value); } /// /// Iso流量 /// private string _isoflow2 = "0"; public string IsoFlow2 { get => _isoflow2; set => SetProperty(ref _isoflow2, value); } /// /// Pol温度 /// private string _PoleTmperature2 = "0"; public string PoleTmperature2 { get => _PoleTmperature2; set => SetProperty(ref _PoleTmperature2, value); } /// /// Iso温度 /// private string _isoTemperature2 = "0"; public string IsoTemperature2 { get => _isoTemperature2; set => SetProperty(ref _isoTemperature2, value); } /// /// 料位 /// private string _PolMaterialLevel2 = "0"; public string PolMaterialLevel2 { get => _PolMaterialLevel2; set => SetProperty(ref _PolMaterialLevel2, value); } /// /// Iso温度 /// private string _IsoMaterialLevel2 = "0"; public string IsoMaterialLevel2 { get => _IsoMaterialLevel2; set => SetProperty(ref _IsoMaterialLevel2, value); } /// /// 压力 /// private string _pressure2 = "0.00"; public string Pressure2 { get => _pressure2; set => SetProperty(ref _pressure2, value); } /// /// 温度 /// private string _temperature2 = "0.00"; public string Temperature2 { get => _temperature2; set => SetProperty(ref _temperature2, value); } /// /// A枪状态 /// private string _status2 = ""; public string Status2 { get => _status2; set => SetProperty(ref _status2, value); } /// /// B枪状态 /// private string _status12 = ""; public string Status12 { get => _status12; set => SetProperty(ref _status12, value); } /// /// 压力 /// private string _POLPressure2 = "0.00"; public string POLPressure2 { get => _POLPressure2; set => SetProperty(ref _POLPressure2, value); } /// /// 温度 /// private string _POLTemperature2 = "0.00"; public string POLTemperature2 { get => _POLTemperature2; set => SetProperty(ref _POLTemperature2, value); } /// /// A枪压力 /// private string _ISOPressure2 = "0.00"; public string ISOPressure2 { get => _ISOPressure2; set => SetProperty(ref _ISOPressure2, value); } /// ///A枪温度 /// private string _ISOTemperature22 = "0.0"; public string ISOTemperature22 { get => _ISOTemperature22; set => SetProperty(ref _ISOTemperature22, value); } /// /// B枪温度 /// private string _ISOTemperature222 = "0.0"; public string ISOTemperature222 { get => _ISOTemperature222; set => SetProperty(ref _ISOTemperature222, value); } /// /// B枪温度 /// private string _POLPressure22 = "0.0"; public string POLPressure22 { get => _POLPressure22; set => SetProperty(ref _POLPressure22, value); } /// /// B枪ISO温度 /// private string _POLTemperature22 = "0.0"; public string POLTemperature22 { get => _POLTemperature22; set => SetProperty(ref _POLTemperature22, value); } /// /// B枪ISO压力 /// private string _ISOPressure22 = "0.0"; public string ISOPressure22 { get => _ISOPressure22; set => SetProperty(ref _ISOPressure22, value); } #endregion } }