黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/Residence/ResidenceManagementForm.cs
@@ -659,44 +659,53 @@
            //开启进度条
            this.ShowProgressBar();
            var result = HdlResidenceLogic.Current.DeleteCloundHouse(Common.Config.Instance.Home.Id);
            if (result == false)
            if (Common.Config.Instance.Home.IsOtherShare == false)
            {
                //关闭进度条
                this.CloseProgressBar();
                return;
            }
            //因为删除的是当前的住宅,所以需要先切换到别的住宅
            string deleteId = Common.Config.Instance.Home.Id;
            string deleteFile = Common.Config.Instance.Home.FileName;
            int index = 0;
            for (; index < Common.Config.Instance.HomeFilePathList.Count; index++)
            {
                //当前住宅所处的位置(住宅数肯定大于1,不然不会出现删除按钮)
                if (Common.Config.Instance.HomeFilePathList[index] != deleteFile)
                //删除主人自己的住宅
                var result = HdlResidenceLogic.Current.DeleteCloundHouse(Common.Config.Instance.Home.Id);
                if (result == false)
                {
                    break;
                    //关闭进度条
                    this.CloseProgressBar();
                    return;
                }
            }
            else
            {
                //删除分享的住宅,使用主人的Token,把自己删了
                var result = HdlMemberLogic.Current.DeleteMember(Common.Config.Instance.Guid);
                if (result == false)
                {
                    //关闭进度条
                    this.CloseProgressBar();
                    return;
                }
            }
            var myHouse = HdlResidenceLogic.Current.GetHouseByFilePath(Common.Config.Instance.HomeFilePathList[index]);
            //因为删除的是当前的住宅,所以需要先切换到别的住宅
            var listLocalHouse = HdlResidenceLogic.Current.GetAllLocalResidenceListByDirectory();
            //取一个住宅id
            string houseId = string.Empty;
            foreach (var myHouse in listLocalHouse)
            {
                houseId = myHouse.Id;
                if (houseId != Common.Config.Instance.Home.Id)
                {
                    //随便取一个和当前住宅不相等的ID
                    break;
                }
            }
            //当前住宅ID
            string nowHouseId = Common.Config.Instance.Home.Id;
            //切换住宅
            Common.Config.Instance.HomeId = myHouse.Id;
            Common.Config.Instance.Home = myHouse;
            Common.Global.CreateHomeDirectory(myHouse.Id);
            Common.Config.Instance.Save();
            //刷新个人中心的内存及线程
            bool result2 = HdlUserCenterLogic.Current.InitUserCenterMenmoryAndThread(false);
            bool result2 = HdlResidenceLogic.Current.SwitchResidence(houseId);
            //删掉这个文件夹
            HdlResidenceLogic.Current.DeleteHouseMemmory(nowHouseId);
            if (result2 == false)
            {
                //开启了调试功能
                return;
            }
            //删除住宅
            HdlResidenceLogic.Current.DeleteHouseMemmory(deleteId);
            HdlThreadLogic.Current.RunMain(() =>
            {
@@ -778,16 +787,21 @@
        /// <param name="addresName">位置名称</param>
        private void SaveResidenceAdrress(NormalViewControl btnLocation, double latitude, double longitude, string addresName)
        {
            //开启进度条
            this.ShowProgressBar();
            //保存经纬度
            var result = HdlResidenceLogic.Current.EditorResidenceLongitudeAndLatitude(latitude, longitude, addresName);
            this.CloseProgressBar();
            if (result == false)
            //如果不是虚拟住宅,才更新云端
            if (Common.Config.Instance.Home.IsVirtually == false)
            {
                return;
                //开启进度条
                this.ShowProgressBar();
                var result = HdlResidenceLogic.Current.EditorResidenceLongitudeAndLatitude(latitude, longitude, addresName);
                if (result == false)
                {
                    //关闭进度条
                    this.CloseProgressBar();
                    return;
                }
                //关闭进度条
                this.CloseProgressBar();
            }
            HdlThreadLogic.Current.RunMain(() =>
            {