From 00ab3ddb140ba8bb88b5cf572b004a85e1da85e9 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期四, 02 一月 2020 19:51:56 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/dev-tzy' into DEV_GXC --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs | 131 ++++++++++++++++++++----------------------- 1 files changed, 60 insertions(+), 71 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs index 766493a..8b0d4e2 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs @@ -572,41 +572,45 @@ //鍏堝垵濮嬪寲鎴块棿 foreach (string fileName in listFile) { - if (fileName.StartsWith("Room_") == true) + try { - //鎴块棿鏂囦欢 - var byteData = this.GetShardFileContent(fileName); - if (byteData != null) + if (fileName.StartsWith("Room_") == true) { - string valueData = System.Text.Encoding.UTF8.GetString(byteData); - var roomTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.Room>(valueData); - memberShardInfo.dicShardRoom[fileName] = roomTemp; + //鎴块棿鏂囦欢 + var byteData = this.GetShardFileContent(fileName); + if (byteData != null) + { + string valueData = System.Text.Encoding.UTF8.GetString(byteData); + var roomTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.Room>(valueData); + memberShardInfo.dicShardRoom[fileName] = roomTemp; + } } - } - else if (fileName == DirNameResourse.ShardFloorFile) - { - //妤煎眰鏂囦欢 - var byteData = this.GetShardFileContent(fileName); - if (byteData != null) + else if (fileName == DirNameResourse.ShardFloorFile) { - string valueData = System.Text.Encoding.UTF8.GetString(byteData); - memberShardInfo.dicShardFloor = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(valueData); + //妤煎眰鏂囦欢 + var byteData = this.GetShardFileContent(fileName); + if (byteData != null) + { + string valueData = System.Text.Encoding.UTF8.GetString(byteData); + memberShardInfo.dicShardFloor = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(valueData); + } } - } - else if (fileName.StartsWith("Device_") == true) - { - string[] Arry = fileName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); - string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(Arry[2], Convert.ToInt32(Arry[3])); - this.dicShardDeviceFile[mainKeys] = fileName; + else if (fileName.StartsWith("Device_") == true) + { + string[] Arry = fileName.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries); + string mainKeys = Common.LocalDevice.Current.GetDeviceMainKeys(Arry[2], Convert.ToInt32(Arry[3])); + this.dicShardDeviceFile[mainKeys] = fileName; - //璁惧鏂囦欢 - listDeviceFile.Add(fileName); + //璁惧鏂囦欢 + listDeviceFile.Add(fileName); + } + else if (fileName.StartsWith("Scene_") == true) + { + //鍦烘櫙鏂囦欢 + listSceneFile.Add(fileName); + } } - else if (fileName.StartsWith("Scene_") == true) - { - //鍦烘櫙鏂囦欢 - listSceneFile.Add(fileName); - } + catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); } } //璁剧疆鎴块棿閲岄潰璁惧鐨刄I瀵硅薄(鍥犱负杩欎釜涓滆タ鏄弽搴忓垪鍖栧嚭鏉ョ殑,璁惧UI瀵硅薄鏄笉搴忓垪鍖栧璞�) @@ -827,13 +831,12 @@ //鍏嬮殕涓�涓璞� roomTemp = nowRoom.CloneRoomClass(); memberShardInfo.TempRoom = roomTemp; - //鏂板垎浜殑鎴块棿,濡傛灉鍥剧墖鏄嚜瀹氫箟鐨�,鍒欎笂浼犲浘鐗� - if (roomTemp.BackgroundImageType != 0) + //鏂板垎浜殑鎴块棿,濡傛灉鍥剧墖鏄嚜瀹氫箟鐨�,骞朵笖杩欎釜鍥剧墖鏄瓨鍦ㄧ殑,鍒欎笂浼犲浘鐗� + if (roomTemp.BackgroundImageType != 0 && Common.Global.IsExistsByHomeId(roomTemp.BackgroundImage) == true) { //鑷畾涔夌殑鍥剧墖,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰� - string[] Arry = roomTemp.BackgroundImage.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); - listFile.Add(Arry[Arry.Length - 1]); - this.AddShardFile(Arry[Arry.Length - 1]); + listFile.Add(roomTemp.BackgroundImage); + this.AddShardFile(roomTemp.BackgroundImage); } } else @@ -845,15 +848,13 @@ if (roomTemp.BackgroundImageType != 0) { //鍒犻櫎鑷畾涔夊浘鐗� - string[] Arry = roomTemp.BackgroundImage.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); - listDelPic.Add(Arry[Arry.Length - 1]); + listDelPic.Add(roomTemp.BackgroundImage); } - if (nowRoom.BackgroundImageType != 0) + if (nowRoom.BackgroundImageType != 0 && Common.Global.IsExistsByHomeId(nowRoom.BackgroundImage) == true) { //鑷畾涔夌殑鍥剧墖,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰� - string[] Arry = nowRoom.BackgroundImage.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); - listFile.Add(Arry[Arry.Length - 1]); - this.AddShardFile(Arry[Arry.Length - 1]); + listFile.Add(nowRoom.BackgroundImage); + this.AddShardFile(nowRoom.BackgroundImage); } //鍙樻洿鍥剧墖璁剧疆 roomTemp.BackgroundImageType = nowRoom.BackgroundImageType; @@ -891,12 +892,11 @@ //鍦烘櫙 foreach (var secene in listScene) { - if (secene.IconPathType != 0) + if (secene.IconPathType != 0 && Common.Global.IsExistsByHomeId(secene.IconPath) == true) { - //鑷畾涔夌殑鍥剧墖,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰� - string[] Arry = secene.IconPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); - listFile.Add(Arry[Arry.Length - 1]); - this.AddShardFile(Arry[Arry.Length - 1]); + //鑷畾涔夌殑鍥剧墖,瀹冨瓨鍦ㄤ簬鏈湴 + listFile.Add(secene.IconPath); + this.AddShardFile(secene.IconPath); } listFile.Add(secene.FileName); @@ -1025,7 +1025,7 @@ if (memberShardInfo.dicAllShardKeys.ContainsKey(fileName) == false) { var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/AddShareData", false, info); - if (string.IsNullOrEmpty(result) == true) + if (result == null) { return false; } @@ -1073,24 +1073,19 @@ nvc.Add("HouseDistributedMark", Common.Config.Instance.Home.Id); nvc.Add("SubAccountDistributedMark", memberShardInfo.SubAccountDistributedMark); nvc.Add("ShareDataBytes", Convert.ToBase64String(this.GetShardFileContent(fileName))); - nvc.Add("IsOtherAccountCtrl", Common.Config.Instance.isAdministrator.ToString()); //杩藉姞鍏变韩 if (memberShardInfo.dicAllShardKeys.ContainsKey(fileName) == false) { - var result = this.UpLoadBigBackupFileToDB("ZigbeeDataShare/AddShareData", fullName, nvc); - if (string.IsNullOrEmpty(result) == true) - { - return null; - } //杩欓噷鏈夌偣鐗规畩锛屾帴鍙f槸鐩存帴杩斿洖涓婚敭鍥炴潵鐨勶紝鑰屼笉鏄疛soin + var result = this.DoUpLoadBigBackupFileToDB("ZigbeeDataShare/AddShareData", fullName, nvc); return result; } else { nvc.Add("DistributedMark", memberShardInfo.dicAllShardKeys[fileName]); - var result = this.UpLoadBigBackupFileToDB("ZigbeeDataShare/EditShareData", fullName, nvc); - if (result != "1") + var result = this.DoUpLoadBigBackupFileToDB("ZigbeeDataShare/EditShareData", fullName, nvc); + if (result == null) { return null; } @@ -1099,26 +1094,17 @@ } /// <summary> - /// 涓婁紶澶ф枃浠� + /// 鎵ц涓婁紶澶ф枃浠� /// </summary> /// <param name="RequestName">璇锋眰鎺ュ彛</param> /// <param name="fullFileName">鏂囦欢鍚嶅瓧(鍚矾寰�)</param> /// <param name="nvc"></param> /// <returns></returns> - private string UpLoadBigBackupFileToDB(string RequestName, string fullFileName, NameValueCollection nvc) + private string DoUpLoadBigBackupFileToDB(string RequestName, string fullFileName, NameValueCollection nvc) { string paramName = "file"; string contentType = "application/octet-stream"; string requestUrl = $"{CommonPage.RequestHttpsHost}/{RequestName}"; - //鍚敤绠$悊鍛樻潈闄� - //if (Config.Instance.isAdministrator == true) - //{ - // requestUrl = $"{Config.Instance.AdminRequestBaseUrl}/{RequestName}"; - //} - //else - //{ - // requestUrl = $"{CommonPage.RequestHttpsHost}/{RequestName}"; - //} string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x"); byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n"); @@ -1128,6 +1114,8 @@ wr.Method = "POST"; wr.KeepAlive = true; wr.Credentials = System.Net.CredentialCache.DefaultCredentials; + + wr.Headers.Add(HttpRequestHeader.Authorization, Config.Instance.Token); var rs = wr.GetRequestStream(); @@ -1167,23 +1155,24 @@ StreamReader reader2 = new StreamReader(stream2); string result = reader2.ReadToEnd(); - if (RequestName == "ZigbeeDataShare/AddShareData") - { - return result; - } var data = Newtonsoft.Json.JsonConvert.DeserializeObject<Shared.Common.ResponseEntity.ResponsePack>(result); bool flage = UserCenterLogic.CheckNotEorrorMsg(data, requestUrl); if (flage == true) { - return "1"; + //缂栬緫鐨勬椂鍊欙紝杩欎釜涓滆タ浼氭槸null + return data.ResponseData == null ? "1" : data.ResponseData.ToString(); } - return "0"; + + //Log鍑哄姏 + IMessageCommon.Current.GetMsgByRequestName(RequestName, data, nvc); + + return null; } catch { - return "-1"; + return null; } finally { -- Gitblit v1.8.0