陈嘉乐
2021-03-05 b1ced15165c0c120483f821079fc23c63d455e8e
HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/PirMain.cs
@@ -10,7 +10,7 @@
        public PirMain()
        {
            Tag = "PirMain";
            GetPirDeviceList();
        }
        /// <summary>
        /// 临时储存设备类型列表
@@ -179,7 +179,8 @@
                Text = "mini智能遥控器",
            };
            deviceListFLayout.AddChidren(deviceNameBtn);
            if (Pir.pirDeviceList.Count!=0) {
            if (Pir.pirDeviceList.Count != 0)
            {
                deviceNameBtn.Text = Pir.pirDeviceList[0].name;
                Pir.currPir = Pir.pirDeviceList[0];
            }
@@ -330,7 +331,8 @@
                    if (if_value == 7)
                    {
                        Method method = new Method();
                        method.AddControl(this,(control) => {
                        method.AddControl(this, (control) =>
                        {
                            AddButton addButton = new AddButton();
                            MainPage.BasePageView.AddChidren(addButton);
                            addButton.Show(control);
@@ -359,7 +361,8 @@
                                }
                            }
                            Application.RunOnMainThread(()=> {
                            Application.RunOnMainThread(() =>
                            {
                                BrandList brandObj = new BrandList();
                                MainPage.BasePageView.AddChidren(brandObj);
                                brandObj.Show(brandList, strList, strings[1]);
@@ -573,7 +576,6 @@
                }
            }, "", "设备类型列表");
        }
        /// <summary>
        /// 读取红外设备类型的品牌列表
        /// </summary>
@@ -610,74 +612,6 @@
                }
            }, id, "品牌列表");
        }
        /// <summary>
        /// 获取红外设备列表
        /// </summary>
        private void GetPirDeviceList( )
        {
            //加载log
            Loading loading = new Loading();
            this.AddChidren(loading);
            HDL_ON.DAL.Server.ResponsePackNew responsePackNew = null;
            loading.Start();
            new System.Threading.Thread(() =>
            {
                try
                {
                    responsePackNew = PirSend.GetDeviceList("ir.module");
                }
                catch { }
                finally
                {
                    Application.RunOnMainThread(() =>
                    {
                        loading.Hide();
                        try {
                        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")
                                {
                                    //数据返序列化为Logic对象
                                    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);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            Method method = new Method();
                            method.ErrorShow(responsePackNew);
                        }
                        }
                        catch { }
                    });
                }
            })
            { IsBackground = true }.Start();
        }
    }
  
}