using System; using System.Collections.Generic; using Shared.Phone.UserCenter; namespace Shared.Common { /// /// 住宅文件 /// [System.Serializable] public class House { #region ◆ 变量____________________________ /// /// 住宅文件 /// /// The file path. [Newtonsoft.Json.JsonIgnore] public string FileName { get { return $"House_{Id}.json"; } } /// /// 住宅id--使用云端提供的住宅唯一Id /// public string Id = string.Empty; /// /// 住宅名称 /// public string Name = string.Empty; /// /// 是否为其他主用户分享过来的住宅 /// public bool IsOthreShare; /// /// 当前住宅是其他主帐号分享过来的主帐号的分布式Id /// public string MainUserDistributedMark; /// /// 该住宅是否是虚拟的,true的话代表网关和设备都是虚拟的(默认为false) /// public bool IsVirtually = false; /// /// 仅子账号登陆的时候使用,当【IsOthreShare】为"true",并且【AccountType】为"1"时,该账号拥有管理员权限 /// public int AccountType; /// /// 经度 /// public double Longitude = 0; /// /// 纬度 /// public double Latitude = 0; /// /// 住宅所在的地理位置的名称 /// public string ResidenceAddressName = string.Empty; /// /// 楼层字典 /// key:FloorId /// value:FloorName /// public Dictionary FloorDics = new Dictionary { }; #endregion #region ◆ 楼层____________________________ /// /// GetCurrentFloorName /// /// [Newtonsoft.Json.JsonIgnore] public string GetCurrentFloorName { get { return HdlResidenceLogic.Current.GetFloorNameById(CurrentFloorId); } } /// /// 当前楼层ID /// [Newtonsoft.Json.JsonIgnore] public string CurrentFloorId = string.Empty; #endregion #region ◆ 保存____________________________ /// /// 保存 /// /// 是否备份 public void Save(bool autoBackup = true) { var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, Config.Instance.Guid, Id); //如果没有存在住宅目录,先创建 if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } path = System.IO.Path.Combine(path, FileName); HdlFileLogic.Current.SaveFileContent(path, this); if (autoBackup == true && Id == Config.Instance.HomeId) { HdlAutoBackupLogic.AddOrEditorFile(FileName); } } #endregion } }