| | |
| | | public Scene() |
| | | { |
| | | sid = NewSid(); |
| | | if (!string.IsNullOrEmpty(DB_ResidenceData.residenceData.HomeGateway.gatewayId)) |
| | | if (!DB_ResidenceData.Instance.CheckWhetherGatewayIdIsNull()) |
| | | { |
| | | gatewayId = DB_ResidenceData.residenceData.HomeGateway.gatewayId; |
| | | gatewayId = DB_ResidenceData.Instance.HomeGateway.gatewayId; |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | string roomNameList = ""; |
| | | foreach (var roomId in roomIds) |
| | | { |
| | | var findRoom = DB_ResidenceData.residenceData.Rooms.Find(obj => obj.roomId == roomId); |
| | | var findRoom = SpatialInfo.CurrentSpatial.RoomList.Find(obj => obj.roomId == roomId); |
| | | if (findRoom == null) |
| | | { |
| | | continue; |
| | |
| | | Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | MainPage.Log($"Save Scene Data : {savePath}"); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 修改场景 |
| | | /// </summary> |
| | | public string UpdateScene() |
| | | { |
| | | var pm = new HttpServerRequest(); |
| | | var revPack = pm.EditScene(this); |
| | | if (revPack.Code == StateCode.SUCCESS) |
| | | { |
| | | var scenes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Scene>>(revPack.Data.ToString()); |
| | | var tempScene = scenes.Find((obj) => obj.sid == sid); |
| | | if (tempScene != null) |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(tempScene)); |
| | | Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | } |
| | | } |
| | | return revPack.Code; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加场景 |
| | | /// </summary> |
| | | public string AddScene() |
| | | { |
| | | var pm = new HttpServerRequest(); |
| | | var revPack = pm.AddScene(this); |
| | | if (revPack.Code == StateCode.SUCCESS) |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); |
| | | Common.FileUtlis.Files.WriteFileByBytes(savePath, ssd); |
| | | } |
| | | return revPack.Code; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// 本地对应的功能 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public Function localFunction { |
| | | public Function localFunction |
| | | { |
| | | get |
| | | { |
| | | if(_localFunction == null) |
| | | if (_localFunction == null) |
| | | { |
| | | _localFunction = ConvertFunctionObject(); |
| | | } |
| | |
| | | /// <returns></returns> |
| | | Function ConvertFunctionObject() |
| | | { |
| | | var localFunction = DB_ResidenceData.functionList.GetAllDeviceFunctionList().Find((obj) => obj.sid == sid); |
| | | foreach (var s in status) |
| | | { |
| | | localFunction.attributes.Add(new FunctionAttributes() { key = s.key, curValue = s.value, value = new List<string>() { s.value } }); |
| | | } |
| | | var localFunction = FunctionList.List.GetDeviceFunctionList().Find((obj) => obj.sid == sid); |
| | | return localFunction; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | /// <summary> |