From fe3b2466c68b5db70d38e78039703add3b8b1dfe Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 31 十二月 2020 19:29:43 +0800
Subject: [PATCH] 合并了代码

---
 ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListMainForm.cs |   97 ++++++++++++++++++++++++++++--------------------
 1 files changed, 56 insertions(+), 41 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListMainForm.cs
index 9e23323..d37511f 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListMainForm.cs
@@ -18,7 +18,7 @@
         /// <summary>
         /// 浣忓畢鏁版嵁(鏈夌綉鏃朵娇鐢�)
         /// </summary>
-        private Dictionary<string, ResidenceInformation> dicResidenceData = null;
+        private Dictionary<string, Common.ResponseEntity.ResidenceObj> dicResidenceData = null;
         /// <summary>
         /// 浣忓畢鏁版嵁(鏃犵綉鏃朵娇鐢�)
         /// </summary>
@@ -123,11 +123,16 @@
         private bool SetResidenceInfoByOnline()
         {
             //鑾峰彇浣忓畢淇℃伅
-            var listHouse = HdlResidenceLogic.Current.GetHomeListsFromDb(ShowNetCodeMode.No);
-            if (listHouse == null)
+            var Pra = new GetResidenceInfoPra();
+            string resultData = UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomePager", false, Pra, new List<string> { "NotCheck" }, false);
+            if (string.IsNullOrEmpty(resultData) == true)
             {
                 return false;
             }
+            var pageData = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResidenceRes>(resultData);
+            //鎺掑簭浣忓畢
+            var listHouse = HdlResidenceLogic.Current.SortHouse(pageData.PageData);
+
             HdlThreadLogic.Current.RunMain(() =>
             {
                 if (this.Parent == null)
@@ -136,7 +141,7 @@
                 }
                 listView.Height = bodyFrameLayout.Height;
 
-                this.dicResidenceData = new Dictionary<string, ResidenceInformation>();
+                this.dicResidenceData = new Dictionary<string, Common.ResponseEntity.ResidenceObj>();
                 for (int i = 0; i < listHouse.Count; i++)
                 {
                     var info = listHouse[i];
@@ -156,7 +161,7 @@
         /// 娣诲姞浣忓畢鐨勮(鏈夌綉鎯呭喌)
         /// </summary>
         /// <param name="info"></param>
-        private void AddRowLayoutByOnline(ResidenceInformation info, bool addLine)
+        private void AddRowLayoutByOnline(Common.ResponseEntity.ResidenceObj info, bool addLine)
         {
             var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
             this.listView.AddChidren(rowLayout);
@@ -169,7 +174,7 @@
             if (info.Id == Config.Instance.Home.Id)
             {
                 //浣忓畢鍚嶇О
-                btnHome = rowLayout.frameTable.AddLeftCaption(info.HomeName, 800, 60, true);
+                btnHome = rowLayout.frameTable.AddLeftCaption(info.Name, 800, 60, true);
                 btnHome.TextSize = 15;
                 btnHome.Y = Application.GetRealHeight(12) + rowLayout.chidrenYaxis;
                 rowLayout.frameTable.AddChidren(btnHome, ChidrenBindMode.BindEvent);
@@ -184,7 +189,7 @@
             else
             {
                 //浣忓畢鍚嶇О
-                btnHome = rowLayout.frameTable.AddLeftCaption(info.HomeName, 800, true);
+                btnHome = rowLayout.frameTable.AddLeftCaption(info.Name, 800, true);
                 btnHome.TextSize = 15;
             }
             //鍙崇澶�
@@ -203,7 +208,7 @@
                     string msg = Language.StringByID(R.MyInternationalizationString.uSwitchResidenceMsg);
                     if (msg.Contains("{0}") == true)
                     {
-                        msg = string.Format(msg, info.HomeName);
+                        msg = string.Format(msg, info.Name);
                     }
                     this.ShowMassage(ShowMsgType.Confirm, msg, () =>
                     {
@@ -240,7 +245,7 @@
                 }
             };
 
-            if (info.IsOtherShare == true)
+            if (info.IsOthreShare == true)
             {
                 //鍒嗕韩鐨�,涓嶈兘鏇存敼
                 return;
@@ -411,9 +416,9 @@
         /// </summary>
         /// <param name="info">鏈夌綉鏃朵娇鐢�</param>
         /// <param name="i_house">鏃犵綉鏃堕�傜敤</param>
-        private void ShowEditorNameForm(ResidenceInformation info, House i_house, NormalViewControl btnHome)
+        private void ShowEditorNameForm(Common.ResponseEntity.ResidenceObj info, House i_house, NormalViewControl btnHome)
         {
-            string oldName = info != null ? info.HomeName : i_house.Name;
+            string oldName = info != null ? info.Name : i_house.Name;
             //鐢熸垚涓�涓脊绐楃敾闈�
             var dialogForm = new DialogInputControl();
             //缂栬緫浣忓畢
@@ -452,7 +457,7 @@
                             return;
                         }
                         //鍒锋柊鍐呭瓨鐨勪綇瀹呭悕
-                        HdlResidenceLogic.Current.EditorHouseByHouseId(i_house.Id, textValue, null, null);
+                        HdlResidenceLogic.Current.EditorHouseByHouseId(i_house.Id, textValue);
                         //鏇存敼鏄剧ず鐨勫悕瀛�
                         btnHome.Text = textValue;
                     }
@@ -466,7 +471,7 @@
         /// <param name="ResidenceName"></param>
         /// <param name="info"></param>
         /// <returns></returns>
-        private void EditorResidenceName(string ResidenceName, ResidenceInformation info, NormalViewControl btnHome)
+        private void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
         {
             //妫�娴嬭兘鍚︿繚瀛樹綇瀹�
             if (this.CheckIsCanSaveResidence(info.Id, ResidenceName, true) == false)
@@ -476,7 +481,7 @@
             //寮�鍚繘搴︽潯
             this.ShowProgressBar();
 
-            var result = HdlResidenceLogic.Current.EditorResidenceName(info.Id, ResidenceName, null, null);
+            var result = HdlResidenceLogic.Current.EditorResidenceName(info.Id, ResidenceName);
 
             //鍏抽棴杩涘害鏉�
             this.CloseProgressBar();
@@ -486,10 +491,10 @@
                 HdlThreadLogic.Current.RunMain(() =>
                 {
                     //鍒锋柊鍐呭瓨鐨勪綇瀹呭悕
-                    HdlResidenceLogic.Current.EditorHouseByHouseId(info.Id, ResidenceName, null, null);
+                    HdlResidenceLogic.Current.EditorHouseByHouseId(info.Id, ResidenceName);
                     //鏇存敼鏄剧ず鐨勫悕瀛�
                     btnHome.Text = ResidenceName;
-                    info.HomeName = ResidenceName;
+                    info.Name = ResidenceName;
                 });
             }
         }
@@ -545,19 +550,28 @@
             //寮�鍚繘搴︽潯
             this.ShowProgressBar();
 
-            //鍒涘缓浣忓畢
-            var newId = HdlResidenceLogic.Current.CreatNewResidence(ResidenceName, null, null);
-            this.CloseProgressBar();
-
-            if (newId != null)
+            var Pra = new AddResidencePra();
+            Pra.Name = ResidenceName;
+            //娣诲姞浣忓畢
+            string resultData = UserCenterLogic.GetResponseDataByRequestHttps("App/AddHome", false, Pra);
+            if (string.IsNullOrEmpty(resultData) == true)
             {
-                HdlThreadLogic.Current.RunMain(() =>
-                {
-                    //閲嶆柊鍒锋柊鍒楄〃
-                    this.listView.RemoveAll();
-                    this.SetResidenceInfo(2);
-                });
+                //鍏抽棴杩涘害鏉�
+                this.CloseProgressBar();
+                return;
             }
+
+            var newInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<NewResidenceInfo>>(resultData);
+
+            HdlResidenceLogic.Current.AddHouseToMemmory(newInfo[0].Id, ResidenceName);
+
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                //閲嶆柊鍒锋柊鍒楄〃
+                this.listView.RemoveAll();
+                this.SetResidenceInfo(2);
+            });
+
         }
 
         #endregion
@@ -576,13 +590,13 @@
                 var result2 = HdlGatewayLogic.Current.ResetComandToBindBackupGateway();
                 if (result2 == false)
                 {
-                    //缁戝畾缃戝叧澶辫触,璇烽噸鏂版搷浣�
-                    this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uBindGatewayFailPleaseDoAgain));
+                    //涓存椂杩欎箞鍐�,鏂颁簯绔氨浼氬啓鍒癛鏂囦欢浜�
+                    this.ShowMassage(ShowMsgType.Tip, "缁戝畾缃戝叧澶辫触,璇烽噸鏂版搷浣�");
                     this.CloseProgressBar();
                     return;
                 }
                 //妫�娴嬪畠鏈夋病鏈夊浠�
-                var listBack = HdlBackupLogic.Current.GetBackupListNameFromDB(BackUpMode.A鎵嬪姩澶囦唤);
+                var listBack = HdlBackupLogic.Current.GetBackupListNameFromDB();
                 this.CloseProgressBar();
 
                 if (listBack == null)
@@ -612,7 +626,7 @@
                              HdlThreadLogic.Current.RunThread(() =>
                              {
                                  //鍒涘缓涓�涓浠藉悕瀛�
-                                 string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(textValue, BackUpMode.A鎵嬪姩澶囦唤);
+                                 string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(textValue);
                                  if (backupClassId == null)
                                  {
                                      //鍒涘缓澶囦唤鍚嶅瓧澶辫触
@@ -656,7 +670,7 @@
         /// 妫�娴嬫湰鍦版湁娌℃湁杩欎釜浣忓畢
         /// </summary>
         /// <param name="info"></param>
-        private void CheckIsExsitResidence(ResidenceInformation info)
+        private void CheckIsExsitResidence(Common.ResponseEntity.ResidenceObj info)
         {
             var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, info.Id);
             bool isExsit = System.IO.Directory.Exists(path);
@@ -666,9 +680,10 @@
             //鍒涘缓鏂扮殑浣忓畢
             var house = new House();
             house.Id = info.Id;
-            house.Name = info.HomeName;
-            house.IsOtherShare = info.IsOtherShare;
-            house.AccountType = info.AccountType == "ADMIN" ? 1 : 0;
+            house.Name = info.Name;
+            house.IsOthreShare = info.IsOthreShare;
+            house.AccountType = info.AccountType;
+            house.MainUserDistributedMark = info.MainUserDistributedMark;
             house.Longitude = info.Longitude;
             house.Latitude = info.Latitude;
             house.Save(false);
@@ -686,14 +701,14 @@
         /// </summary>
         /// <param name="info"></param>
         /// <returns></returns>
-        private bool CheckIsCanDeleteResidence(ResidenceInformation info)
+        private bool CheckIsCanDeleteResidence(Common.ResponseEntity.ResidenceObj info)
         {
-            if (info.IsOtherShare == false)
+            if (info.IsOthreShare == false)
             {
                 int myCount = 0;
                 foreach (var data in this.dicResidenceData.Values)
                 {
-                    if (data.IsOtherShare == false)
+                    if (data.IsOthreShare == false)
                     {
                         myCount++;
                     }
@@ -751,12 +766,12 @@
                 //浣忓畢鍚嶅瓧閲嶅妫�娴�
                 foreach (string strId in this.dicResidenceData.Keys)
                 {
-                    if (this.dicResidenceData[strId].IsOtherShare == true)
+                    if (this.dicResidenceData[strId].IsOthreShare == true)
                     {
                         //鍒嗕韩鐨勪綇瀹呬笉鑰冭檻
                         continue;
                     }
-                    if (residenceId != strId && residenceName == this.dicResidenceData[strId].HomeName)
+                    if (residenceId != strId && residenceName == this.dicResidenceData[strId].Name)
                     {
                         //浣忓畢鍚嶅瓧宸茬粡瀛樺湪
                         int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
@@ -770,7 +785,7 @@
             {
                 foreach (var myHouse in this.listLocalHouse)
                 {
-                    if (myHouse.IsOtherShare == true)
+                    if (myHouse.IsOthreShare == true)
                     {
                         //鍒嗕韩鐨勪綇瀹呬笉鑰冭檻
                         continue;

--
Gitblit v1.8.0