From 05ce435c3b58e53eeab04c672affdeeab75f3036 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 15 十一月 2019 14:41:39 +0800
Subject: [PATCH] 2019.11.15-1

---
 ZigbeeApp/Shared/Common/House.cs |   80 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 74 insertions(+), 6 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/House.cs b/ZigbeeApp/Shared/Common/House.cs
index 8b7f693..d78cfa6 100644
--- a/ZigbeeApp/Shared/Common/House.cs
+++ b/ZigbeeApp/Shared/Common/House.cs
@@ -46,12 +46,31 @@
         /// <summary>
         /// 浠呭瓙璐﹀彿鐧婚檰鐨勬椂鍊欎娇鐢�,褰撱�怚sOthreShare銆戜负"true"锛屽苟涓斻�怉ccountType銆戜负"1"鏃讹紝璇ヨ处鍙锋嫢鏈夌鐞嗗憳鏉冮檺
         /// </summary>
-        public int AccountType;
+        public int AccountType;
+        /// <summary>
+        /// 缁忓害
+        /// </summary>
+        public double Longitude = 0;
+        /// <summary>
+        /// 绾害
+        /// </summary>
+        public double Latitude = 0;
 
         /// <summary>
         /// 鎴块棿璺緞鍒楄〃
         /// </summary>
         public List<string> RoomFilePathList = new List<string> { };
+
+        /// <summary>
+        /// 妤煎眰瀛楀吀
+        /// key:FloorId
+        /// value:FloorName
+        /// </summary>
+        public Dictionary<string,string> FloorDics = new Dictionary<string,string> { };
+        /// <summary>
+        /// 褰撳墠妤煎眰
+        /// </summary>
+        public string CurrentFloorId;
 
         /// <summary>
         /// 鍏ㄥ眬鍦烘櫙璺緞鍒楄〃---澶囩敤
@@ -170,6 +189,7 @@
             }
             home.Name = houseName;
             home.Save();
+            Config.Instance.Save();
         }
 
         #endregion
@@ -234,9 +254,6 @@
             };
             try
             {
-                //澶嶅師绠$悊鍛樻爣璇�(鑾峰彇浣忓畢鏃讹紝浣跨敤浠栧師鏉ヨ嚜宸辩殑Token)
-                Common.Config.Instance.isAdministrator = false;
-
                 var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj);
                 var revertObj = await CommonPage.Instance.RequestHttpsZigbeeAsync("App/GetHomePager", System.Text.Encoding.UTF8.GetBytes(requestJson));
                 if (revertObj == null)
@@ -261,6 +278,11 @@
                     }
                     else
                     {
+                        if (Config.Instance.HomeId == string.Empty && responseDataObj.PageData.Count > 0)
+                        {
+                            //璧嬩竴涓垵濮嬪��
+                            Config.Instance.HomeId = responseDataObj.PageData[0].Id;
+                        }
                         foreach (var residence in responseDataObj.PageData)
                         {
                             Config.Instance.HomeFilePathList.Add($"House_{residence.Id}.json");
@@ -273,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
@@ -282,7 +306,9 @@
                                 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();
@@ -382,6 +408,44 @@
 
         #endregion
 
+        #region 鈼� 妤煎眰____________________________
+
+        /// <summary>
+        /// GetCurrentFloorName
+        /// </summary>
+        /// <returns></returns>
+        public string GetCurrentFloorName
+        {
+            get
+            {
+                return GetFloorNameById(CurrentFloorId);
+            }
+        }
+
+        /// <summary>
+        /// 鑾峰彇妤煎眰鍚嶇О
+        /// </summary>
+        /// <param name="floorId"></param>
+        /// <returns></returns>
+        public string GetFloorNameById(string floorId)
+        {
+            if (Config.Instance.Home.FloorDics.Count == 0)
+            {
+                return null;
+            }
+
+            foreach (var floor in Config.Instance.Home.FloorDics)
+            {
+                if (floorId == floor.Key)
+                {
+                    return floor.Value;
+                }
+            }
+            return null;
+        }
+
+        #endregion
+
         #region 鈼� 鎴块棿____________________________
 
         #region 鈼� 娣诲姞鎴块棿璺緞_________________________
@@ -442,6 +506,10 @@
             }
             path = System.IO.Path.Combine(path, FileName);
             Shared.IO.FileUtils.WriteFileByBytes(path, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)));
+            if (autoBackup == true && Id == Config.Instance.HomeId)
+            {
+                HdlAutoBackupLogic.AddOrEditorFile(FileName);
+            }
         }
         #endregion
     }

--
Gitblit v1.8.0