From bbc74a6dae2e90a811b2507c5896fe89aa29ccc0 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 08 一月 2020 11:30:46 +0800
Subject: [PATCH] 2020-01-08 1.替换新服务器接口。

---
 Crabtree/SmartHome/UI/SimpleControl/Phone/Room/UserRoom.cs |   56 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/UserRoom.cs b/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/UserRoom.cs
index e514a4b..906560d 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/UserRoom.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/Phone/Room/UserRoom.cs
@@ -245,6 +245,29 @@
             base.RemoveFromParent ();
         }
 
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="stateCodeStr"></param>
+        void ShowGetHomePagerErrorInfo (string stateCodeStr)
+        {
+            string mes = "";
+            //2020-01-06 寰呰ˉ鍏�
+            if (stateCodeStr == ErrorCode.NetworkError) {
+                mes = ErrorCode.NetworkError;
+            } else {
+                mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr;
+
+            }
+            if (!string.IsNullOrEmpty (mes)) {
+                Application.RunOnMainThread (() => {
+                    new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show ();
+                });
+            }
+
+
+        }
+
         public void InitRoomView (string RoomFilePath)
         {
             try {
@@ -362,7 +385,7 @@
                     Height = Application.GetRealHeight (26),
                     UnSelectedImagePath = "Room/godown.png",
                 };
-                NameButton.Text = UserConfig.Instance.CurrentRegion.RegionName;
+                NameButton.Text = UserConfig.Instance.CurrentRegion.Name;
                 topView.AddChidren (btnGoDownTip);
 
                 //椤堕儴鏍囬鎸夐挳鍒囨崲浣忓畢鍖哄煙
@@ -370,13 +393,20 @@
                     MainPage.Loading.Start ();
                     System.Threading.Tasks.Task.Run (() => {
                         if (UserConfig.Instance.HomeLists.Count == 0) {
-                            var requestObj2 = new HomeListObj ();
+                            var requestObj2 = new GetHomePagerObj ();
+                            requestObj2.ReqDto.LoginAccessToken = MainPage.LoginUser.LoginTokenString;
+                            //var requestObj2 = new HomeListObj ();
                             var requestJson2 = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj2);
-                            var revertObj2 = MainPage.RequestHttps ("HomeList", requestJson2);
-                            if (revertObj2.StateCode == "SUCCESS") {
-                                var responseDataObj = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RegionInfoRes>> (revertObj2.ResponseData.ToString ());
-                                UserConfig.Instance.HomeLists = responseDataObj;
-                                UserConfig.Instance.SaveUserConfig ();
+                            var revertObj2 = MainPage.RequestHttps (API.GetHomePager, requestJson2);
+                            if (revertObj2.StateCode.ToUpper() == "SUCCESS") {
+                                var mResidenceRes = Newtonsoft.Json.JsonConvert.DeserializeObject<ResidenceRes> (revertObj2.ResponseData.ToString ());
+
+                                if (mResidenceRes.PageData != null && mResidenceRes.PageData.Count > 0) {
+                                    UserConfig.Instance.HomeLists = mResidenceRes.PageData;
+                                    UserConfig.Instance.SaveUserConfig ();
+                                }
+                            } else {
+                                ShowGetHomePagerErrorInfo (revertObj2.StateCode);
                             }
                         }
                         Application.RunOnMainThread (() => {
@@ -420,13 +450,13 @@
                                     Gravity = Gravity.CenterVertical,
                                     UnSelectedImagePath = "Item/Point.png",
                                     SelectedImagePath = "Item/Point.png",
-                                    Visible = homeTemp.RegionID != UserConfig.Instance.CurrentRegion.RegionID
+                                    Visible = homeTemp.Id != UserConfig.Instance.CurrentRegion.Id
                                 };
                                 rowView.AddChidren (btnPoint);
 
                                 var btnName = new Button () {
                                     Width = Application.GetRealWidth (550),
-                                    Text = homeTemp.RegionName,
+                                    Text = homeTemp.Name,
                                     TextAlignment = TextAlignment.CenterLeft,
                                     X = Application.GetRealWidth (90),
                                     TextColor = SkinStyle.Current.TextColor1,
@@ -434,7 +464,7 @@
                                 rowView.AddChidren (btnName);
 
                                 btnName.MouseUpEventHandler += (ss, ee) => {
-                                    if (UserConfig.Instance.CurrentRegion.RegionID == homeTemp.RegionID) {
+                                    if (UserConfig.Instance.CurrentRegion.Id == homeTemp.Id) {
                                         return;
                                     }
                                     MainPage.Loading.Start ("Please wait...");
@@ -442,7 +472,7 @@
                                         try {
                                             var backuplist = IO.FileUtils.ReadFiles ();
                                             int index = 0;
-                                            string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.RegionName);
+                                            string oldRegionRootPath = IO.FileUtils.CreateRegionBackup (UserConfig.Instance.CurrentRegion.Name);
                                             IO.FileUtils.DeleteRegionFiles (oldRegionRootPath);
                                             foreach (var fileName in backuplist) {
                                                 System.IO.FileInfo fileInfo = new System.IO.FileInfo (IO.FileUtils.RootPath + fileName);
@@ -457,7 +487,7 @@
                                                 });
                                             }
                                             IO.FileUtils.DeleteAllFile ();
-                                            string newRegionRootPath = IO.FileUtils.CreateRegionBackup (homeTemp.RegionName);
+                                            string newRegionRootPath = IO.FileUtils.CreateRegionBackup (homeTemp.Name);
                                             IO.FileUtils.RestoreRegionFiles (newRegionRootPath);
                                             UserConfig.Instance.RefreshUserConfig ();
                                             UserConfig.Instance.CurrentRegion = homeTemp;
@@ -487,7 +517,7 @@
                                         }
                                     });
                                 };
-                                if (homeTemp.RegionID == UserConfig.Instance.CurrentRegion.RegionID) {
+                                if (homeTemp.Id == UserConfig.Instance.CurrentRegion.Id) {
                                     Button btnCheck = new Button () {
                                         X = Application.GetRealWidth (20),
                                         Y = Application.GetRealHeight (25),

--
Gitblit v1.8.0