wei
2021-03-03 d4811b7d34b45ff6b21b97f11da128b5572ec526
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs
@@ -32,7 +32,32 @@
            }
        }
        /// <summary>
        /// 遥控器红外码学习
        /// 遥控器添加
        /// </summary>
        /// <returns></returns>
        public static ResponsePackNew Add(Control control)
        {
            var jObject = new JObject { };
            jObject.Add("homeId", HomeId);
            jObject.Add("deviceId", control.deviceId);
            jObject.Add("name", control.name);
            jObject.Add("spk", "ir.module");
            jObject.Add("type", control.type);
            if (control.type == "library")
            {
                //jObject.Add("group_id", "123");
                var libraryjay = new JArray { };
                for (int i = 0; i < control.library.Count; i++)
                {
                    libraryjay.Add(control.library[i]);
                }
                jObject.Add("library", libraryjay);
            }
            var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_Add);
            return responsePackNew;
        }
        /// <summary>
        /// 红外码学习
        /// </summary>
        /// <returns></returns>
        public static void CodeStudy(ButtonObj buttonObj, Action<ResponsePackNew> action)
@@ -44,11 +69,13 @@
            //    var days = whichDayAry[b].ToString();
            //    timer.whichDay.Add(int.Parse(days));
            //}
            var jArray = new JArray { };
            var job = new JObject { };
            job.Add("key", buttonObj.Key);
            job.Add("value", buttonObj.value);
            job.Add("data_type", "string");
            var valuejArray = new JArray { };
            valuejArray.Add(buttonObj.value);
            job.Add("value", valuejArray);
            var jArray = new JArray { };
            jArray.Add(job);
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", "0" }, { "attributes", jArray } };
            ResponsePackNew responsePackNew = null;
@@ -73,6 +100,24 @@
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 自学按键删除
        /// </summary>
        /// <returns></returns>
        public static ResponsePackNew CodeRemove(ButtonObj buttonObj)
        {
            var job = new JObject { };
            job.Add("key", buttonObj.Key);
            job.Add("data_type", "string");
            var valuejArray = new JArray { };
            valuejArray.Add(buttonObj.value);
            job.Add("value", valuejArray);
            var jArray = new JArray { };
            jArray.Add(job);
            var jObject = new JObject { { "homeId", HomeId }, { "deviceId", "0" }, { "attributes", jArray } };
            var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeRemove);
            return responsePackNew;
        }
        /// <summary>
        /// 获取逻辑
        /// </summary>
        /// <param name="listIdList">逻辑ID列表</param>
@@ -95,25 +140,7 @@
            return responsePackNew;
        }
        public static bool Error(ResponsePackNew responsePackNew)
        {
            if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
            {
                return true;
            }
            else if (responsePackNew != null && responsePackNew.Code == "14005")
            {
                // new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
                return false;
            }
            else
            {
                // new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
                return false;
            }
        }
        /// <summary>
        ///请求服务器(与住宅有关:例如;homeId)