From 97e259d966cb5cb5d73c105d5dbaadcc1f920614 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 18 十月 2019 13:48:43 +0800
Subject: [PATCH] 合并了全部的代码

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs |  149 +++++++++++++++++++++++++++++++------------------
 1 files changed, 94 insertions(+), 55 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
index c62be4d..20c6cb8 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
@@ -391,7 +391,7 @@
         /// 閲嶆柊缁戝畾缃戝叧(1:姝e父  -1:寮傚父  0:褰撳墠鐨勭綉鍏崇粦瀹氬湪浜嗗綋鍓嶈处鍙蜂笅鐨勪笉鍚屼綇瀹呴噷闈�)
         /// </summary>
         /// <param name="zbGateway">缃戝叧</param>
-        public async Task<int> ReBindNewGateway(ZbGateway zbGateway)
+        public async Task<int> ReBindNewGateway(ZbGateway zbGateway, NormalViewControl btnMsg = null)
         {
             if (zbGateway == null)
             {
@@ -424,9 +424,19 @@
                 HdlGatewayLogic.Current.BackupGatewayIdOnNotNetwork(zbGateway);
             }
 
-            //缃戝叧鍐呴儴鏁版嵁鍙樻洿涓�,璇风◢鍚�
-            ProgressBar.SetValue(Language.StringByID(R.MyInternationalizationString.uGatewayDataIsChangingPleaseWhait));
-
+            if (btnMsg == null)
+            {
+                //缃戝叧鍐呴儴鏁版嵁鍙樻洿涓�,璇风◢鍚�
+                ProgressBar.SetValue(Language.StringByID(R.MyInternationalizationString.uGatewayDataIsChangingPleaseWhait));
+            }
+            else
+            {
+                HdlThreadLogic.Current.RunMain(() =>
+                {
+                    //缃戝叧鍐呴儴鏁版嵁鍙樻洿涓�,璇风◢鍚�
+                    btnMsg.TextID = R.MyInternationalizationString.uGatewayDataIsChangingPleaseWhait;
+                });
+            }
             await System.Threading.Tasks.Task.Delay(8000);
 
             //鑾峰彇缃戝叧鐨勪俊鎭�
@@ -1053,38 +1063,60 @@
         }
 
         /// <summary>
-        /// 鑾峰彇缃戝叧闀滃儚绫诲瀷鐨勭炕璇戝悕瀛�
+        /// 璁剧疆缃戝叧闀滃儚绫诲瀷鐨勭炕璇戝悕瀛�
         /// </summary>
+        /// <param name="button"></param>
         /// <param name="zbGateway"></param>
         /// <returns></returns>
-        public string GetGatewayImageText(ZbGateway zbGateway)
+        public void SetGatewayImageText(Button button, ZbGateway zbGateway)
         {
+            //鍒濆鍊�:鏃犳硶璇嗗埆鐨勭綉鍏宠澶�
+            button.TextID = R.MyInternationalizationString.uUnDistinguishTheGatewayDevice;
+
             string gwId = this.GetGatewayId(zbGateway);
-            int imageType = -1;
             if (this.dicGateway.ContainsKey(gwId) == false || this.dicGateway[gwId].getGwInfo == null)
             {
                 //濡傛灉杩欎釜缃戝叧娌℃湁淇℃伅锛屽垯浠庢柊鑾峰彇
-                var result = this.GetGatewayNewInfo(zbGateway, ShowErrorMode.NO);
-                if (result == null)
+                if (zbGateway.getGwInfo != null && zbGateway.getGwInfo.LinuxImageType != 0)
                 {
-                    //鏃犳硶璇嗗埆鐨勭綉鍏宠澶�
-                    return Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice);
+                    string keyName = Common.LocalDevice.deviceModelIdName + zbGateway.getGwInfo.LinuxImageType;
+                    if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true)
+                    {
+                        //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗�
+                        button.TextID = LocalDevice.Current.dicDeviceDefultNameID[keyName];
+                    }
                 }
-                imageType = result.LinuxImageType;
+                else
+                {
+                    //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷
+                    HdlThreadLogic.Current.RunThread(async () =>
+                    {
+                        var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO);
+                        if (result != null)
+                        {
+                            zbGateway.getGwInfo = result;
+                            HdlThreadLogic.Current.RunMain(() =>
+                            {
+                                string keyName = Common.LocalDevice.deviceModelIdName + zbGateway.getGwInfo.LinuxImageType;
+                                if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true)
+                                {
+                                    //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗�
+                                    button.TextID = LocalDevice.Current.dicDeviceDefultNameID[keyName];
+                                }
+                            });
+                        }
+                    });
+                }
             }
             else
             {
-                imageType = Convert.ToInt32(this.GetGwInfoAttribute(this.dicGateway[gwId], "LinuxImageType"));
+                string keyName = Common.LocalDevice.deviceModelIdName + this.dicGateway[gwId].getGwInfo.LinuxImageType;
+                if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true)
+                {
+                    //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗�
+                    button.TextID = Common.LocalDevice.Current.dicDeviceDefultNameID[keyName];
+                }
             }
-            string keyName = Common.LocalDevice.deviceModelIdName + imageType;
-            if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true)
-            {
-                //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗�
-                return Language.StringByID(Common.LocalDevice.Current.dicDeviceDefultNameID[keyName]);
-            }
-
-            //鏃犳硶璇嗗埆鐨勭綉鍏宠澶�
-            return Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice);
         }
 
         #endregion
@@ -1314,7 +1346,7 @@
         #region 鈻� 涓荤綉鍏冲垽瀹歘________________________
 
         /// <summary>
-        /// 鍒ゆ柇鏄惁涓荤綉鍏�(1:涓荤綉鍏� 0:涓嶅湪绾� -1:杩滅▼妯″紡,涓嶅瓨鍦ㄥ暐涓荤綉鍏崇殑璇存硶)
+        /// 鍒ゆ柇鏄惁涓荤綉鍏�(1:涓荤綉鍏� 0:涓嶅湪绾� 2:瀛愮綉鍏�)
         /// </summary>
         /// <param name="zbGateway">缃戝叧瀵硅薄</param>
         /// <returns></returns>
@@ -1325,7 +1357,7 @@
         }
 
         /// <summary>
-        /// 鍒ゆ柇鏄惁涓荤綉鍏�(1:涓荤綉鍏� 0:涓嶅湪绾� -1:杩滅▼妯″紡,涓嶅瓨鍦ㄥ暐涓荤綉鍏崇殑璇存硶)
+        /// 鍒ゆ柇鏄惁涓荤綉鍏�(1:涓荤綉鍏� 0:涓嶅湪绾� 2:瀛愮綉鍏�)
         /// </summary>
         /// <param name="waiID">缃戝叧id</param>
         /// <returns></returns>
@@ -1336,7 +1368,7 @@
             {
                 return 0;
             }
-            return zbGateway.IsMainGateWay == true ? 1 : 0;
+            return zbGateway.IsMainGateWay == true ? 1 : 2;
         }
 
         #endregion
@@ -1344,7 +1376,7 @@
         #region 鈻� 璁剧疆缃戝叧鍥剧墖_______________________
 
         /// <summary>
-        /// 璁剧疆鐪熷疄缃戝叧鐨勫浘鐗囷紝瑙勬牸锛�915X492
+        /// 璁剧疆鐪熷疄缃戝叧鐨勫浘鐗�
         /// </summary>
         /// <param name="button"></param>
         /// <param name="zbGateway"></param>
@@ -1354,30 +1386,35 @@
             var localWay = this.GetLocalGateway(gwID);
             if (localWay == null || localWay.getGwInfo == null)
             {
-                //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷
-                HdlThreadLogic.Current.RunThread(async () =>
+                if (zbGateway.getGwInfo != null && zbGateway.getGwInfo.LinuxImageType != 0)
                 {
-                    var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO);
-                    if (result != null)
+                    button.UnSelectedImagePath = "Gateway/RealGateway" + zbGateway.getGwInfo.LinuxImageType + ".png";
+                }
+                else
+                {
+                    //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷
+                    HdlThreadLogic.Current.RunThread(async () =>
                     {
-                        Application.RunOnMainThread(() =>
+                        var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO);
+                        if (result != null)
                         {
-                            if (button != null)
+                            zbGateway.getGwInfo = result;
+                            HdlThreadLogic.Current.RunMain(() =>
                             {
                                 button.UnSelectedImagePath = "Gateway/RealGateway" + result.LinuxImageType + ".png";
-                            }
-                        });
-                    }
-                });
+                            });
+                        }
+                    });
+                }
             }
             else
             {
-                button.UnSelectedImagePath = "Gateway/RealGateway" + this.GetGwInfoAttribute(localWay, "LinuxImageType").ToString() + ".png";
+                button.UnSelectedImagePath = "Gateway/RealGateway" + localWay.getGwInfo.LinuxImageType + ".png";
             }
         }
 
         /// <summary>
-        /// 璁剧疆缃戝叧鍥炬爣锛岃鏍硷細110X110
+        /// 璁剧疆缃戝叧鍥炬爣
         /// </summary>
         /// <param name="button"></param>
         /// <param name="zbGateway"></param>
@@ -1387,28 +1424,30 @@
             var localWay = this.GetLocalGateway(gwID);
             if (localWay == null || localWay.getGwInfo == null)
             {
-                //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷
-                HdlThreadLogic.Current.RunThread(async () =>
+                if (zbGateway.getGwInfo != null && zbGateway.getGwInfo.LinuxImageType != 0)
                 {
-                    var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO);
-                    if (result != null)
+                    button.UnSelectedImagePath = "Gateway/GatewayIcon" + zbGateway.getGwInfo.LinuxImageType + ".png";
+                }
+                else
+                {
+                    //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷
+                    HdlThreadLogic.Current.RunThread(async () =>
                     {
-                        Application.RunOnMainThread(() =>
+                        var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO);
+                        if (result != null)
                         {
-                            if (button != null)
+                            zbGateway.getGwInfo = result;
+                            HdlThreadLogic.Current.RunMain(() =>
                             {
                                 button.UnSelectedImagePath = "Gateway/GatewayIcon" + result.LinuxImageType + ".png";
-                                button.SelectedImagePath = "Gateway/GatewayIcon" + result.LinuxImageType + "Selected.png";
-                            }
-                        });
-                    }
-                });
+                            });
+                        }
+                    });
+                }
             }
             else
             {
-                string linType = this.GetGwInfoAttribute(localWay, "LinuxImageType").ToString();
-                button.UnSelectedImagePath = "Gateway/GatewayIcon" + linType + ".png";
-                button.SelectedImagePath = "Gateway/GatewayIcon" + linType + "Selected.png";
+                button.UnSelectedImagePath = "Gateway/GatewayIcon" + localWay.getGwInfo.LinuxImageType + ".png";
             }
         }
 
@@ -1443,13 +1482,13 @@
 
         #endregion
 
-        #region 鈻� 娴嬭瘯缃戝叧___________________________
+        #region 鈻� 缃戝叧瀹氫綅___________________________
 
         /// <summary>
-        /// 鍙戦�佹祴璇曟寚浠ゅ埌璁惧(缃戝叧LED闂儊璇嗗埆)
+        /// 鍙戦�佹寚浠ゅ埌缃戝叧杩涜瀹氫綅(缃戝叧LED闂儊璇嗗埆)
         /// </summary>
         /// <param name="zbGateway"></param>
-        public void SetTestCommand(ZbGateway zbGateway)
+        public void SetFixedPositionCommand(ZbGateway zbGateway)
         {
             ZbGateway realWay = null;
             if (this.GetRealGateway(ref realWay, zbGateway) == false)

--
Gitblit v1.8.0