From 21736b2944d5e88cd705a39ff87fd73d5a16e609 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期六, 09 五月 2020 11:06:35 +0800
Subject: [PATCH] 安川
---
ZigbeeApp/Shared/Common/House.cs | 180 +++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 124 insertions(+), 56 deletions(-)
diff --git a/ZigbeeApp/Shared/Common/House.cs b/ZigbeeApp/Shared/Common/House.cs
index 29609c6..dbb051f 100755
--- a/ZigbeeApp/Shared/Common/House.cs
+++ b/ZigbeeApp/Shared/Common/House.cs
@@ -23,17 +23,14 @@
return $"House_{Id}.json";
}
}
-
/// <summary>
/// 浣忓畢id--浣跨敤浜戠鎻愪緵鐨勪綇瀹呭敮涓�Id
/// </summary>
public string Id = string.Empty;
-
/// <summary>
/// 浣忓畢鍚嶇О
/// </summary>
public string Name = string.Empty;
-
/// <summary>
/// 鏄惁涓哄叾浠栦富鐢ㄦ埛鍒嗕韩杩囨潵鐨勪綇瀹�
/// </summary>
@@ -42,37 +39,40 @@
/// 褰撳墠浣忓畢鏄叾浠栦富甯愬彿鍒嗕韩杩囨潵鐨勪富甯愬彿鐨勫垎甯冨紡Id
/// </summary>
public string MainUserDistributedMark;
-
+ /// <summary>
+ /// 璇ヤ綇瀹呮槸鍚︽槸铏氭嫙鐨�,true鐨勮瘽浠h〃缃戝叧鍜岃澶囬兘鏄櫄鎷熺殑(榛樿涓篺alse)
+ /// </summary>
+ public bool IsVirtually = false;
/// <summary>
/// 浠呭瓙璐﹀彿鐧婚檰鐨勬椂鍊欎娇鐢�,褰撱�怚sOthreShare銆戜负"true"锛屽苟涓斻�怉ccountType銆戜负"1"鏃讹紝璇ヨ处鍙锋嫢鏈夌鐞嗗憳鏉冮檺
/// </summary>
- public int AccountType;
-
- /// <summary>
- /// 鎴块棿璺緞鍒楄〃
+ public int AccountType;
+ /// <summary>
+ /// 缁忓害
+ /// </summary>
+ public double Longitude = 0;
+ /// <summary>
+ /// 绾害
+ /// </summary>
+ public double Latitude = 0;
+ /// <summary>
+ /// 浣忓畢鎵�鍦ㄧ殑鍦扮悊浣嶇疆鐨勫悕绉�
/// </summary>
- public List<string> RoomFilePathList = new List<string> { };
-
+ public string ResidenceAddressName = string.Empty;
/// <summary>
- /// 鍏ㄥ眬鍦烘櫙璺緞鍒楄〃---澶囩敤
+ /// 鎴块棿鍒楄〃(鎴块棿鐨処D)
/// </summary>
- public List<string> SceneFilePathList = new List<string> { };
+ public List<string> ListRooms = new List<string>();
/// <summary>
- /// 璁惧璺緞鍒楄〃---澶囩敤
+ /// 妤煎眰瀛楀吀
+ /// key:FloorId
+ /// value:FloorName
/// </summary>
- public List<string> DeviceFilePathList = new List<string> { };
+ public Dictionary<string,string> FloorDics = new Dictionary<string,string> { };
/// <summary>
- /// 鍔熻兘璺緞鍒楄〃---澶囩敤
+ /// 褰撳墠妤煎眰Id
/// </summary>
- public List<string> FunctionFilePathList = new List<string> { };
- /// <summary>
- /// 閫氱敤鏍囪瘑--澶囩敤
- /// </summary>
- public object Tag;
- /// <summary>
- /// 鏈熴�佹爧銆佸眰绛夊尯鍩�---澶囩敤
- /// </summary>
- public Dictionary<string, string> LocationInfoList = new Dictionary<string, string> { };
+ public string CurrentFloorId = string.Empty;
#endregion
@@ -163,6 +163,10 @@
/// <param name="houseName">House name.</param>
public static void EditorHouseByHouseId(string houseId, string houseName)
{
+ if (Config.Instance.Home.Id == houseId)
+ {
+ Config.Instance.Home.Name = houseName;
+ }
var home = GetHouseByHouseId(houseId);
if (home == null)
{
@@ -215,8 +219,6 @@
/// </summary>
public static async System.Threading.Tasks.Task<List<string>> GetHomeLists()
{
- //娓呯┖褰撳墠浣忓畢鍒楄〃
- Config.Instance.HomeFilePathList.Clear();
var pageSetting = new SendDataToServer.ResidenceListPageSettingObj()
{
PageSize = CommonPage.PageSize
@@ -246,18 +248,14 @@
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) =>
- {
- if (e)
- {
- //
- }
- };
}
else
{
+ //娓呯┖褰撳墠浣忓畢鍒楄〃
+ Config.Instance.HomeFilePathList.Clear();
+ var listHouse = new List<House>();
foreach (var residence in responseDataObj.PageData)
{
Config.Instance.HomeFilePathList.Add($"House_{residence.Id}.json");
@@ -270,7 +268,9 @@
Name = residence.Name,
IsOthreShare = residence.IsOthreShare,
AccountType = residence.AccountType,
- MainUserDistributedMark = residence.MainUserDistributedMark
+ MainUserDistributedMark = residence.MainUserDistributedMark,
+ Longitude = residence.Longitude,
+ Latitude = residence.Latitude
};
}
else
@@ -279,15 +279,29 @@
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);
+ listHouse.Add(house);
}
- //鍖归厤褰撳墠浣忓畢
- if (Config.Instance.HomeFilePathList.Find((obj) => obj == $"House_{Config.Instance.HomeId}.json") == null)
+ //濡傛灉鍒囨崲浜嗚处鍙�,鎴栬�呭師鏉ョ殑id涓嶅瓨鍦�,鍒欓噸缃綇瀹匢D
+ if (Config.Instance.TheSameLoginAccount == false ||
+ Config.Instance.HomeFilePathList.Find((obj) => obj == $"House_{Config.Instance.HomeId}.json") == null)
{
- Config.Instance.HomeId = GetHouseIdByFilePath(Config.Instance.HomeFilePathList[0]);
+ Config.Instance.HomeId = listHouse[0].Id;
+ foreach (var house in listHouse)
+ {
+ //鍒濆閫夋嫨瀹冭嚜宸辩殑浣忓畢
+ if (house.IsOthreShare == false)
+ {
+ Config.Instance.HomeId = house.Id;
+ Config.Instance.Home = House.GetHouseByHouseId(house.Id);
+ break;
+ }
+ }
}
Config.Instance.Save();
}
@@ -379,24 +393,76 @@
#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 string.Empty;
+ }
+
+ foreach (var floor in Config.Instance.Home.FloorDics)
+ {
+ if (floorId == floor.Key)
+ {
+ return floor.Value;
+ }
+ }
+ return string.Empty;
+ }
+
+ /// <summary>
+ /// 璁剧疆褰撳墠妤煎眰鐨処D
+ /// </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 鈼� 鎴块棿____________________________
#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
@@ -404,19 +470,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
@@ -439,6 +503,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