From c7698e163e43cea9e7f8ee45f8e3f91c9265cca4 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 04 十一月 2019 19:11:41 +0800 Subject: [PATCH] 合并了全部的代码 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs | 41 +++++++++++++++++++++++++++++++---------- 1 files changed, 31 insertions(+), 10 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs index ef0bb03..75734e9 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs @@ -282,26 +282,33 @@ { //杩樺師璁惧瀵硅薄 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); @@ -406,8 +413,10 @@ //鐢熸垚鏂囦欢 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) { //鎴块棿鏂囦欢鐗规畩澶勭悊 @@ -473,13 +482,25 @@ 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); @@ -813,7 +834,7 @@ this.AddShardFile(device.FilePath); //璁惧鐨刄I - var deviceUi = $"DeviceUI_{device.FilePath}"; + var deviceUi = device.FilePath; if (roomTemp.DeviceUIFilePathList.Contains(deviceUi) == false) { roomTemp.DeviceUIFilePathList.Add(deviceUi); @@ -1229,7 +1250,7 @@ string deviceFileName = device.FilePath; //绉婚櫎璺緞鍒楄〃 - roomTemp.DeviceUIFilePathList.Remove($"DeviceUI_{device.FilePath}"); + roomTemp.DeviceUIFilePathList.Remove(device.FilePath); if (listHadShard.Contains(deviceFileName) == true) { //鍏朵粬鍦烘櫙鍒嗕韩鏈夎繖涓澶�,鎵�浠ヤ笉鍒犻櫎杩欎釜璁惧鐨勬牴婧愭枃浠�,鍙槸鎶婃埧闂寸殑璁惧鍒楄〃璺緞绉婚櫎 @@ -1564,7 +1585,7 @@ //璁惧 foreach (var deviceUi in roomTemp.DeviceUIFilePathList) { - string deviceFile = deviceUi.Replace("DeviceUI_", string.Empty); + string deviceFile = deviceUi; if (listDeleteFile.Contains(deviceFile) == true) { //鍥犱负涓�涓洖璺彧鑳藉垎閰嶄竴涓尯鍩�,鎵�浠ュ彲浠ョ洿鎺ュ垽鏂� -- Gitblit v1.8.0