陈嘉乐
2021-03-12 94968f63b181eee088dab157881daf50ec5cb56a
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
@@ -228,7 +228,8 @@
        /// <summary>
        /// 获取遥控器列表
        /// </summary>
        public static void GetControlList(Action actio)
        /// <param name="action">回调函数</param>
        public static void GetControlList(Action action)
        {
            new System.Threading.Thread(() =>
@@ -272,81 +273,10 @@
                    Application.RunOnMainThread(() =>
                    {
                        actio();
                    });
                }
            })
            { IsBackground = true }.Start();
        }
        /// <summary>
        /// 获取遥控器列表
        /// </summary>
        /// <param name="frame">log图标加载界面</param>
        /// <param name="action">回调函数</param>
        public static void GetControlList1(FrameLayout frame, Action action)
        {
            //加载log
            Loading loading = new Loading();
            frame.AddChidren(loading);
            HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
            loading.Start();
            new System.Threading.Thread(() =>
            {
                try
                {
                    for (int i = 0; i < Pir.pirDeviceList.Count; i++)
                    {
                        var pirDevice = Pir.pirDeviceList[i];
                        try
                        {
                            responsePackNew = PirSend.ControlList(pirDevice);
                        }
                        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];
                                            //数据返序列化为Logic对象
                                            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();