From a469a96ee8c38f7d98366dcd633e3a15f92fec65 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期一, 01 三月 2021 17:53:52 +0800 Subject: [PATCH] 2021-3-1-1 --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs | 155 +++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 117 insertions(+), 38 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..8d2b7d3 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirSend.cs @@ -32,63 +32,142 @@ } } /// <summary> - /// 閬ユ帶鍣ㄧ孩澶栫爜瀛︿範 + /// 閬ユ帶鍣ㄦ坊鍔� /// </summary> /// <returns></returns> - public static ResponsePackNew CodeStudy(ButtonObj buttonObj) + public static ResponsePackNew Add(Control control) { - var jArray = new JArray { }; - var job = new JObject { }; - job.Add("key", buttonObj.Key); - job.Add("value", buttonObj.value); - 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 { }; + 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> - /// <param name="listIdList">閫昏緫ID鍒楄〃</param> /// <returns></returns> - public static ResponsePackNew GetLogic(List<string> listIdList) + 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("data_type", "string"); + var valuejArray = new JArray { }; + valuejArray.Add(buttonObj.value); + job.Add("value", valuejArray); var jArray = new JArray { }; - for (int i = 0; i < listIdList.Count; i++) + jArray.Add(job); + var jObject = new JObject { { "homeId", HomeId }, { "deviceId", "0" }, { "attributes", jArray } }; + ResponsePackNew responsePackNew = null; + new System.Threading.Thread(() => { - jArray.Add(listIdList[i]); - } - var jObject = new JObject { { "userLogicIds", jArray } }; - var responsePackNew = RequestServerhomeId(jObject, NewAPI.API_POST_Logic_Info); - //濡傛灉鏄痶oken杩囨湡鍒欏埛鏂皌oken - if (responsePackNew.Code == StateCode.TOKEN_EXPIRED) - { - RefreshToken(); - GetLogic(listIdList); - } + + 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; } - - public static bool Error(ResponsePackNew responsePackNew) + /// <summary> + /// 鏌ヨ绾㈠璁惧绫诲瀷鍒楄〃/鍝佺墝鍒楄〃/鍝佺墝绾㈠鐮佸簱鍒楄〃 + /// </summary> + /// <param name="frameLayout">鍔犺浇log鐨勭埗鎺т欢</param> + /// <param name="action">鍥炶皟鍑芥暟</param> + public static void GetDeviceTypesList(FrameLayout frameLayout, Action<ResponsePackNew> action, string id, string if_str) { - if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + DAL.Server.ResponsePackNew responsePackNew = null; + Loading loading = new Loading(); + frameLayout.AddChidren(loading); + loading.Start(); + new System.Threading.Thread(() => { - 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; - } + try + { + string url = ""; + var jObject = new JObject { }; + if (if_str == "璁惧绫诲瀷鍒楄〃") + { + url = "/smart-footstone/app/ir/device-type/list"; + } + else if (if_str == "鍝佺墝鍒楄〃") + { + url = "/smart-footstone/app/ir/brand/list"; + jObject.Add("deviceTypeId", id); + } + else if (if_str == "鍝佺墝绾㈠鐮佸簱鍒楄〃") + { + url = "/smart-footstone/app/ir/code/list"; + jObject.Add("brandId", id); + } + responsePackNew = RequestServerhomeId(jObject, url); + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + action(responsePackNew); + }); + } + }) + { IsBackground = true }.Start(); + } + + /// <summary> ///璇锋眰鏈嶅姟鍣紙涓庝綇瀹呮湁鍏�:渚嬪锛沨omeId锛� /// </summary> -- Gitblit v1.8.0