From 25429f085093d89d543a0b90e30d0d62d1b7dac9 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 30 八月 2022 09:37:38 +0800
Subject: [PATCH] 合并了IOS的代码

---
 ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs |  119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 113 insertions(+), 6 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs b/ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs
old mode 100755
new mode 100644
index a5bfc72..ae83791
--- a/ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs
+++ b/ZigbeeApp/Shared/Phone/MainPage/HomeMainPageForm.cs
@@ -84,6 +84,8 @@
             this.AddSensorDeviceReportEvent();
             //寮�鍚紶鎰熷櫒鐘舵�佽繕鍘熺殑绾跨▼
             this.StartRecoverSenorStatuThread();
+            //鏄剧ずApp鍏憡
+            this.ShowAppNotice();
         }
 
         /// <summary>
@@ -658,7 +660,6 @@
                         else
                         {
                             cardContr = new Controls.DeviceTemperatureCardControl();
-
                         }
                     }
                     //闂ㄩ攣
@@ -672,7 +673,7 @@
                         cardContr = new Controls.DeviceColorTemperatureCardControl();
                     }
                     //鏃犳硶璇嗗埆
-                    else
+                    if (cardContr == null)
                     {
                         cardContr = new Controls.DeviceCardCommon();
                     }
@@ -1140,10 +1141,13 @@
 
                     //鏅捐。鏋朵笂鎶ラ渶瑕佺壒娈婂鐞嗭紝鍏朵粬涓婃姤鐨勫洖璺粺涓�杞负绔偣1
                     var tempList = LocalDevice.Current.GetDevicesByMac(report.DeviceAddr);
-                    var tempDeviceEnum = LocalDevice.Current.GetMyDeviceEnumInfo(tempList);
-                    if (tempDeviceEnum.ConcreteType == Common.DeviceConcreteType.Airer)
+                    if (tempList.Count > 0)
                     {
-                        mainKeys = report.DeviceAddr + "_" + 1;
+                        var tempDeviceEnum = LocalDevice.Current.GetMyDeviceEnumInfo(tempList);
+                        if (tempDeviceEnum.ConcreteType == Common.DeviceConcreteType.Airer)
+                        {
+                            mainKeys = report.DeviceAddr + "_" + 1;
+                        }
                     }
 
                     if (this.dicDeviceCardControl.ContainsKey(mainKeys) == true)
@@ -1312,6 +1316,109 @@
             return true;
         }
 
+        /// <summary>
+        /// 鏄剧ずApp鍏憡
+        /// </summary>
+        private void ShowAppNotice()
+        {
+            HdlThreadLogic.Current.RunThread(() =>
+            {
+                if (HdlFirmwareUpdateLogic.CheckCanShowNotice() == true)
+                {
+                    while (this.IsFormOpen("HdlAutoBackupForm") == true)
+                    {
+                        //鑷姩澶囦唤鐨勭晫闈㈡鍦ㄦ墦寮�涓�
+                        System.Threading.Thread.Sleep(1000);
+                    }
+                    HdlThreadLogic.Current.RunMain(() =>
+                    {
+                        //鍔犺浇绯荤粺鍏憡
+                        var form2 = new AppNoticeForm();
+                        UserView.UserPage.Instance.AddChidren(form2);
+                        form2.Show();
+                        form2.FinishEvent += () =>
+                        {
+                            HdlThreadLogic.Current.RunThread(() =>
+                            {
+                                System.Threading.Thread.Sleep(1000);
+                                //鏄剧ずApp鍗囩骇鐨勫脊绐�
+                                this.ShowUpdateAppDialog();
+
+                            }, ShowErrorMode.NO);
+                        };
+
+                    }, ShowErrorMode.NO);
+                }
+                else
+                {
+                    //鏄剧ずApp鍗囩骇鐨勫脊绐�
+                    this.ShowUpdateAppDialog();
+                }
+            }, ShowErrorMode.NO);
+        }
+
+        /// <summary>
+        /// 鏄剧ずApp鍗囩骇鐨勫脊绐�
+        /// </summary>
+        private void ShowUpdateAppDialog()
+        {
+            //App鍗囩骇鎻愮ず
+            if (string.IsNullOrEmpty(FirmwareUpdateResourse.AppNeedUpdateUrl) == false)
+            {
+                //鏁翠簡涓�娆′箣鍚庡氨涓嶆暣浜�
+                string updateUrl = FirmwareUpdateResourse.AppNeedUpdateUrl;
+                FirmwareUpdateResourse.AppNeedUpdateUrl = string.Empty;
+
+                while (this.IsFormOpen("HdlAutoBackupForm") == true)
+                {
+                    //鑷姩澶囦唤鐨勭晫闈㈡鍦ㄦ墦寮�涓�
+                    System.Threading.Thread.Sleep(1000);
+                }
+                //鍙戠幇APP鏂扮増鏈�,椹笂鍗囩骇{0}寮�鍚柊浣撻獙鍝
+                this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uAppUpdateMsg1).Replace("{0}", "\r\n"), () =>
+                {
+#if iOS
+                    Uri url = new Uri(updateUrl);
+                    UIKit.UIApplication.SharedApplication.OpenUrl(url);
+#endif
+#if Android
+                    HDLUtils.OpenUrl(updateUrl);
+#endif
+                }, Language.StringByID(R.MyInternationalizationString.uLevelUp));
+                //App鍗囩骇鎻愮ず浼樺厛
+                return;
+            }
+            //缃戝叧鍗囩骇鎻愮ず
+            if (FirmwareUpdateResourse.ListGatewayNeedUpdate.Count > 0)
+            {
+                //鏁村畬涔嬪悗灏辨竻绌�
+                var listGateway = new List<string>();
+                listGateway.AddRange(FirmwareUpdateResourse.ListGatewayNeedUpdate);
+                FirmwareUpdateResourse.ListGatewayNeedUpdate = new List<string>();
+
+                while (this.IsFormOpen("HdlAutoBackupForm") == true)
+                {
+                    //鑷姩澶囦唤鐨勭晫闈㈡鍦ㄦ墦寮�涓�
+                    System.Threading.Thread.Sleep(1000);
+                }
+                foreach (var gwId in listGateway)
+                {
+                    //鐩墠鍙暣涓�涓�
+                    if (HdlGatewayLogic.Current.IsGatewayExist(gwId) == true)
+                    {
+                        //鍙戠幇缃戝叧鏂扮増鏈�,椹笂鍗囩骇{0}寮�鍚柊浣撻獙鍝
+                        this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uGatewayUpdateMsg1).Replace("{0}", "\r\n"), () =>
+                        {
+                            var form = new UserCenter.GatewayUpdate.GatewayFirmwareUpdateForm();
+                            form.AddForm(HdlGatewayLogic.Current.GetLocalGateway(gwId));
+                        });
+                        break;
+                    }
+                }
+                return;
+            }
+        }
+
         #endregion
 
         #region 鈻� 鐣岄潰閲嶆柊婵�娲讳簨浠禵__________________
@@ -1325,6 +1432,6 @@
             return 1;
         }
 
-        #endregion
+#endregion
     }
 }

--
Gitblit v1.8.0