From 9b44e30275621a48335fbea7b32b5065a2859c9c Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 16 三月 2021 16:54:33 +0800 Subject: [PATCH] Merge branch 'WJC' into temp-wxr --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs | 336 ++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 221 insertions(+), 115 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs index 840df69..e62c484 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs @@ -28,12 +28,12 @@ /// <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) + public void EditControlName(int tipText, List<string> list, string currName, Action<string, Dialog> action, Action actionCancel, bool tag = false) { new View.TipView().InputBox(tipText, currName, StringId.nameNull, StringId.NameAlreadyExists, list, (text, view ) => { - action(text,view); + action(text, view); }, () => { actionCancel(); }, tag); } /// <summary> @@ -84,7 +84,8 @@ if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") { string sid = responsePackNew.Data.ToString(); - mqttdate = MqttDate(sid); + controldata = ""; + mqttdate = MqttDate("閬ユ帶鍣�", sid); if (mqttdate != null) { control.sid = sid; @@ -180,18 +181,30 @@ var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str); if (pirJosn != null) { - if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) + +/* 椤圭洰鈥淗DL-ON_iOS鈥濈殑鏈悎骞剁殑鏇存敼 +鍦ㄦ涔嬪墠: + if (null == Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) +鍦ㄦ涔嬪悗: + if (null == list.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) +*/ + if (null == PirDevice.Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId)) { - Pir.pirDeviceList.Add(pirJosn); + +/* 椤圭洰鈥淗DL-ON_iOS鈥濈殑鏈悎骞剁殑鏇存敼 +鍦ㄦ涔嬪墠: + Pir.pirDeviceList.Add(pirJosn); +鍦ㄦ涔嬪悗: + list.pirDeviceList.Add(pirJosn); +*/ + PirDevice.Pir.pirDeviceList.Add(pirJosn); } } } } - //GetControlList(frame, action); - // GetControlList(); } } @@ -200,20 +213,22 @@ { Application.RunOnMainThread(() => { - loading.Hide(); - - // action(); try { if (Pir.pirDeviceList.Count != 0) { - GetControlList1(frame, action); - var list = Pir.pirDeviceList; + GetControlList(() => + { + loading.Hide(); + action(); + + }); } else { - //Method method = new Method(); - //method.ErrorShow(responsePackNew); + loading.Hide(); + Method method = new Method(); + method.ErrorShow(null,"璇诲彇绾㈠瀹濆垪琛ㄥけ璐�"); } } catch { } @@ -228,60 +243,10 @@ /// <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 GetControlList1(FrameLayout frame, Action action) + public static void GetControlList(Action action) { - //鍔犺浇log - Loading loading = new Loading(); - frame.AddChidren(loading); - HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null; - loading.Start(); + new System.Threading.Thread(() => { try @@ -291,52 +256,42 @@ var pirDevice = Pir.pirDeviceList[i]; try { - responsePackNew = PirSend.ControlList(pirDevice); + 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 { } - finally - { - Application.RunOnMainThread(() => - { - try - { - if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") - { - var jArray = Newtonsoft.Json.Linq.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 { } - - }); - } } } catch { } finally { + Application.RunOnMainThread(() => { - loading.Hide(); action(); }); } + }) { IsBackground = true }.Start(); @@ -379,38 +334,167 @@ }) { IsBackground = true }.Start(); } + /// <summary> - /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁 + /// 鍙戦�佸懡浠ょ嚎绋� /// </summary> - public static string mqttdata = ""; + /// <param name="control">鍙戦�佹暟鎹璞�</param> + /// <param name="action">鍥炶皟鍑芥暟</param> + /// <param name="str">鍒ゆ柇瀛楃</param> + /// <param name="frame">log鐖舵帶浠�</param> + public void ThreadSend(Control control, Action<ResponsePackNew> action, string str, FrameLayout frame) + { + + //鍔犺浇log + Loading loading = new Loading(); + frame.AddChidren(loading); + loading.Start(); + ResponsePackNew responsePackNew = null; + new System.Threading.Thread(() => + { + try + { + if (str == "鍒犻櫎") + { + responsePackNew = PirSend.DeleteDevice(control.deviceId); + } + else if (str == "淇敼鍚嶇О") + { + + responsePackNew = PirSend.DeviceRename(control.deviceId, control.name); + } + else if (str == "鍒犻櫎鎸夐敭") { + // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name); + } + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + action(responsePackNew); + } + else + { + Method method = new Method(); + method.ErrorShow(responsePackNew, ""); + } + + }); + } + + }) + { IsBackground = true }.Start(); + + + } + /// <summary> + /// 鍙戦�佸懡浠ょ嚎绋� + /// </summary> + /// <param name="control">鍙戦�佹暟鎹璞�</param> + /// <param name="action">鍥炶皟鍑芥暟</param> + /// <param name="str">鍒ゆ柇瀛楃</param> + /// <param name="dialog">log鐖舵帶浠�</param> + public void ThreadSend(Control control, Action<ResponsePackNew> action, string str,Dialog dialog) + { + //鍔犺浇log + Loading loading = new Loading(); + dialog.AddChidren(loading); + ResponsePackNew responsePackNew = null; + loading.Start(); + new System.Threading.Thread(() => + { + try + { + + + if (str == "鍒犻櫎") + { + responsePackNew = PirSend.DeleteDevice(control.deviceId); + } + else if (str == "淇敼鍚嶇О") + { + + responsePackNew = PirSend.DeviceRename(control.deviceId, control.name); + } + else if (str == "鍒犻櫎鎸夐敭") + { + // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name); + } + } + catch { } + finally + { + Application.RunOnMainThread(() => + { + loading.Hide(); + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + action(responsePackNew); + } + else + { + Method method = new Method(); + method.ErrorShow(responsePackNew, ""); + } + + }); + } + + }) + { IsBackground = true }.Start(); + + + } + /// <summary> + /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑閬ユ帶鍣ㄦ暟鎹� + /// </summary> + public static string controldata = ""; + /// <summary> + /// MQTT涓婚鎺ㄩ�佷笅鏉ユ寜閿殑鏁版嵁 + /// </summary> + public static string buttondata = ""; /// <summary> /// 鍒ゆ柇杩欎釜涓婚鏄惁鏄坊鍔犻仴鎺у櫒涓婚 /// </summary> + /// <param name="text">琛ㄧず涓嶅悓涓婚鏁版嵁</param> /// <param name="sid">鍞竴鏍囪瘑</param> /// <param name="timeValue">绛夊緟鏃堕棿鍊�</param> /// <returns></returns> - public Cloud MqttDate(string sid, int timeValue = 10) + public Cloud MqttDate(string text, string sid, int timeValue = 10) { Cloud cloud = null; var dateTime = DateTime.Now; while ((DateTime.Now - dateTime).TotalMilliseconds < timeValue * 1000) { - if (!string.IsNullOrEmpty(mqttdata)) + string str = ""; + if (text == "閬ユ帶鍣�") + { + str = controldata; + } + else if (text == "鎸夐敭") + { + str = buttondata; + } + + if (!string.IsNullOrEmpty(controldata)) { try { - var cloudjson = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(mqttdata); + var cloudjson = Newtonsoft.Json.JsonConvert.DeserializeObject<Cloud>(str); for (int i = 0; i < cloudjson.objects.Count; i++) { var objects = cloudjson.objects[i]; if (sid == objects.sid) { cloud = cloudjson; - mqttdata = ""; break; } } - if (cloud!=null) + if (cloud != null) { break; } @@ -425,41 +509,63 @@ /// 閿欒鐮佹彁绀� /// </summary> /// <param name="responsePackNew"></param> - /// <param name="str"></param> - public void ErrorShow(ResponsePackNew responsePackNew, string str = "") + /// <param name="text">鑷畾涔夐敊璇枃鏈�</param> + /// <param name="popValue">寮规绫诲瀷锛�1=闂儊寮规锛�</param> + public void ErrorShow(ResponsePackNew responsePackNew, string text, int popValue = 1) { - if (str == "鍒犻櫎閬ユ帶鍣�") + string str = ""; + if (text == "鍒犻櫎閬ユ帶鍣�") { - new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.delFail)); + str = Language.StringByID(StringId.delFail); + } + else if (text == "璇诲彇绾㈠瀹濆垪琛ㄥけ璐�") + { + str = "璇诲彇绾㈠瀹濆垪琛ㄥけ璐�"; //Language.StringByID(StringId.delFail); } else { - if (responsePackNew != null) { + switch (responsePackNew.Code) { case "14005": { - new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline)); + str = Language.StringByID(StringId.gatewayNotOnline); + } break; case "10807": { - //绾㈠瀹濅笅閬ユ帶鍣ㄨ秴杩囨渶澶�(10涓�)鏁伴噺闄愬埗 - new Intelligence.Automation.LogicView.TipPopView().FlashingBox("绾㈠瀹濅笅閬ユ帶鍣ㄨ秴杩囨渶澶�(10涓�)鏁伴噺闄愬埗"); + str = "绾㈠瀹濅笅閬ユ帶鍣ㄨ秴杩囨渶澶�(10涓�)鏁伴噺闄愬埗";// Language.StringByID(StringId.gatewayNotOnline); + + + } + break; + case "2": + { + str = "绯荤粺缁存姢涓瓇璇风◢鍚庡啀璇晘"; } break; default: { - new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail)); + str ="鑾峰彇鏁版嵁澶辫触" ;// Language.StringByID(StringId.saveFail); } break; } } - + } + switch (popValue) + { + case 1: + { + new Intelligence.Automation.LogicView.TipPopView().FlashingBox(str); + } + break; + case 2: { } break; + case 3: { } break; } } -- Gitblit v1.8.0