| | |
| | | {
|
| | | //还原设备对象
|
| | | tempRoom.DeviceUIList.Clear();
|
| | | foreach (string uiPath in tempRoom.DeviceUIFilePathList)
|
| | | for (int i = 0; i < tempRoom.DeviceUIFilePathList.Count; i++)
|
| | | {
|
| | | string deviceFile = uiPath.Replace("DeviceUI_", string.Empty);
|
| | | string deviceFile = tempRoom.DeviceUIFilePathList[i];
|
| | | //这个设备文件匹配得到房间
|
| | | listDeviceFile.Remove(deviceFile);
|
| | | if (this.IsFileExists(deviceFile) == false)
|
| | | {
|
| | | //移除掉这个不对劲的路径
|
| | | tempRoom.DeviceUIFilePathList.RemoveAt(i);
|
| | | i--;
|
| | | continue;
|
| | | }
|
| | | tempRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(uiPath));
|
| | | tempRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFile));
|
| | | }
|
| | | //还原场景对象
|
| | | tempRoom.SceneUIList.Clear();
|
| | | foreach (string uiPath in tempRoom.SceneUIFilePathList)
|
| | | for (int i = 0; i < tempRoom.SceneUIFilePathList.Count; i++)
|
| | | {
|
| | | string uiPath = tempRoom.SceneUIFilePathList[i];
|
| | | //这个场景文件匹配得到房间
|
| | | listSceneFile.Remove(uiPath);
|
| | | var byteData = this.GetShardFileContent(uiPath);
|
| | | if (byteData == null)
|
| | | {
|
| | | //移除掉这个不对劲的路径
|
| | | tempRoom.SceneUIFilePathList.RemoveAt(i);
|
| | | i--;
|
| | | continue;
|
| | | }
|
| | | string valueData = System.Text.Encoding.UTF8.GetString(byteData);
|
| | |
| | | //生成文件
|
| | | foreach (string fileName in listDbFile)
|
| | | {
|
| | | var data = this.GetShardFileContent(fileName);
|
| | | Global.WriteFileByBytesByHomeId(fileName, data);
|
| | | var oldPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
|
| | | var newPath = System.IO.Path.Combine(Config.Instance.FullPath, fileName);
|
| | | System.IO.File.Copy(oldPath, newPath, true);
|
| | |
|
| | | if (fileName.StartsWith("Room_") == true)
|
| | | {
|
| | | //房间文件特殊处理
|
| | |
| | | var listLocalFile = Global.FileListByHomeId();
|
| | | foreach (string fileName in listLocalFile)
|
| | | {
|
| | | if (fileName == DirNameResourse.ShardFloorFile)
|
| | | {
|
| | | //楼层文件
|
| | | var varData = Global.ReadFileByHomeId(fileName);
|
| | | var dicFloor = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(Encoding.UTF8.GetString(varData));
|
| | | Common.Config.Instance.Home.FloorDics = dicFloor;
|
| | | Common.Config.Instance.Home.Save(false);
|
| | |
|
| | | Global.DeleteFilebyHomeId(fileName);
|
| | | }
|
| | |
|
| | | if (listShardFile.Contains(fileName) == true)
|
| | | {
|
| | | //本地的这个文件还分享着,没有问题
|
| | | continue;
|
| | | }
|
| | |
|
| | | //检测本地设备文件,是否存在已经取消了共享了的
|
| | | if (fileName.StartsWith(Common.LocalDevice.deviceFirstName) == true)
|
| | | if (fileName.StartsWith("Device_") == true)
|
| | | {
|
| | | //删除掉这个设备文件
|
| | | Global.DeleteFilebyHomeId(fileName);
|
| | |
| | | this.AddShardFile(device.FilePath);
|
| | |
|
| | | //设备的UI
|
| | | var deviceUi = $"DeviceUI_{device.FilePath}";
|
| | | var deviceUi = device.FilePath;
|
| | | if (roomTemp.DeviceUIFilePathList.Contains(deviceUi) == false)
|
| | | {
|
| | | roomTemp.DeviceUIFilePathList.Add(deviceUi);
|
| | |
| | | string deviceFileName = device.FilePath;
|
| | |
|
| | | //移除路径列表
|
| | | roomTemp.DeviceUIFilePathList.Remove($"DeviceUI_{device.FilePath}");
|
| | | roomTemp.DeviceUIFilePathList.Remove(device.FilePath);
|
| | | if (listHadShard.Contains(deviceFileName) == true)
|
| | | {
|
| | | //其他场景分享有这个设备,所以不删除这个设备的根源文件,只是把房间的设备列表路径移除
|
| | |
| | | //设备
|
| | | foreach (var deviceUi in roomTemp.DeviceUIFilePathList)
|
| | | {
|
| | | string deviceFile = deviceUi.Replace("DeviceUI_", string.Empty);
|
| | | string deviceFile = deviceUi;
|
| | | if (listDeleteFile.Contains(deviceFile) == true)
|
| | | {
|
| | | //因为一个回路只能分配一个区域,所以可以直接判断
|