From c0ce2f57a4f836ebeb9e7b8b4b5a4407fd78dc86 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期三, 23 九月 2020 10:06:05 +0800
Subject: [PATCH] 上传

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlFirmwareUpdateLogic.cs |   72 ++++++++++++++++++++++++++++++++++--
 1 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlFirmwareUpdateLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlFirmwareUpdateLogic.cs
index 45aed43..36407c7 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlFirmwareUpdateLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlFirmwareUpdateLogic.cs
@@ -445,7 +445,11 @@
 
             //鑾峰彇闇�瑕佷笅杞界殑鍥轰欢鏁版嵁
             var listVersion = GetNeedToDownLoadVersionData(listTempDevice, listTempGateway);
-            if (listVersion.Count == 0)
+            //鑾峰彇闇�瑕佷笅杞界殑绌鸿皟妯″潡
+            var listAcOta = new List<OTADevice>();
+            var listAcUpdate = GetNeedDownLoadAirConditionerModule(listTempDevice, ref listAcOta);
+
+            if (listVersion.Count == 0 && listAcUpdate.Count == 0)
             {
                 return 0;
             }
@@ -468,6 +472,8 @@
             //鍥轰欢瀛樺偍璺緞
             string firmwareDir = DirNameResourse.FirmwareUpdateDirectory;
             int nowCount = 0;
+            int macCount = listVersion.Count + listAcUpdate.Count;
+
             foreach (var versionData in listVersion)
             {
                 nowCount++;
@@ -476,6 +482,8 @@
                 if (result == -1)
                 {
                     ProgressFormBar.Current.Close();
+                    //淇濆瓨鍒楄〃鍚嶅瓧
+                    HdlFileLogic.Current.SaveFileContent(DirNameResourse.FirmwareUpdateList, dicFirmwareName);
                     return -1;
                 }
                 //鑾峰彇褰撳墠杩欎釜鐗堟湰鐨勫浐浠朵俊鎭�
@@ -483,15 +491,17 @@
                 if (versionFirmware == null)
                 {
                     //浜戠娌℃湁杩欎釜鐗堟湰  杩涘害鍊�
-                    ProgressFormBar.Current.SetValue(nowCount, listVersion.Count);
+                    ProgressFormBar.Current.SetValue(nowCount, macCount);
                     continue;
                 }
                 //鍘讳笅杞借繖涓浐浠�
                 var pra = new { RequestVersion = Common.CommonPage.RequestVersion, DistributedMark = versionFirmware.DistributedMark };
-                var byteData = UserCenterLogic.GetByteResponseDataByRequestHttps("FirmwareMana/DownloadPlatformUploadFirmware", false, pra, null, true);
+                var byteData = UserCenterLogic.GetByteResponseDataByRequestHttps("FirmwareMana/DownloadPlatformUploadFirmware", false, pra, new List<string> { "NotCheck" }, true);
                 if (byteData == null)
                 {
                     ProgressFormBar.Current.Close();
+                    //淇濆瓨鍒楄〃鍚嶅瓧
+                    HdlFileLogic.Current.SaveFileContent(DirNameResourse.FirmwareUpdateList, dicFirmwareName);
                     return -1;
                 }
                 //淇濆瓨鍥轰欢
@@ -500,8 +510,29 @@
                 dicFirmwareName[saveFile] = versionFirmware.Name;
 
                 //杩涘害鍊�
-                ProgressFormBar.Current.SetValue(nowCount, listVersion.Count);
+                ProgressFormBar.Current.SetValue(nowCount, macCount);
             }
+            for (int i = 0; i < listAcUpdate.Count; i++)
+            {
+                //涓嬭浇绌鸿皟妯″潡
+                var pra = new { RequestVersion = Common.CommonPage.RequestVersion, DistributedMark = listAcUpdate[i].DistributedMark };
+                var deviceFirmwareByte = UserCenterLogic.GetByteResponseDataByRequestHttps("FirmwareMana/DownloadPlatformUploadFirmware", false, pra, new List<string> { "NotCheck" }, true);
+                if (deviceFirmwareByte == null)
+                {
+                    ProgressFormBar.Current.Close();
+                    //淇濆瓨鍒楄〃鍚嶅瓧
+                    HdlFileLogic.Current.SaveFileContent(DirNameResourse.FirmwareUpdateList, dicFirmwareName);
+                    return -1;
+                }
+                //淇濆瓨鍥轰欢
+                string fileName = "AC_" + listAcOta[i].HwVersion + "_" + listAcOta[i].ImgTypeId + "_" + listAcUpdate[i].Name;
+                var saveFile = System.IO.Path.Combine(firmwareDir, fileName);
+                HdlFileLogic.Current.SaveByteToFile(saveFile, deviceFirmwareByte);
+
+                //杩涘害鍊�
+                ProgressFormBar.Current.SetValue(nowCount, macCount);
+            }
+
             //淇濆瓨鍒楄〃鍚嶅瓧
             HdlFileLogic.Current.SaveFileContent(DirNameResourse.FirmwareUpdateList, dicFirmwareName);
             ProgressFormBar.Current.Close();
@@ -601,6 +632,39 @@
         }
 
         /// <summary>
+        /// 鑾峰彇闇�瑕佷笅杞界殑绌鸿皟妯″潡
+        /// </summary>
+        /// <param name="listDevice">璁惧鍒楄〃</param>
+        /// <param name="listTaget">涓庤繑鍥炲�煎搴旂殑涓滆タ</param>
+        private static List<FirmwareVersionInfo> GetNeedDownLoadAirConditionerModule(List<OTADevice> listDevice, ref List<OTADevice> listTaget)
+        {
+            var listUpdate = new List<FirmwareVersionInfo>();
+            //鍥轰欢瀛樺偍璺緞
+            string firmwareDir = DirNameResourse.FirmwareUpdateDirectory;
+
+            foreach (var otaDevice in listDevice)
+            {
+                var myType = Common.LocalDevice.Current.GetMyDeviceEnumInfo(new List<CommonDevice> { otaDevice });
+                if (myType.ConcreteType != Common.DeviceConcreteType.AirConditioner_ZbGateway)
+                {
+                    //鍙鐞嗕腑澶┖璋�
+                    continue;
+                }
+                var list = GetFirmwareVersionListInfo(FirmwareLevelType.A璁惧, otaDevice.HwVersion.ToString(), otaDevice.ImgTypeId.ToString());
+                foreach (var data in list)
+                {
+                    if (data.Name.EndsWith(".bin") == true && System.IO.File.Exists(firmwareDir) == false)
+                    {
+                        //鍙.bin鏂囦欢
+                        listUpdate.Add(data);
+                        listTaget.Add(otaDevice);
+                    }
+                }
+            }
+            return listUpdate;
+        }
+
+        /// <summary>
         /// 妯℃澘璁惧鐨勭増鏈俊鎭�
         /// </summary>
         private class TemplateDeviceVersion

--
Gitblit v1.8.0