黄学彪
2020-04-28 e22fdb94322e6cec38e5e4a9aec13d431a133fde
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs
@@ -32,6 +32,71 @@
        #endregion
        #region ■ 获取本地住宅列表___________________
        /// <summary>
        /// 获取本地住宅列表
        /// </summary>
        /// <returns></returns>
        public List<Common.House> GetLocalResidenceList()
        {
            //如果是虚拟住宅,则从根目录中获取
            if (Common.Config.Instance.Home.IsVirtually == true)
            {
                //从文件夹中获取全部的住宅对象
                return this.GetAllLocalResidenceListByDirectory();
            }
            var listHome = new List<Common.House>();
            foreach (var housePath in Common.Config.Instance.HomeFilePathList)
            {
                var home = Common.House.GetHouseByFilePath(housePath);
                if (home == null)
                {
                    continue;
                }
                listHome.Add(home);
            }
            return listHome;
        }
        /// <summary>
        /// 从文件夹中获取全部的住宅对象
        /// </summary>
        /// <returns></returns>
        public List<Common.House> GetAllLocalResidenceListByDirectory()
        {
            var strPath = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Common.Config.Instance.Guid);
            var listHome = new List<Common.House>();
            //获取全部的文件夹
            var listDirectory = new List<string>();
            var arryDirs = System.IO.Directory.GetDirectories(strPath);
            foreach (var file in arryDirs)
            {
                string[] arry = file.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                listDirectory.Add(arry[arry.Length - 1]);
            }
            foreach (var myDir in listDirectory)
            {
                //获取各个文件夹里面的住宅文件
                string nowPath = System.IO.Path.Combine(strPath, myDir);
                var arryHouse = System.IO.Directory.GetFiles(nowPath, "House_*");
                if (arryHouse.Length > 0)
                {
                    //读取文件内容
                    var textValue = UserCenterLogic.LoadFileContent(System.IO.Path.Combine(nowPath, arryHouse[0]));
                    if (textValue != null)
                    {
                        var myHouse = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.House>(textValue);
                        listHome.Add(myHouse);
                    }
                }
            }
            return listHome;
        }
        #endregion
        #region ■ 一般方法___________________________
        /// <summary>