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();
}
///
/// 订阅绑定第三方iot账号结果
///
private void SubscribeAsync3tyIotbind()
{
new System.Threading.Thread(async () =>
{
try
{
var result = await DAL.Mqtt.MqttClient.SubscribeAsync3tyIotbind();
}
catch { }
finally
{
}
})
{ IsBackground = true }.Start();
}
///
/// 取消订阅绑定第三方iot账号结果
///
private void UnsubscribeAsync3tyIotbind()
{
new System.Threading.Thread(async () =>
{
try
{
var result = await DAL.Mqtt.MqttClient.UnsubscribeAsync3tyIotbind();
}
catch { }
finally
{
}
})
{ IsBackground = true }.Start();
}
///
/// 搜索第三方设备
///
private void SearchDevice()
{
var pack = http.Search3tyIotDevice(brand_Iot.companyId);
if(pack!= null)
{
}
}
///
/// 获取第三方功能列表
///
private void GetFunction()
{
var pack = http.Get3tyIotDeviceFunctionList(brand_Iot.companyId);
if(pack != null)
{
}
}
}
}