JLChen
2021-05-14 3bedb23993745f97e5870eca160c9f00c053c44c
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
using Shared;
using HDL_ON.UI.CSS;
using HDL_ON.Stan;
using System;
using System.Collections.Generic;
using System.Text;
using HDL_ON.Entity;
 
namespace HDL_ON.UI
{
    /// <summary>
    /// 门锁历史记录的界面(多门锁时,才能进来)
    /// </summary>
    public class DoorLockHistoryInfoPage : EditorCommonForm
    {
        #region ■ 变量声明___________________________
 
        /// <summary>
        /// 门锁设备列表
        /// </summary>
        private List<Function> listDevice = new List<Function>();
        /// <summary>
        /// 成员列表
        /// </summary>
        private List<ResidenceMemberInfo> listMember = null;
        /// <summary>
        /// 默认选择的用户
        /// </summary>
        private List<string> listSelectUser = new List<string> { "all" };
        /// <summary>
        /// 默认选择的开锁方式
        /// </summary>
        private List<string> listUnlock = new List<string> { "all" };
        /// <summary>
        /// 默认选择的信息类型
        /// </summary>
        private List<string> listMsgType = new List<string> { "all" };
 
        #endregion
 
        #region ■ 初始化_____________________________
 
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_listDevice">门锁设备列表</param>
        public void ShowForm(List<Function> i_listDevice)
        {
            this.listDevice.AddRange(i_listDevice);
 
            //历史记录
            base.SetTitleText(Language.StringByID(StringId.HistoryLog));
 
            //初始化头部筛选控件
            this.InitTopScreenControl();
 
            //初始化中部信息
            this.InitMiddleFrame();
        }
 
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空bodyFrame
            this.ClearBodyFrame();
        }
 
        #endregion
 
        #region ■ 初始化筛选控件_____________________
 
        /// <summary>
        /// 初始化头部筛选控件
        /// </summary>
        private void InitTopScreenControl()
        {
            //右上角的筛选控件
            var btnScreenContr = new PicViewControl(28, 28);
            btnScreenContr.X = Application.GetRealWidth(337);
            btnScreenContr.Y = Application.GetRealHeight(9);
            btnScreenContr.UnSelectedImagePath = "FunctionIcon/DoorLock/Screen.png";
            topFrameLayout.AddChidren(btnScreenContr);;
            btnScreenContr.ButtonClickEvent += (sender, e) =>
            {
                //初始化成员列表信息
                if (this.InitMemberListInfo() == false)
                {
                    return;
                }
 
                var form = new DoorLockHistoryTypeScreenPage(null, this.listMember);
                form.InitControl(null, this.listSelectUser, this.listUnlock, this.listMsgType);
                form.FinishEvent += (list1, list2, list3, list4) =>
                {
                    //更改缓存
                    this.listSelectUser.Clear();
                    this.listSelectUser.AddRange(list2);
 
                    this.listUnlock.Clear();
                    this.listUnlock.AddRange(list3);
 
                    this.listMsgType.Clear();
                    this.listMsgType.AddRange(list4);
                };
            };
        }
 
        #endregion
 
        #region ■ 初始化成员列表信息_________________
 
        /// <summary>
        /// 初始化成员列表信息
        /// </summary>
        /// <returns></returns>
        private bool InitMemberListInfo()
        {
            //已经初始化
            if (this.listMember != null) { return true; }
 
            //主账号需要去获取成员列表,而子账号只能他自己
            if (DB_ResidenceData.Instance.CurrentRegion.isOtherShare == false)
            {
                //获取成员列表
                var responePack = new DAL.Server.HttpServerRequest().GetResidenceMemberAccount();
                if (responePack.Code == DAL.Server.StateCode.SUCCESS)
                {
                    this.listMember = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ResidenceMemberInfo>>(responePack.Data.ToString());
                }
                //失败
                else
                {
                    //提示
                    DAL.Server.IMessageCommon.Current.ShowErrorInfoAlter(responePack.Code);
                    return false;
                }
            }
            else
            {
                //先初始化
                this.listMember = new List<ResidenceMemberInfo>();
            }
 
            //自身加进去,自己位于首位
            var info = new ResidenceMemberInfo();
            info.childAccountId = OnAppConfig.Instance.LastLoginUserId;
            info.childAccountType = DB_ResidenceData.Instance.CurrentRegion.isOtherShare == false ? "ADMIN" : "ORDINARY";
            info.nickName = UserInfo.Current.userName;
            this.listMember.Insert(0, info);
            if (string.IsNullOrEmpty(info.nickName))
            {
                info.nickName = UserInfo.Current.AccountString;
            }
 
            foreach (var info2 in this.listMember)
            {
                //设置用户昵称
                if (string.IsNullOrEmpty(info2.nickName))
                {
                    info2.nickName = info2.memberName;
                }
            }
 
            return true;
        }
        #endregion
 
        #region ■ 一般方法___________________________
 
        #endregion
    }
}