wxr
2022-08-02 66c72ee19b9e3543537621b8dd25685c9b5c03c4
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
using System;
using Shared;
using HDL_ON.Entity;
using HDL_ON.DAL.Server;
 
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();
                });
            };
            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)
            {
 
            }
        }
 
    }
}