using System;
|
using System.Collections.Generic;
|
using HDL_ON.DAL.Server;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock;
|
using Shared;
|
using static HDL_ON.UI.UI2.FuntionControlView.VideoDoorLock.CommonMethod;
|
|
namespace HDL_ON.UI.UI2.FuntionControlView.HisenseTV
|
{
|
public class Send
|
{
|
private static Send sendMethod = null;
|
/// <summary>
|
/// 获取对象
|
/// </summary>
|
public static Send Current
|
{
|
get
|
{
|
if (sendMethod == null)
|
{
|
sendMethod = new Send();
|
}
|
|
return sendMethod;
|
|
}
|
|
}
|
|
/// <summary>
|
///删除设备
|
/// </summary>
|
/// <param name="deviceId">设备id</param>
|
/// <param name="action">成功返回true</param>
|
/// <param name="tipType">是否需要提示,默认提示</param>
|
public bool DelDevice(string deviceId,Action<bool>action, TipType tipType = TipType.flicker)
|
{
|
Dictionary<string, object> d = new Dictionary<string, object>();
|
d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.id);
|
d.Add("deviceId", deviceId);//设备id
|
var responsePackNew = UI.Music.SendMethod.Current.RequestServerhomeId(d, NewAPI.Api_Post_Aks_KeypadExecute, "删除海信电视");
|
if (!this.DataChecking(responsePackNew, tipType))
|
{
|
return false;
|
}
|
return true;
|
}
|
|
|
/// <summary>
|
///请求服务器(与住宅有关:例如;homeId)
|
/// </summary>
|
/// <param name="o">发送数据</param>
|
/// <param name="api_Url">请求地址(不是绝对地址)</param>
|
/// <param name="tag">标记->描述接口(自定义)</param>
|
/// <returns></returns>
|
public ResponsePackNew RequestServerhomeId(object o, string api_Url, string tag, int mTimeout = 3)
|
{
|
Log($"{DateTime.Now}->发送->{tag}", api_Url, o.ToString());
|
var requestJson = HttpUtil.GetSignRequestJson(o);
|
var r = HttpUtil.RequestHttpsPostFroHome(api_Url, requestJson, mTimeout);
|
Log($"{DateTime.Now}->回复->{tag}", "", Newtonsoft.Json.JsonConvert.SerializeObject(r));
|
return r;
|
|
}
|
|
|
/// <summary>
|
/// <summary>
|
/// 检验数据回复成功或者失败
|
/// </summary>
|
/// <param name="responsePackNew">回复数据对象</param>
|
/// <param name="tipType">是否需要提示</param>
|
/// <returns></returns>
|
private bool DataChecking(ResponsePackNew responsePackNew, TipType tipType)
|
{
|
if (responsePackNew.Data == null || responsePackNew.Code != "0" || responsePackNew.Data.ToString() == "")
|
{
|
if (TipType.flicker == tipType)
|
{
|
if (responsePackNew == null)
|
{
|
responsePackNew = new ResponsePackNew { message = "没回复,请确认网络是否正常.", Code = "-1", };
|
}
|
Application.RunOnMainThread(() =>
|
{
|
//new Tip()
|
//{
|
// CloseTime = 1,
|
// Text = responsePackNew.message + "(" + responsePackNew.Code + ")",
|
// Direction = AMPopTipDirection.None,
|
//}.Show(MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1));
|
CommonMethod.Current.ShowTip(responsePackNew.message + "(" + responsePackNew.Code + ")", 3);
|
});
|
}
|
return false;
|
}
|
return true;
|
}
|
/// <summary>
|
/// 打印日志
|
/// </summary>
|
/// <param name="tag">打印标记</param>
|
/// <param name="content">打印内容</param>
|
public void Log(string tag, string url, string content)
|
{
|
#if DEBUG
|
Console.WriteLine(tag + $"\r\n{url}\r\n{content}");
|
#endif
|
}
|
}
|
}
|