wxr
2023-04-07 0041a49139ebb21f228de022b38462b137c2d71e
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
using System;
using Shared;
using HDL_ON.Entity;
using HDL_ON.DAL.Server;
using HDL_ON.UI.CSS;
 
namespace HDL_ON.UI
{
    public class Iot_AuthorizedPage
    {
        HttpServerRequest http = new HttpServerRequest();
 
        IntegratedBrand_Iot brand_Iot;
 
        Action boudedAction;
 
        public Iot_AuthorizedPage(IntegratedBrand_Iot brand,Action action)
        {
            brand_Iot = brand;
            boudedAction = action;
        }
 
        
 
        public void LoadView()
        {
            string url = brand_Iot.authorizationUrl + $"?companyId={brand_Iot.companyId}&openUId={UserInfo.Current.ID}&client_id={brand_Iot.clientId}";
            var dd = new WebViewDialog(()=> {
                UnsubscribeAsync3tyIotbind();
            });
            dd.LoadPage("", url);
            DAL.Mqtt.MqttClient.Bind3tyIotAction = () => {
                UnsubscribeAsync3tyIotbind();
                Application.RunOnMainThread(() =>
                {
                    //http.Search3tyIotDevice(brand_Iot.companyId);
                    boudedAction?.Invoke();
                    dd.Close();
 
 
 
                    {
                        Dialog dialog = new Dialog()
                        {
                            BackgroundColor = CSS_Color.DialogTransparentColor1,
                        };
 
                        FrameLayout contentView = new FrameLayout()
                        {
                            Gravity = Gravity.Center,
                            Width = Application.GetRealWidth(305),
                            Height = Application.GetRealHeight(180),
                            BackgroundColor = CSS.CSS_Color.MainBackgroundColor,
                            BorderColor = 0x00000000,
                            BorderWidth = 0,
                            Radius = (uint)Application.GetMinRealAverage(10),
                        };
                        dialog.AddChidren(contentView);
 
                        Button btnTitle = new Button()
                        {
                            Gravity = Gravity.CenterHorizontal,
                            Y = Application.GetRealHeight(10),
                            Height = Application.GetRealHeight(38),
                            TextAlignment = TextAlignment.Center,
                            IsBold = true,
                            TextColor = 0xFF222222,
                            TextSize = CSS_FontSize.SubheadingFontSize,
                            TextID = StringId.Tip
                        };
                        contentView.AddChidren(btnTitle);
 
                        Button btnMsg = new Button()
                        {
                            Gravity = Gravity.CenterHorizontal,
                            Height = Application.GetRealHeight(70),
                            Y = Application.GetRealHeight(55),
                            TextAlignment = TextAlignment.TopCenter,
                            TextColor = CSS_Color.FirstLevelTitleColor,
                            TextSize = CSS_FontSize.SubheadingFontSize,
                            Padding = new Padding(0, Application.GetRealWidth(16), 0, Application.GetRealWidth(16)),
                            TextID = StringId.BindIotAccountTip,
                            IsMoreLines = true,
                        };
                        contentView.AddChidren(btnMsg);
 
                        Button btnLine = new Button()
                        {
                            Y = Application.GetRealHeight(125),
                            Height = Application.GetRealHeight(1),
                            BackgroundColor = CSS.CSS_Color.DividingLineColor,
                        };
                        contentView.AddChidren(btnLine);
 
                        Button btnConfirm = new Button()
                        {
                            Y = btnLine.Bottom,
                            Height = Application.GetRealHeight(55),
                            TextAlignment = TextAlignment.Center,
                            TextColor = CSS_Color.MainColor,
                            TextSize = CSS_FontSize.SubheadingFontSize,
                            SelectedTextColor = CSS_Color.MainBackgroundColor,
                            SelectedBackgroundColor = CSS_Color.MainColor,
                            TextID = StringId.Confirm,
                        };
                        btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomLeft);
                        btnConfirm.SetCornerWithSameRadius(Application.GetMinRealAverage(10), HDLUtils.RectCornerBottomRight);
                        contentView.AddChidren(btnConfirm);
 
                        dialog.Show();
 
                        btnConfirm.MouseDownEventHandler += (sender, e) =>
                        {
                            btnConfirm.IsSelected = true;
                        };
                        btnConfirm.MouseUpEventHandler += (sender, e) =>
                        {
                            dialog.Close();
                        };
 
                    }
 
 
 
                });
            };
            SubscribeAsync3tyIotbind();
        }
 
        /// <summary>
        /// 订阅绑定第三方iot账号结果
        /// </summary>
        private void SubscribeAsync3tyIotbind()
        {
            new System.Threading.Thread(async () =>
            {
                try
                {
                    var result = await DAL.Mqtt.MqttClient.SubscribeAsync3tyIotbind();
                }
                catch { }
                finally
                {
 
                }
            })
            { IsBackground = true }.Start();
        }
 
        /// <summary>
        /// 取消订阅绑定第三方iot账号结果
        /// </summary>
        private void UnsubscribeAsync3tyIotbind()
        {
            new System.Threading.Thread(async () =>
            {
                try
                {
                    var result = await DAL.Mqtt.MqttClient.UnsubscribeAsync3tyIotbind();
                }
                catch { }
                finally
                {
 
                }
            })
            { IsBackground = true }.Start();
        }
        ///// <summary>
        ///// 搜索第三方设备
        ///// </summary>
        //private void SearchDevice()
        //{
        //    var pack = http.Search3tyIotDevice(brand_Iot.companyId);
        //    if(pack!= null)
        //    {
        //    }
        //}
 
        /// <summary>
        /// 获取第三方功能列表
        /// </summary>
        private void GetFunction()
        {
            var pack = http.Get3tyIotDeviceFunctionList(brand_Iot.companyId);
            if(pack != null)
            {
 
            }
        }
 
    }
}