From ba9e028d73bab5b7a0f000d11b39460d2b57707a Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期五, 19 三月 2021 18:07:10 +0800
Subject: [PATCH] 2021-3-19-2

---
 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs |  163 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 101 insertions(+), 62 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
index e62c484..19bca3c 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
@@ -8,6 +8,36 @@
 {
     public class Method
     {
+        /// <summary>
+        /// 绋嬪簭涓诲叆鍙�
+        /// </summary>
+        /// <param name="frame"></param>
+        /// <param name="function"></param>
+        public void MainView(FrameLayout frame, Entity.Function function,Action action)
+        {
+            Pir pirDevice = new Pir();
+            if (function != null)
+            {//鏁版嵁杞崲
+                pirDevice.name = function.name;
+                pirDevice.deviceId = function.deviceId;
+                pirDevice.sid = function.sid;
+                pirDevice.online = function.online;
+            }
+            Pir.currPir = pirDevice;
+            GetControlList(frame, () =>
+            {
+                Application.RunOnMainThread(() =>
+                {
+                    var page = new PirMain();
+                    MainPage.BasePageView.AddChidren(page);
+                    page.Show();
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                    page.BackAction += () => {
+                        action?.Invoke();
+                    };
+                });
+            }, Pir.currPir);
+        }
 
         /// <summary>
         /// 绠$悊浣嶇疆
@@ -241,7 +271,7 @@
 
         }
         /// <summary>
-        /// 鑾峰彇閬ユ帶鍣ㄥ垪琛�
+        /// 鑾峰彇鎵�鏈夌孩澶栧疂閬ユ帶鍣ㄥ垪琛�
         /// </summary>
         /// <param name="action">鍥炶皟鍑芥暟</param>
         public static void GetControlList(Action action)
@@ -296,6 +326,64 @@
             { IsBackground = true }.Start();
 
         }
+
+        /// <summary>
+        /// 鑾峰彇鍗曚釜绾㈠瀹濋仴鎺у櫒鍒楄〃
+        /// </summary>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        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();
+
+        }
         /// <summary>
         /// 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid)
         /// </summary>
@@ -334,20 +422,29 @@
             })
             { IsBackground = true }.Start();
         }
-   
+
         /// <summary>
         /// 鍙戦�佸懡浠ょ嚎绋�
         /// </summary>
         /// <param name="control">鍙戦�佹暟鎹璞�</param>
         /// <param name="action">鍥炶皟鍑芥暟</param>
         /// <param name="str">鍒ゆ柇瀛楃</param>
+        /// <param name="view">鍒ゆ柇log鐖舵帶浠�</param>
         /// <param name="frame">log鐖舵帶浠�</param>
-        public void ThreadSend(Control control, Action<ResponsePackNew> action, string str, FrameLayout frame)
+        /// <param name="dialog">log鐖舵帶浠�</param>
+        public static void ThreadSend(Control control, Action<ResponsePackNew> action, string str,string view, FrameLayout frame, Dialog dialog)
         {
            
             //鍔犺浇log
             Loading loading = new Loading();
-            frame.AddChidren(loading);
+            if (view == "dialog")
+            {
+                dialog.AddChidren(loading);
+            }
+            else
+            {
+                frame.AddChidren(loading);
+            }
             loading.Start();
             ResponsePackNew responsePackNew = null;
             new System.Threading.Thread(() =>
@@ -364,64 +461,6 @@
                         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);
                     }
                 }

--
Gitblit v1.8.0