| | |
| | | var floorsDataString = System.Text.Encoding.UTF8.GetString(floorsDataBytes); |
| | | MainPage.Log(floorsDataString); |
| | | floors = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SpatialInfo>>(floorsDataString); |
| | | if (floors == null) |
| | | { |
| | | floors = new List<SpatialInfo>(); |
| | | } |
| | | } |
| | | if (floors == null) |
| | | { |
| | | floors = new List<SpatialInfo>(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | if (floor.SaveFloorData() == StateCode.SUCCESS) |
| | | { |
| | | FloorList.Add(floor); |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(FloorList)); |
| | | FileUtils.WriteFileByBytes(dataSavePath, ssd); |
| | | MainPage.Log($"Save floor Data"); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | /// <param name="floor"></param> |
| | | public void UpdateFloor() |
| | | { |
| | | SaveFloorData(); |
| | | if(SaveFloorData() == StateCode.SUCCESS) |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(FloorList)); |
| | | FileUtils.WriteFileByBytes(dataSavePath, ssd); |
| | | MainPage.Log($"Save floor Data"); |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 删除楼层 |
| | |
| | | var code = pm.DeleteRoom(new List<string>() { floor.roomId }).Code; |
| | | if (code == StateCode.SUCCESS) |
| | | { |
| | | var tRoom = FloorList.Find((obj) => obj.uid == floor.uid); |
| | | var tRoom = FloorList.Find((obj) => obj.roomId == floor.roomId); |
| | | if (tRoom != null) |
| | | { |
| | | FloorList.Remove(floor); |
| | |
| | | var pack = SaveSpatialInfo(); |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(FloorList)); |
| | | FileUtils.WriteFileByBytes(dataSavePath, ssd); |
| | | MainPage.Log($"Save floor Data"); |
| | | } |
| | | else |
| | | { |
| | |
| | | var pack = pm.DeleteRoom(new List<string>() { room.roomId }); |
| | | if (pack.Code == StateCode.SUCCESS) |
| | | { |
| | | var tRoom = RoomList.Find((obj) => obj.uid == room.uid); |
| | | var tRoom = RoomList.Find((obj) => obj.roomId == room.roomId); |
| | | if (tRoom != null) |
| | | { |
| | | RoomList.Remove(room); |
| | |
| | | { |
| | | var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this)); |
| | | FileUtils.WriteFileByBytes(dataSavePath, ssd); |
| | | MainPage.Log($"Save Room Data {roomName} : {uid}"); |
| | | MainPage.Log($"Save Room Data {dataSavePath}"); |
| | | } |
| | | return packCode; |
| | | } |
| | |
| | | { |
| | | get |
| | | { |
| | | if (FloorList.Count > 0) |
| | | if (CurrentSpatial.FloorList.Count > 0) |
| | | { |
| | | var f = FloorList.Find((obj) => obj.uid == parentId); |
| | | var f = CurrentSpatial.FloorList.Find((obj) => obj.uid == parentId); |
| | | if (f != null) |
| | | { |
| | | return f.roomName + " "; |
| | | } |
| | | else |
| | | { |
| | | foreach(var f1 in CurrentSpatial.FloorList) |
| | | { |
| | | if(f1.uid == parentId) |
| | | { |
| | | return f.roomName + " "; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return ""; |
| | |
| | | { |
| | | foreach (var f in DB_ResidenceData.functionList.GetAllFunction()) |
| | | { |
| | | if (f.roomIds.Contains(uid) && uid != null) |
| | | if (f.roomIds.Contains(roomId) && roomId != null) |
| | | { |
| | | functions.Add(f); |
| | | } |
| | |
| | | { |
| | | foreach (var s in DB_ResidenceData.functionList.scenes) |
| | | { |
| | | if (s.roomIds.Contains(uid) && uid != null) |
| | | if (s.roomIds.Contains(roomId) && roomId != null) |
| | | { |
| | | scenes.Add(s); |
| | | } |