From f2c1e5bf3a67478076fb5bbcf546824b3127db15 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期六, 12 十二月 2020 19:11:40 +0800
Subject: [PATCH] Merge branch 'NewFilePath' into CJL
---
HDL_ON/Entity/DB_ResidenceData.cs | 123 ++++++++++++-----------------------------
1 files changed, 36 insertions(+), 87 deletions(-)
diff --git a/HDL_ON/Entity/DB_ResidenceData.cs b/HDL_ON/Entity/DB_ResidenceData.cs
index f733b0e..4cdf89b 100644
--- a/HDL_ON/Entity/DB_ResidenceData.cs
+++ b/HDL_ON/Entity/DB_ResidenceData.cs
@@ -25,18 +25,18 @@
{
if (MainPage.NoLoginMode)
{
- return new RegionInfoRes() { Name = "鏈湴妯″紡" };
+ return new RegionInfoRes() { Name = "鏈湴妯″紡" , };
}
else
{
- var curRegion = UserInfo.Current.regionList.Find((obj) => obj.RegionID == CurReginID);
+ var curRegion = UserInfo.Current.regionList.Find((obj) => obj.RegionID == UserInfo.Current.CurReginID);
if (curRegion == null)
{
if (UserInfo.Current.regionList != null && UserInfo.Current.regionList.Count > 0)
{
- CurReginID = UserInfo.Current.regionList[0].RegionID;
+ UserInfo.Current.CurReginID = UserInfo.Current.regionList[0].RegionID;
//鎭㈠澶囦唤
- HDLCommon.Current.RestoreHomeBackup(CurReginID);
+ //HDLCommon.Current.RestoreHomeBackup(CurReginID);
return UserInfo.Current.regionList[0];
}
@@ -45,12 +45,6 @@
return new RegionInfoRes();
}
}
-
- //if (curRegion == null)
- //{
- // CurReginID = UserInfo.Current.regionList[0].RegionID;
- // return UserInfo.Current.regionList[0];
- //}
return curRegion;
}
}
@@ -87,10 +81,6 @@
// }
//}
/// <summary>
- /// 褰撳墠閫夋嫨鐨勪綇瀹呯储寮�
- /// </summary>
- public string CurReginID = "";
- /// <summary>
/// 鍔熻兘绫诲瀷鍒楄〃
/// </summary>
public List<ShowFunction> functionTypeList = new List<ShowFunction>();
@@ -104,7 +94,7 @@
{
try
{
- var residenceDataBytes = FileUtils.ReadFile("DB_ResidenceData");
+ var residenceDataBytes = Common.FileUtlis.Files.ReadFile("DB_ResidenceData");
var userConfigString = System.Text.Encoding.UTF8.GetString(residenceDataBytes);
DB_ResidenceData temp = null;
@@ -133,31 +123,12 @@
});
instance.SaveResidenceData();
}
-
- new Light()
- {
- sid = "030101123456780202010005ABCD",
- name = "鐏厜1",
- attributes = new List<FunctionAttributes>() {
- new FunctionAttributes { key="on_off", max=100,min = 0, value= new List<string> { "on","off"} },
- },
- roomIds = new List<string>() { "0001" },
- bus_Data = new BusData
- {
- addresses = "2A06",
- loopId = 1,
- },
- }.SaveFunctionData();
-
-
-
-
-
-
}
catch (Exception ex)
{
MainPage.Log($"浣忓畢鏁版嵁鍒濆鍖栧け璐ワ細{ex.Message}");
+ instance = new DB_ResidenceData { };
+ return instance;
}
instance.residenceImage = "Classification/Room/Roombg.png";
//鍒濆鍖栦綇瀹呭姛鑳芥暟鎹�
@@ -173,9 +144,10 @@
public void EixtAccount()
{
instance = null;
- Rooms = null;
ins_OidList = null;
- functionList = null;
+ HomeGateway = null;
+ SpatialInfo.CurrentSpatial.ClearRooms();
+ FunctionList.List.Clear();
if (MainPage.IsRemote)
{
DAL.Mqtt.MqttClient.DisConnectRemote("閫�鍑虹櫥褰曪紝鎴栬�呭垏鎹綇瀹�");
@@ -210,6 +182,24 @@
}
}
}
+
+ /// <summary>
+ /// 妫�娴嬩綇瀹呮槸鍚︾粦瀹氫簡缃戝叧
+ /// gatewayId 鍒ょ┖
+ /// </summary>
+ /// <returns></returns>
+ public bool CheckWhetherGatewayIdIsNull()
+ {
+ if (HomeGateway != null && !string.IsNullOrEmpty(HomeGateway.gatewayId))
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
/// <summary>
/// 妫�娴嬩綇瀹呮槸鍚︾粦瀹氫簡缃戝叧
/// </summary>
@@ -272,8 +262,7 @@
if (this == null || this.residecenInfo == null)
return;
var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
- FileUtils.WriteFileByBytes("DB_ResidenceData", ssd);
- MainPage.Log("Save DB_ResidenceData");
+ Common.FileUtlis.Files.WriteFileByBytes("DB_ResidenceData", ssd);
}
/// <summary>
@@ -281,51 +270,11 @@
/// </summary>
public string CurFoor = Language.StringByID(StringId.All);
- /// <summary>
- /// 鎴块棿鍒楄〃
- /// </summary>
- public List<Room> Rooms = SpatialInfo.CurrentSpatial.RoomList;
-
- #region 鍔熻兘鏁版嵁
- public static FunctionList functionList = FunctionList.List;
-
- /// <summary>
- /// 鍒锋柊浣忓畢閲岄潰鐨勬悳绱㈣澶囩姸鎬�
- /// </summary>
- public void RefreshResidenceFunctionStatus()
- {
- new Thread(() =>
- {
- try
- {
- foreach (var function in functionList.GetAllDeviceFunctionList())
- {
- Thread.Sleep(100);
- switch (function.functionCategory)
- {
- case FunctionCategory.Light:
- case FunctionCategory.Electrical:
- case FunctionCategory.SwitchDevice:
- case FunctionCategory.Curtain:
- case FunctionCategory.Thermostat:
- if (DB_ResidenceData.residenceData.GatewayType == 0)
- {
- DriverLayer.Control.Ins.SendReadCommand(function);
- }
- break;
- }
- }
- }
- catch (Exception ex)
- {
- MainPage.Log($"Refresh Residence Function Status Error : {ex.Message}");
- }
- })
- { IsBackground = true }.Start();
- }
-
-
- #endregion
+ ///// <summary>
+ ///// 鎴块棿鍒楄〃
+ ///// </summary>
+ //[Newtonsoft.Json.JsonIgnore]
+ //public List<Room> Rooms = SpatialInfo.CurrentSpatial.RoomList;
#region oid鍒楄〃 a鍗忚杞琤us鍗忚鎺у埗浣跨敤
/// <summary>
@@ -340,7 +289,7 @@
{
if (ins_OidList == null)
{
- var bytes = FileUtils.ReadFile(OidSavePathName);
+ var bytes = Common.FileUtlis.Files.ReadFile(OidSavePathName);
if (bytes == null || bytes.Length == 0)
{
ins_OidList = new List<FunctionOid>();
@@ -376,7 +325,7 @@
{
var oidBytes = System.Text.Encoding.UTF8.GetBytes(oidJsonString);
- FileUtils.WriteFileByBytes(OidSavePathName, oidBytes);
+ Common.FileUtlis.Files.WriteFileByBytes(OidSavePathName, oidBytes);
}
#endregion
--
Gitblit v1.8.0