duheng
2024-03-26 11c7908bcc2ca699e88b7a0a17bc32e45521c349
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
using DevExpress.XtraCharts;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.BandedGrid;
using IStation.Unit;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace IStation.WinFrmUI.Monitor
{
    public partial class DataListGridCtrl : XtraUserControl
    {
        public DataListGridCtrl()
        {
            InitializeComponent();
            this.gridView1.SetNormalView();
            this.gridView1.OptionsView.ShowDetailButtons = true;
            this.gridView1.OptionsDetail.ShowDetailTabs = false;
            this.gridView2.SetNormalView();
        }
 
 
        public class CurrentViewModel : Model.StationSignalRecord
        {
            public CurrentViewModel() { }
            public CurrentViewModel(Model.StationSignalRecord rhs) : base(rhs) { }
            public string Date { get; set; }
 
        }
 
 
        private List<CurrentViewModel> _allBindingList = null;
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData()
        {
            var list = new BLL.MonthSignalRecordPacket().Get();
            SetBindingData(list);
        }
 
 
        /// <summary>
        /// 绑定数据
        /// </summary>
        public void SetBindingData(List<Model.MonthSignalRecordPacket> list)
        {
            _allBindingList = new List<CurrentViewModel>();
            if (list != null && list.Any())
            {
                foreach (var packet in list)
                {
                    if (packet.StationSignalRecords == null || !packet.StationSignalRecords.Any())
                        continue;
                    foreach (var stationSignalRecords in packet.StationSignalRecords)
                    {
                        var vm = new CurrentViewModel(stationSignalRecords);
                        vm.Date = packet.Year + "-" + packet.Month;
                        _allBindingList.Add(vm);
                    }
                }
            }
 
            this.currentViewModelBindingSource.DataSource = _allBindingList;
        }
 
 
        /// <summary>
        /// 分析并保存
        /// </summary>
        public void AnalysisAndSave()
        {
            if (XtraMessageBox.Show("是否重新分析数据?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
                return;
            WaitFrmHelper.ShowWaitForm();
            var result = new BLL.MonthSignalRecordPacket_Analy().AnalysisAndSave();
            if (!result)
            {
                WaitFrmHelper.HideWaitForm();
                XtraMessageBox.Show("重新分析失败!");
                return;
            }
            SetBindingData();
            XtraMessageBox.Show("重新分析成功!");
            WaitFrmHelper.HideWaitForm();
 
        }
    }
 
}