wei
2021-08-27 eda3fb873e59544ff36301b51e05aef64f87b0f9
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs
@@ -12,8 +12,20 @@
    public class PirSend
    {
        public static string pirId = "1367032976869658625";
        /// <summary>
        /// 网关ID(获取嘉乐网关ID)
        /// </summary>
        public static string GatewayId
        {
            get
            {
                if (Entity.DB_ResidenceData.Instance.HomeGateway == null)
                {
                    return DriverLayer.Control.Ins.GatewayId;
                }
                return Entity.DB_ResidenceData.Instance.HomeGateway.gatewayId;
            }
        }
        /// <summary>
        /// 住宅ID
        /// </summary>
@@ -21,9 +33,16 @@
        {
            get
            {
                return Entity.DB_ResidenceData.Instance.CurrentRegion.RegionID;
                return Entity.DB_ResidenceData.Instance.CurrentRegion.id;
            }
        }
        /// <summary>
        /// 乐橙subAccessToken
        /// </summary>
        public static string LcSubAccessToken = "";
        /// <summary>
        /// 是否为其他主用户分享过来的住宅
        /// </summary>
@@ -31,7 +50,7 @@
        {
            get
            {
                return Entity.DB_ResidenceData.Instance.CurrentRegion.IsOthreShare;
                return Entity.DB_ResidenceData.Instance.CurrentRegion.isOtherShare;
            }
        }
        /// <summary>
@@ -67,9 +86,9 @@
        /// <summary>
        /// 获取遥控器列表
        /// </summary>
        public static ResponsePackNew ControlList(Pir pir)
        public static ResponsePackNew ControlList(string deviceId)
        {
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", pir.deviceId } };
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", deviceId} };
            var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_List);
            return responsePackNew;
        }
@@ -138,15 +157,8 @@
        /// 红外码学习
        /// </summary>
        /// <returns></returns>
        public static void CodeStudy(Control control,AttributesStatus buttonObj,Action<ResponsePackNew> action)
        public static void CodeStudy(Control control, AttributesStatus buttonObj, Action<Cloud> action)
        {
            //var whichDayJson = jay["whichDay"].ToString();
            //var whichDayAry = Newtonsoft.Json.Linq.JArray.Parse(whichDayJson);
            //for (int b = 0; b < whichDayAry.Count; b++)
            //{
            //    var days = whichDayAry[b].ToString();
            //    timer.whichDay.Add(int.Parse(days));
            //}
            var job = new JObject { };
            job.Add("key", buttonObj.key);
            job.Add("data_type", "string");
@@ -156,21 +168,32 @@
            var jArray = new JArray { };
            jArray.Add(job);
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", control.deviceId }, { "attributes", jArray } };
            ResponsePackNew responsePackNew = null;
            Cloud cloud = null;
            new System.Threading.Thread(() =>
            {
                try
                {
                    //发送红外码学习命令
                    responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeStudy);
                    var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeStudy);
                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
                    {
                        PirMethod method = new PirMethod();
                        PirMethod.buttondata = "";
                        cloud = method.MqttDate("按键", control.sid, 25);
                    }
                    else
                    {
                        PirMethod method = new PirMethod();
                        method.ErrorShow(responsePackNew, "");
                    }
                }
                catch { }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        action(responsePackNew);
                        action(cloud);
                    });
                }
@@ -181,7 +204,7 @@
        /// 自学按键删除
        /// </summary>
        /// <returns></returns>
        public static ResponsePackNew CodeRemove(AttributesStatus buttonObj)
        public static ResponsePackNew CodeRemove(AttributesStatus buttonObj,string deviceId)
        {
            var job = new JObject { };
            job.Add("key", buttonObj.key);
@@ -191,11 +214,10 @@
            job.Add("value", valuejArray);
            var jArray = new JArray { };
            jArray.Add(job);
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", pirId }, { "attributes", jArray } };
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", deviceId }, { "attributes", jArray } };
            var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeRemove);
            return responsePackNew;
        }
        /// <summary>
        /// 红外宝/遥控器删除
        /// </summary>
@@ -207,12 +229,12 @@
            return responsePackNew;
        }
        /// <summary>
        /// 修改红外宝名称
        /// 修改红外宝/设备名称
        /// </summary>
        /// <returns></returns>
        public static ResponsePackNew DeviceRename(Pir  pir)
        public static ResponsePackNew DeviceRename(string deviceId,string name)
        {
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", pir.deviceId }, { "name", pir.name } };
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", deviceId }, { "name", name} };
            var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_DeviceRename);
            return responsePackNew;
        }
@@ -248,7 +270,7 @@
                        url = "/smart-footstone/app/ir/code/list";
                        jObject.Add("brandId", id);
                    }
                    responsePackNew = RequestServerhomeId(jObject, url);
                    responsePackNew = RequestServerhomeId(jObject, url,5);
                }
                catch { }
                finally
@@ -263,7 +285,6 @@
            { IsBackground = true }.Start();
        }
        /// <summary>
        ///请求服务器(与住宅有关:例如;homeId) 
        /// </summary>