using System;
|
using System.Collections.Generic;
|
using HDL_ON.DAL;
|
|
namespace HDL_ON.Entity
|
{
|
public class DB_ResidenceData
|
{
|
public DB_ResidenceData()
|
{
|
}
|
/// <summary>
|
/// 住宅名称
|
/// </summary>
|
public string residenceName;
|
/// <summary>
|
/// 住宅图片
|
/// </summary>
|
public string residenceImage;
|
/// <summary>
|
/// 房间列表
|
/// </summary>
|
public List<Room> rooms = new List<Room>();
|
/// <summary>
|
/// 功能列表
|
/// </summary>
|
public List<Function> functions = new List<Function>();
|
/// <summary>
|
/// 场景列表
|
/// </summary>
|
public List<Scene> scenes = new List<Scene>();
|
|
static DB_ResidenceData instance;
|
public static DB_ResidenceData residenceData
|
{
|
get
|
{
|
if (instance == null)
|
{
|
try
|
{
|
var residenceDataBytes = MyIO.FileUtils.ReadFile("DB_ResidenceData");
|
var userConfigString = CommonPage.MyEncodingUTF8.GetString(residenceDataBytes);
|
DB_ResidenceData temp = null;
|
if (userConfigString != null)
|
{
|
temp = Newtonsoft.Json.JsonConvert.DeserializeObject<DB_ResidenceData>(userConfigString);
|
}
|
if (temp == null)
|
{
|
instance = new DB_ResidenceData { };
|
}
|
else
|
{
|
instance = temp;
|
}
|
}
|
catch { }
|
#if DEBUG
|
instance.residenceName = "妮儿的家";
|
instance.residenceImage = "Classification/Room/Roombg.png";
|
var r = new Room() { sid = "0001", name = "Room-1", floor = "1F", backgroundImage = "Classification/Room/Roombg.png" };
|
r.functions.Add(new Function()
|
{
|
sid = "000000000000000000000000000000000001",
|
funcType = FunctionType.AC,
|
Name = "空调",
|
roomIdList = new List<string>() { "0001" },
|
lastState = "制冷 中风 18°C"
|
});
|
r.functions.Add(new Function()
|
{
|
sid = "000000000000000000000000000000000002",
|
funcType = FunctionType.Light,
|
Name = "客厅灯",
|
roomIdList = new List<string>() { "0001" },
|
lastState = "打开20%亮度"
|
});
|
r.functions.Add(new Function()
|
{
|
sid = "000000000000000000000000000000000003",
|
funcType = FunctionType.Curtain,
|
Name = "窗帘",
|
roomIdList = new List<string>() { "0001" },
|
lastState = "打开20%"
|
});
|
r.functions.Add(new Function()
|
{
|
sid = "000000000000000000000000000000000004",
|
funcType = FunctionType.FloorHeating,
|
Name = "地热",
|
roomIdList = new List<string>() { "0001" },
|
lastState = ""
|
});
|
|
//--------------------
|
instance.functions.Add(new Function()
|
{
|
sid = "000000000000000000000000000000000001",
|
funcType = FunctionType.AC,
|
Name = "空调",
|
roomIdList = new List<string>() { "0001" },
|
lastState = "制冷 中风 18°C"
|
});
|
instance.functions.Add(new Function()
|
{
|
sid = "000000000000000000000000000000000002",
|
funcType = FunctionType.Light,
|
Name = "客厅灯",
|
roomIdList = new List<string>() { "0001" },
|
lastState = "打开20%亮度"
|
});
|
instance.functions.Add(new Function()
|
{
|
sid = "000000000000000000000000000000000003",
|
funcType = FunctionType.Curtain,
|
Name = "窗帘",
|
roomIdList = new List<string>() { "0001" },
|
lastState = "打开20%"
|
});
|
instance.functions.Add(new Function()
|
{
|
sid = "000000000000000000000000000000000004",
|
funcType = FunctionType.FloorHeating,
|
Name = "地热",
|
roomIdList = new List<string>() { "0001" },
|
lastState = ""
|
});
|
|
instance.rooms.Add(r);
|
#endif
|
}
|
return instance;
|
}
|
}
|
|
public void SaveResidenceData()
|
{
|
var ssd = CommonPage.MyEncodingUTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
|
MyIO.FileUtils.WriteFileByBytes("DB_ResidenceData", ssd);
|
}
|
}
|
}
|