From 25ce81434a6ce69cf10f12d4f5a25ab80a339ba7 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期三, 03 三月 2021 17:50:53 +0800 Subject: [PATCH] 2021-3-3-3 --- HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs | 88 ++++++++++++++++++++++++++++++-------------- 1 files changed, 60 insertions(+), 28 deletions(-) diff --git a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs index 0c7d14f..0790aa6 100644 --- a/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs +++ b/HDL_ON/UI/UI2/4-PersonalCenter/PirDevice/Method.cs @@ -1,6 +1,8 @@ 锘縰sing System; using HDL_ON.DAL.Server; using Shared; +using System.Collections.Generic; +using Newtonsoft.Json.Linq; namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice { @@ -9,37 +11,37 @@ /// <summary> /// 娣诲姞閬ユ帶鍣ㄧ殑鏂规硶 /// </summary> - public void AddControl() + public void AddControl(FrameLayout frameLayout,Action<Control> action) { View.TipView tipView = new View.TipView(); - tipView.InputBox("", (s, dialog) => + tipView.InputBox(frameLayout,"", (name, frame) => { ///娓呴櫎涔嬪墠鍒楄〃鏁版嵁 Pir.BuottonList.Clear(); - if (!string.IsNullOrEmpty(s)) + if (!string.IsNullOrEmpty(name)) { Control control = new Control(); - control.name = s; + control.name = name; control.type = "learn"; - ThreadAddControl(control,dialog); + ThreadAddControl(control, frame, action); } - },false); + }, false); } /// <summary> /// 鍙戦�侀仴鎺у櫒鍛戒护鏂规硶 /// </summary> /// <param name="control"></param> - /// <param name="dialog"></param> - public void ThreadAddControl(Control control, Dialog dialog) { + /// <param name="frame"></param> + public void ThreadAddControl(Control control, FrameLayout frame,Action<Control> action) { DAL.Server.ResponsePackNew responsePackNew = null; Loading loading = new Loading(); - dialog.AddChidren(loading); + frame.AddChidren(loading); loading.Start(); new System.Threading.Thread(() => { @@ -53,31 +55,59 @@ Application.RunOnMainThread(() => { loading.Hide(); - //if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") - //{ - ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔� - dialog.Close();//娣诲姞鎴愬姛鍏抽棴寮圭獥 - AddButton addButton = new AddButton(); - MainPage.BasePageView.AddChidren(addButton); - addButton.Show(control); - MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1; + if (responsePackNew != null && responsePackNew.Code == "0" && responsePackNew.Data.ToString() != "") + { + if (!string.IsNullOrEmpty(Sid("sid"))) + { + //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀� + View.FailView failView = new View.FailView(); + failView.ShouError((view) => + { + view.Close(); + ThreadAddControl(control, frame, action); + }); + } + else + { + ///杩欓噷锛氱洃鍚琈TTP鎺ㄩ�佷笅鏉ヤ富棰橈紝鎵嶇煡閬撴槸鍚︽坊鍔犳垚鍔� + frame.RemoveFromParent();//娣诲姞鎴愬姛鍏抽棴寮圭獥 + action(control); + } - //鐩戝惉Mqtt鎺ㄩ�佷笅鏉ョ姸鎬佺爜鍋氭彁绀� - //View.FailView failView = new View.FailView(); - //failView.ShouError((view) => { - // view.Close(); - // ThreadAddControl(control, dialog); - //}); - //} - //else - //{ - // ErrorShow(responsePackNew); - //} + + } + else + { + ErrorShow(responsePackNew); + } }); } }) { IsBackground = true }.Start(); + } + + /// <summary> + /// MQTT涓婚鎺ㄩ�佷笅鏉ョ殑鏁版嵁(閬ユ帶鍣ㄦ坊鍔�) + /// </summary> + public static string addcontronsid = ""; + /// <summary> + /// + /// </summary> + /// <param name="sid"></param> + /// <returns></returns> + public string Sid(string sid) + { + var dateTime = DateTime.Now; + while ((DateTime.Now - dateTime).TotalMilliseconds < 5* 1000) + { + if (!string.IsNullOrEmpty(addcontronsid) && addcontronsid == sid) + { + break; + } + + } + return addcontronsid; } /// <summary> /// 閿欒鐮佹彁绀� @@ -97,5 +127,7 @@ } } + } + } -- Gitblit v1.8.0