From e90209beae6a4e822cecb18e6889f8bda23f630e Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 14 十二月 2020 11:16:06 +0800
Subject: [PATCH] 合并了晾衣架(非新云端)

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs |   98 ++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 80 insertions(+), 18 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Common/Logic/HdlWifiLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs
similarity index 82%
rename from ZigbeeApp/Shared/Phone/Common/Logic/HdlWifiLogic.cs
rename to ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs
index a69667b..6aee9ce 100644
--- a/ZigbeeApp/Shared/Phone/Common/Logic/HdlWifiLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlWifiLogic.cs
@@ -3,7 +3,7 @@
 using System.Security.Cryptography;
 using System.Text;
 
-namespace Shared.Phone
+namespace Shared.Phone.UserCenter
 {
     /// <summary>
     /// WiFi鐨勯�昏緫
@@ -131,6 +131,35 @@
         /// </summary>
         private bool hadAddListenNetWork = false;
 
+        /// <summary>
+        /// 鑳藉惁璁块棶http
+        /// </summary>
+        private bool m_CanAccessHttp = true;
+        /// <summary>
+        /// 涓婁竴娆¤闂甴ttp鐨勬椂闂�
+        /// </summary>
+        private DateTime oldAccessHttpTime = DateTime.Now;
+        /// <summary>
+        /// 鑳藉惁璁块棶http
+        /// </summary>
+        public bool CanAccessHttp
+        {
+            set
+            {
+                m_CanAccessHttp = value;
+                oldAccessHttpTime = DateTime.Now;
+            }
+            get
+            {
+                //8绉掑悗鍏佽鍐嶆璁块棶
+                if (m_CanAccessHttp == true || (DateTime.Now - oldAccessHttpTime).TotalMilliseconds > 8 * 1000)
+                {
+                    oldAccessHttpTime = DateTime.Now;
+                    return true;
+                }
+                return false;
+            }
+        }
         /// <summary>
         /// 鍙樻洿缃戠粶鏃剁殑浜嬩欢
         /// </summary>
@@ -369,12 +398,15 @@
             //娌℃湁缃戠粶
             if (value == 0)
             {
+                this.CanAccessHttp = false;
                 //鍏抽棴Socket
                 ZigBee.Common.Application.FindGateWaySocket.Stop();
             }
             //WIFI鎴栬��4G鏃�
             if (value == 1 || value == 2)
             {
+                //鍏佽鑱旂綉
+                this.CanAccessHttp = true;
                 this.changedNetworkTime = DateTime.Now.ToString("yyyyMMdd HH.mm.ss");
                 //褰撳墠鎵ц姝ょ嚎绋嬬殑鏃堕棿
                 string thisThreadTime = this.changedNetworkTime;
@@ -384,6 +416,19 @@
                     //涓嶇濡備綍,閮借鏄剧ず杞湀
                     ProgressBar.Show();
 
+                    //妫�娴嬫槸鍚﹀凡缁忓畬鎴愯处鍙蜂俊鎭垵濮嬪寲
+                    if (UserCenterResourse.UserInfo.InitUserInfoSuccess == false
+                       && Common.Config.Instance.HomeId != string.Empty)
+                    {
+                        //閲嶆柊鍒濆鍖栬处鍙蜂俊鎭�
+                        UserCenterLogic.ReInitUserAccoutInfo();
+                        //鍥犱负涓婇潰杩欎釜涓滆タ鑰楁椂铔箙鐨�,鎵�浠ュ鐞嗗畬涔嬪悗杩涜鍒ゆ柇
+                        if (thisThreadTime != this.changedNetworkTime)
+                        {
+                            //鍦ㄥ鐞嗙殑杩囩▼涓�,鍒囨崲浜嗙綉缁�,鎶婁笅闈㈢殑澶勭悊浜ょ粰鍙﹀鐨勭嚎绋�
+                            return;
+                        }
+                    }
                     //閲嶆柊鍒濆鍖朣ocket
                     ZigBee.Common.Application.FindGateWaySocket.Stop();
                     System.Threading.Thread.Sleep(100);
@@ -393,30 +438,47 @@
                     //鏂帀杩滅▼
                     ZigBee.Device.ZbGateway.CloseRemoteConnectionOnForce();
 
-                    //鍚姩socket
-                    ZigBee.Common.Application.FindGateWaySocket.Start();
-
-                    //閲嶆柊鍒濆鍖栬处鍙蜂俊鎭� (鍙兘鐨勭姸鎬佺爜:Sucess  NotNetWork  AuthorityChangd  TokenTimeOunt)(-1:鏃犵綉 1:姝e父 2:鐧婚檰涓嶈繘鍘� 3:鏉冮檺鍙樻洿浜�)
-                    var result = HdlAccountLogic.Current.ReInitUserAccoutInfo();
-                    if (result == AccountStatu.TokenTimeOunt || result == AccountStatu.AuthorityChangd)
+                    //濡傛灉鏄痺ifi
+                    if (value == 2)
                     {
-                        //杩欎袱涓凡缁忚韪㈠埌浜嗙櫥闄嗙晫闈�
-                        ProgressBar.Close();
-                        return;
-                    }
-                    //褰撴棤缃戞椂,閲岄潰宸茬粡绛夊緟浜�3绉�
-                    int waitCount = result == AccountStatu.NotNetWork ? 3 : 9;
-                    //鍥哄畾绛夊緟4.5绉�
-                    for (int i = 0; i < waitCount; i++)
-                    {
+                        ZigBee.Common.Application.FindGateWaySocket.Start();
+                        //鍊熺敤涓�涓嬭繖涓彉閲�(妫�娴嬭兘鍚﹀箍鎾埌缃戝叧)
+                        UserCenterResourse.DicReceiveGatewayTest = new Dictionary<string, ZigBee.Device.ZbGateway>();
+                        UserCenterResourse.HideOption.CheckCanReceiveGateway = 1;
+                        //鍥哄畾绛変釜3绉掑惂
+                        System.Threading.Thread.Sleep(2500);
                         if (thisThreadTime != this.changedNetworkTime)
                         {
-                            //鍦ㄥ鐞嗙殑杩囩▼涓�,鍒囨崲浜嗙綉缁�,鎶婁笅闈㈢殑澶勭悊浜ょ粰鍙﹀鐨勭嚎绋�
+                            //鍙樻洿浜嗙綉缁�,浜ょ敱鍏朵粬绾跨▼澶勭悊
                             return;
                         }
+                        UserCenterResourse.HideOption.CheckCanReceiveGateway = 0;
                         System.Threading.Thread.Sleep(500);
-                    }
 
+                        bool canReceiveGw = false;
+                        foreach (var gateway in UserCenterResourse.DicReceiveGatewayTest.Values)
+                        {
+                            if (gateway.HomeId == Common.Config.Instance.Home.Id)
+                            {
+                                //鑳藉鎼滅储寰楀埌缃戝叧
+                                canReceiveGw = true;
+                                break;
+                            }
+                        }
+                        UserCenterResourse.DicReceiveGatewayTest = null;
+                        //璁剧疆杩滅▼杩炴帴鐨勫垵濮嬪��
+                        ZigBee.Device.ZbGateway.IsRemote = canReceiveGw == false;
+                        if (canReceiveGw == false)
+                        {
+                            //濡傛灉鏄繙绋嬬殑璇�,杩藉姞绛夊緟鏃堕棿(鎬诲叡5绉�)
+                            System.Threading.Thread.Sleep(2000);
+                        }
+                    }
+                    else if (value == 1)
+                    {
+                        //濡傛灉鏄�4G鐨勮瘽,鐩存帴绛夊緟
+                        System.Threading.Thread.Sleep(4500);
+                    }
                     ProgressBar.Close();
 
                 }, ShowErrorMode.NO);

--
Gitblit v1.8.0