wxr
2024-06-06 f54a487bb42ac49bf81bd7b5eea311fc79231bc6
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
using System;
using System.Collections.Generic;
using HDL_ON.Common;
using HDL_ON.DAL.Server;
using HDL_ON.Entity;
using HDL_ON.UI.CSS;
using Shared;
 
namespace HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock
{
    public class VideoDoorlockUserListPage : FrameLayout
    {
        FrameLayout bodyView;
        VerticalScrolViewLayout contentView;
 
        Function device;
 
        List<VideoDoorlockUser> userList;
 
        public VideoDoorlockUserListPage(Function function)
        {
            bodyView = this;
            device = function;
            userList = new List<VideoDoorlockUser>();
        }
 
        public void LoadPage()
        {
            new TopViewDiv(bodyView, Language.StringByID(StringId.UserManagement)).LoadTopView();
            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
 
 
 
            contentView = new VerticalScrolViewLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(607 - 70),
            };
            bodyView.AddChidren(contentView);
 
            var btnTip = new Button()
            {
                Y = Application.GetRealHeight(667 - 70),
                Gravity = Gravity.CenterHorizontal,
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(60),
                TextAlignment = TextAlignment.TopLeft,
                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
                TextColor = CSS_Color.TextualColor,
                TextID = StringId.VideoDoorlockManagerTip,
                IsMoreLines = true,
            };
            bodyView.AddChidren(btnTip);
 
            var waitPage = new Loading();
            bodyView.AddChidren(waitPage);
            waitPage.Start("");
 
            new System.Threading.Thread(() => {
                try
                {
                    var pack = ApiUtlis.Ins.HttpRequest.GetDoorlockUserList(device.deviceId);
                    if (pack != null)
                    {
                        if (pack.Code == StateCode.SUCCESS)
                        {
                            userList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<VideoDoorlockUser>>(pack.Data.ToString());
                            if (userList != null)
                            {
                                Application.RunOnMainThread(() => {
                                    initView();
                                });
                            }
                        }
                        else
                        {
                            Application.RunOnMainThread(() =>
                            {
                                IMessageCommon.Current.ShowErrorInfoAlter(pack.Code);
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    MainPage.Log($"获取门锁用户异常:{ex.Message}");
                }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        waitPage.Hide();
                    });
                }
            })
            { IsBackground = true }.Start();
 
 
        }
 
 
        void initView()
        {
            contentView.RemoveAll();
 
            foreach (var user in userList)
            {
                contentView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
 
                var row = new FrameLayout()
                {
                    Gravity = Gravity.CenterHorizontal,
                    Height = Application.GetRealHeight(50),
                    Radius = (uint)Application.GetRealWidth(12),
                    BackgroundColor = CSS_Color.MainBackgroundColor,
                    Width = Application.GetRealWidth(343),
                };
                contentView.AddChidren(row);
 
                var btnRight = new Button()
                {
                    X = Application.GetRealWidth(307),
                    Gravity = Gravity.CenterVertical,
                    Width = Application.GetMinRealAverage(16),
                    Height = Application.GetMinRealAverage(16),
                    UnSelectedImagePath = "Public/Right.png",
                };
                row.AddChidren(btnRight);
 
                var btnName = new Button()
                {
                    X = Application.GetRealWidth(12),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = CSS_Color.FirstLevelTitleColor,
                    TextSize = CSS_FontSize.TextFontSize,
                    Text = user.lockUserName
                };
                row.AddChidren(btnName);
 
                btnName.MouseUpEventHandler = (sender, e) => {
                    var page = new VideoDoorlockUserManagerPage(device, user);
                    page.delCallBackAction = () => {
                        userList.Remove(user);
                        initView();
                    };
                    page.updataUserNameAction = (name) => {
                        btnName.Text = name;
                        user.lockUserName = name;
                    };
                    MainPage.BasePageView.AddChidren(page);
                    page.LoadPage();
                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
                };
            }
 
 
        }
 
 
    }
 
    public class VideoDoorlockUser
    {
        /// <summary>
        ///  开始时间    integer(int32)
        /// </summary>
        public string beginTime;
        /// <summary>
        /// 感应卡密码数量 integer(int32)
        /// </summary>
        public int cardCount;
        /// <summary>
        /// 结束时间    integer(int32)
        /// </summary>
        public int endTime;
        /// <summary>
        ///  是否过期    integer(int32)
        /// </summary>
        public string expiredEnable;
        /// <summary>
        ///  门锁用户id  string
        /// </summary>
        public string extUserId;
        /// <summary>
        ///        string
        /// </summary>
        public string extUserName;
        /// <summary>
        ///  人脸密码数量 integer(int32)
        /// </summary>
        public int faceCount;
        /// <summary>
        ///  指纹密码数量  integer(int32)
        /// </summary>
        public int fingerCount;
        /// <summary>
        /// 用户备注名   string
        /// </summary>
        public string lockRemarkName;
        /// <summary>
        ///  锁用户类型// 0-主用户,1-普通用户    integer(int32)
        /// </summary>
        public int lockType;
        /// <summary>
        ///  门锁用户id string
        /// </summary>
        public string lockUserIndex;
        /// <summary>
        /// 用户名 string
        /// </summary>
        public string lockUserName;
        /// <summary>
        /// 数字密码数量 integer(int32)
        /// </summary>
        public int pwdCount;
    }
}