From c1de48884fa145a16a0f8bcee93274dcfaa0ff82 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 07 五月 2020 10:40:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into dev-2020xm

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs |  114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 114 insertions(+), 0 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs
new file mode 100755
index 0000000..997240b
--- /dev/null
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlResidenceLogic.cs
@@ -0,0 +1,114 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Shared.Phone.UserCenter
+{
+    /// <summary>
+    /// 浣忓畢瀵硅薄鐨勯�昏緫
+    /// </summary>
+    public class HdlResidenceLogic
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 浣忓畢瀵硅薄鐨勯�昏緫
+        /// </summary>
+        private static HdlResidenceLogic m_Current = null;
+        /// <summary>
+        /// 浣忓畢瀵硅薄鐨勯�昏緫
+        /// </summary>
+        public static HdlResidenceLogic Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    m_Current = new HdlResidenceLogic();
+                }
+                return m_Current;
+            }
+        }
+
+        #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>
+        /// 鑾峰彇妤煎眰鍚嶇О
+        /// </summary>
+        /// <param name="i_FloorId">妤煎眰ID</param>
+        /// <returns></returns>
+        public string GetFloorNameById(string i_FloorId)
+        {
+            return Common.Config.Instance.Home.GetFloorNameById(i_FloorId);
+        }
+
+        #endregion
+    }
+}

--
Gitblit v1.8.0