ningshuxia
21 小时以前 71c12ff40d58c3dbdde6867396dd99224e57fc32
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
using Yw;
using Yw.Dto.Auth;
using Yw.WinFrmUI;
 
namespace HStation.WinFrmUI
{
    public partial class UserLoginLogPage : DocumentPage
    {
        public UserLoginLogPage()
        {
            InitializeComponent();
            this.listBoxControl1.DisplayMember = "Name";
            this.listBoxControl1.ValueMember = "ID";
            this.gridView1.SetNormalView(30);
            this.PageTitle.Caption = "登录日志";
            this.PageTitle.SvgImageSize = new Size(24, 24);
            this.dtStart.DateTime = DateTime.Now.Date.AddDays(-2);
            this.dtEnd.DateTime = DateTime.Now.Date;
        }
 
        private List<UserLoginViewModel> _allBindingList;
 
        public override async void InitialDataSource()
        {
            _allBindingList = new();
            var allList = await BLLFactory<Yw.BLL.User>.Instance.GetByCorpID(LoginUserInfo.CorpID);
            if (allList != null)
            {
                this.userLoginViewModelBindingSource.DataSource = _allBindingList;
                this.listBoxControl1.DataSource = allList;
            }
            this.userLoginViewModelBindingSource.ResetBindings(false);
        }
 
        private void listBoxControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            SetBindingData();
        }
 
        private void btnSearch_Click(object sender, EventArgs e)
        {
            SetBindingData();
        }
 
        private async void SetBindingData()
        {
            _allBindingList.Clear();
            var selectedId = (long)listBoxControl1.SelectedValue;
            if (selectedId <= 0)
                return;
            var user = new QueryPageListOfTimeRangeByUserIDInput()
            {
                UserID = selectedId,
                StartTime = new DateTime(dtStart.DateTime.Year, dtStart.DateTime.Month, dtStart.DateTime.Day, 0, 0, 0), // 设置为当天的 00:00:00
                EndTime = new DateTime(dtEnd.DateTime.Year, dtEnd.DateTime.Month, dtEnd.DateTime.Day, 23, 59, 59), // 设置为当天的 23:59:59
                PageIndex = 1,
                PageSize = 10000,
            };
            var allList = await BLLFactory<Yw.BLL.UserLoginLog>.Instance.GetStandardPageListByUserID(user);
            if (allList != null && allList.List != null)
            {
                foreach (var item in allList.List)
                {
                    _allBindingList.Add(new UserLoginViewModel(item));
                }
            }
            this.userLoginViewModelBindingSource.ResetBindings(false);
        }
    }
}