WJC
2020-04-02 94e4e5b9fd3da964c44b7b14227d6fe2bbb426d7
ZigbeeApp/Shared/Common/House.cs
@@ -46,12 +46,20 @@
        /// <summary>
        /// 仅子账号登陆的时候使用,当【IsOthreShare】为"true",并且【AccountType】为"1"时,该账号拥有管理员权限
        /// </summary>
        public int AccountType;
        public int AccountType;
        /// <summary>
        /// 经度
        /// </summary>
        public double Longitude = 0;
        /// <summary>
        /// 纬度
        /// </summary>
        public double Latitude = 0;
        /// <summary>
        /// 房间路径列表
        /// 房间列表(房间的ID)
        /// </summary>
        public List<string> RoomFilePathList = new List<string> { };
        public List<string> ListRooms = new List<string>();
        /// <summary>
        /// 楼层字典
@@ -60,9 +68,9 @@
        /// </summary>
        public Dictionary<string,string> FloorDics = new Dictionary<string,string> { };
        /// <summary>
        /// 当前楼层
        /// 当前楼层Id
        /// </summary>
        public string CurrentFloorId;
        public string CurrentFloorId = string.Empty;
        /// <summary>
        /// 全局场景路径列表---备用
@@ -227,8 +235,6 @@
        /// </summary>
        public static async System.Threading.Tasks.Task<List<string>> GetHomeLists()
        {
            //清空当前住宅列表
            Config.Instance.HomeFilePathList.Clear();
            var pageSetting = new SendDataToServer.ResidenceListPageSettingObj()
            {
                PageSize = CommonPage.PageSize
@@ -258,7 +264,7 @@
                    if (responseDataObj.TotalCount == 0)
                    {
                        //当住宅为空时先提示用户新建住宅
                        var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.CurrentlyTheUserIshHouseIsEmptyPleaseBuildANewHouseFirst), Language.StringByID(R.MyInternationalizationString.Close), Language.StringByID(R.MyInternationalizationString.OK));
                        var alert = new Alert(Language.StringByID(R.MyInternationalizationString.TIP), Language.StringByID(R.MyInternationalizationString.CurrentlyTheUserIshHouseIsEmptyPleaseBuildANewHouseFirst), Language.StringByID(R.MyInternationalizationString.Close), Language.StringByID(R.MyInternationalizationString.Confrim));
                        alert.Show();
                        alert.ResultEventHandler += (sender, e) =>
                        {
@@ -270,6 +276,8 @@
                    }
                    else
                    {
                        //清空当前住宅列表
                        Config.Instance.HomeFilePathList.Clear();
                        if (Config.Instance.HomeId == string.Empty && responseDataObj.PageData.Count > 0)
                        {
                            //赋一个初始值
@@ -287,7 +295,9 @@
                                    Name = residence.Name,
                                    IsOthreShare = residence.IsOthreShare,
                                    AccountType = residence.AccountType,
                                    MainUserDistributedMark = residence.MainUserDistributedMark
                                    MainUserDistributedMark = residence.MainUserDistributedMark,
                                    Longitude = residence.Longitude,
                                    Latitude = residence.Latitude
                                };
                            }
                            else
@@ -296,10 +306,12 @@
                                house.Name = residence.Name;
                                house.IsOthreShare = residence.IsOthreShare;
                                house.AccountType = residence.AccountType;
                                house.MainUserDistributedMark = residence.MainUserDistributedMark;
                                house.MainUserDistributedMark = residence.MainUserDistributedMark;
                                house.Longitude = residence.Longitude;
                                house.Latitude = residence.Latitude;
                            }
                            Global.CreateHomeDirectory(residence.Id);
                            house.Save();
                            house.Save(false);
                        }
                        //匹配当前住宅
                        if (Config.Instance.HomeFilePathList.Find((obj) => obj == $"House_{Config.Instance.HomeId}.json") == null)
@@ -307,11 +319,6 @@
                            Config.Instance.HomeId = GetHouseIdByFilePath(Config.Instance.HomeFilePathList[0]);
                        }
                        Config.Instance.Save();
                        //检测住宅对象
                        if (Config.Instance.Home.Id == string.Empty)
                        {
                            Config.Instance.Home = House.GetHouseByHouseId(Config.Instance.HomeId);
                        }
                    }
                }
            }
@@ -437,6 +444,22 @@
            return null;
        }
        /// <summary>
        /// 设置当前楼层的ID
        /// </summary>
        public void SetCurrentFloorId()
        {
            if (Config.Instance.Home.FloorDics.Count > 0 && string.IsNullOrEmpty(CurrentFloorId))
            {
                foreach (var floor in Config.Instance.Home.FloorDics)
                {
                    CurrentFloorId = floor.Key;
                    Save(false);
                    return;
                }
            }
        }
        #endregion
        #region ◆ 房间____________________________
@@ -444,19 +467,17 @@
        #region ◆ 添加房间路径_________________________
        /// <summary>
        /// 添加【房间路径】到房间路径列表
        /// 添加房间ID
        /// </summary>
        /// <returns><c>true</c>, if room list file path was added, <c>false</c> otherwise.</returns>
        /// <param name="roomFilePath">Room file path.</param>
        public bool AddRoomListFilePath(string roomFilePath)
        public void AddRoomId(string roomId)
        {
            if (RoomFilePathList.Contains(roomFilePath))
            {
                return false;
            if (ListRooms.Contains(roomId) == false)
            {
                ListRooms.Add(roomId);
                this.Save();
            }
            RoomFilePathList.Add(roomFilePath);
            Save();
            return true;
        }
        #endregion
@@ -464,19 +485,17 @@
        #region ◆ 删除房间路径_________________________
        /// <summary>
        /// 移除房间路径
        /// 移除房间Id
        /// </summary>
        /// <returns><c>true</c>, if room list file path was added, <c>false</c> otherwise.</returns>
        /// <param name="roomFilePath">Room file path.</param>
        public bool RemoveRoomListFilePath(string roomFilePath)
        public void RemoveRoomId(string roomId)
        {
            if (!RoomFilePathList.Contains(roomFilePath))
            {
                return false;
            if (ListRooms.Contains(roomId)==true)
            {
                ListRooms.Remove(roomId);
                Save();
            }
            RoomFilePathList.Remove(roomFilePath);
            Save();
            return true;
        }
        #endregion