From 29209469ac17d877eb92d008456b58ad901bfb58 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期三, 30 十月 2019 14:37:42 +0800
Subject: [PATCH] 2019-10-30-1
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs | 873 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 750 insertions(+), 123 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs
index 07ebc6e..66555a5 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs
@@ -1,6 +1,9 @@
锘縰sing Shared.Common;
using System;
using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.IO;
+using System.Net;
using System.Text;
using System.Threading.Tasks;
using ZigBee.Device;
@@ -57,12 +60,19 @@
//鏂囦欢澶�
string strDir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory);
+ //涓嶅厑璁告寜绯荤粺鐨勮繑鍥為敭
+ Shared.Common.CommonPage.BackKeyCanClick = false;
+ UserCenterResourse.Option.AppCanSignout = false;
+
foreach (string keys in listDistributedMark)
{
var dataPra = new { DistributedMark = keys, HouseDistributedMark = Common.Config.Instance.Home.Id, IsOtherAccountControl = Common.Config.Instance.isAdministrator };
var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetOneShareData", false, dataPra);
if (result == null)
{
+ //鍏佽鎸夌郴缁熺殑杩斿洖閿�
+ Shared.Common.CommonPage.BackKeyCanClick = true;
+ UserCenterResourse.Option.AppCanSignout = true;
return null;
}
var dataResult = Newtonsoft.Json.JsonConvert.DeserializeObject<GetShardInfoResult>(result);
@@ -73,6 +83,10 @@
//璁剧疆杩涘害鍊�
ProgressBar.SetValue(1);
}
+
+ //鍏佽鎸夌郴缁熺殑杩斿洖閿�
+ Shared.Common.CommonPage.BackKeyCanClick = true;
+ UserCenterResourse.Option.AppCanSignout = true;
return listFile;
}
@@ -97,27 +111,28 @@
/// <summary>
/// 鑾峰彇鏈湴鍏ㄩ儴鐨勫叡浜枃浠�
/// </summary>
- /// <param name="room">鎸囧畾鍙幏鍙栨寚瀹氭埧闂寸殑</param>
/// <returns></returns>
- public List<string> GetLocalAllShardFile(Common.Room room = null)
+ public List<string> GetLocalAllShardFile()
{
string path = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory);
var listFile = HdlAutoBackupLogic.GetFileFromDirectory(path);
- if (room == null)
+
+ return listFile;
+ }
+
+ /// <summary>
+ /// 鏂囦欢鏄惁瀛樺湪
+ /// </summary>
+ /// <param name="fileName"></param>
+ /// <returns></returns>
+ public bool IsFileExists(string fileName)
+ {
+ string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
+ if (System.IO.File.Exists(fullName) == false)
{
- return listFile;
+ return false;
}
- //鎴块棿
- var listRoomFile = new List<string>() { room.FileName };
- //鍦烘櫙鏂囦欢
- listRoomFile.AddRange(room.SceneUIFilePathList);
- //璁惧鏂囦欢
- foreach (var uiName in room.DeviceUIFilePathList)
- {
- string deviceName = uiName.Replace("DeviceUI_", string.Empty);
- listRoomFile.Add(deviceName);
- }
- return null;
+ return true;
}
#endregion
@@ -169,6 +184,20 @@
Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
}
+ /// <summary>
+ /// 娣诲姞妤煎眰瀵硅薄鍒扮紦瀛�
+ /// </summary>
+ /// <param name="dic">妤煎眰</param>
+ public void AddShardFile(Dictionary<string, string> dic)
+ {
+ var data = Newtonsoft.Json.JsonConvert.SerializeObject(dic);
+ var byteData = System.Text.Encoding.UTF8.GetBytes(data);
+
+ string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, DirNameResourse.ShardFloorFile);
+ //鍐欏叆鍐呭
+ Shared.IO.FileUtils.WriteFileByBytes(fullName, byteData);
+ }
+
#endregion
#region 鈻� 鍒犻櫎鍒嗕韩鏂囦欢_______________________
@@ -198,6 +227,122 @@
#endregion
+ #region 鈻� 鑾峰彇鎴愬憳鍏变韩鍒楄〃___________________
+
+ /// <summary>
+ /// 浠庢湰鍦拌幏鍙栨垚鍛樼殑鍒嗕韩鍒楄〃
+ /// </summary>
+ /// <param name="memberShardInfo">鎴愬憳鐨勫垎浜暟鎹殑缂撳瓨(璋冪敤杩欎釜鍑芥暟浼氬埛鏂拌繖涓彉閲忕殑淇℃伅)</param>
+ public void GetMemberShardContentListFromLocal(MemberShardInfoData memberShardInfo)
+ {
+ memberShardInfo.dicShardRoom = new Dictionary<string, Common.Room>();
+
+ var listDeviceFile = new HashSet<string>();
+ var listSceneFile = new HashSet<string>();
+
+ var listFile = this.GetLocalAllShardFile();
+ //鍏堝垵濮嬪寲鎴块棿
+ foreach (string fileName in listFile)
+ {
+ if (fileName.StartsWith("Room_") == true)
+ {
+ //鎴块棿鏂囦欢
+ 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)
+ {
+ string valueData = System.Text.Encoding.UTF8.GetString(byteData);
+ memberShardInfo.dicShardFloor = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(valueData);
+ }
+ }
+ else if (fileName.StartsWith("Device_") == true)
+ {
+ //璁惧鏂囦欢
+ listDeviceFile.Add(fileName);
+ }
+ else if (fileName.StartsWith("Scene_") == true)
+ {
+ //鍦烘櫙鏂囦欢
+ listSceneFile.Add(fileName);
+ }
+ }
+
+ //璁剧疆鎴块棿閲岄潰璁惧鐨刄I瀵硅薄(鍥犱负杩欎釜涓滆タ鏄弽搴忓垪鍖栧嚭鏉ョ殑,璁惧UI瀵硅薄鏄笉搴忓垪鍖栧璞�)
+ foreach (var tempRoom in memberShardInfo.dicShardRoom.Values)
+ {
+ //杩樺師璁惧瀵硅薄
+ tempRoom.DeviceUIList.Clear();
+ for (int i = 0; i < tempRoom.DeviceUIFilePathList.Count; i++)
+ {
+ 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(deviceFile));
+ }
+ //杩樺師鍦烘櫙瀵硅薄
+ tempRoom.SceneUIList.Clear();
+ 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);
+ var tempUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData);
+ tempRoom.SceneUIList.Add(tempUi);
+ }
+ }
+ //濡傛灉瀛樺湪鍖归厤涓嶄笂鐨勬枃浠�
+ if (listDeviceFile.Count != 0 || listSceneFile.Count != 0)
+ {
+ //鍒涘缓涓�涓复鏃舵埧闂存潵瀛樺偍
+ var roomTemp = new Room();
+ roomTemp.Id = "Other";
+ roomTemp.FloorId = "Other";
+ memberShardInfo.dicShardRoom[roomTemp.FileName] = roomTemp;
+ roomTemp.Name = Language.StringByID(R.MyInternationalizationString.uSharedRoom);
+ //杩樺師璁惧瀵硅薄
+ foreach (string deviceFile in listDeviceFile)
+ {
+ roomTemp.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFile));
+ }
+ //杩樺師鍦烘櫙瀵硅薄
+ foreach (string uiPath in listSceneFile)
+ {
+ var byteData = this.GetShardFileContent(uiPath);
+ string valueData = System.Text.Encoding.UTF8.GetString(byteData);
+ var tempUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData);
+ roomTemp.SceneUIList.Add(tempUi);
+ }
+ }
+ }
+
+ #endregion
+
#region 鈻� 鍚屾鏈嶅姟鍣ㄧ殑鍒嗕韩鍐呭_______________
/// <summary>
@@ -212,7 +357,7 @@
}
//鑾峰彇涓讳汉鍒嗕韩缁欐垚鍛樼殑鏂囦欢鍒楄〃
- var infoPra = new { DistributedMark = Config.Instance.Guid, HouseDistributedMark = Common.Config.Instance.Home.Id , IsOtherAccountControl = Common.Config.Instance.isAdministrator };
+ var infoPra = new { DistributedMark = Config.Instance.Guid, HouseDistributedMark = Common.Config.Instance.Home.Id, IsOtherAccountControl = Common.Config.Instance.isAdministrator };
var listNotShow = new List<string>() { "NotSetAgain" };
var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra, listNotShow);
if (string.IsNullOrEmpty(result) == true)
@@ -425,6 +570,87 @@
#endregion
+ //----------------------------------鍒嗗壊绾�(鏁版嵁棰勫)-------------------------------------------------
+
+ #region 鈻� 鏁版嵁棰勫___________________________
+
+ /// <summary>
+ /// 鑾峰彇鎴愬憳鍏变韩鍒楄〃鐒跺悗淇濆瓨鍒版湰鍦�(鐢ㄥ畬涔嬪悗鏈�濂借皟鐢ㄦ竻绌� ClearShardDirectory鍑芥暟娓呯┖)
+ /// </summary>
+ /// <param name="SubAccountDistributedMark">鎴愬憳鍒楄〃鎺ュ彛杩斿洖鐨凷ubAccountDistributedMark</param>
+ /// <param name="memberShardInfo">
+ /// <para>鎴愬憳鐨勫垎浜暟鎹�</para>
+ /// <para>濡傛灉涓嶇煡閬撹繖鏄粈涔堜笢瑗�,灏盢ew涓�涓�,鐒跺悗缂撳瓨璧锋潵,璋冪敤鍏朵粬鍑芥暟閮介渶瑕佽繖涓笢瑗�</para>
+ /// <para>New鐨勬椂鍊欒寰楀SubAccountDistributedMark璧嬪��,瀹冩槸鎴愬憳鍒楄〃鎺ュ彛杩斿洖鐨凷ubAccountDistributedMark</para>
+ /// </param>
+ /// <returns></returns>
+ public async Task<bool> GetMemberShardContentListAndSetToLocation(MemberShardInfoData memberShardInfo)
+ {
+ if (memberShardInfo.Refresh == false)
+ {
+ return true;
+ }
+ memberShardInfo.Refresh = false;
+
+ //鎵撳紑杩涘害鏉�
+ ProgressBar.Show();
+
+ var infoPra = new
+ {
+ DistributedMark = memberShardInfo.SubAccountDistributedMark,
+ HouseDistributedMark = Shared.Common.Config.Instance.HomeId,
+ IsOtherAccountControl = Common.Config.Instance.isAdministrator
+ };
+ var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra);
+ if (result == null)
+ {
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ return false;
+ }
+ var listData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ReceiveShardInfoResult>>(result);
+ //鍏堟竻绌哄叡浜枃浠跺す
+ this.ClearShardDirectory();
+
+ var listMark = new List<string>();
+ foreach (var data in listData)
+ {
+ //鎬ц兘浼樺寲锛氬鏋滄湰鍦版嫢鏈夎繖涓枃浠剁殑璇�,鐩存帴浣跨敤閭d釜鏂囦欢
+ string fileName = data.ShareName;
+ //璁板綍璧峰畠鐨勪富閿�
+ memberShardInfo.dicAllShardKeys[fileName] = data.DistributedMark;
+
+ if (fileName.StartsWith("Room_") == true || fileName.StartsWith("Scene_") == true)
+ {
+ //鎴块棿鏂囦欢鍜屽満鏅枃浠堕渶瑕侀噸鏂板弽搴忓垪鍖�
+ listMark.Add(data.DistributedMark);
+ continue;
+ }
+ if (Shared.Common.Global.IsExistsByHomeId(fileName) == true)
+ {
+ //鍏朵粬鏂囦欢鐨勮瘽锛屽鏋滄湰鍦板瓨鍦紝鍒欎互鏈湴鏂囦欢涓哄噯
+ this.AddShardFile(fileName);
+ continue;
+ }
+ listMark.Add(data.DistributedMark);
+ }
+
+ //灏嗗垎浜殑鏁版嵁瀛樺叆鏈湴,杩斿洖鐨勬槸鏂囦欢鍚嶅瓧(寮傚父鏃惰繑鍥瀗ull)
+ var listFile = await this.SetShardFileToLocation(listMark);
+ if (listFile == null)
+ {
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ return false;
+ }
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+
+ return true;
+ }
+
+ #endregion
+
//----------------------------------鍒嗗壊绾�(涓婁紶鏂扮殑鍒嗕韩)---------------------------------------------
#region 鈻� 鎵ц涓婁紶鏂扮殑鍒嗕韩___________________
@@ -435,10 +661,16 @@
/// <param name="memberShardInfo">鎴愬憳鐨勫垎浜暟鎹�</param>
/// <param name="nowRoom">褰撳墠鐨勬埧闂村璞�</param>
/// <param name="listDevice">閫夋嫨涓婁紶鐨勮澶�</param>
- /// <param name="listScene">閫夋嫨涓婁紶鐨勫満鏅�</param>
+ /// <param name="listScene">閫夋嫨涓婁紶鐨勫満鏅�(涓嶈鑾峰彇瀹冮噷闈㈢殑缁戝畾鍒楄〃)</param>
+ /// <param name="BarMaxValue">杩涘害鏉$殑鏈�澶у��,濡傛灉涓嶄负-1,鍒欏唴閮ㄤ笉浼氳嚜鍔ㄥ脊鍑鸿繘搴︽潯</param>
+ /// <param name="listCheckFile">鏂囦欢閲嶅涓婁紶妫�娴�</param>
public async Task<bool> DoUploadSharedContent(MemberShardInfoData memberShardInfo, Common.Room nowRoom,
- List<CommonDevice> listDevice, List<Common.SceneUI> listScene)
+ List<CommonDevice> listDevice, List<Common.SceneUI> listScene, int BarMaxValue = -1, HashSet<string> listCheckFile = null)
{
+ if (listDevice.Count == 0 && listScene.Count == 0)
+ {
+ return true;
+ }
var listCheck = new HashSet<string>();
//鑾峰彇鍦烘櫙閲岄潰宓屽鐨勫瓙璁惧鍜屽瓙鍦烘櫙
@@ -450,65 +682,145 @@
this.GetSceneDeviceList(SceneTemp, listCheck, listChirdScene, listChirdDevice);
}
+ //杩欎釜涔熸槸澶囦唤
+ int BackgroundImageType = 0;
+ string BackgroundImage = string.Empty;
+ if (memberShardInfo.dicShardRoom.ContainsKey(nowRoom.FileName) == true)
+ {
+ BackgroundImageType = memberShardInfo.dicShardRoom[nowRoom.FileName].BackgroundImageType;
+ BackgroundImage = memberShardInfo.dicShardRoom[nowRoom.FileName].BackgroundImage;
+ }
//闃叉鍑虹幇閿欒,鏆傛椂淇濆瓨涓や釜鍒楄〃(铏界劧娌¢偅涔堥夯鐑︼紝涓嶈繃鏃㈢劧宸茬粡杩欐牱鍐欎簡灏辫繖鏍蜂簡)
var dicBackDevice = new Dictionary<string, List<string>>();
var dicBackScene = new Dictionary<string, List<string>>();
//涓存椂澶囦唤鎴块棿璁惧鍒楄〃
this.BackupRoomDevicelistTemporary(memberShardInfo, dicBackDevice, dicBackScene);
- Common.Room roomTemp = null;
- if (memberShardInfo.dicShardRoom.ContainsKey(nowRoom.FileName) == false)
- {
- //鍏嬮殕涓�涓璞�
- roomTemp = nowRoom.CloneRoomClass();
- memberShardInfo.dicShardRoom[nowRoom.FileName] = roomTemp;
- }
- roomTemp = memberShardInfo.dicShardRoom[nowRoom.FileName];
-
//鑾峰彇涓婁紶鐨勬枃浠�,鐒跺悗灏嗘枃浠跺鍒跺埌鎸囧畾鏂囦欢澶�
- var listFile = this.GetUploadListFile(ref roomTemp, listDevice, listScene, listChirdDevice, listChirdScene);
+ var listDelPic = new List<string>();
+ var listFile = this.GetUploadListFile(memberShardInfo, nowRoom, listDevice, listScene, listChirdDevice, listChirdScene, listDelPic);
- //鎵撳紑杩涘害鏉�
- ProgressBar.Show();
- //璁剧疆鏈�澶у��
- ProgressBar.SetMaxValue(listFile.Count);
+ //涓嶅厑璁告寜绯荤粺鐨勮繑鍥為敭
+ Shared.Common.CommonPage.BackKeyCanClick = false;
+ UserCenterResourse.Option.AppCanSignout = false;
+
+ if (BarMaxValue == -1)
+ {
+ //鎵撳紑杩涘害鏉�
+ ProgressBar.Show();
+ //璁剧疆鏈�澶у��
+ ProgressBar.SetMaxValue(listFile.Count);
+ }
+ else
+ {
+ //璁剧疆鏈�澶у��
+ ProgressBar.SetMaxValue(BarMaxValue);
+ }
+
//涓婁紶鍒嗕韩
- var result = await this.DoUploadShardContent(memberShardInfo, nowRoom, listFile);
- //鍏抽棴杩涘害鏉�
- ProgressBar.Close();
+ var result = await this.DoUploadShardContent(memberShardInfo, listFile, listCheckFile);
+ if (result == true)
+ {
+ //鍒犻櫎鎸囧畾鑷畾涔夊浘鐗�
+ result = await this.DoDeleteSharedContent(memberShardInfo, listDelPic);
+ }
+ if (BarMaxValue == -1)
+ {
+ //鍏抽棴杩涘害鏉�
+ ProgressBar.Close();
+ }
+
+ //鍏佽鎸夌郴缁熺殑杩斿洖閿�
+ Shared.Common.CommonPage.BackKeyCanClick = true;
+ UserCenterResourse.Option.AppCanSignout = true;
if (result == false)
{
//鎭㈠鍘熸暟鎹�
+ if (memberShardInfo.TempRoom == null)
+ {
+ memberShardInfo.dicShardRoom[nowRoom.FileName].BackgroundImageType = BackgroundImageType;
+ memberShardInfo.dicShardRoom[nowRoom.FileName].BackgroundImage = BackgroundImage;
+ }
this.RecoverRoomDevicelistTemporary(memberShardInfo, dicBackDevice, dicBackScene, listFile);
- return false;
}
+ else
+ {
+ //瑕嗙洊鏁版嵁
+ if (memberShardInfo.TempRoom != null)
+ {
+ memberShardInfo.dicShardRoom[nowRoom.FileName] = memberShardInfo.TempRoom;
+ }
+ }
+ memberShardInfo.TempRoom = null;
- return true;
+ return result;
}
/// <summary>
/// 鑾峰彇涓婁紶鐨勬枃浠跺悕
/// </summary>
- /// <param name="roomTemp">闇�瑕佷笂浼犲埌浜戠鐨勬埧闂村璞�</param>
- /// <param name="listDevice">鍒嗕韩鐨勮澶囧垪琛�</param>
- /// <param name="listScene">鍒嗕韩鐨勫満鏅垪琛�</param>
+ /// <param name="memberShardInfo">鎴愬憳鐨勫垎浜暟鎹�</param>
+ /// <param name="nowRoom">闇�瑕佷笂浼犲埌浜戠鐨勬埧闂村璞�(娉ㄦ剰,杩欎釜鎴块棿鏄富浜虹殑鎴块棿瀵硅薄,鑰屼笉鏄櫄鎷熺殑)</param>
+ /// <param name="listDevice">鍒嗕韩鐨勮澶囧垪琛�(娉ㄦ剰,杩欎釜涓滆タ鏄富浜虹殑)</param>
+ /// <param name="listScene">鍒嗕韩鐨勫満鏅垪琛�(娉ㄦ剰,杩欎釜涓滆タ鏄富浜虹殑)</param>
/// <param name="listChirdDevice">鍦烘櫙閲岄潰閫掑綊鑾峰彇鐨勮澶�</param>
/// <param name="listChirdScene">鍦烘櫙閲岄潰閫掑綊鑾峰彇鐨勫満鏅�</param>
+ /// <param name="listDelPic">闇�瑕佸垹闄ょ殑鍥剧墖</param>
/// <returns></returns>
- private List<string> GetUploadListFile(ref Common.Room roomTemp, List<CommonDevice> listDevice, List<Common.SceneUI> listScene,
- List<CommonDevice> listChirdDevice, List<Common.SceneUI> listChirdScene)
+ private List<string> GetUploadListFile(MemberShardInfoData memberShardInfo, Common.Room nowRoom, List<CommonDevice> listDevice, List<Common.SceneUI> listScene,
+ List<CommonDevice> listChirdDevice, List<Common.SceneUI> listChirdScene, List<string> listDelPic)
{
var listFile = new List<string>();
- var listOtaCheck = new List<string>();
+
+ Common.Room roomTemp = null;
+ if (memberShardInfo.dicShardRoom.ContainsKey(nowRoom.FileName) == false)
+ {
+ //鍏嬮殕涓�涓璞�
+ roomTemp = nowRoom.CloneRoomClass();
+ memberShardInfo.TempRoom = roomTemp;
+ //鏂板垎浜殑鎴块棿,濡傛灉鍥剧墖鏄嚜瀹氫箟鐨�,鍒欎笂浼犲浘鐗�
+ if (roomTemp.BackgroundImageType != 0)
+ {
+ //鑷畾涔夌殑鍥剧墖,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰�
+ string[] Arry = roomTemp.BackgroundImage.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+ listFile.Add(Arry[Arry.Length - 1]);
+ this.AddShardFile(Arry[Arry.Length - 1]);
+ }
+ }
+ else
+ {
+ roomTemp = memberShardInfo.dicShardRoom[nowRoom.FileName];
+ //濡傛灉浜戠鍒嗕韩鐨勬埧闂寸殑鍥剧墖鍜屼富浜虹殑涓嶄竴鏍风殑鏃跺��
+ if (roomTemp.BackgroundImage != nowRoom.BackgroundImage)
+ {
+ if (roomTemp.BackgroundImageType != 0)
+ {
+ //鍒犻櫎鑷畾涔夊浘鐗�
+ string[] Arry = roomTemp.BackgroundImage.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+ listDelPic.Add(Arry[Arry.Length - 1]);
+ }
+ if (nowRoom.BackgroundImageType != 0)
+ {
+ //鑷畾涔夌殑鍥剧墖,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰�
+ string[] Arry = nowRoom.BackgroundImage.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+ listFile.Add(Arry[Arry.Length - 1]);
+ this.AddShardFile(Arry[Arry.Length - 1]);
+ }
+ //鍙樻洿鍥剧墖璁剧疆
+ roomTemp.BackgroundImageType = nowRoom.BackgroundImageType;
+ roomTemp.BackgroundImage = nowRoom.BackgroundImage;
+ }
+ }
+
foreach (var device in listDevice)
{
//璁惧
listFile.Add(device.FilePath);
- HdlShardLogic.Current.AddShardFile(device.FilePath);
+ this.AddShardFile(device.FilePath);
//璁惧鐨刄I
- var deviceUi = $"DeviceUI_{device.FilePath}";
+ var deviceUi = device.FilePath;
if (roomTemp.DeviceUIFilePathList.Contains(deviceUi) == false)
{
roomTemp.DeviceUIFilePathList.Add(deviceUi);
@@ -519,14 +831,22 @@
{
//璁惧
listFile.Add(device.FilePath);
- HdlShardLogic.Current.AddShardFile(device.FilePath);
+ this.AddShardFile(device.FilePath);
}
//鍦烘櫙
foreach (var secene in listScene)
{
+ if (secene.IconPathType != 0)
+ {
+ //鑷畾涔夌殑鍥剧墖,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰�
+ string[] Arry = secene.IconPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+ listFile.Add(Arry[Arry.Length - 1]);
+ this.AddShardFile(Arry[Arry.Length - 1]);
+ }
+
listFile.Add(secene.FileName);
- HdlShardLogic.Current.AddShardFile(secene);
+ this.AddShardFile(secene);
if (roomTemp.SceneUIFilePathList.Contains(secene.FileName) == false)
{
@@ -537,11 +857,19 @@
foreach (var secene in listChirdScene)
{
listFile.Add(secene.FileName);
- HdlShardLogic.Current.AddShardFile(secene);
+ this.AddShardFile(secene);
}
//鎴块棿鏂囦欢涔熺粰杩囧幓
listFile.Add(roomTemp.FileName);
- HdlShardLogic.Current.AddShardFile(roomTemp);
+ this.AddShardFile(roomTemp);
+
+ //鍙嶆妤煎眰鏂囦欢寰堝皬,涓�璧风粰杩囧幓鍚�
+ if (roomTemp.FloorId != string.Empty)
+ {
+ memberShardInfo.dicShardFloor[roomTemp.FloorId] = roomTemp.FloorName; ;
+ }
+ this.AddShardFile(memberShardInfo.dicShardFloor);
+ listFile.Add(DirNameResourse.ShardFloorFile);
return listFile;
}
@@ -554,7 +882,7 @@
/// <param name="listSceneUI">娣诲姞鍒嗕韩鐨勫満鏅垪琛�</param>
/// <param name="listDevice">娣诲姞鍒嗕韩鐨勮澶囧垪琛�</param>
/// <returns></returns>
- private void GetSceneDeviceList(Common.SceneUI scene, HashSet<string> listCheck, List<Common.SceneUI> listSceneUI, List<CommonDevice> listDevice)
+ public void GetSceneDeviceList(Common.SceneUI scene, HashSet<string> listCheck, List<Common.SceneUI> listSceneUI, List<CommonDevice> listDevice)
{
foreach (var data in scene.AddSceneMemberDataList)
{
@@ -604,57 +932,216 @@
/// 涓婁紶鍒嗕韩(杩斿洖浜戠鍒嗕韩鏂囦欢鐨勪富閿�:DistributedMark)
/// </summary>
/// <param name="memberShardInfo">鎴愬憳鐨勫垎浜暟鎹�</param>
- /// <param name="nowRoom">褰撳墠鐨勬埧闂村璞�</param>
/// <param name="listFile">涓婁紶鐨勬枃浠跺悕</param>
+ /// <param name="listCheckFile">閲嶅鏂囦欢涓婁紶妫�娴�</param>
/// <returns></returns>
- private async Task<bool> DoUploadShardContent(MemberShardInfoData memberShardInfo, Common.Room nowRoom, List<string> listFile)
+ private async Task<bool> DoUploadShardContent(MemberShardInfoData memberShardInfo, List<string> listFile, HashSet<string> listCheckFile)
{
var dicKeys = new Dictionary<string, string>();
for (int i = 0; i < listFile.Count; i++)
{
string fileName = listFile[i];
- var info = new UploadShardContent();
- info.SubAccountDistributedMark = memberShardInfo.SubAccountDistributedMark;
- info.ShareName = fileName;
- info.ShareDataBytes = HdlShardLogic.Current.GetShardFileContent(fileName);
-
- //杩藉姞鍏变韩
- if (memberShardInfo.dicAllShardKeys.ContainsKey(fileName) == false)
+ if (listCheckFile != null)
{
- var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/AddShareData", false, info);
- if (string.IsNullOrEmpty(result) == true)
+ if (listCheckFile.Contains(fileName) == true)
+ {
+ //閲嶅鏂囦欢涓嶅啀涓婁紶
+ continue;
+ }
+ listCheckFile.Add(fileName);
+ }
+ if (fileName.EndsWith(".png") == true)
+ {
+ //涓婁紶鍥剧墖
+ var result = this.UpLoadBigBackupFileToDB(memberShardInfo, fileName);
+ if (result == null)
{
return false;
}
- //杩欓噷鏈夌偣鐗规畩锛屾帴鍙f槸鐩存帴杩斿洖涓婚敭鍥炴潵鐨勶紝鑰屼笉鏄疛soin
dicKeys[fileName] = result;
}
else
{
- info.DistributedMark = memberShardInfo.dicAllShardKeys[fileName];
- var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/EditShareData", false, info);
- if (result == false)
+ var info = new UploadShardContent();
+ info.SubAccountDistributedMark = memberShardInfo.SubAccountDistributedMark;
+ info.ShareName = fileName;
+ info.ShareDataBytes = HdlShardLogic.Current.GetShardFileContent(fileName);
+
+ //杩藉姞鍏变韩
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(fileName) == false)
{
- return false;
+ var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/AddShareData", false, info);
+ if (string.IsNullOrEmpty(result) == true)
+ {
+ return false;
+ }
+ //杩欓噷鏈夌偣鐗规畩锛屾帴鍙f槸鐩存帴杩斿洖涓婚敭鍥炴潵鐨勶紝鑰屼笉鏄疛soin
+ dicKeys[fileName] = result;
}
- dicKeys[fileName] = info.DistributedMark;
+ else
+ {
+ info.DistributedMark = memberShardInfo.dicAllShardKeys[fileName];
+ var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/EditShareData", false, info);
+ if (result == false)
+ {
+ return false;
+ }
+ dicKeys[fileName] = info.DistributedMark;
+ }
}
//璁剧疆杩涘害鍊�
ProgressBar.SetValue(1);
}
//濡傛灉娌℃湁閿欒,鍒欐坊鍔犱复鏃剁紦瀛�
- var listShard = memberShardInfo.dicAllMemberShard[nowRoom.FileName];
foreach (var keys in dicKeys.Keys)
{
- if (listShard.Contains(keys) == false)
- {
- listShard.Add(keys);
- }
memberShardInfo.dicAllShardKeys[keys] = dicKeys[keys];
}
return true;
}
+
+ /// <summary>
+ /// 涓婁紶鍥剧墖鏂囦欢鍒颁簯绔�
+ /// </summary>
+ /// <param name="fullDir">鏂囦欢澶圭殑鍏ㄨ矾寰�</param>
+ /// <param name="listPicFile">鍥剧墖鏂囦欢鍒楄〃</param>
+ /// <returns></returns>
+ private string UpLoadBigBackupFileToDB(MemberShardInfoData memberShardInfo, string fileName)
+ {
+ string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory, fileName);
+ if (System.IO.File.Exists(fullName) == false)
+ {
+ return null;
+ }
+ var nvc = new NameValueCollection();
+ nvc.Add("ShareName", fileName);
+ 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
+ return result;
+ }
+ else
+ {
+ nvc.Add("DistributedMark", memberShardInfo.dicAllShardKeys[fileName]);
+ var result = this.UpLoadBigBackupFileToDB("ZigbeeDataShare/EditShareData", fullName, nvc);
+ if (result != "1")
+ {
+ return null;
+ }
+ return memberShardInfo.dicAllShardKeys[fileName];
+ }
+ }
+
+ /// <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)
+ {
+ 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");
+
+ var wr = (HttpWebRequest)WebRequest.Create(requestUrl);
+ wr.ContentType = "multipart/form-data; boundary=" + boundary;
+ wr.Method = "POST";
+ wr.KeepAlive = true;
+ wr.Credentials = System.Net.CredentialCache.DefaultCredentials;
+
+ var rs = wr.GetRequestStream();
+
+ string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
+ foreach (string key in nvc.Keys)
+ {
+ rs.Write(boundarybytes, 0, boundarybytes.Length);
+ string formitem = string.Format(formdataTemplate, key, nvc[key]);
+ byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
+ rs.Write(formitembytes, 0, formitembytes.Length);
+ }
+ rs.Write(boundarybytes, 0, boundarybytes.Length);
+
+ string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\nContent-Type: {2}\r\n\r\n";
+ string header = string.Format(headerTemplate, paramName, fullFileName, contentType);
+ byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
+ rs.Write(headerbytes, 0, headerbytes.Length);
+
+ var fileStream = new FileStream(fullFileName, FileMode.Open, FileAccess.Read);
+ byte[] buffer = new byte[4096];
+ int bytesRead = 0;
+ while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0)
+ {
+ rs.Write(buffer, 0, bytesRead);
+ }
+ fileStream.Close();
+
+ byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
+ rs.Write(trailer, 0, trailer.Length);
+ rs.Close();
+
+ WebResponse wresp = null;
+ try
+ {
+ wresp = wr.GetResponse();
+ Stream stream2 = wresp.GetResponseStream();
+ 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";
+ }
+ return "0";
+ }
+ catch
+ {
+ return "-1";
+ }
+ finally
+ {
+ if (wresp != null)
+ {
+ wresp.Close();
+ wresp = null;
+ }
+ wr = null;
+ }
+ }
+
#endregion
@@ -692,7 +1179,7 @@
foreach (string fileName in listFile)
{
//鐢熸垚鐨勬枃浠跺叏閮ㄥ垹闄�,鎴块棿鏂囦欢鐨勮瘽,涓嬮潰浼氶噸鏂扮敓鎴�
- HdlShardLogic.Current.DeleteShardFile(fileName);
+ this.DeleteShardFile(fileName);
}
foreach (var roomKeys in memberShardInfo.dicShardRoom.Keys)
@@ -708,7 +1195,7 @@
memberShardInfo.dicShardRoom[roomKeys].SceneUIFilePathList.AddRange(dicBackScene[roomKeys]);
//瑕嗙洊鎴块棿鏂囦欢
- HdlShardLogic.Current.AddShardFile(memberShardInfo.dicShardRoom[roomKeys]);
+ this.AddShardFile(memberShardInfo.dicShardRoom[roomKeys]);
}
}
@@ -739,10 +1226,7 @@
var listMark = new List<string>();
//瑕佸垹闄ょ殑鏂囦欢鍚嶅瓧
var listDeleteFile = new List<string>();
- //杩欎釜鏄彧绉婚櫎缂撳瓨鐨勬枃浠跺悕瀛�
- var listDeleteFileEx = new List<string>();
- //浜戠鐨勬寚瀹氭埧闂寸殑鍏变韩鏂囦欢鍒楄〃
- var dicShardFile = memberShardInfo.dicAllMemberShard[nowRoom.FileName];
+
//闄や簡瑕佸垹闄ょ殑鐩爣澶栵紝杩樺垎浜殑鏁版嵁
var listHadShard = this.GetAllShardedFileNameFromDictionary(memberShardInfo, nowRoom, listDevice, listSceneUI);
@@ -752,16 +1236,15 @@
string deviceFileName = device.FilePath;
//绉婚櫎璺緞鍒楄〃
- roomTemp.DeviceUIFilePathList.Remove($"DeviceUI_{device.FilePath}");
+ roomTemp.DeviceUIFilePathList.Remove(device.FilePath);
if (listHadShard.Contains(deviceFileName) == true)
{
- //鍏朵粬鎴块棿鍒嗕韩鏈夎繖涓澶�,鎵�浠ヤ笉鍒犻櫎杩欎釜璁惧鐨勬牴婧愭枃浠�,鍙槸鎶婃埧闂寸殑璁惧鍒楄〃璺緞绉婚櫎
- listDeleteFileEx.Add(deviceFileName);
+ //鍏朵粬鍦烘櫙鍒嗕韩鏈夎繖涓澶�,鎵�浠ヤ笉鍒犻櫎杩欎釜璁惧鐨勬牴婧愭枃浠�,鍙槸鎶婃埧闂寸殑璁惧鍒楄〃璺緞绉婚櫎
continue;
}
//璁惧涓婚敭
- if (dicShardFile.Contains(deviceFileName) == true)
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(deviceFileName) == true)
{
listMark.Add(memberShardInfo.dicAllShardKeys[deviceFileName]);
}
@@ -778,21 +1261,31 @@
//浣嗘槸瀹冪粦瀹氱殑璁惧鐩爣瑕佸垹闄�
if (listHadShard.Contains(sceneUI.FileName) == true)
{
- listDeleteFileEx.Add(sceneUI.FileName);
+ continue;
}
- else
+ //鑾峰彇瑕佸垹闄ょ殑鍒嗕韩涓婚敭
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(sceneUI.FileName) == true)
{
- //鑾峰彇瑕佸垹闄ょ殑鍒嗕韩涓婚敭
- if (dicShardFile.Contains(sceneUI.FileName) == true)
+ listMark.Add(memberShardInfo.dicAllShardKeys[sceneUI.FileName]);
+ }
+ listDeleteFile.Add(sceneUI.FileName);
+
+ //鍒犻櫎鑷畾涔夊浘鐗�,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰�
+ if (sceneUI.IconPathType != 0)
+ {
+ string[] Arry = sceneUI.IconPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+ string sceneFile = Arry[Arry.Length - 1];
+ listDeleteFile.Add(sceneFile);
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(sceneFile) == true)
{
- listMark.Add(memberShardInfo.dicAllShardKeys[sceneUI.FileName]);
+ listMark.Add(memberShardInfo.dicAllShardKeys[sceneFile]);
}
- listDeleteFile.Add(sceneUI.FileName);
}
//鎵ц鍒犻櫎宓屽鐨勮澶�
var listTemp = new HashSet<string>();
- this.GetSceneBindFileName(sceneUI, ref listTemp);
+ var dicBindScene = new Dictionary<string, SceneUI>();
+ this.GetSceneBindFileName(sceneUI, ref listTemp, ref dicBindScene);
foreach (var fileName in listTemp)
{
if (listHadShard.Contains(fileName) == true)
@@ -800,19 +1293,47 @@
continue;
}
//鑾峰彇瑕佸垹闄ょ殑鍒嗕韩涓婚敭
- if (dicShardFile.Contains(fileName) == true)
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(fileName) == true)
{
listMark.Add(memberShardInfo.dicAllShardKeys[fileName]);
}
listDeleteFile.Add(fileName);
+
+ if (dicBindScene.ContainsKey(fileName) == true && dicBindScene[fileName].IconPathType != 0)
+ {
+ //鍒犻櫎鑷畾涔夊満鏅浘鐗�,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰�
+ string[] Arry = dicBindScene[fileName].IconPath.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+ string sceneFile = Arry[Arry.Length - 1];
+ listDeleteFile.Add(sceneFile);
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(sceneFile) == true)
+ {
+ listMark.Add(memberShardInfo.dicAllShardKeys[sceneFile]);
+ }
+ }
}
}
//濡傛灉杩欎釜鎴块棿鐨勫垎浜澶囧拰鍦烘櫙鍏ㄩ儴鍒犻櫎鐨勮瘽,鎶婂垎浜埧闂存枃浠朵篃涓�璧峰垹闄�
if (roomTemp.DeviceUIFilePathList.Count == 0 && roomTemp.SceneUIFilePathList.Count == 0)
{
- listMark.Add(memberShardInfo.dicAllShardKeys[nowRoom.FileName]);
+ //鎴块棿鍒犻櫎
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(nowRoom.FileName) == true)
+ {
+ listMark.Add(memberShardInfo.dicAllShardKeys[nowRoom.FileName]);
+ }
listDeleteFile.Add(nowRoom.FileName);
+
+ if (nowRoom.BackgroundImageType != 0)
+ {
+ //鍒犻櫎鑷畾涔夋埧闂村浘鐗�,瀹冨瓨鍦ㄤ簬鏈湴,浣嗘槸瀹冩槸鍏ㄨ矾寰�
+ string[] Arry = nowRoom.BackgroundImage.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
+ string roomFile = Arry[Arry.Length - 1];
+ listDeleteFile.Add(roomFile);
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(roomFile) == true)
+ {
+ listMark.Add(memberShardInfo.dicAllShardKeys[roomFile]);
+ }
+ }
}
//鎵ц绉婚櫎鍒嗕韩鏁版嵁
@@ -820,21 +1341,28 @@
//鍚屾鎴块棿鏂囦欢
if (result == true && listDeleteFile.Contains(roomTemp.FileName) == false)
{
- //鎵ц涓婁紶瀵硅薄
+ //鎵ц涓婁紶鎴块棿瀵硅薄
result = await this.DoUploadRoomObject(memberShardInfo, roomTemp);
}
- if (result == true)
+ //鍚屾妤煎眰鏁版嵁
+ if (result == true && listDeleteFile.Contains(roomTemp.FileName) == true)
{
- foreach (var exFile in listDeleteFileEx)
+ int floorCount = 0;
+ foreach (var myRoom in memberShardInfo.dicShardRoom.Values)
{
- //鍙Щ闄ょ紦瀛�,涓嶅垹闄や簯绔�
- if (dicShardFile.Contains(exFile) == true)
- {
- dicShardFile.Remove(exFile);
- }
+ if (myRoom.FloorId == roomTemp.FloorId) { floorCount++; }
}
+ if (floorCount == 0)
+ {
+ //濡傛灉璇ユゼ灞傚凡缁忓垹瀹屾埧闂翠簡,鍒欐洿鏂版ゼ灞�
+ memberShardInfo.dicShardFloor.Remove(roomTemp.FloorId);
+ //鎵ц涓婁紶瀵硅薄
+ result = await this.DoUploadFloorObject(memberShardInfo);
+ }
+
}
- else
+
+ if (result == false)
{
//鎭㈠
roomTemp.DeviceUIFilePathList.Clear();
@@ -889,8 +1417,7 @@
}
//鍏抽棴杩涘害鏉�
ProgressBar.Close();
-
- var dicShard = memberShardInfo.dicAllMemberShard[nowRoom.FileName];
+ ;
for (int i = 0; i < listDeleteFile.Count; i++)
{
string fileName = listDeleteFile[i];
@@ -898,16 +1425,50 @@
{
//鏈�鍚庝竴涓浐瀹氬彲鑳芥槸鎴块棿鏂囦欢,鐩存帴绉婚櫎鏁翠釜瀵硅薄
memberShardInfo.dicShardRoom.Remove(fileName);
- memberShardInfo.dicAllMemberShard.Remove(fileName);
- }
- else
- {
- //绉婚櫎鎸囧畾鏂囦欢
- dicShard.Remove(fileName);
}
memberShardInfo.dicAllShardKeys.Remove(fileName);
- HdlShardLogic.Current.DeleteShardFile(fileName);
+ this.DeleteShardFile(fileName);
+ }
+ return true;
+ }
+
+ /// <summary>
+ /// 鎵ц绉婚櫎鍒嗕韩鏁版嵁
+ /// </summary>
+ /// <param name="memberShardInfo">鎴愬憳鐨勫垎浜唴瀹�</param>
+ /// <param name="listDelFile">鍒犻櫎鐨勬枃浠�</param>
+ /// <returns></returns>
+ private async Task<bool> DoDeleteSharedContent(MemberShardInfoData memberShardInfo, List<string> listDelFile)
+ {
+ if (listDelFile.Count == 0)
+ {
+ return true;
+ }
+
+ var info = new DeleteShardInfo();
+ foreach (var fileName in listDelFile)
+ {
+ if (memberShardInfo.dicAllShardKeys.ContainsKey(fileName) == false)
+ {
+ //鎴戜篃涓嶇煡閬撲负浠�涔堜細鎵句笉鍒颁富閿�
+ continue;
+ }
+
+ info.DistributedMark = memberShardInfo.dicAllShardKeys[fileName];
+ //鎵ц鍒犻櫎
+ var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/DeleteShareData", false, info);
+ if (result == false)
+ {
+ return false;
+ }
+ }
+ for (int i = 0; i < listDelFile.Count; i++)
+ {
+ string fileName = listDelFile[i];
+ memberShardInfo.dicAllShardKeys.Remove(fileName);
+
+ this.DeleteShardFile(fileName);
}
return true;
}
@@ -924,6 +1485,10 @@
/// <returns></returns>
private async Task<bool> DoUploadRoomObject(MemberShardInfoData memberShardInfo, Common.Room upDateRoom)
{
+ if (upDateRoom.Id == "Other")
+ {
+ return true;
+ }
var info = new EditorShardContent();
info.DistributedMark = memberShardInfo.dicAllShardKeys[upDateRoom.FileName];
info.ShareName = upDateRoom.FileName;
@@ -938,7 +1503,37 @@
return false;
}
//灏嗘埧闂村璞″簭鍒楀寲鍒扮紦瀛�
- HdlShardLogic.Current.AddShardFile(upDateRoom);
+ this.AddShardFile(upDateRoom);
+
+ return true;
+ }
+
+ #endregion
+
+ #region 鈻� 涓婁紶妤煎眰瀵硅薄_______________________
+
+ /// <summary>
+ /// 涓婁紶妤煎眰瀵硅薄
+ /// </summary>
+ /// <param name="memberShardInfo">鎴愬憳鐨勫叡浜唴瀹�</param>
+ /// <returns></returns>
+ private async Task<bool> DoUploadFloorObject(MemberShardInfoData memberShardInfo)
+ {
+ var info = new EditorShardContent();
+ info.DistributedMark = memberShardInfo.dicAllShardKeys[DirNameResourse.ShardFloorFile];
+ info.ShareName = DirNameResourse.ShardFloorFile;
+ info.SubAccountDistributedMark = memberShardInfo.SubAccountDistributedMark;
+
+ var data = Newtonsoft.Json.JsonConvert.SerializeObject(memberShardInfo.dicShardFloor);
+ var byteData = System.Text.Encoding.UTF8.GetBytes(data);
+ info.ShareDataBytes = byteData;
+ var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/EditShareData", false, info);
+ if (result == false)
+ {
+ return false;
+ }
+ //灏嗘埧闂村璞″簭鍒楀寲鍒扮紦瀛�
+ this.AddShardFile(memberShardInfo.dicShardFloor);
return true;
}
@@ -973,20 +1568,21 @@
//鑾峰彇杩樺浜庡垎浜姸鎬佺殑鏂囦欢
foreach (var roomTemp in memberShardInfo.dicShardRoom.Values)
{
- bool flage = roomTemp.FileName == nowRoom.FileName;
//璁惧
foreach (var deviceUi in roomTemp.DeviceUIFilePathList)
{
- string deviceFile = deviceUi.Replace("DeviceUI_", string.Empty);
- if (flage == true && listDeleteFile.Contains(deviceFile) == true)
+ string deviceFile = deviceUi;
+ if (listDeleteFile.Contains(deviceFile) == true)
{
- //褰撳墠鎴块棿鐨勮鐗规畩澶勭悊锛屽鏋滄槸鍒犻櫎鐩爣锛屽垯涓嶆坊鍔�
+ //鍥犱负涓�涓洖璺彧鑳藉垎閰嶄竴涓尯鍩�,鎵�浠ュ彲浠ョ洿鎺ュ垽鏂�
continue;
}
if (listShardFile.Contains(deviceFile) == false)
{
+ //杩欎釜鏂囦欢杩樺垎浜潃
listShardFile.Add(deviceFile);
}
+
}
//鍦烘櫙
foreach (var scene in roomTemp.SceneUIList)
@@ -996,14 +1592,19 @@
//杩欎釜鍦烘櫙宸茬粡琚垹闄�
continue;
}
- if (flage == true && listDeleteFile.Contains(scene.FileName) == true)
+ if (roomTemp.FileName == nowRoom.FileName)
{
- //褰撳墠鎴块棿鐨勮鐗规畩澶勭悊锛屽鏋滄槸鍒犻櫎鐩爣锛屽垯涓嶆坊鍔�
- continue;
+ //濡傛灉寰幆鍒颁簡褰撳墠鎴块棿
+ if (listDeleteFile.Contains(scene.FileName) == true)
+ {
+ //濡傛灉鏄垹闄ょ洰鏍囷紝鍒欎笉娣诲姞
+ continue;
+ }
}
//鑾峰彇鍦烘櫙閲岄潰鐨勫叏閮ㄧ洰鏍�
var listTemp = new HashSet<string>();
- this.GetSceneBindFileName(scene, ref listTemp);
+ var dicTemp = new Dictionary<string, SceneUI>();
+ this.GetSceneBindFileName(scene, ref listTemp, ref dicTemp);
if (listShardFile.Contains(scene.FileName) == false)
{
@@ -1027,7 +1628,8 @@
/// </summary>
/// <param name="scene">鍦烘櫙</param>
/// <param name="listFile">鏂囦欢鍒楄〃(閲岄潰瀛樼殑鏄澶嘦I鏂囦欢鍜岃澶囨枃浠跺拰鍦烘櫙鏂囦欢)</param>
- private void GetSceneBindFileName(Common.SceneUI scene, ref HashSet<string> listFile)
+ /// <param name="dicBindScene">缁戝畾鐨勫満鏅璞�</param>
+ private void GetSceneBindFileName(Common.SceneUI scene, ref HashSet<string> listFile,ref Dictionary<string, SceneUI> dicBindScene)
{
foreach (var data in scene.AddSceneMemberDataList)
{
@@ -1035,17 +1637,28 @@
if (data.Type == 0)
{
var device = Common.LocalDevice.Current.GetDevice(data.DeviceAddr, data.Epoint);
- if (device != null&& listFile.Contains(device.FilePath) == false)
+ if (device != null && listFile.Contains(device.FilePath) == false)
{
listFile.Add(device.FilePath);
}
}
if (data.Type == 1)
{
- var sceneTemp = Room.CurrentRoom.GetSceneUIBySceneId(data.ElseScenesId);
- if (sceneTemp != null && listFile.Contains(sceneTemp.FileName))
+ var temp = new SceneUI();
+ temp.Id = data.ElseScenesId;
+ var byteData = this.GetShardFileContent(temp.FileName);
+ if (byteData != null)
{
- listFile.Add(sceneTemp.FileName);
+ string valueData = System.Text.Encoding.UTF8.GetString(byteData);
+ var roomTemp = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(valueData);
+ if (roomTemp != null)
+ {
+ dicBindScene[roomTemp.FileName] = roomTemp;
+ if (listFile.Contains(roomTemp.FileName) == false)
+ {
+ listFile.Add(roomTemp.FileName);
+ }
+ }
}
}
}
@@ -1124,6 +1737,20 @@
public string SubAccountDistributedMark = string.Empty;
}
+ /// <summary>
+ /// 鎺ユ敹鍒嗕韩鏁版嵁
+ /// </summary>
+ private class ReceiveShardInfoResult
+ {
+ /// <summary>
+ /// 鏂囦欢鍚嶅瓧
+ /// </summary>
+ public string ShareName = string.Empty;
+ /// <summary>
+ /// 涓婚敭
+ /// </summary>
+ public string DistributedMark = string.Empty;
+ }
#endregion
}
--
Gitblit v1.8.0