using ivf_tl_CustomControls; using ivf_tl_Entity; using ivf_tl_Operate.Converts; using ivf_tl_Operate.CustomUserControls; using ivf_tl_Operate.ViewModel; using ivf_tl_Operate.Windows; using System; using System.Collections.Generic; using System.Linq; 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; using static log4net.Appender.RollingFileAppender; namespace ivf_tl_Operate.View { /// /// AlarmPageView.xaml 的交互逻辑 /// public partial class AlarmPageView : UserControl { private AlarmPageViewModel vm; private bool isHis = false; public AlarmPageView() { InitializeComponent(); Loaded += (s, e) => { vm = this.DataContext as AlarmPageViewModel; if (vm == null) return; vm.RightDate = DateTime.Now; vm.LeftDate = DateTime.Now.AddDays(-1); SelectAlarm(false); }; } private void CustomControlPagination_PageChangedEvent(int obj) { if (vm == null) return; var task = new Task(() => { this.Dispatcher.Invoke(() => { _container.Children.Clear(); AlarmHistoryResult alarmHistoryResult = null; if (isHis) { //alarmHistoryResult = AppData.Instance.HttpHelper.SearchAlarmHistoryApi(new SearchAlarmResponse { current = obj, selectType = 3, size = vm.PageSize, tlSn = AppData.Instance.TlSn }); alarmHistoryResult = AppData.Instance.HttpHelper.SearchAlarmHistoryApi(new SearchAlarmResponse { current = obj, selectType = 3, size = vm.PageSize, tlSn = AppData.Instance.TlSn, startTime = vm.LeftDate.ToString("yyyy-MM-dd HH:mm:ss"), endTime = vm.RightDate.ToString("yyyy-MM-dd HH:mm:ss") }); } else { alarmHistoryResult = AppData.Instance.HttpHelper.SearchAlarmHistoryApi(new SearchAlarmResponse { current = obj, selectType = 2, size = vm.PageSize, tlSn = AppData.Instance.TlSn}); } if (!alarmHistoryResult.IsSuccess) return; foreach (var item in alarmHistoryResult.records) { var alarmControl = new AlarmControl { Data = item }; //alarmControl.OnMute += (alarm) => //{ // new AlarmProvider().Mute(alarm); //}; _container.Children.Add(alarmControl); } }); }); task.Start(); } private void Return_Click(object sender, RoutedEventArgs e) { AppData.Instance.BackMainPage(); } private void Border_MouseUp_GetRightDate(object sender, MouseButtonEventArgs e) { GetDateWindow getDate = new GetDateWindow(AppData.Instance.MainWindow); getDate._dateControl.SetNYR(true); getDate.SetSelectTime(vm.RightDate); AppData.Instance.MainWindow.Mark(true); var result = getDate.ShowDialog(); AppData.Instance.MainWindow.Mark(false); if (result.Value == true) { vm.RightDate = Convert.ToDateTime(getDate.Date).AddDays(1).Date.AddSeconds(-1); if (bool.Parse(Button_His.Tag.ToString())) SelectAlarm(true); } } private void Border_MouseUp(object sender, MouseButtonEventArgs e) { GetDateWindow getDate = new GetDateWindow(AppData.Instance.MainWindow); getDate._dateControl.SetNYR(true); getDate.SetSelectTime(vm.LeftDate); AppData.Instance.MainWindow.Mark(true); var result = getDate.ShowDialog(); AppData.Instance.MainWindow.Mark(false); if (result.Value == true) { vm.LeftDate = Convert.ToDateTime(getDate.Date).Date; if (bool.Parse(Button_His.Tag.ToString())) SelectAlarm(true); } //if (result.Value == true) //{ // vm.LeftDate = getDate.Date; // SelectAlarm(bool.Parse(_his_ButtonImage.Tag.ToString())); // ShowAlarm(); //} } private void SelectAlarm(bool checkState) { if (vm == null) return; _container.Children.Clear(); vm.DataCount = -1; if (checkState) { //vm.DataCount = AppData.Instance.HttpHelper.SearchAlarmHistoryNumApi(new SearchAlarmResponse { current = 1, selectType = 3, size = vm.PageSize, tlSn = AppData.Instance.TlSn}).history; //vm.DataCount = AppData.Instance.HttpHelper.SearchAlarmHistoryNumApi(new SearchAlarmResponse { current = 1, selectType = 3, size = vm.PageSize, tlSn = AppData.Instance.TlSn, startTime = vm.LeftDate.ToString("yyyy-MM-dd HH:mm:ss"), endTime = vm.RightDate.ToString("yyyy-MM-dd HH:mm:ss") }).history; vm.DataCount = AppData.Instance.HttpHelper.SearchAlarmHistoryApi(new SearchAlarmResponse { current = 1, selectType = 3, size = vm.PageSize, tlSn = AppData.Instance.TlSn, startTime = vm.LeftDate.ToString("yyyy-MM-dd HH:mm:ss"), endTime = vm.RightDate.ToString("yyyy-MM-dd HH:mm:ss") }).total; } else { vm.DataCount = AppData.Instance.HttpHelper.SearchAlarmHistoryNumApi(new SearchAlarmResponse { current = 1, selectType = 2, size = vm.PageSize, tlSn = AppData.Instance.TlSn}).current; } } private void ButtonImage_Click(object sender, RoutedEventArgs e) { if (!(sender is ButtonLeftImage buttonImage)) return; bool isHis = bool.Parse(buttonImage.Tag.ToString()); if (!isHis) { //当前为实时记录 //buttonImage.Content = "实时记录"; buttonImage.Content = KeyToStringConvert.GetLanguageStringByKey("C0260"); buttonImage.IconSource = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/AlarmRealTimeIcon.png", UriKind.RelativeOrAbsolute)); isHis = true; } else { //当前为历史记录 //buttonImage.Content = "历史记录"; buttonImage.Content = KeyToStringConvert.GetLanguageStringByKey("C0156"); buttonImage.IconSource = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/AlarmHistroyIcon.png", UriKind.RelativeOrAbsolute)); isHis = false; } buttonImage.Tag = isHis; this.isHis = isHis; SelectAlarm(isHis); } } }