wxr
2021-12-08 b4f5f74d74a0a0996358d8348956601b30f17266
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
using System;
using System.Collections.Generic;
using HDL_ON.UI.UI2.Intelligence.Automation;
using Shared;
 
namespace HDL_ON.UI
{
    public class PushConfigPage : FrameLayout
    {
        FrameLayout bodyView;
 
        public PushConfigPage()
        {
            bodyView = this;
        }
        public void Show(Entity.SecurityAlarm alarm)
        {
      
            new TopViewDiv(bodyView, Language.StringByID(StringId.fasongtongzhi)).LoadTopView();
 
            this.BackgroundColor = CSS.CSS_Color.BackgroundColor;
 
            var viewLayout = new FrameLayout()
            {
                Y = Application.GetRealHeight(64),
                Height = Application.GetRealHeight(527),
            };
            bodyView.AddChidren(viewLayout);
 
            #region  通知内容
            UI2.Intelligence.Automation.LogicView.AddOutputInputTextView addInputTextView = new UI2.Intelligence.Automation.LogicView.AddOutputInputTextView();
            addInputTextView.btnIf.TextID = StringId.tongzhineirong;
            viewLayout.AddChidren(addInputTextView.FLayoutView(46, 12));
            ///输入推送文本
            EditTextView textBox = new EditTextView//EditText
            {
                Y = Application.GetRealHeight(42),
                X = Application.GetRealWidth(16),
                Width = Application.GetRealWidth(343),
                Height = Application.GetRealHeight(152),
                TextAlignment = TextAlignment.TopLeft,
                Radius = (uint)Application.GetRealHeight(12),
                Text = alarm.noticeConfig.noticeContent,
                TextSize = UI2.Intelligence.Automation.LogicView.TextSize.text14,
                TextColor = CSS.CSS_Color.textColor,
                //PlaceholderText = Language.StringByID(StringId.xianzhichangdu),//"(100字以内)",
                //PlaceholderTextColor = CSS.CSS_Color.textCancelColor,
                BackgroundColor = CSS.CSS_Color.textWhiteColor,
 
            };
            viewLayout.AddChidren(textBox);
            textBox.TextChangeEventHandler += (sender, e) =>
            {
                var leng = e.Length;
                if (leng > 100)
                {
                    textBox.Text = e.Substring(0, 100);
#if __Android__
                    textBox.SetSelectionEnd();
#endif
 
                }
 
            };
            #endregion
            #region  App推送
            UI2.Intelligence.Automation.LogicView.LogicTypeTitleView appPush = new UI2.Intelligence.Automation.LogicView.LogicTypeTitleView();
            appPush.frameLayout.Y = Application.GetRealHeight(206);
            appPush.frameLayout.Radius = (uint)Application.GetRealHeight(12);
            appPush.btnText.TextID = StringId.apptuisong;
            appPush.btnText.X = Application.GetRealWidth(12);
            viewLayout.AddChidren(appPush.FLayoutView(false));
            //定义一个局部账号列表用来记录选中数据;
            List<string> selectedAccountList = new List<string>();
            appPush.btnClick.MouseUpEventHandler += (sender, e) =>
            {
                var userList = new List<HDL_ON.Entity.ResidenceMemberInfo>();
                Loading loading = new Loading();
                this.AddChidren(loading);
                loading.Start();
                new System.Threading.Thread(() =>
                {
                    try
                    {
                        userList = Send.GetResidenceMemberAccount();
 
                    }
                    catch { }
                    finally
                    {
                        Application.RunOnMainThread(() =>
                        {
                            loading.Hide();
                            userList.Add(new Entity.ResidenceMemberInfo { childAccountId = UserInfo.Current.ID, childAccountPhone = UserInfo.Current.userMobileInfo, childAccountEmail = UserInfo.Current.userEmailInfo });
                            //住宅子账号列表
                            List<string> accountList = new List<string>();
                            //之前状态列表
                            List<string> stateList = new List<string>();
                            for (int i = 0; i < userList.Count; i++)
                            {
                                var user = userList[i];
                                accountList.Add(user.Account);
                            }
 
                            if (alarm.pushConfigs.Count > 0)
                            {
                                var list = alarm.pushConfigs[0].pushTarget;
                                for (int i = 0; i < userList.Count; i++)
                                {
 
                                    var user = userList[i];
                                    if (list.Contains(user.childAccountId))
                                    {
                                        stateList.Add(user.Account);
                                    }
 
                                }
 
 
                            }
 
                            PublicInterface view = new PublicInterface();
                            view.FrameOrVvList(this, accountList, stateList, StringId.zhanghaoxuanze
                               , (list) =>
                               {
                                   //清空旧数据列表
                                   selectedAccountList.Clear();
                                   for (int i = 0; i < userList.Count; i++)
                                   {
                                       var user = userList[i];
                                       if (list.Contains(user.Account))
                                       {
                                           selectedAccountList.Add(user.childAccountId);
                                       }
                                   }
 
                               });
                        });
                    }
                })
                { IsBackground = true }.Start();
            };
 
            #endregion
            #region  确认
            UI2.Intelligence.Automation.LogicView.SaveView saveView = new UI2.Intelligence.Automation.LogicView.SaveView();
            saveView.btnSave.TextID = StringId.queren;
            saveView.frameLayout.SetCornerWithSameRadius(Application.GetRealHeight(24), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight);
            this.AddChidren(saveView.FLayoutView());
 
 
            saveView.btnClick.MouseUpEventHandler += (e, sen) =>
            {
                alarm.noticeConfig.noticeContent = textBox.Text.Trim();
                if (selectedAccountList.Count > 0)
                {
                    alarm.pushConfigs.Clear();//清空旧数据列表
                    alarm.pushConfigs.Add(new Entity.SecurityPushConfig { pushMethod = "APP", pushTarget = selectedAccountList });
                }
                //账号列表为空默认推送当前账号
                if (alarm.pushConfigs.Count == 0)
                {
                    //初始化对象
                    Entity.SecurityPushConfig pushConfigs = new Entity.SecurityPushConfig();
                    pushConfigs.pushMethod = "APP";
                    //默认添加推送当前账号
                    pushConfigs.pushTarget.Add(UserInfo.Current.ID);
                    alarm.pushConfigs.Add(pushConfigs);
                }
                this.RemoveFromParent();
            };
            #endregion
 
        }
 
        /// <summary>
        /// 手机账号为先,手机账号为空,其次到邮箱账号
        /// </summary>
        private string Account
        {
            get
            {
                ///手机账号为先,手机账号为空,其次到邮箱账号;
                if (!string.IsNullOrEmpty(UserInfo.Current.userMobileInfo))
                {
                    //默认推送当前手机账号
                    return UserInfo.Current.userMobileInfo;
                }
                else
                {
                    //默认推送当前邮箱账号
                    return UserInfo.Current.userEmailInfo;
                }
            }
        }
    }
}