From d4811b7d34b45ff6b21b97f11da128b5572ec526 Mon Sep 17 00:00:00 2001 From: wei <kaede@kaededeMacBook-Air.local> Date: 星期三, 03 三月 2021 16:03:03 +0800 Subject: [PATCH] 20210303-1 --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs | 103 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 78 insertions(+), 25 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs index 17262bf..abb0874 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs @@ -32,18 +32,89 @@ } } /// <summary> - /// 閬ユ帶鍣ㄧ孩澶栫爜瀛︿範 + /// 閬ユ帶鍣ㄦ坊鍔� /// </summary> /// <returns></returns> - public static ResponsePackNew CodeStudy(ButtonObj buttonObj) + public static ResponsePackNew Add(Control control) { - var jArray = new JArray { }; + 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) + { + //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("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" }, { "status", jArray } }; - var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeStudy); + var jObject = new JObject { { "homeId", HomeId }, { "deviceId", "0" }, { "attributes", jArray } }; + ResponsePackNew responsePackNew = null; + new System.Threading.Thread(() => + { + + try + { + //鍙戦�佺孩澶栫爜瀛︿範鍛戒护 + responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Ir_CodeStudy); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + action(responsePackNew); + }); + } + + }) + { 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> @@ -69,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> ///璇锋眰鏈嶅姟鍣紙涓庝綇瀹呮湁鍏�:渚嬪锛沨omeId锛� -- Gitblit v1.8.0