using MaterialTraceability.Entity.DAO; using MaterialTraceability.Entity.DTO; using MaterialTraceability.SqlSugar; using MaterialTraceability.SqlSugar.ServiceImpl; using MaterialTraceabilityUI.Common; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace MaterialTraceabilityUI { /// /// LogRecordControl.xaml 的交互逻辑 /// public partial class LogRecordControl : UserControl { private AppConfigDto appConfig = AppConfigDto.Instance; private IBaseServices logInfoServices = new BaseServices(); public LogRecordControl() { InitializeComponent(); } private void Seach_Click(object sender, RoutedEventArgs e) { Refresh(); } private void Refresh() { Expression> exp = s1 => true; if (this.beginTime.Text.ToString() != "") { DateTime beginTime = Convert.ToDateTime(this.beginTime.Text.ToString()); exp = exp.And(x => Convert.ToDateTime(x.recordTime) >= beginTime); } if (this.endTime.Text.ToString() != "") { DateTime endTime = Convert.ToDateTime(this.endTime.Text.ToString()); exp = exp.And(x => Convert.ToDateTime(x.recordTime) <= endTime); } if(Convert.ToString(this.logType.SelectedItem) != "") { exp = exp.And(x => x.alarmType == Convert.ToString(this.logType.SelectedItem)); } if (Convert.ToString(this.isAlarm.SelectedItem) != "") { int isAlarm = Convert.ToString(this.isAlarm.SelectedItem) == "是" ? 1 : 0; exp = exp.And(x => x.isAlarm == isAlarm); } if (appConfig.processId == "AB") { exp = exp.And(x => x.machineId == appConfig.machineId.ToString()); } List recordLogInfos = logInfoServices.Query(exp).Result; this.LogRecordDataGrid.ItemsSource = recordLogInfos; } private void UserControl_Loaded(object sender, RoutedEventArgs e) { this.beginTime.Text = DateTime.Now.ToLongDateString(); this.endTime.Text = DateTime.Now.AddDays(1).ToLongDateString(); List types = new List() { "MES", "PLC", "RFID", "" }; this.logType.ItemsSource = types; List isAlarm = new List() { "是", "否", "" }; this.isAlarm.ItemsSource = isAlarm; Refresh(); } } }