old mode 100755
new mode 100644
| | |
| | | {
|
| | | if (m_CurrentRoom == null && Lists.Count > 0)
|
| | | {
|
| | | if (m_CurrentRoom == null) { m_CurrentRoom = Lists[0]; }
|
| | | return Lists[0];
|
| | | }
|
| | | return m_CurrentRoom;
|
| | |
| | | var sceneList = new List<SceneUI> { }; |
| | | foreach (var r in Shared.Common.Room.Lists) |
| | | { |
| | | if(r.IsLove) |
| | | { |
| | | continue; |
| | | } |
| | | if (r.SceneUIList.Count == 0) |
| | | { |
| | | continue; |
| | |
| | | var pathList = new List<string> { }; |
| | | foreach (var r in Lists) |
| | | { |
| | | if(r.IsLove) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | if (r.SceneUIFilePathList.Count == 0) |
| | | { |
| | | continue; |
| | |
| | | for (int i = 0; i < Lists.Count; i++) |
| | | {
|
| | | var room = Lists[i]; |
| | | if (room.IsSharedRoom) |
| | | if (room.IsSharedRoom || room.IsLove) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | Config.Instance.Home.InitFloor(); |
| | | |
| | | RefreshRoomListView(); |
| | | CurrentRoom.RefreshRoomListView(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新房间视图列表 |
| | | /// </summary> |
| | | public static void RefreshRoomListView() |
| | | public void RefreshRoomListView() |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | |
| | | /// </summary> |
| | | public static void RefreshAllRoomByLocation()
|
| | | {
|
| | | Lists.Clear();
|
| | | var homeTemp = Config.Instance.Home;
|
| | | homeTemp.RoomFilePathList.Clear();
|
| | |
|
| | |
| | | if (listFile.Contains(fRoom) == true)
|
| | | {
|
| | | listFile.Remove(fRoom);
|
| | | homeTemp.AddRoomListFilePath(fRoom);
|
| | | homeTemp.RoomFilePathList.Add(fRoom);
|
| | | }
|
| | |
|
| | | var listRoomFile = new List<string>();
|
| | |
| | | {
|
| | | if (fileName.StartsWith("Room_"))
|
| | | {
|
| | | homeTemp.AddRoomListFilePath(fileName);
|
| | | homeTemp.RoomFilePathList.Add(fileName);
|
| | | listRoomFile.Add(fileName);
|
| | | }
|
| | | }
|
| | |
| | | } |
| | | Save(); |
| | | HdlAutoBackupLogic.AddOrEditorFile(room.FileName); |
| | | CurrentRoom.RefreshRoomListView(); |
| | | return true; |
| | | } |
| | | |
| | |
| | | Global.DeleteFilebyHomeId(roomFilePath); |
| | | Lists.Remove(room); |
| | | HdlAutoBackupLogic.DeleteFile(roomFilePath); |
| | | |
| | | CurrentRoom.RefreshRoomListView(); |
| | | |
| | | return true; |
| | | } |
| | | |
| | |
| | | //设备(deviceUI) |
| | | beforeRoom.DeviceUIList.Clear(); |
| | | foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList) |
| | | {
|
| | | beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath)); |
| | | { |
| | | var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceFilePath)); |
| | | var tempDeviceUI = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo); |
| | | if (tempDeviceUI != null) |
| | | { |
| | | var delCommon = tempDeviceUIList.Find((obj) => obj.CommonDevice != null && tempDeviceUI.CommonDevice != null && obj.CommonDevice.Type == tempDeviceUI.CommonDevice.Type && obj.CommonDevice.CommonDeviceAddrEpoint == tempDeviceUI.CommonDevice.CommonDeviceAddrEpoint); |
| | | if (delCommon != null) |
| | | { |
| | | beforeRoom.DeviceUIList.Add(delCommon); |
| | | } |
| | | else |
| | | { |
| | | beforeRoom.AddDevice(deviceFilePath); |
| | | } |
| | | } |
| | | } |
| | | //场景(SceneUI) |
| | | beforeRoom.SceneUIList.Clear(); |
| | |
| | | { |
| | | foreach (var r in Lists) |
| | | { |
| | | if(r.IsLove) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var scene in r.SceneUIList) |
| | | { |
| | | if (scene.Id == sceneId) |
| | |
| | | /// <returns></returns> |
| | | public List<Room> GetRoomsByFloorId(string id) |
| | | { |
| | | if (Config.Instance.Home.FloorDics.Count == 0) |
| | | try |
| | | { |
| | | return Lists; |
| | | if (Lists == null || Lists.Count == 0 || Lists.Count == 1) |
| | | { |
| | | return null; |
| | | } |
| | | if (Config.Instance.Home.FloorDics.Count == 0) |
| | | { |
| | | return Lists; |
| | | } |
| | | return Lists.FindAll((obj) => obj.FloorId == id); |
| | | } |
| | | return Lists.FindAll((obj) => obj.FloorId == id); |
| | | catch(Exception ex) |
| | | { |
| | | System.Console.WriteLine(ex.Message); |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 获取当前楼层的房间名称 |
| | |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取房间所在区域 |
| | | /// 楼层,房间名 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public string GetZoneName() |
| | | { |
| | | if (string.IsNullOrEmpty(FloorId)) |
| | | { |
| | | return Name; |
| | | } |
| | | var floorName = Config.Instance.Home.GetFloorNameById(FloorId); |
| | | if (floorName == null) |
| | | { |
| | | return Name; |
| | | } |
| | | return $"{floorName},{Name}"; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 更新房间_________________________ |
| | |
| | | //保存到本地 |
| | | Save(); |
| | | |
| | | //添加自动备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(FileName); |
| | | if (saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1)
|
| | | {
|
| | | //如果只有一个回路,则修改真实物理设备的房间
|
| | |
| | | List<DeviceUI> deviceUIs = new List<DeviceUI> { }; |
| | | var dList = AllRoomDeviceUIList; |
| | | var commonDeviceList = Common.LocalDevice.Current.listAllDevice; |
| | | |
| | | if (dList.Count == 0) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | foreach (var device in commonDeviceList) |
| | | { |
| | | if (dList.Find((obj) => obj.CommonDevice == device) == null) |
| | | if (dList.Find((obj) => obj.CommonDevice.DeviceEpoint == device.DeviceEpoint && obj.CommonDevice.DeviceAddr == device.DeviceAddr) == null) |
| | | { |
| | | deviceUIs.Add(Common.LocalDevice.Current.GetDeviceUI(device)); |
| | | } |
| | |
| | | /// <param name="sceneIconPath">背景图片,不包含住宅路径 如果iconPathType=1或者2 需要拼接住宅 变成 住宅/sceneIconPath</param> |
| | | /// <param name="commons">Commons.</param> |
| | | /// <param name="iconPathType">I场景背景图片来源类型 图片来源 0--本地图库 1--拍照 2--系统图库 默认0</param> |
| | | public async System.Threading.Tasks.Task<int> AddScene(string sceneName, string sceneIconPath, List<ZigBee.Device.Scene.AddSceneMemberData> commons, int iconPathType = 0) |
| | | public async System.Threading.Tasks.Task<int> AddScene(string sceneName, string sceneIconPath, List<ZigBee.Device.Scene.AddSceneMemberData> commons, int iconPathType) |
| | | { |
| | | var scenes = GetSceneUIsByFloorId(FloorId); |
| | | if(scenes!=null && scenes.Count>0) |
| | | { |
| | | if (scenes.Find(s => s.Name == sceneName) != null) |
| | | { |
| | | return -1; |
| | | } |
| | | } |
| | | //var scenes = GetSceneUIsByFloorId(FloorId); |
| | | //if(scenes!=null && scenes.Count>0) |
| | | //{ |
| | | // if (scenes.Find(s => s.Name == sceneName) != null) |
| | | // { |
| | | // return -1; |
| | | // } |
| | | //} |
| | | |
| | | var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName); |
| | | if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null) |
| | |
| | | //加入成功 |
| | | if (result) |
| | | { |
| | | //iconPathType=0 直接传值, iconPathType=1和iconPathType=2需要拼接住宅路径 |
| | | var fullPath = sceneIconPath; |
| | | if (iconPathType == 1 || iconPathType == 2) |
| | | { |
| | | Common.Room.CurrentRoom.MoveBackGroundIamageFileToDirectory(sceneIconPath, $"{Config.Instance.FullPath}/{sceneIconPath}"); |
| | | fullPath = $"{Config.Instance.FullPath}/{sceneIconPath}"; |
| | | } |
| | | var sceneUI = new SceneUI |
| | | { |
| | | Name = sceneName, |
| | | Id = getSceneIdData.NewScenesId, |
| | | IconPath = fullPath, |
| | | IconPath = sceneIconPath, |
| | | IconPathType = iconPathType, |
| | | AddSceneMemberDataList= commons |
| | | }; |
| | | sceneUI.Save(); |
| | | SceneUIList.Add(sceneUI); |
| | | SceneUIFilePathList.Add(sceneUI.FileName); |
| | | sceneUI.Save(); |
| | | Save(); |
| | | HdlAutoBackupLogic.AddOrEditorFile(sceneUI.FileName); |
| | | return 1; |
| | | } |
| | | return 0; |
| | |
| | | /// <param name="scene">Scene.</param> |
| | | public void AddScene(SceneUI scene) |
| | | { |
| | | //var sceneUI = new SceneUI |
| | | //{ |
| | | // Name = scene.Name, |
| | | // Id = scene.Id, |
| | | // IconPath = scene.IconPath, |
| | | // IconPathType = scene.IconPathType, |
| | | // AddSceneMemberDataList = scene.AddSceneMemberDataList |
| | | //}; |
| | | SceneUIList.Add(scene); |
| | | SceneUIFilePathList.Add(scene.FileName); |
| | | scene.Save(); |
| | | Save(); |
| | | } |
| | | |
| | |
| | | /// <param name="scene"></param> |
| | | public void DeleteScene(SceneUI scene) |
| | | { |
| | | //scene.IsCollected = false; |
| | | scene.Save(); |
| | | SceneUIList.Remove(scene); |
| | | SceneUIFilePathList.Remove(scene.FileName); |
| | | var curScene = SceneUIList.Find((obj) => obj.Id == scene.Id); |
| | | if (curScene == null) |
| | | { |
| | | return; |
| | | } |
| | | SceneUIList.Remove(curScene); |
| | | SceneUIFilePathList.Remove(curScene.FileName); |
| | | Save(); |
| | | } |
| | | |
| | |
| | | /// <summary> |
| | | /// 是否是收藏设备 |
| | | /// </summary> |
| | | /// <param name="room"></param> |
| | | /// <param name="filePath"></param> |
| | | /// <returns></returns> |
| | | public bool IsCollectInRoom(Room room,string filePath) |
| | | public bool IsCollectInRoom(string filePath) |
| | | { |
| | | if(room.IsLove) |
| | | { |
| | | return true; |
| | | } |
| | | if (GetLoveRoom().DeviceUIFilePathList.Find((obj) => obj == filePath) == null) |
| | | { |
| | | return false; |
| | |
| | | { |
| | | sceneUI.AddSceneMemberDataList = addCommons; |
| | | sceneUI.Save(); |
| | | if (IsLove == false) |
| | | { |
| | | var curScene = Common.Room.CurrentRoom.GetLoveRoom().SceneUIList.Find((obj) => obj.Id == sceneUI.Id); |
| | | if (curScene != null) |
| | | { |
| | | curScene.Name = sceneUI.Name; |
| | | curScene.IconPath = sceneUI.IconPath; |
| | | curScene.IconPathType = sceneUI.IconPathType; |
| | | curScene.AddSceneMemberDataList = sceneUI.AddSceneMemberDataList; |
| | | curScene.SceneDelayTime = sceneUI.SceneDelayTime; |
| | | curScene.Save(false); |
| | | Common.Room.CurrentRoom.GetLoveRoom().Save(); |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置、同步延时时间 |
| | | /// </summary> |
| | | /// <param name="scene"></param> |
| | | public void ModifySceneDelayTime(SceneUI scene) |
| | | { |
| | | if (IsLove) |
| | | { |
| | | foreach (var r in Lists) |
| | | { |
| | | if (r.IsLove || r.SceneUIList.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var sce in r.SceneUIList) |
| | | { |
| | | if (sce.Id == scene.Id) |
| | | { |
| | | sce.SceneDelayTime = scene.SceneDelayTime; |
| | | sce.Save(false); |
| | | r.Save(false); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var curScene = Common.Room.CurrentRoom.GetLoveRoom().SceneUIList.Find((obj) => obj.Id == scene.Id); |
| | | if (curScene != null) |
| | | { |
| | | curScene.SceneDelayTime = scene.SceneDelayTime; |
| | | curScene.Save(false); |
| | | Common.Room.CurrentRoom.GetLoveRoom().Save(false); |
| | | } |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | |
| | | { |
| | | return; |
| | | } |
| | | SceneUIList.Remove(sceneUI); |
| | | SceneUIFilePathList.Remove(sceneUI.FileName); |
| | | Save(); |
| | | |
| | | if (sceneUI.IconPathType == 1 || sceneUI.IconPathType == 2) |
| | | { |
| | | if (Global.IsExistsByHomeId(sceneUI.IconPath))
|
| | | {
|
| | | Global.DeleteFilebyHomeId(sceneUI.IconPath);
|
| | | HdlAutoBackupLogic.DeleteFile(sceneUI.IconPath);
|
| | | } |
| | | } |
| | | |
| | | if (IsLove == false) |
| | | { |
| | | if (CurrentRoom.GetLoveRoom().SceneUIList.Find((obj) => obj.Id == sceneUI.Id) != null) |
| | |
| | | CurrentRoom.GetLoveRoom().DeleteScene(sceneUI); |
| | | } |
| | | } |
| | | |
| | | SceneUIList.Remove(sceneUI); |
| | | SceneUIFilePathList.Remove(sceneUI.FileName); |
| | | Save(); |
| | | |
| | | Global.DeleteFilebyHomeId(sceneUI.FileName); |
| | | HdlAutoBackupLogic.DeleteFile(sceneUI.FileName); |
| | | } |
| | |
| | | { |
| | | foreach (var r in Lists) |
| | | { |
| | | if (r.IsLove) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var sceneUI in r.SceneUIList) |
| | | { |
| | | if (sceneUI.Id == sceneId) |
| | |
| | | /// </summary> |
| | | public async System.Threading.Tasks.Task<bool> RefreshSceneUIList() |
| | | { |
| | | return false; |
| | | //System.Console.WriteLine($"开始请求网关场景****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); |
| | | //bool result = true; |
| | | //var sceneList = await ZigBee.Device.Scene.GetSceneListAsync(); |
| | | //System.Console.WriteLine($"结束请求网关场景****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); |
| | | //if (sceneList == null) |
| | | //{ |
| | | // return false; |
| | | //} |
| | | //List<int> sceneIDList = new List<int> { }; |
| | | //System.Console.WriteLine($"开始本地场景****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); |
| | | //foreach (var scene in sceneList) |
| | | //{ |
| | | // if (scene == null) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // sceneIDList.Add(scene.ScenesId); |
| | | //} |
| | | //foreach(var r in Lists) |
| | | //{ |
| | | // if(r.SceneUIList==null || r.SceneUIList.Count==0) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // foreach(var rScene in r.SceneUIList) |
| | | // { |
| | | // if(rScene==null) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // //var scene = sceneList.Find((obj) => rScene.ScenesId == obj.ScenesId); |
| | | // if(sceneIDList.Contains(rScene.ScenesId)==false) |
| | | // { |
| | | // var removeResult = r.SceneUIList.Remove(rScene); |
| | | // r.Save(); |
| | | // if (removeResult == false) |
| | | // { |
| | | // result = false; |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | //System.Console.WriteLine($"结束本地场景****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****"); |
| | | //return result; |
| | | bool result = true; |
| | | var sceneList = await ZigBee.Device.Scene.GetSceneListAsync(); |
| | | if (sceneList == null) |
| | | { |
| | | return false; |
| | | } |
| | | List<int> sceneIDList = new List<int> { }; |
| | | foreach (var scene in sceneList) |
| | | { |
| | | if (scene == null) |
| | | { |
| | | continue; |
| | | } |
| | | sceneIDList.Add(scene.ScenesId); |
| | | } |
| | | foreach (var r in Lists) |
| | | { |
| | | if(r.IsLove) |
| | | { |
| | | continue; |
| | | } |
| | | if (r.SceneUIList == null || r.SceneUIList.Count == 0) |
| | | { |
| | | continue; |
| | | } |
| | | foreach (var rScene in r.SceneUIList) |
| | | { |
| | | if (rScene == null) |
| | | { |
| | | continue; |
| | | } |
| | | if (sceneIDList.Contains(rScene.Id) == false) |
| | | { |
| | | r.RemoveScene(rScene); |
| | | result = true; |
| | | } |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | #endregion |