From ff472d6300cd86eb9c014d43cae51d79438718d7 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期四, 11 三月 2021 17:49:39 +0800 Subject: [PATCH] 2021-3-11-1 --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs | 291 +++++++++++++++++++++++++++++++++------------------------ 1 files changed, 169 insertions(+), 122 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs index 8fd747b..840df69 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs @@ -24,13 +24,13 @@ /// <summary> /// 淇敼鍚嶇О /// </summary> - /// <param name="tipText">鎻愮ず鏂囨湰</param> + /// <param name="tipText">鎻愮ず鏍囬鏂囨湰</param> /// <param name="list">褰撳墠瀛樺湪鍚嶇О鍒楄〃</param> /// <param name="currName">褰撳墠鍚嶇О</param> /// <param name="action">鍥炶皟鍑芥暟</param> public void EditControlName(int tipText ,List<string> list, string currName, Action<string, Dialog> action,Action actionCancel, bool tag=false) { - new View.TipView().InputBox(StringId.editName, currName, StringId.nameNull, StringId.NameAlreadyExists, list, (text, view + new View.TipView().InputBox(tipText, currName, StringId.nameNull, StringId.NameAlreadyExists, list, (text, view ) => { action(text,view); @@ -71,7 +71,7 @@ /// <param name="action">鍥炶皟鍑芥暟</param> public void ThreadAddControl(Control control, FrameLayout frame, Action<Control> action) { - DAL.Server.ResponsePackNew responsePackNew = null; + Cloud mqttdate = null; Loading loading = new Loading(); frame.AddChidren(loading); loading.Start(); @@ -80,10 +80,16 @@ try { //鍙戦�佹坊鍔犲懡浠� - responsePackNew = PirSend.Add(control); - - - + var responsePackNew = PirSend.Add(control); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + string sid = responsePackNew.Data.ToString(); + mqttdate = MqttDate(sid); + if (mqttdate != null) + { + control.sid = sid; + } + } } catch { } @@ -92,55 +98,47 @@ Application.RunOnMainThread(() => { loading.Hide(); - if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰�; + if (mqttdate != null) { - string sid = responsePackNew.Data.ToString(); - var mqttdate =MqttDate(sid); - ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔� - if (mqttdate != null) + //浼戠湢500姣锛屼负绛夊緟浜戠鍒涘缓deviceid锛� + System.Threading.Thread.Sleep(500); + //璇诲彇娣诲姞閬ユ帶鍣╠eviceID锛屾墠鐭ラ亾鏄惁娣诲姞鎴愬姛锛� + GetControl(frame, control, (device) => { - control.sid = sid; - //浼戠湢500姣锛屼负绛夊緟浜戠鍒涘缓deviceid锛� - System.Threading.Thread.Sleep(500); - GetControl(frame, control, (device) => + if (device != null) { - if (device != null) - { - control.deviceId = device.deviceId; - frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥 - - action(control); - } - else - { - //璇诲彇deviceid杩斿洖閿欒鎻愮ず - View.FailView failView = new View.FailView(); - failView.ShouError((view) => - { - view.Close(); - ThreadAddControl(control, frame, action); - }); - - } - }); - } - else - { - //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀� - View.FailView failView = new View.FailView(); - failView.ShouError((view) => + control.deviceId = device.deviceId; + frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥 + action(control); + } + else { - view.Close(); - ThreadAddControl(control, frame, action); - }); - } + //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀� + View.FailView failView = new View.FailView(); + failView.ShouError((view) => + { + view.Close(); + ThreadAddControl(control, frame, action); + }); + + } + + }); } else { - ErrorShow(responsePackNew); + //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀� + View.FailView failView = new View.FailView(); + failView.ShouError((view) => + { + view.Close(); + ThreadAddControl(control, frame, action); + }); } - }); + + }); } }) @@ -159,13 +157,43 @@ //鍔犺浇log Loading loading = new Loading(); frame.AddChidren(loading); - HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; loading.Start(); new System.Threading.Thread(() => { try { - responsePackNew = PirSend.GetDeviceList("ir.module"); + var responsePackNew = PirSend.GetDeviceList("ir.module"); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + var jobject = Newtonsoft.Json.Linq.JObject.Parse(responsePackNew.Data.ToString()); + string list = jobject["list"].ToString(); + + var jArray = Newtonsoft.Json.Linq.JArray.Parse(list); + for (int a = 0; a < jArray.Count; a++) + { + var jay = jArray[a]; + string spk = jay["spk"].ToString(); + if (spk == "ir.module") + { + //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄 + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); + var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str); + if (pirJosn != null) + { + if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) + { + + Pir.pirDeviceList.Add(pirJosn); + + } + } + } + + } + //GetControlList(frame, action); + // GetControlList(); + + } } catch { } finally @@ -173,42 +201,19 @@ Application.RunOnMainThread(() => { loading.Hide(); + + // action(); try { - if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + if (Pir.pirDeviceList.Count != 0) { - var jobject = Newtonsoft.Json.Linq.JObject.Parse(responsePackNew.Data.ToString()); - string list = jobject["list"].ToString(); - - var jArray = Newtonsoft.Json.Linq.JArray.Parse(list); - for (int a = 0; a < jArray.Count; a++) - { - var jay = jArray[a]; - string spk = jay["spk"].ToString(); - if (spk == "ir.module") - { - //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄 - var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); - var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str); - if (pirJosn != null) - { - if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) - { - - Pir.pirDeviceList.Add(pirJosn); - - } - } - } - - } - GetControlList(frame, action); - + GetControlList1(frame, action); + var list = Pir.pirDeviceList; } else { - Method method = new Method(); - method.ErrorShow(responsePackNew); + //Method method = new Method(); + //method.ErrorShow(responsePackNew); } } catch { } @@ -223,9 +228,54 @@ /// <summary> /// 鑾峰彇閬ユ帶鍣ㄥ垪琛� /// </summary> + public static void GetControlList() + { + + new System.Threading.Thread(() => + { + + for (int i = 0; i < Pir.pirDeviceList.Count; i++) + { + var pirDevice = Pir.pirDeviceList[i]; + try + { + var responsePackNew = PirSend.ControlList(pirDevice); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + var jArray = JArray.Parse(responsePackNew.Data.ToString()); + for (int a = 0; a < jArray.Count; a++) + { + var jay = jArray[a]; + //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄 + var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay); + var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str); + if (pirJosn != null) + { + if (null == pirDevice.FunctioList.Find((c) => c.sid == pirJosn.sid)) + { + pirDevice.FunctioList.Add(pirJosn); + } + } + + } + } + + } + catch { } + + } + + + }) + { IsBackground = true }.Start(); + + } + /// <summary> + /// 鑾峰彇閬ユ帶鍣ㄥ垪琛� + /// </summary> /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param> /// <param name="action">鍥炶皟鍑芥暟</param> - public static void GetControlList(FrameLayout frame, Action action) + public static void GetControlList1(FrameLayout frame, Action action) { //鍔犺浇log Loading loading = new Loading(); @@ -270,11 +320,7 @@ } } - else - { - //Method method = new Method(); - //method.ErrorShow(responsePackNew); - } + } catch { } @@ -307,43 +353,26 @@ //鍔犺浇log Loading loading = new Loading(); frame.AddChidren(loading); - HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; loading.Start(); new System.Threading.Thread(() => { try { // 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid) - responsePackNew = PirSend.GetinfoBySid(control); + var responsePackNew = PirSend.GetinfoBySid(control); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + //var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString()); + function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString()); + } } catch { } finally { Application.RunOnMainThread(() => { - try - { - if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") - { - var str = Newtonsoft.Json.JsonConvert.SerializeObject(responsePackNew.Data.ToString()); - function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(str); - } - else - { - Method method = new Method(); - method.ErrorShow(responsePackNew); - } - } - catch { } - finally - { - Application.RunOnMainThread(() => - { - loading.Hide(); - action(function); - }); - } - + loading.Hide(); + action(function); }); } @@ -377,10 +406,14 @@ if (sid == objects.sid) { cloud = cloudjson; + mqttdata = ""; break; } } - break; + if (cloud!=null) + { + break; + } } catch { } } @@ -393,23 +426,40 @@ /// </summary> /// <param name="responsePackNew"></param> /// <param name="str"></param> - public void ErrorShow(ResponsePackNew responsePackNew,string str="") + public void ErrorShow(ResponsePackNew responsePackNew, string str = "") { - if (str == "鍒犻櫎閬ユ帶鍣�") { + if (str == "鍒犻櫎閬ユ帶鍣�") + { new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.delFail)); } else { - if (responsePackNew != null && responsePackNew.Code == "14005") - { - new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); - } - else + if (responsePackNew != null) { - new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); + switch (responsePackNew.Code) + { + case "14005": + { + new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); + } + break; + case "10807": + { + //绾㈠瀹濅笅閬ユ帶鍣ㄨ秴杩囨渶澶�(10涓�)鏁伴噺闄愬埗 + new Intelligence.Automation.LogicView.TipPopView().FlashingBox("绾㈠瀹濅笅閬ユ帶鍣ㄨ秴杩囨渶澶�(10涓�)鏁伴噺闄愬埗"); + } + break; + default: + { + new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); + } + break; + + } } + } } @@ -417,9 +467,6 @@ [Serializable] public class Cloud { - /// <summary> - /// 璁惧id - /// </summary> public string id = ""; public List<Objects> objects = new List<Objects>(); public string time_stamp = string.Empty; -- Gitblit v1.8.0