From 9c16d3614d9b88c637f967518a329f239fcd3aaf Mon Sep 17 00:00:00 2001
From: lss <316519258@qq.com>
Date: 星期五, 12 六月 2020 09:22:04 +0800
Subject: [PATCH] 2020.06.12

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayUpdateLogic.cs |   51 +++++++++++++++++++++++----------------------------
 1 files changed, 23 insertions(+), 28 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayUpdateLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayUpdateLogic.cs
index 1d0ea04..36fc2e9 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayUpdateLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayUpdateLogic.cs
@@ -9,7 +9,7 @@
     /// <summary>
     /// 缃戝叧鐨勫崌绾ч�昏緫
     /// </summary>
-    public class HdlGatewayUpdateLogic
+    public class HdlGatewayUpdateLogic : HdlDeviceUpdateCommonLogic
     {
         #region 鈻� 鍙橀噺澹版槑___________________________
 
@@ -23,7 +23,7 @@
         /// </summary>
         public Action<int, string> UpdateStatuChangedEvent = null;
         /// <summary>
-        /// 杩涘害鍊间簨浠�
+        /// 杩涘害鍊间簨浠�(宸茬粡鏄櫨鍒嗘瘮鐨勫��)
         /// </summary>
         public Action<decimal> ProgressEvent = null;
         /// <summary>
@@ -38,14 +38,6 @@
         /// 缃戝叧鏂扮増鏈殑鍥轰欢淇℃伅
         /// </summary>
         public FirmwareVersionInfo gatewayFirmware = null;
-        /// <summary>
-        /// 褰撳墠鎵ц鐘舵��(鍑虹幇閿欒鏃�,瀹冧篃浼氬彉鎴恡rue)
-        /// </summary>
-        public UpdateStatuMode UpdateStatu = UpdateStatuMode.None;
-        /// <summary>
-        /// 鍗囩骇鏄惁瀹屾垚
-        /// </summary>
-        public bool IsFinishUpdate = true;
 
         /// <summary>
         /// 鍓嶄竴娆$殑鏈�缁堢姸鎬�
@@ -71,6 +63,7 @@
         public HdlGatewayUpdateLogic(ZbGateway zbGateway, FirmwareVersionInfo i_virtualFirmware,
             FirmwareVersionInfo i_coordinatorFirmware, FirmwareVersionInfo i_gatewayFirmware)
         {
+            this.ClassDiv = 1;
             this.upDatezbGateway = zbGateway;
             this.virtualFirmware = i_virtualFirmware;
             this.coordinatorFirmware = i_coordinatorFirmware;
@@ -89,10 +82,10 @@
             if (this.UpdateStatu == UpdateStatuMode.Wait)
             {
                 //濡傛灉鏄瓑寰呮ā寮忥紝鍐嶆鐐瑰嚮鏃讹紝绉婚櫎鍒楄〃
-                string gwId = HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway);
-                if (FirmwareUpdateResourse.dicGatewayUpdateList.ContainsKey(gwId) == true)
+                string gwId = this.upDatezbGateway.GwId;
+                if (FirmwareUpdateResourse.dicUpdateList.ContainsKey(gwId) == true)
                 {
-                    FirmwareUpdateResourse.dicGatewayUpdateList.Remove(gwId);
+                    FirmwareUpdateResourse.dicUpdateList.Remove(gwId);
                 }
                 this.UpdateStatu = UpdateStatuMode.None;
                 //鍙栨秷
@@ -108,8 +101,8 @@
 
             //杩涘叆绛夊緟妯″紡
             this.UpdateStatu = UpdateStatuMode.Wait;
-            string gwId2 = HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway);
-            FirmwareUpdateResourse.dicGatewayUpdateList[gwId2] = this;
+            string gwId2 = this.upDatezbGateway.GwId;
+            FirmwareUpdateResourse.dicUpdateList[gwId2] = this;
             //绛夊緟涓��
             this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uWaitting));
 
@@ -120,7 +113,7 @@
         /// <summary>
         /// 寮�濮嬫墽琛屾洿鏂版搷浣�(FirmwareUpdateLogic璋冪敤)
         /// </summary>
-        public void DoStartUpdate()
+        public override void DoStartUpdate()
         {
             //鐘舵�佸彉鏇�
             this.IsFinishUpdate = false;
@@ -247,7 +240,7 @@
                 return;
             }
             var tempZb = (ZbGateway)objValue;
-            if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway))
+            if (tempZb.GwId != this.upDatezbGateway.GwId)
             {
                 //涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
                 return;
@@ -350,7 +343,7 @@
                 return;
             }
             var tempZb = (ZbGateway)objValue;
-            if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway))
+            if (tempZb.GwId != this.upDatezbGateway.GwId)
             {
                 //涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
                 return;
@@ -412,6 +405,7 @@
 
             //鍗忚皟鍣ㄥ浐浠朵笅杞戒腑
             this.UpdateStatuChangedEvent(0, Language.StringByID(R.MyInternationalizationString.uCoordinatorFirmwareDownLoading));
+            this.SetProgressValue(0, 100);
 
             //涓嬭浇鍗忚皟鍣ㄦ枃浠剁殑杩涘害
             this.upDatezbGateway.ReportAction += this.DownLoadCoordinatorFileProgress;
@@ -451,7 +445,7 @@
                 return;
             }
             var tempZb = (ZbGateway)objValue;
-            if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway))
+            if (tempZb.GwId != this.upDatezbGateway.GwId)
             {
                 //涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
                 return;
@@ -462,6 +456,7 @@
 
             //璁剧疆杩涘害
             var responData = tempZb.downloadFileProgressResponData;
+            this.SetProgressValue(responData.DownloadPercent, 100);
 
             //鍗忚皟鍣ㄥ浐浠朵笅杞戒腑
             this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uCoordinatorFirmwareDownLoading));
@@ -548,7 +543,7 @@
             }
 
             var tempZb = (ZbGateway)objValue;
-            if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway))
+            if (tempZb.GwId != this.upDatezbGateway.GwId)
             {
                 //涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
                 return;
@@ -610,6 +605,7 @@
 
             //缃戝叧鍥轰欢涓嬭浇涓�
             this.UpdateStatuChangedEvent?.Invoke(0, Language.StringByID(R.MyInternationalizationString.uGatewayFirmwareDownLoading));
+            this.SetProgressValue(0, 100);
 
             //涓嬭浇缃戝叧鏂囦欢鐨勮繘搴�
             this.upDatezbGateway.ReportAction += this.DownLoadGatewayFileProgress;
@@ -647,7 +643,7 @@
                 return;
             }
             var tempZb = (ZbGateway)objValue;
-            if (tempZb.CurrentGateWayId != HdlGatewayLogic.Current.GetGatewayId(this.upDatezbGateway))
+            if (tempZb.GwId != this.upDatezbGateway.GwId)
             {
                 //涓嶆槸鑷繁鐨勭綉鍏虫帹閫侊紝鍒欎笉澶勭悊
                 return;
@@ -754,7 +750,10 @@
                 //鎵ц涓嬩竴涓崌绾�
                 HdlFirmwareUpdateLogic.DoUpdateNextFirmware();
                 //缃戝叧鍗囩骇鎴愬姛!
-                this.UpdateStatuChangedEvent?.Invoke(1, "");
+                this.SetProgressValue(100, 100);
+                System.Threading.Thread.Sleep(1500);
+
+                this.UpdateStatuChangedEvent?.Invoke(1, Language.StringByID(R.MyInternationalizationString.uGatewayUpdateSuccess));
             });
         }
 
@@ -807,7 +806,7 @@
                 return;
             }
             decimal result = value / maxValue;
-            this.ProgressEvent?.Invoke(value);
+            this.ProgressEvent?.Invoke(result);
         }
 
         /// <summary>
@@ -980,10 +979,6 @@
         {
             HdlThreadLogic.Current.RunThread(async () =>
             {
-                //褰撳墠缃戝叧鐨勭増鏈�
-                var oldVersion = HdlGatewayLogic.Current.GetGwInfoAttribute(this.upDatezbGateway, "LinuxFWVersion");
-                int oldLinuxVersion = Convert.ToInt32(oldVersion);
-
                 //鍏堢瓑涓�120绉掑惂锛岀綉鍏冲崌绾у拰缃戝叧瀹屽叏閲嶅惎闇�瑕佸緢闀挎椂闂�
                 int count = 12;
                 for (int i = 0; i < count; i++)
@@ -1023,7 +1018,7 @@
         /// <summary>
         /// 閲婃斁缂撳瓨
         /// </summary>
-        public void Dispose()
+        public override void Dispose()
         {
             this.ProgressEvent = null;
             this.UpdateStatuChangedEvent = null;

--
Gitblit v1.8.0