using System;
using System.Collections.Generic;
using HDL_ON.DAL;
namespace HDL_ON.Entity
{
public class DB_ResidenceData
{
public DB_ResidenceData()
{
}
///
/// 住宅名称
///
public string residenceName;
///
/// 住宅图片
///
public string residenceImage;
///
/// 房间列表
///
public List rooms = new List();
///
/// 功能列表
///
public List functions = new List();
///
/// 场景列表
///
public List scenes = new List();
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(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() { "0001" },
lastState = "制冷 中风 18°C"
});
r.functions.Add(new Function()
{
sid = "000000000000000000000000000000000002",
funcType = FunctionType.Light,
Name = "客厅灯",
roomIdList = new List() { "0001" },
lastState = "打开20%亮度"
});
r.functions.Add(new Function()
{
sid = "000000000000000000000000000000000003",
funcType = FunctionType.Curtain,
Name = "窗帘",
roomIdList = new List() { "0001" },
lastState = "打开20%"
});
r.functions.Add(new Function()
{
sid = "000000000000000000000000000000000004",
funcType = FunctionType.FloorHeating,
Name = "地热",
roomIdList = new List() { "0001" },
lastState = ""
});
//--------------------
instance.functions.Add(new Function()
{
sid = "000000000000000000000000000000000001",
funcType = FunctionType.AC,
Name = "空调",
roomIdList = new List() { "0001" },
lastState = "制冷 中风 18°C"
});
instance.functions.Add(new Function()
{
sid = "000000000000000000000000000000000002",
funcType = FunctionType.Light,
Name = "客厅灯",
roomIdList = new List() { "0001" },
lastState = "打开20%亮度"
});
instance.functions.Add(new Function()
{
sid = "000000000000000000000000000000000003",
funcType = FunctionType.Curtain,
Name = "窗帘",
roomIdList = new List() { "0001" },
lastState = "打开20%"
});
instance.functions.Add(new Function()
{
sid = "000000000000000000000000000000000004",
funcType = FunctionType.FloorHeating,
Name = "地热",
roomIdList = new List() { "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);
}
}
}