From d72ca686a3e262693f8a6e45e747e8e8da43335b Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期二, 06 七月 2021 09:39:03 +0800
Subject: [PATCH] 2021-07-06 1.更新

---
 HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs |  719 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 616 insertions(+), 103 deletions(-)

diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
index ce82452..064080f 100644
--- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
+++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs
@@ -8,46 +8,124 @@
 {
     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;
+                pirDevice.versions = function.versions;
+            }
+            Pir.currPir = pirDevice;
+            GetControlList(frame, () =>
+            {
+                Application.RunOnMainThread(() =>
+                {
+                    var page = new PirMain();
+                    MainPage.BasePageView.AddChidren(page);
+                    page.Show();
+                    MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                    PirMain.BackAction += () =>
+                    {
+                        action?.Invoke();
+                        PirMain.BackAction = null;
+                    };
+                });
+            }, Pir.currPir);
+        }
+
+        /// <summary>
+        /// 绠$悊浣嶇疆
+        /// </summary>
+        /// <param name="control">褰撳墠璁惧</param>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        public void ManagementPosition(Entity.Function control, Action action)
+        {
+            var view = new ChooseRoomPage(control, action);
+            MainPage.BasePageView.AddChidren(view);
+            view.LoadPage();
+            MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+        }
+        /// <summary>
+        /// 淇敼鍚嶇О
+        /// </summary>
+        /// <param name="tipText">鎻愮ず鏍囬鏂囨湰</param>
+        /// <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)
+        {
+            new View.TipView().InputBox(tipText, currName, StringId.nameNull, StringId.NameAlreadyExists, list, (text, view
+                ) =>
+            {
+                action(text, view);
+            }, () => { actionCancel(); }, tag);
+        }
         /// <summary>
         /// 娣诲姞閬ユ帶鍣ㄧ殑鏂规硶
         /// </summary>
-        public void AddControl()
+        /// <param name="frameLayout">log鍥炬爣鍔犺浇鐣岄潰</param>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        public void AddControl(FrameLayout frameLayout, Action<Control> action)
         {
             View.TipView tipView = new View.TipView();
-            tipView.InputBox("", (s, dialog) =>
-            {
-                ///娓呴櫎涔嬪墠鍒楄〃鏁版嵁
-                Pir.BuottonList.Clear();
-                if (!string.IsNullOrEmpty(s))
-                {
-                    Control control = new Control();
-                    control.name = s;
-                    control.type = "learn";
-
-                    ThreadAddControl(control, dialog);
-
-
-
-                }
-            }, false);
+            tipView.InputBox(frameLayout, "", (name, frame) =>
+             {
+                 if (Pir.currPir != null && Pir.currPir.FunctioList.Count < 10)
+                 {
+                     Control control = new Control();
+                     control.name = name;
+                     control.type = "learn";
+                     control.spk = "ir.learn";
+                     control.deviceId = Pir.currPir.deviceId;
+                     ThreadAddControl(control, frame, action);
+                 }
+                 else
+                 {
+                     View.TipView tt = new View.TipView();
+                     tt.TipBox(StringId.tip, StringId.bunengchaoguo10);
+                 }
+             }, false);
 
         }
         /// <summary>
         /// 鍙戦�侀仴鎺у櫒鍛戒护鏂规硶
         /// </summary>
-        /// <param name="control"></param>
-        /// <param name="dialog"></param>
-        public void ThreadAddControl(Control control, Dialog dialog) {
-
-            DAL.Server.ResponsePackNew responsePackNew = null;
+        /// <param name="control">鍙戦�佸弬鏁板璞�</param>
+        /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        public void ThreadAddControl(Control control, FrameLayout frame, Action<Control> action)
+        {
+            Cloud mqttdate = null;
             Loading loading = new Loading();
-            dialog.AddChidren(loading);
+            frame.AddChidren(loading);
             loading.Start();
             new System.Threading.Thread(() =>
             {
                 try
                 {
-                    responsePackNew = PirSend.Add(control);
+                    //鍙戦�佹坊鍔犲懡浠�
+                    var responsePackNew = PirSend.Add(control);
+                    if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+                    {
+                        string sid = responsePackNew.Data.ToString();
+                        controldata = "";
+                        mqttdate = MqttDate("閬ユ帶鍣�", sid);
+                        if (mqttdate != null)
+                        {
+                            control.sid = sid;
+                        }
+                    }
+
                 }
                 catch { }
                 finally
@@ -55,126 +133,561 @@
                     Application.RunOnMainThread(() =>
                     {
                         loading.Hide();
-                        //if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
-                        //{
-                        if (!string.IsNullOrEmpty(Sid("sid"))) { }
-                        ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔�
-                        dialog.Close();//娣诲姞鎴愬姛鍏抽棴寮圭獥
-                        AddButton addButton = new AddButton();
-                        MainPage.BasePageView.AddChidren(addButton);
-                        addButton.Show(control);
-                        MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
+                        ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰�;
+                        if (mqttdate != null)
+                        {
+                            //浼戠湢1000姣锛屼负绛夊緟浜戠鍒涘缓deviceid锛�
+                            System.Threading.Thread.Sleep(1000);
+                            //璇诲彇娣诲姞閬ユ帶鍣╠eviceID锛屾墠鐭ラ亾鏄惁娣诲姞鎴愬姛锛�
+                            GetControl(frame, control, (device) =>
+                            {
+                                if (device != null)
+                                {
 
-                        //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀�
-                        //View.FailView failView = new View.FailView();
-                        //failView.ShouError((view) => {
-                        //    view.Close();
-                        //    ThreadAddControl(control, dialog);
-                        //});
-                        //}
-                        //else
-                        //{
-                        //    ErrorShow(responsePackNew);
-                        //}
+                                    control.deviceId = device.deviceId;
+                                    //閬ユ帶鍣ㄦ坊鍔犲埌鍒楄〃锛�
+                                    if (null == Pir.currPir.FunctioList.Find((c) => c.deviceId == device.deviceId))
+                                    {
+                                        Pir.currPir.FunctioList.Add(device);
+                                    }
+                                    frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥
+                                    action(control);
+                                }
+                                else
+                                {
+                                    //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀�
+                                    View.FailView failView = new View.FailView();
+                                    failView.ShouError((view) =>
+                                    {
+                                        view.Close();
+                                        ThreadAddControl(control, frame, action);
+                                    });
+
+                                }
+
+                            });
+                        }
+                        else
+                        {
+                            //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀�
+                            View.FailView failView = new View.FailView();
+                            failView.ShouError((view) =>
+                            {
+                                view.Close();
+                                ThreadAddControl(control, frame, action);
+                            });
+                        }
+
+
                     });
+
                 }
             })
             { IsBackground = true }.Start();
 
         }
-
-        public  List<DD> GetLsit(FrameLayout frameLayout, Action<ResponsePackNew> action, string id, string if_str)
+        /// <summary>
+        /// 鑾峰彇绾㈠璁惧鍒楄〃
+        /// </summary>
+        /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        public static void GetPirDeviceList(FrameLayout frame, Action action)
         {
-            List<DD> list = new List<DD>();
-            ResponsePackNew responsePackNew = null;
-           PirSend.GetDeviceTypesList(frameLayout, action, id, if_str);
-
-            if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+            //娓呴櫎涔嬪墠鍒楄〃;
+            Pir.pirDeviceList.Clear();
+            //鍔犺浇log
+            Loading loading = new Loading();
+            frame.AddChidren(loading);
+            loading.Start();
+            new System.Threading.Thread(() =>
             {
-                var jArray = JArray.Parse(responsePackNew.Data.ToString());
-                for (int a = 0; a < jArray.Count; a++)
+                try
                 {
-                    var jay = jArray[a];
-                    var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
-                    list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<DD>>(str);
-                   
+                    var responsePackNew = PirSend.GetDeviceList("ir.module");
+                    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")
+                            {
+                                //鏁版嵁杩斿簭鍒楀寲涓篖ogic瀵硅薄
+                                var str = Newtonsoft.Json.JsonConvert.SerializeObject(jay);
+                                var pirJosn = Newtonsoft.Json.JsonConvert.DeserializeObject<Pir>(str);
+                                if (pirJosn != null)
+                                {
+
+                                    if (null == PirDevice.Pir.pirDeviceList.Find((c) => c.deviceId == pirJosn.deviceId))
+                                    {
+                                        PirDevice.Pir.pirDeviceList.Add(pirJosn);
+                                    }
+                                }
+                            }
+
+                        }
+
+                    }
                 }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        try
+                        {
+                            if (Pir.pirDeviceList.Count != 0)
+                            {
+                                GetControlList(() =>
+                                {
+                                    loading.Hide();
+                                    action();
+
+                                });
+                            }
+                            else
+                            {
+                                loading.Hide();
+                                Method method = new Method();
+                                method.ErrorShow(null, "璇诲彇绾㈠瀹濆垪琛ㄥけ璐�");
+                            }
+                        }
+                        catch { }
+
+                    });
+                }
+
+            })
+            { IsBackground = true }.Start();
+
+        }
+        /// <summary>
+        /// 鑾峰彇鎵�鏈夌孩澶栧疂閬ユ帶鍣ㄥ垪琛�
+        /// </summary>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        public static void GetControlList(Action action)
+        {
+
+            new System.Threading.Thread(() =>
+            {
+                try
+                {
+                    for (int i = 0; i < Pir.pirDeviceList.Count; i++)
+                    {
+                        var pirDevice = Pir.pirDeviceList[i];
+                        try
+                        {
+                            var responsePackNew = PirSend.ControlList(pirDevice.deviceId);
+                            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(() =>
+                    {
+                        action();
+                    });
+                }
+
+            })
+            { IsBackground = true }.Start();
+
+        }
+
+        /// <summary>
+        /// 鑾峰彇鍗曚釜绾㈠瀹濋仴鎺у櫒鍒楄〃
+        /// </summary>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        public static void GetControlList(FrameLayout frame, Action action, Pir pirDevice)
+        {
+            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>
+        /// 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid)
+        /// </summary>
+        /// <param name="frame">log鍥炬爣鍔犺浇鐣岄潰</param>
+        /// <param name="control">鍙戦�佸弬鏁板璞�</param>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        public void GetControl(FrameLayout frame, Control control, Action<Entity.Function> action)
+        {
+            ThreadSend(control, (responsePackNew) =>
+            {
+                var function = Newtonsoft.Json.JsonConvert.DeserializeObject<Entity.Function>(responsePackNew.Data.ToString());
+                action(function);
+            }, "鑾峰彇璁惧璇︽儏", "frame", frame, null);
+        }
+        /// <summary>
+        /// 鍙戦�佸懡浠ょ嚎绋�
+        /// </summary>
+        /// <param name="control">鍙戦�佹暟鎹璞�</param>
+        /// <param name="action">鍥炶皟鍑芥暟</param>
+        /// <param name="str">鍒ゆ柇瀛楃</param>
+        /// <param name="view">鍒ゆ柇log鐖舵帶浠�</param>
+        /// <param name="frame">log鐖舵帶浠�</param>
+        /// <param name="dialog">log鐖舵帶浠�</param>
+        /// <param name="attributesStatus">瀛︿範鎸夐敭</param>
+        public static void ThreadSend(Control control, Action<ResponsePackNew> action, string str, string view, FrameLayout frame, Dialog dialog, Entity.AttributesStatus attributesStatus=null)
+        {
+
+            //鍔犺浇log
+            Loading loading = new Loading();
+            if (view == "dialog")
+            {
+                dialog.AddChidren(loading);
             }
             else
             {
-                Method method = new Method();
-                method.ErrorShow(responsePackNew);
+                frame.AddChidren(loading);
             }
-            return list;
+            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 == "鍒犻櫎鎸夐敭")
+                    {
+                        if (attributesStatus != null)
+                        {
+                            responsePackNew = PirSend.CodeRemove(attributesStatus, control.deviceId);
+                        }
+                    }
+                    else if (str == "鑾峰彇璁惧璇︽儏")
+                    {
+                        // 鑾峰彇璁惧璇︽儏閫氳繃(spk,sid)
+                        responsePackNew = PirSend.GetinfoBySid(control);
+                    }
+                    else if (str == "鑾峰彇閬ユ帶鍣ㄥ垪琛�")
+                    {
+                        responsePackNew = PirSend.ControlList(control.deviceId);
+                    }
+                    else if (str == "搴撶爜娴嬭瘯")
+                    {
+                        responsePackNew = PirSend.CodeTest(control);
+                    }
+                }
+                catch { }
+                finally
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        loading.Hide();
+                        if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "")
+                        {
+                            action(responsePackNew);
+                        }
+                        else
+                        {
+                            Method method = new Method();
+                            //鑷畾涔夐敊璇彁绀烘枃鏈�
+                            string eorroText = "";
+                            if (str == "鍒犻櫎")
+                            {
+                            }
+                            else if (str == "淇敼鍚嶇О")
+                            {
+
+                            }
+                            else if (str == "鍒犻櫎鎸夐敭")
+                            {
+                            }
+                            else if (str == "鑾峰彇璁惧璇︽儏")
+                            {
+                            }
+                            else if (str == "鑾峰彇閬ユ帶鍣ㄥ垪琛�")
+                            {
+                            }
+                            else if (str == "搴撶爜娴嬭瘯")
+                            {
+                            }
+                            method.ErrorShow(responsePackNew, eorroText);
+                        }
+
+                    });
+                }
+
+            })
+            { IsBackground = true }.Start();
+
+
         }
         /// <summary>
-        /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁(閬ユ帶鍣ㄦ坊鍔�)
+        /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑閬ユ帶鍣ㄦ暟鎹�
         /// </summary>
-        public static string addcontronsid = "";
+        public static string controldata = "";
         /// <summary>
-        /// 
+        /// MQTT涓婚鎺ㄩ�佷笅鏉ユ寜閿殑鏁版嵁
         /// </summary>
-        /// <param name="sid"></param>
+        public static string buttondata = "";
+        /// <summary>
+        /// 鍒ゆ柇杩欎釜涓婚鏄惁鏄坊鍔犻仴鎺у櫒涓婚
+        /// </summary>
+        /// <param name="text">琛ㄧず涓嶅悓涓婚鏁版嵁</param>
+        /// <param name="sid">鍞竴鏍囪瘑</param>
+        /// <param name="timeValue">绛夊緟鏃堕棿鍊�</param>
         /// <returns></returns>
-        public string Sid(string sid)
+        public Cloud MqttDate(string text, string sid, int timeValue = 10)
         {
+            Cloud cloud = null;
             var dateTime = DateTime.Now;
-            while ((DateTime.Now - dateTime).TotalMilliseconds < 5* 1000)
+            while ((DateTime.Now - dateTime).TotalMilliseconds < timeValue * 1000)
             {
-                if (!string.IsNullOrEmpty(addcontronsid) && addcontronsid == sid)
+                string str = "";
+                if (text == "閬ユ帶鍣�")
                 {
-                    break;
+                    str = controldata;
+                }
+                else if (text == "鎸夐敭")
+                {
+                    str = buttondata;
+                }
+
+                if (!string.IsNullOrEmpty(str))
+                {
+                    try
+                    {
+                        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;
+                                break;
+                            }
+                        }
+                        if (cloud != null)
+                        {
+                            break;
+                        }
+                    }
+                    catch { }
                 }
 
             }
-            return addcontronsid;
+            return cloud;
         }
         /// <summary>
         /// 閿欒鐮佹彁绀�
         /// </summary>
         /// <param name="responsePackNew"></param>
-        public  void ErrorShow(ResponsePackNew responsePackNew)
+        /// <param name="text">鑷畾涔夐敊璇枃鏈�</param>
+        /// <param name="popValue">寮规绫诲瀷锛�1=闂儊寮规锛�</param>
+        public void ErrorShow(ResponsePackNew responsePackNew, string text, int popValue = 1)
         {
-
-            if (responsePackNew != null && responsePackNew.Code == "14005")
+            string str = "";
+            if (text == "鍒犻櫎閬ユ帶鍣�")
             {
-                new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.gatewayNotOnline));
-
+                str = Language.StringByID(StringId.delFail);
+            }
+            else if (text == "璇诲彇绾㈠瀹濆垪琛ㄥけ璐�")
+            {
+                str = Language.StringByID(StringId.huoqushujushibao);
+            }
+            else if (text == "娣诲姞澶辫触")
+            {
+                str = Language.StringByID(StringId.tianjiashibai);
             }
             else
             {
-                new Intelligence.Automation.LogicView.TipPopView().FlashingBox(Language.StringByID(StringId.saveFail));
+                if (responsePackNew != null)
+                {
+
+                    switch (responsePackNew.Code)
+                    {
+
+                        case "14005":
+                            {
+                                str = Language.StringByID(StringId.gatewayNotOnline);
+
+                            }
+                            break;
+                        case "10807":
+                            {
+                                str = Language.StringByID(StringId.bunengchaoguo10);
+
+
+                            }
+                            break;
+                        case "2":
+                            {
+                                str = Language.StringByID(StringId.xitongweihuzhong);
+                            }
+                            break;
+                        default:
+                            {
+                                str = Language.StringByID(StringId.huoqushujushibao);
+                            }
+                            break;
+
+                    }
+                }
+            }
+            switch (popValue)
+            {
+                case 1:
+                    {
+                        new Intelligence.Automation.LogicView.TipPopView().FlashingBox(str);
+                    }
+                    break;
+                case 2: { } break;
+                case 3: { } break;
+            }
+        }
+        /// <summary>
+        ///鎸囧畾鍒锋柊鐣岄潰
+        /// </summary>
+        /// <param name="strView">鍒ゆ柇瀛楃</param>
+        public static void RefreshView(string strView)
+        {
+            //鏍囪鏄笉鏄凡缁忓埛鏂板畬鎴�
+            bool if_bool = false;
+            for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--)
+            {
+                var view = MainPage.BasePageView.GetChildren(i);
+                if (strView == "PirMain")
+                {
+                    if (view.GetType() == typeof(PirMain))
+                    {
+                        //寮哄埗杞崲瀵硅薄
+                        var f = (PirMain)view;
+                        //绉婚櫎鎵�鏈夊瓙鎺т欢
+                        f.RemoveAll();
+                        //閲嶆柊鍔犺浇UI
+                        f.Show();
+                        //閫�鍑篺or寰幆
+                        //break;
+                        if_bool = true;
+                    }
+                }
+                if (if_bool)
+                {
+                    //閫�鍑篺or寰幆
+                    break;
+                }
+            }
+        }
+        /// <summary>
+        /// 鎸囧畾鍒犻櫎鐣岄潰
+        /// </summary>
+        /// <param name="strView">鍒ゆ柇瀛楃</param>
+        public static void RemoveView(string strView)
+        {
+
+            for (int i = MainPage.BasePageView.ChildrenCount - 1; 0 <= i; i--)
+            {
+                var view = MainPage.BasePageView.GetChildren(i);
+                if (strView == "PirMain")
+                {
+                    if (view.GetType() == typeof(PirMain))
+                    {
+                        //绉婚櫎鐣岄潰
+                        view.RemoveFromParent();
+                    }
+
+                }
+                else if (strView == "AddControl")
+                {
+
+                    if (view.GetType() == typeof(AddControl))
+                    {
+                        //鎵惧埌绉婚櫎
+                        view.RemoveFromParent();
+                    }
+                }
+                else if (strView == "AddControlComplete")
+                {
+
+                    if (view.GetType() == typeof(AddControlComplete))
+                    {
+                        //鎵惧埌绉婚櫎
+                        view.RemoveFromParent();
+                    }
+                }
 
             }
         }
-        [Serializable]
-        public class DD
-        {
-            /// <summary>
-            /// 璁惧绫诲瀷涓婚敭Id
-            /// </summary>
-            public string id=string.Empty;
-            /// <summary>
-            /// 璁惧绫诲瀷(鎶曞奖浠�,椋庢墖,鏈洪《鐩�...)
-            /// </summary>
-            public string deviceType = string.Empty;
-            /// <summary>
-            ///鍝佺墝鍚嶇О
-            /// </summary>
-            public string brandName = string.Empty;
-            /// <summary>
-            /// 绾㈠鐮�
-            /// </summary>
-            public string irCode = string.Empty;
-            /// <summary>
-            /// 鍝佺墝涓婚敭Id
-            /// </summary>
-            public string brandId = string.Empty;
-            /// <summary>
-            /// 绾㈠鐮佺储寮曞簭鍙�
-            /// </summary>
-            public string irIndex = string.Empty;
-        }
+
+    }
+    [Serializable]
+    public class Cloud
+    {
+        public string id = "";
+        public List<Objects> objects = new List<Objects>();
+        public string time_stamp = string.Empty;
+
+
+    }
+    [Serializable]
+    public class Objects
+    {
+
+        public string sid = string.Empty;
+        public string spk = string.Empty;
+        public List<Attributes> attributes = new List<Attributes>();
+    }
+    [Serializable]
+    public class Attributes
+    {
+        public string key = "";
+        public string data_type = "";
+        public List<string> value = new List<string>();
+
     }
 }

--
Gitblit v1.8.0