From b1a0bdaa13e1eced0da2c411ce6dd0cbf7327a9a Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 24 三月 2021 16:24:44 +0800
Subject: [PATCH] 2021-24-3-3
---
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs | 135 +++++++++++++++-----------------------------
1 files changed, 46 insertions(+), 89 deletions(-)
diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
index 0fbb506..9236d52 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
@@ -8,6 +8,7 @@
{
public class Method
{
+
/// <summary>
/// 绾㈠瀹濈▼搴忎富鍏ュ彛
/// </summary>
@@ -15,7 +16,6 @@
/// <param name="function"></param>
public void MainView(FrameLayout frame, Entity.Function function,Action action)
{
-
Pir pirDevice = new Pir();
if (function != null)
{//鏁版嵁杞崲
@@ -23,6 +23,7 @@
pirDevice.deviceId = function.deviceId;
pirDevice.sid = function.sid;
pirDevice.online = function.online;
+ pirDevice.versions = function.versions;
}
Pir.currPir = pirDevice;
GetControlList(frame, () =>
@@ -33,7 +34,8 @@
MainPage.BasePageView.AddChidren(page);
page.Show();
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
- page.BackAction += () => {
+ PirMain.BackAction += () =>
+ {
action?.Invoke();
};
});
@@ -272,7 +274,7 @@
var pirDevice = Pir.pirDeviceList[i];
try
{
- var responsePackNew = PirSend.ControlList(pirDevice);
+ var responsePackNew = PirSend.ControlList(pirDevice.deviceId);
if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
{
var jArray = JArray.Parse(responsePackNew.Data.ToString());
@@ -317,57 +319,27 @@
/// 鑾峰彇鍗曚釜绾㈠瀹濋仴鎺у櫒鍒楄〃
/// </summary>
/// <param name="action">鍥炶皟鍑芥暟</param>
- public static void GetControlList(FrameLayout frame ,Action action, Pir pirDevice)
+ public static void GetControlList(FrameLayout frame, Action action, Pir pirDevice)
{
- Loading loading = new Loading();
- frame.AddChidren(loading);
- loading.Start();
- new System.Threading.Thread(() =>
- {
- try
- {
-
- 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 { }
-
-
- }
- catch { }
- finally
- {
-
- Application.RunOnMainThread(() =>
- {
- loading.Hide();
- action();
- });
- }
-
- })
- { IsBackground = true }.Start();
+ ThreadSend(new Control { deviceId = pirDevice.deviceId }, (responsePackNew) =>
+ {
+ 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.deviceId == pirJosn.deviceId))
+ {
+ pirDevice.FunctioList.Add(pirJosn);
+ }
+ }
+ }
+ action();
+ }, "鑾峰彇閬ユ帶鍣ㄥ垪琛�", "frame", frame, null);
}
/// <summary>
@@ -378,37 +350,12 @@
/// <param name="action">鍥炶皟鍑芥暟</param>
public void GetControl(FrameLayout frame, Control control, Action<Entity.Function> action)
{
- Entity.Function function = null;
- //鍔犺浇log
- Loading loading = new Loading();
- frame.AddChidren(loading);
- loading.Start();
- new System.Threading.Thread(() =>
+ ThreadSend(control, (responsePackNew) =>
{
- try
- {
- // 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid)
- 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(() =>
- {
- loading.Hide();
- action(function);
- });
- }
-
- })
- { IsBackground = true }.Start();
+ var function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString());
+ action(function);
+ }, "鑾峰彇璁惧璇︽儏", "frame", frame, null);
}
-
/// <summary>
/// 鍙戦�佸懡浠ょ嚎绋�
/// </summary>
@@ -446,8 +393,18 @@
responsePackNew = PirSend.DeviceRename(control.deviceId, control.name);
}
- else if (str == "鍒犻櫎鎸夐敭") {
- // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name);
+ else if (str == "鍒犻櫎鎸夐敭")
+ {
+ // responsePackNew = PirSend.CodeRemove(control.deviceId, control.name);
+ }
+ else if (str == "鑾峰彇璁惧璇︽儏")
+ {
+ // 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid)
+ responsePackNew = PirSend.GetinfoBySid(control);
+ }
+ else if (str == "鑾峰彇閬ユ帶鍣ㄥ垪琛�")
+ {
+ responsePackNew = PirSend.ControlList(control.deviceId);
}
}
catch { }
@@ -505,7 +462,7 @@
str = buttondata;
}
- if (!string.IsNullOrEmpty(controldata))
+ if (!string.IsNullOrEmpty(str))
{
try
{
@@ -545,7 +502,7 @@
}
else if (text == "璇诲彇绾㈠瀹濆垪琛ㄥけ璐�")
{
- str = "璇诲彇绾㈠瀹濆垪琛ㄥけ璐�"; //Language.StringByID(StringId.delFail);
+ str = Language.StringByID(StringId.huoqushujushibao);
}
else
{
@@ -563,19 +520,19 @@
break;
case "10807":
{
- str = "绾㈠瀹濅笅閬ユ帶鍣ㄨ秴杩囨渶澶�(10涓�)鏁伴噺闄愬埗";// Language.StringByID(StringId.gatewayNotOnline);
+ str = Language.StringByID(StringId.bunengchaoguo10);
}
break;
case "2":
{
- str = "绯荤粺缁存姢涓瓇璇风◢鍚庡啀璇晘";
+ str = Language.StringByID(StringId.xitongweihuzhong);
}
break;
default:
{
- str ="鑾峰彇鏁版嵁澶辫触" ;// Language.StringByID(StringId.saveFail);
+ str = Language.StringByID(StringId.huoqushujushibao);
}
break;
--
Gitblit v1.8.0