From 18b93d511dc764b469d7c4a7e755f7274f89cdb4 Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期一, 27 四月 2020 17:55:14 +0800
Subject: [PATCH] 2020-4-27-1

---
 ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs |   75 ++++++++++++++++++++++++++-----------
 1 files changed, 53 insertions(+), 22 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
index a20b2b5..393b9e2 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
@@ -68,7 +68,6 @@
             }
 
             listView = new VerticalListControl(29);
-            listView.Y = Application.GetRealHeight(-6);
             listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
             listView.BackgroundColor = UserCenterColor.Current.White;
             bodyFrameLayout.AddChidren(listView);
@@ -146,11 +145,9 @@
                         continue;
                     }
                     var info = dicData[listResidenceSort[i]];
-                    if (info.IsOthreShare == false)
-                    {
-                        //鏀堕泦璇ヨ处鍙锋墍鎷ユ湁鐨勮嚜宸辩殑浣忓畢鐨勬暟鎹�
-                        this.dicResidenceData[info.Id] = info;
-                    }
+
+                    //鏀堕泦璇ヨ处鍙蜂綇瀹呯殑鏁版嵁
+                    this.dicResidenceData[info.Id] = info;
                     this.AddRowLayout(info, i != listResidenceSort.Count - 1);
                 }
                 //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
@@ -221,8 +218,10 @@
                         {
                             this.ShowProgressBar();
 
+                            //妫�娴嬫湰鍦版湁娌℃湁杩欎釜浣忓畢
+                            this.CheckIsExsitResidence(info);
+
                             Config.Instance.HomeId = info.Id;
-                            Global.CreateHomeDirectory(info.Id);
                             //閲嶆柊鍒濆鍖栦綇瀹呭璞�
                             Config.Instance.Home = House.GetHouseByHouseId(info.Id);
                             Config.Instance.Save();
@@ -255,13 +254,8 @@
                 return;
             }
             //鏇存敼
-            var btnChanged = new NormalViewControl(Application.GetRealWidth(184), rowLayout.Height, false);
-            btnChanged.BackgroundColor = 0xff4a4a4a;
-            btnChanged.TextSize = 12;
-            btnChanged.TextColor = UserCenterColor.Current.White;
-            btnChanged.TextAlignment = TextAlignment.Center;
+            var btnChanged = rowLayout.AddEditorControl();
             btnChanged.TextID = R.MyInternationalizationString.uChanged1;
-            rowLayout.AddRightView(btnChanged);
             btnChanged.ButtonClickEvent += (sender, e) =>
             {
                 //鏄剧ず缂栬緫鍚嶇О鐣岄潰
@@ -418,25 +412,57 @@
         #region 鈻� 涓�鑸柟娉昣__________________________
 
         /// <summary>
+        /// 妫�娴嬫湰鍦版湁娌℃湁杩欎釜浣忓畢
+        /// </summary>
+        /// <param name="info"></param>
+        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);
+            if (isExsit == true) { return; }
+            //鍒涘缓鏂囦欢澶�
+            Global.CreateHomeDirectory(info.Id);
+            //鍒涘缓鏂扮殑浣忓畢
+            var house = new House();
+            house.Id = info.Id;
+            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);
+
+            string fileName = house.FileName;
+            if (Config.Instance.HomeFilePathList.Contains(fileName) == false)
+            {
+                //娣诲姞鍒楄〃
+                Config.Instance.HomeFilePathList.Add(fileName);
+            }
+        }
+
+        /// <summary>
         /// 妫�娴嬭兘鍚﹀垹闄や綇瀹�
         /// </summary>
         /// <param name="info"></param>
         /// <returns></returns>
         private bool CheckIsCanDeleteResidence(Common.ResponseEntity.ResidenceObj info)
         {
-            if (this.dicResidenceData.Count == 1)
+            if (info.IsOthreShare == false)
             {
-                //濡傛灉姝よ处鍙蜂笅鍙墿涓嬪敮涓�涓�涓嚜宸辩殑浣忓畢锛屽綋鍒犻櫎杩欎釜浣忓畢鏃讹紝鎻愮ず涓嶈兘鍒犻櫎
-                //鍥犱负鏈�灏戣鏈変竴涓綇瀹�
-                if (this.dicResidenceData.ContainsKey(info.Id) == true)
+                int myCount = 0;
+                foreach (var data in this.dicResidenceData.Values)
+                {
+                    if (data.IsOthreShare == false)
+                    {
+                        myCount++;
+                    }
+                }
+                //濡傛灉姝よ处鍙蜂笅鍙墿涓嬪敮涓�涓�涓嚜宸辩殑浣忓畢锛屽垯涓嶈兘鍐嶅垹闄�
+                if (myCount == 1)
                 {
                     return false;
                 }
-            }
-            if (info.IsOthreShare == true)
-            {
-                //鍒嗕韩杩囨潵鐨勪綇瀹呬笉鑳藉垹闄�
-                return false;
             }
             return true;
         }
@@ -453,6 +479,11 @@
             //浣忓畢鍚嶅瓧閲嶅妫�娴�
             foreach (string strId in this.dicResidenceData.Keys)
             {
+                if (this.dicResidenceData[strId].IsOthreShare == true)
+                {
+                    //鍒嗕韩鐨勪綇瀹呬笉鑰冭檻
+                    continue;
+                }
                 if (residenceId != strId && residenceName == this.dicResidenceData[strId].Name)
                 {
                     //浣忓畢鍚嶅瓧宸茬粡瀛樺湪

--
Gitblit v1.8.0