From 38ab16c66df6fc523f2c385fd583a2f2e86a781c Mon Sep 17 00:00:00 2001
From: 陈嘉乐 <cjl@hdlchina.com.cn>
Date: 星期三, 29 四月 2020 17:58:45 +0800
Subject: [PATCH] 2020-4-29-1

---
 ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs |  418 +++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 331 insertions(+), 87 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
index 393b9e2..0dd08fd 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceListForm.cs
@@ -16,9 +16,13 @@
         /// </summary>
         private VerticalListControl listView = null;
         /// <summary>
-        /// 浣忓畢鏁版嵁
+        /// 浣忓畢鏁版嵁(鏈夌綉鏃朵娇鐢�)
         /// </summary>
         private Dictionary<string, Common.ResponseEntity.ResidenceObj> dicResidenceData = null;
+        /// <summary>
+        /// 浣忓畢鏁版嵁(鏃犵綉鏃朵娇鐢�)
+        /// </summary>
+        private List<House> listLocalHouse = null;
         /// <summary>
         /// 浣忓畢椤哄簭
         /// </summary>
@@ -36,16 +40,20 @@
             //璁剧疆鏍囬淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.ResidenceManagement));
 
-            //鍙充笂娣诲姞鎸夐挳
-            var btnTopIcon = new MostRightIconControl(69, 69);
-            btnTopIcon.UnSelectedImagePath = "Item/Add.png";
-            topFrameLayout.AddChidren(btnTopIcon);
-            btnTopIcon.InitControl();
-            btnTopIcon.ButtonClickEvent += (sender, e) =>
+            //铏氭嫙浣忓畢鏃犳硶鏂板缓浣忓畢
+            if (Common.Config.Instance.Home.IsVirtually == false)
             {
-                //鏄剧ず娣诲姞浣忓畢鍚嶇О鐨勭敾闈�
-                this.ShowAddNameForm();
-            };
+                //鍙充笂娣诲姞鎸夐挳
+                var btnTopIcon = new MostRightIconControl(69, 69);
+                btnTopIcon.UnSelectedImagePath = "Item/Add.png";
+                topFrameLayout.AddChidren(btnTopIcon);
+                btnTopIcon.InitControl();
+                btnTopIcon.ButtonClickEvent += (sender, e) =>
+                {
+                    //鏄剧ず娣诲姞浣忓畢鍚嶇О鐨勭敾闈�
+                    this.ShowAddNameForm();
+                };
+            }
 
             //鍒濆鍖栦腑閮ㄦ帶浠�
             this.InitMiddleFrame();
@@ -64,7 +72,6 @@
             if (strData != null)
             {
                 listResidenceSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData);
-                strData = null;
             }
 
             listView = new VerticalListControl(29);
@@ -72,37 +79,68 @@
             listView.BackgroundColor = UserCenterColor.Current.White;
             bodyFrameLayout.AddChidren(listView);
 
-            HdlThreadLogic.Current.RunThread(() =>
+            //璁剧疆浣忓畢淇℃伅
+            this.SetResidenceInfo(1);
+        }
+
+        /// <summary>
+        /// 璁剧疆浣忓畢淇℃伅(1:鍏堣鍙栦簯绔�,鏃犳硶鑱旂綉,鍐嶈鍙栨湰鍦�  2:鍙浜戠  3:鍙鏈湴)
+        /// </summary>
+        /// <param name="div">1:鍏堣鍙栦簯绔�,鏃犳硶鑱旂綉,鍐嶈鍙栨湰鍦�  2:鍙浜戠  3:鍙鏈湴</param>
+        private void SetResidenceInfo(int div)
+        {
+            HdlThreadLogic.Current.RunThread(async () =>
             {
-                //璁剧疆浣忓畢淇℃伅
-                this.SetResidenceInfo();
+                //铏氭嫙浣忓畢鐨勮瘽,鍙鏈湴
+                if (div == 3 || Config.Instance.Home.IsVirtually == true)
+                {
+                    //鍙鏈湴
+                    this.SetResidenceInfoByOffline();
+                }
+                else
+                {
+                    //寮�鍚繘搴︽潯
+                    this.ShowProgressBar();
+                    //璁剧疆浣忓畢淇℃伅(鏈夌綉鎯呭喌)
+                    var result = await this.SetResidenceInfoByOnline();
+                    if (result == true)
+                    {
+                        //浜戠璇诲彇鎴愬姛
+                        this.CloseProgressBar();
+                        return;
+                    }
+                    if (div == 2)
+                    {
+                        //濡傛灉鍙浜戠 鍏抽棴杩涘害鏉�
+                        this.CloseProgressBar(ShowReLoadMode.YES);
+                        return;
+                    }
+                    //濡傛灉鍦ㄦ病缃戠殑鎯呭喌涓�,浠庢枃浠跺す璺緞涓幏鍙栧叏閮ㄤ綇瀹�,鐒跺悗鏄剧ず
+                    this.SetResidenceInfoByOffline();
+
+                    //鍏抽棴杩涘害鏉�
+                    this.CloseProgressBar();
+                }
             });
         }
 
         #endregion
 
-        #region 鈻� 璁剧疆浣忓畢淇℃伅_______________________
+        #region 鈻� 璁剧疆浣忓畢淇℃伅(鏈夌綉鎯呭喌)_____________
 
         /// <summary>
-        /// 璁剧疆浣忓畢淇℃伅
+        /// 璁剧疆浣忓畢淇℃伅(鏈夌綉鎯呭喌)
         /// </summary>
-        private async void SetResidenceInfo()
+        private async System.Threading.Tasks.Task<bool> SetResidenceInfoByOnline()
         {
-            //寮�鍚繘搴︽潯
-            this.ShowProgressBar();
-
             //鑾峰彇浣忓畢淇℃伅
             var Pra = new GetResidenceInfoPra();
-            string resultData = await UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomePager", false, Pra);
+            var listNotCheck = new List<string>() { "NotSetAgain" };
+            string resultData = await UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomePager", false, Pra, listNotCheck);
             if (resultData == null)
             {
-                //鍏抽棴杩涘害鏉�
-                this.CloseProgressBar(ShowReLoadMode.YES);
-                return;
+                return false;
             }
-            //鍏抽棴杩涘害鏉�
-            this.CloseProgressBar();
-
             var pageData = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.ResponseEntity.ResidenceRes>(resultData);
 
             //鏆傛椂瀛樺偍鏁版嵁
@@ -135,7 +173,7 @@
                 {
                     return;
                 }
-                listView.Height = bodyFrameLayout.Height + Application.GetRealHeight(6);
+                listView.Height = bodyFrameLayout.Height;
 
                 this.dicResidenceData = new Dictionary<string, Common.ResponseEntity.ResidenceObj>();
                 for (int i = 0; i < listResidenceSort.Count; i++)
@@ -148,22 +186,20 @@
 
                     //鏀堕泦璇ヨ处鍙蜂綇瀹呯殑鏁版嵁
                     this.dicResidenceData[info.Id] = info;
-                    this.AddRowLayout(info, i != listResidenceSort.Count - 1);
+                    //娣诲姞浣忓畢鐨勮(鏈夌綉鎯呭喌)
+                    this.AddRowLayoutByOnline(info, i != listResidenceSort.Count - 1);
                 }
                 //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
                 this.listView.AdjustRealHeight(Application.GetRealHeight(23));
             });
+            return true;
         }
 
-        #endregion
-
-        #region 鈻� 娣诲姞浣忓畢鐨勮_______________________
-
         /// <summary>
-        /// 娣诲姞浣忓畢鐨勮
+        /// 娣诲姞浣忓畢鐨勮(鏈夌綉鎯呭喌)
         /// </summary>
         /// <param name="info"></param>
-        private void AddRowLayout(Common.ResponseEntity.ResidenceObj info, bool addLine)
+        private void AddRowLayoutByOnline(Common.ResponseEntity.ResidenceObj info, bool addLine)
         {
             var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
             this.listView.AddChidren(rowLayout);
@@ -216,6 +252,7 @@
                     {
                         HdlThreadLogic.Current.RunThread(async () =>
                         {
+                            //寮�鍚繘搴︽潯
                             this.ShowProgressBar();
 
                             //妫�娴嬫湰鍦版湁娌℃湁杩欎釜浣忓畢
@@ -228,13 +265,13 @@
                             //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
                             await UserCenterLogic.InitUserCenterMenmoryAndThread(false);
 
-                            HdlRoomLogic.Current.InitAllRoom();
-
                             HdlThreadLogic.Current.RunMain(() =>
                             {
                                 //閲嶆柊鍒锋柊鍒楄〃
                                 this.listView.RemoveAll();
-                                this.SetResidenceInfo();
+                                this.SetResidenceInfo(2);
+                                //鍏抽棴杩涘害鏉�
+                                this.CloseProgressBar();
                             });
                         });
                     });
@@ -259,7 +296,132 @@
             btnChanged.ButtonClickEvent += (sender, e) =>
             {
                 //鏄剧ず缂栬緫鍚嶇О鐣岄潰
-                this.ShowEditorNameForm(info, btnHome);
+                this.ShowEditorNameForm(info, null, btnHome);
+            };
+        }
+
+        #endregion
+
+        #region 鈻� 璁剧疆浣忓畢淇℃伅(鏃犵綉鎯呭喌)_____________
+
+        /// <summary>
+        /// 璁剧疆浣忓畢淇℃伅(鏃犵綉鎯呭喌)
+        /// </summary>
+        private void SetResidenceInfoByOffline()
+        {
+            //浠庢枃浠跺す涓幏鍙栧叏閮ㄧ殑浣忓畢瀵硅薄
+            this.listLocalHouse = HdlResidenceLogic.Current.GetAllLocalResidenceListByDirectory();
+            if (listLocalHouse.Count == 0)
+            {
+                return;
+            }
+
+            HdlThreadLogic.Current.RunMain(() =>
+            {
+                listView.Height = bodyFrameLayout.Height;
+
+                for (int i = 0; i < listLocalHouse.Count; i++)
+                {
+                    //娣诲姞浣忓畢鐨勮(鏃犵綉鎯呭喌)
+                    this.AddRowLayoutByOffline(listLocalHouse[i], i != listLocalHouse.Count - 1);
+                }
+                //璋冩暣鍒楄〃鎺т欢鐨勯珮搴�
+                this.listView.AdjustRealHeight(Application.GetRealHeight(23));
+            });
+        }
+
+        /// <summary>
+        /// 娣诲姞浣忓畢鐨勮(鏃犵綉鎯呭喌)
+        /// </summary>
+        /// <param name="i_home"></param>
+        private void AddRowLayoutByOffline(House i_home, bool addLine)
+        {
+            var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
+            this.listView.AddChidren(rowLayout);
+
+            //鍥炬爣
+            var btnIcon = rowLayout.frameTable.AddLeftIcon(81);
+            btnIcon.UnSelectedImagePath = "Item/ResidenceIcon.png";
+            //褰撳墠浣忓畢
+            NormalViewControl btnHome = null;
+            if (i_home.Id == Config.Instance.Home.Id)
+            {
+                //浣忓畢鍚嶇О
+                btnHome = rowLayout.frameTable.AddLeftCaption(i_home.Name, 800, 60, true);
+                btnHome.TextSize = 15;
+                btnHome.Y = Application.GetRealHeight(12) + rowLayout.chidrenYaxis;
+                rowLayout.frameTable.AddChidren(btnHome, ChidrenBindMode.BindEventOnly);
+
+                //褰撳墠浣忓畢
+                var btnNowView = rowLayout.frameTable.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uNowResidence), 800, 49, true);
+                btnNowView.Y = Application.GetRealHeight(72) + rowLayout.chidrenYaxis;
+                btnNowView.TextSize = 12;
+                btnNowView.TextColor = UserCenterColor.Current.TextGrayColor1;
+                rowLayout.frameTable.AddChidren(btnNowView, ChidrenBindMode.BindEventOnly);
+            }
+            else
+            {
+                //浣忓畢鍚嶇О
+                btnHome = rowLayout.frameTable.AddLeftCaption(i_home.Name, 800, true);
+                btnHome.TextSize = 15;
+            }
+            //鍙崇澶�
+            rowLayout.frameTable.AddRightArrow();
+            if (addLine == true)
+            {
+                //搴曠嚎
+                rowLayout.frameTable.AddBottomLine();
+            }
+
+            rowLayout.frameTable.ButtonClickEvent += (sender, e) =>
+            {
+                if (i_home.Id != Config.Instance.Home.Id)
+                {
+                    //纭鍒囨崲褰撳墠浣忓畢鍒般�屻��?
+                    string msg = Language.StringByID(R.MyInternationalizationString.uSwitchResidenceMsg);
+                    if (msg.Contains("{0}") == true)
+                    {
+                        msg = string.Format(msg, i_home.Name);
+                    }
+                    this.ShowMassage(ShowMsgType.Confirm, msg, () =>
+                    {
+                        HdlThreadLogic.Current.RunThread(async () =>
+                        {
+                            this.ShowProgressBar();
+
+                            Config.Instance.HomeId = i_home.Id;
+                            //閲嶆柊鍒濆鍖栦綇瀹呭璞�
+                            Config.Instance.Home = House.GetHouseByHouseId(i_home.Id);
+                            Config.Instance.Save();
+                            //鍒锋柊涓汉涓績鐨勫唴瀛樺強绾跨▼
+                            await UserCenterLogic.InitUserCenterMenmoryAndThread(false);
+
+                            HdlThreadLogic.Current.RunMain(() =>
+                            {
+                                //閲嶆柊鍒锋柊鍒楄〃
+                                this.listView.RemoveAll();
+                                this.SetResidenceInfo(3);
+                                //鍏抽棴杩涘害鏉�
+                                this.CloseProgressBar();
+                            });
+                        });
+                    });
+                }
+                else
+                {
+                    //妫�娴嬭兘鍚﹀垹闄や綇瀹�
+                    bool flage = this.CheckIsCanDeleteResidence(i_home);
+                    var form = new ResidenceManagementForm();
+                    form.AddForm(flage);
+                }
+            };
+            //鏇存敼
+            var btnChanged = rowLayout.AddEditorControl();
+            btnChanged.TextID = R.MyInternationalizationString.uChanged1;
+            btnChanged.ButtonClickEvent += (sender, e) =>
+            {
+                //鏄剧ず缂栬緫鍚嶇О鐣岄潰
+                this.ShowEditorNameForm(null, i_home, btnHome);
             };
         }
 
@@ -270,16 +432,18 @@
         /// <summary>
         /// 鏄剧ず缂栬緫浣忓畢鍚嶇О鐣岄潰
         /// </summary>
-        /// <param name="info"></param>
-        private void ShowEditorNameForm(Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
+        /// <param name="info">鏈夌綉鏃朵娇鐢�</param>
+        /// <param name="i_house">鏃犵綉鏃堕�傜敤</param>
+        private void ShowEditorNameForm(Common.ResponseEntity.ResidenceObj info, House i_house, NormalViewControl btnHome)
         {
+            string oldName = info != null ? info.Name : i_house.Name;
             //鐢熸垚涓�涓脊绐楃敾闈�
             var dialogForm = new DialogInputControl();
             //缂栬緫浣忓畢
             dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uChangedName));
             //璇疯緭鍏ヤ綇瀹呭悕绉�
             dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInputResidenceName));
-            dialogForm.Text = info.Name;
+            dialogForm.Text = oldName;
 
             //鎸変笅纭鎸夐挳
             dialogForm.ComfirmClickEvent += ((textValue) =>
@@ -293,11 +457,25 @@
                 }
                 //鐢婚潰鍏抽棴
                 dialogForm.CloseDialog();
-
-                if (info.Name != textValue)
+                if (oldName != textValue)
                 {
-                    //缂栬緫浜戠鐨勪綇瀹呭悕绉�
-                    this.EditorResidenceName(textValue, info);
+                    if (info != null)
+                    {
+                        //缂栬緫浜戠鐨勪綇瀹呭悕绉�
+                        this.EditorResidenceName(textValue, info, btnHome);
+                    }
+                    else
+                    {
+                        //鐩存帴缂栬緫浣忓畢缂撳瓨
+                        if (this.CheckIsCanSaveResidence(i_house.Id, textValue, true) == false)
+                        {
+                            return;
+                        }
+                        //鍒锋柊鍐呭瓨鐨勪綇瀹呭悕
+                        House.EditorHouseByHouseId(i_house.Id, textValue);
+                        //鏇存敼鏄剧ず鐨勫悕瀛�
+                        btnHome.Text = textValue;
+                    }
                 }
             });
         }
@@ -308,7 +486,7 @@
         /// <param name="ResidenceName"></param>
         /// <param name="info"></param>
         /// <returns></returns>
-        private async void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info)
+        private async void EditorResidenceName(string ResidenceName, Common.ResponseEntity.ResidenceObj info, NormalViewControl btnHome)
         {
             //妫�娴嬭兘鍚︿繚瀛樹綇瀹�
             if (this.CheckIsCanSaveResidence(info.Id, ResidenceName, true) == false)
@@ -321,23 +499,21 @@
             var Pra = new EditorResidencePra();
             Pra.HomeId = info.Id;
             Pra.Name = ResidenceName;
-            if (info.IsOthreShare == true)
-            {
-                Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
-            }
+            Pra.IsOtherAccountCtrl = false;
+            Pra.LoginAccessToken = Config.Instance.Token;
+
             //缂栬緫浣忓畢
-            bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", info.IsOthreShare, Pra);
-            if (flage == false)
+            bool flage = await UserCenterLogic.GetResultStatuByRequestHttps("App/EditHome", false, Pra);
+            //鍏抽棴杩涘害鏉�
+            this.CloseProgressBar();
+
+            if (flage == true)
             {
-                //鍏抽棴杩涘害鏉�
-                this.CloseProgressBar();
-                return;
+                //鍒锋柊鍐呭瓨鐨勪綇瀹呭悕
+                House.EditorHouseByHouseId(info.Id, ResidenceName);
+                //鏇存敼鏄剧ず鐨勫悕瀛�
+                btnHome.Text = ResidenceName;
             }
-            //鍒锋柊鍐呭瓨鐨勪綇瀹呭悕
-            House.EditorHouseByHouseId(info.Id, ResidenceName);
-            //閲嶆柊鍒锋柊鍒楄〃
-            this.listView.RemoveAll();
-            this.SetResidenceInfo();
         }
 
         #endregion
@@ -404,7 +580,7 @@
             House.AddHouse(newInfo[0].Id, ResidenceName, 0);
             //閲嶆柊鍒锋柊鍒楄〃
             this.listView.RemoveAll();
-            this.SetResidenceInfo();
+            this.SetResidenceInfo(2);
         }
 
         #endregion
@@ -442,7 +618,7 @@
         }
 
         /// <summary>
-        /// 妫�娴嬭兘鍚﹀垹闄や綇瀹�
+        /// 妫�娴嬭兘鍚﹀垹闄や綇瀹�(鏈夌綉浣跨敤)
         /// </summary>
         /// <param name="info"></param>
         /// <returns></returns>
@@ -468,6 +644,36 @@
         }
 
         /// <summary>
+        /// 妫�娴嬭兘鍚﹀垹闄や綇瀹�(鏃犵綉浣跨敤)
+        /// </summary>
+        /// <param name="info"></param>
+        /// <returns></returns>
+        private bool CheckIsCanDeleteResidence(House i_house)
+        {
+            if (i_house.IsVirtually == false)
+            {
+                //闈炶櫄鎷熶綇瀹呴兘涓嶅厑璁稿垹闄�,鍙湁鍦ㄨ兘鑱旂綉鐨勬椂鍊�,鎵嶈兘鍒犻櫎
+                return false;
+            }
+
+            int myCount = 0;
+            foreach (var data in this.listLocalHouse)
+            {
+                if (data.IsVirtually == true)
+                {
+                    myCount++;
+                }
+            }
+            //濡傛灉姝よ处鍙蜂笅鍙墿涓嬪敮涓�涓�涓櫄鎷熺殑浣忓畢锛屽垯涓嶈兘鍐嶅垹闄�
+            if (myCount == 1)
+            {
+                return false;
+            }
+
+            return true;
+        }
+
+        /// <summary>
         /// 妫�娴嬭兘鍚︿繚瀛樹綇瀹�
         /// </summary>
         /// <param name="residenceId">浣忓畢ID</param>
@@ -476,21 +682,43 @@
         /// <returns></returns>
         private bool CheckIsCanSaveResidence(string residenceId, string residenceName, bool isEditor)
         {
-            //浣忓畢鍚嶅瓧閲嶅妫�娴�
-            foreach (string strId in this.dicResidenceData.Keys)
+            if (this.dicResidenceData != null)
             {
-                if (this.dicResidenceData[strId].IsOthreShare == true)
+                //浣忓畢鍚嶅瓧閲嶅妫�娴�
+                foreach (string strId in this.dicResidenceData.Keys)
                 {
-                    //鍒嗕韩鐨勪綇瀹呬笉鑰冭檻
-                    continue;
+                    if (this.dicResidenceData[strId].IsOthreShare == true)
+                    {
+                        //鍒嗕韩鐨勪綇瀹呬笉鑰冭檻
+                        continue;
+                    }
+                    if (residenceId != strId && residenceName == this.dicResidenceData[strId].Name)
+                    {
+                        //浣忓畢鍚嶅瓧宸茬粡瀛樺湪
+                        int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
+                        string msg = Language.StringByID(msgId);
+                        this.ShowMassage(ShowMsgType.Error, msg);
+                        return false;
+                    }
                 }
-                if (residenceId != strId && residenceName == this.dicResidenceData[strId].Name)
+            }
+            else
+            {
+                foreach (var myHouse in this.listLocalHouse)
                 {
-                    //浣忓畢鍚嶅瓧宸茬粡瀛樺湪
-                    int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
-                    string msg = Language.StringByID(msgId);
-                    this.ShowMassage(ShowMsgType.Error, msg);
-                    return false;
+                    if (myHouse.IsOthreShare == true)
+                    {
+                        //鍒嗕韩鐨勪綇瀹呬笉鑰冭檻
+                        continue;
+                    }
+                    if (residenceId != myHouse.Id && residenceName == myHouse.Name)
+                    {
+                        //浣忓畢鍚嶅瓧宸茬粡瀛樺湪
+                        int msgId = isEditor == true ? R.MyInternationalizationString.EditZigbeeHome_Exist : R.MyInternationalizationString.AddZigbeeHome_Exist;
+                        string msg = Language.StringByID(msgId);
+                        this.ShowMassage(ShowMsgType.Error, msg);
+                        return false;
+                    }
                 }
             }
             return true;
@@ -505,22 +733,38 @@
         /// </summary>
         public override int FormActionAgainEvent()
         {
-            foreach (string keys in dicResidenceData.Keys)
+            if (dicResidenceData != null)
             {
-                if (Config.Instance.HomeFilePathList.Contains($"House_{keys}.json") == false)
+                foreach (string keys in dicResidenceData.Keys)
                 {
-                    //淇濆瓨椤哄簭
-                    listResidenceSort.Remove(keys);
-                    HdlRoomLogic.Current.SaveFloorSort(listResidenceSort);
-
-                    this.listView.RemoveAll();
-                    //鏁版嵁宸茬粡鍙樻洿
-                    HdlThreadLogic.Current.RunThread(() =>
+                    if (Config.Instance.HomeFilePathList.Contains($"House_{keys}.json") == false)
                     {
-                        //閲嶆柊璁剧疆浣忓畢淇℃伅
-                        this.SetResidenceInfo();
-                    });
-                    break;
+                        //淇濆瓨椤哄簭
+                        listResidenceSort.Remove(keys);
+                        HdlRoomLogic.Current.SaveFloorSort(listResidenceSort);
+
+                        this.listView.RemoveAll();
+                        //鏁版嵁宸茬粡鍙樻洿 閲嶆柊璁剧疆浣忓畢淇℃伅
+                        this.SetResidenceInfo(2);
+                        break;
+                    }
+                }
+            }
+            else
+            {
+                //妫�娴嬭繕鏈夎繖涓綇瀹呮枃浠跺悧
+                var strPath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid);
+                foreach (var myHouse in this.listLocalHouse)
+                {
+                    string fullName = System.IO.Path.Combine(strPath, myHouse.FileName);
+                    //濡傛灉涓嶅瓨鍦ㄤ簡鐨勮瘽
+                    if (System.IO.File.Exists(fullName) == false)
+                    {
+                        //鏁版嵁宸茬粡鍙樻洿 閲嶆柊璁剧疆浣忓畢淇℃伅
+                        this.listView.RemoveAll();
+                        this.SetResidenceInfo(3);
+                        return 1;
+                    }
                 }
             }
             return 1;

--
Gitblit v1.8.0