黄学彪
2020-07-06 f23ad1b3f9f6193f35f72104d690b21dc67d5c1f
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs
@@ -5,7 +5,6 @@
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using ZigBee.Device;
namespace Shared.Phone.UserCenter
@@ -53,7 +52,7 @@
        /// </summary>
        /// <param name="listDistributedMark"></param>
        /// <returns></returns>
        private async Task<List<string>> SetShardFileToLocation(List<string> listDistributedMark)
        private List<string> SetShardFileToLocation(List<string> listDistributedMark)
        {
            if (listDistributedMark.Count == 0)
            {
@@ -73,8 +72,8 @@
            {
                string keys = listDistributedMark[i];
                var dataPra = new { DistributedMark = keys, HouseDistributedMark = Common.Config.Instance.Home.Id, IsOtherAccountControl = Common.Config.Instance.Home.IsOthreShare };
                var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetOneShareData", false, dataPra);
                if (result == null)
                var result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetOneShareData", false, dataPra, null, true);
                if (string.IsNullOrEmpty(result) == true)
                {
                    //允许按系统的返回键
                    Shared.Common.CommonPage.BackKeyCanClick = true;
@@ -239,7 +238,7 @@
        /// <summary>
        /// 同步服务器的分享内容(里面只负责把东西存入本地)
        /// </summary>
        public async Task<bool> SynchronizeDbSharedContent()
        public bool SynchronizeDbSharedContent()
        {
            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
@@ -249,8 +248,7 @@
            //获取主人分享给成员的文件列表
            var infoPra = new { DistributedMark = Config.Instance.Guid, HouseDistributedMark = Common.Config.Instance.Home.Id, IsOtherAccountControl = Common.Config.Instance.Home.IsOthreShare };
            var listNotShow = new List<string>() { "NotSetAgain" };
            var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra, listNotShow);
            var result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra);
            if (string.IsNullOrEmpty(result) == true)
            {
                return false;
@@ -291,7 +289,7 @@
                //将分享的数据存入本地(获取的是本地没有的)
                this.ClearShardDirectory();
                var listDbFile = await this.SetShardFileToLocation(listAddMark);
                var listDbFile = this.SetShardFileToLocation(listAddMark);
                if (listDbFile == null)
                {
                    //关闭
@@ -317,7 +315,7 @@
            }
            //同步服务器的取消了的分享内容
            return await this.SynchronizeDeleteSharedContent(listShardFile, dicUpdateTime);
            return this.SynchronizeDeleteSharedContent(listShardFile, dicUpdateTime);
        }
        /// <summary>
@@ -326,7 +324,7 @@
        /// <param name="listShardFile">云端上面分享的文件,为Null时从新获取</param>
        /// <param name="dicUpdateTime">分享文件的更新时间,为Null时从新获取</param>
        /// <returns></returns>
        public async Task<bool> SynchronizeDeleteSharedContent(HashSet<string> listShardFile = null, Dictionary<string, string> dicUpdateTime = null)
        public bool SynchronizeDeleteSharedContent(HashSet<string> listShardFile = null, Dictionary<string, string> dicUpdateTime = null)
        {
            if (UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
@@ -349,8 +347,7 @@
                listShardFile = new HashSet<string>();
                //获取主人分享给成员的文件列表
                var infoPra = new { DistributedMark = Config.Instance.Guid, HouseDistributedMark = Common.Config.Instance.Home.Id, IsOtherAccountControl = Common.Config.Instance.Home.IsOthreShare };
                var listNotShow = new List<string>() { "NotSetAgain" };
                var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra, listNotShow);
                var result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra);
                if (string.IsNullOrEmpty(result) == true)
                {
                    //关闭
@@ -487,7 +484,7 @@
        /// <para>New的时候记得对SubAccountDistributedMark赋值,它是成员列表接口返回的SubAccountDistributedMark</para>
        /// </param>
        /// <returns></returns>
        public async Task<bool> GetMemberShardContentListAndSetToLocation(MemberShardInfoData memberShardInfo)
        public bool GetMemberShardContentListAndSetToLocation(MemberShardInfoData memberShardInfo)
        {
            if (memberShardInfo.Refresh == false)
            {
@@ -507,8 +504,8 @@
                HouseDistributedMark = Shared.Common.Config.Instance.HomeId,
                IsOtherAccountControl = Common.Config.Instance.Home.IsOthreShare
            };
            var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra);
            if (result == null)
            var result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/GetShareDataBySubAccount", false, infoPra);
            if (string.IsNullOrEmpty(result) == true)
            {
                //关闭进度条
                ProgressFormBar.Current.Close();
@@ -542,7 +539,7 @@
            }
            //将分享的数据存入本地,返回的是文件名字(异常时返回null)
            var listFile = await this.SetShardFileToLocation(listMark);
            var listFile = this.SetShardFileToLocation(listMark);
            if (listFile == null)
            {
                //关闭进度条
@@ -736,7 +733,7 @@
        /// <param name="listScene">选择上传的场景(不要获取它里面的绑定列表)</param>
        /// <param name="BarMaxValue">进度条的最大值,如果不为-1,则内部不会自动弹出进度条</param>
        /// <param name="listCheckFile">文件重复上传检测</param>
        public async Task<bool> DoUploadSharedContent(MemberShardInfoData memberShardInfo, Common.Room nowRoom,
        public bool DoUploadSharedContent(MemberShardInfoData memberShardInfo, Common.Room nowRoom,
            List<CommonDevice> listDevice, List<Common.SceneUI> listScene, int BarMaxValue = -1, HashSet<string> listCheckFile = null)
        {
            if (listDevice.Count == 0 && listScene.Count == 0)
@@ -790,11 +787,11 @@
            }
            //上传分享
            var result = await this.DoUploadShardContent(memberShardInfo, listFile, listCheckFile);
            var result = this.DoUploadShardContent(memberShardInfo, listFile, listCheckFile);
            if (result == true)
            {
                //删除指定自定义图片
                result = await this.DoDeleteSharedContent(memberShardInfo, listDelPic);
                result = this.DoDeleteSharedContent(memberShardInfo, listDelPic);
            }
            if (BarMaxValue == -1)
            {
@@ -1008,7 +1005,7 @@
        /// <param name="listFile">上传的文件名</param>
        /// <param name="listCheckFile">重复文件上传检测</param>
        /// <returns></returns>
        private async Task<bool> DoUploadShardContent(MemberShardInfoData memberShardInfo, List<string> listFile, HashSet<string> listCheckFile)
        private bool DoUploadShardContent(MemberShardInfoData memberShardInfo, List<string> listFile, HashSet<string> listCheckFile)
        {
            var dicKeys = new Dictionary<string, string>();
            for (int i = 0; i < listFile.Count; i++)
@@ -1043,8 +1040,8 @@
                    //追加共享
                    if (memberShardInfo.dicAllShardKeys.ContainsKey(fileName) == false)
                    {
                        var result = await UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/AddShareData", false, info);
                        if (result == null)
                        var result = UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeDataShare/AddShareData", false, info, null, true);
                        if (string.IsNullOrEmpty(result) == true)
                        {
                            return false;
                        }
@@ -1054,7 +1051,7 @@
                    else
                    {
                        info.DistributedMark = memberShardInfo.dicAllShardKeys[fileName];
                        var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/EditShareData", false, info);
                        var result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/EditShareData", false, info, null, true);
                        if (result == false)
                        {
                            return false;
@@ -1275,7 +1272,7 @@
        /// <param name="listDevice">要取消的设备</param>
        /// <param name="listSceneUI">要取消的场景</param>
        /// <returns></returns>
        public async Task<bool> DoDeleteSharedContent(MemberShardInfoData memberShardInfo, Common.Room nowRoom,
        public bool DoDeleteSharedContent(MemberShardInfoData memberShardInfo, Common.Room nowRoom,
            List<CommonDevice> listDevice, List<SceneUI> listSceneUI)
        {
            var roomTemp = memberShardInfo.dicShardRoom[nowRoom.FileName];
@@ -1404,12 +1401,12 @@
            }
            //执行移除分享数据
            var result = await this.DoDeleteSharedContent(memberShardInfo, nowRoom, listMark, listDeleteFile);
            var result = this.DoDeleteSharedContent(memberShardInfo, nowRoom, listMark, listDeleteFile);
            //同步房间文件
            if (result == true && listDeleteFile.Contains(roomTemp.FileName) == false)
            {
                //执行上传房间对象
                result = await this.DoUploadRoomObject(memberShardInfo, roomTemp);
                result = this.DoUploadRoomObject(memberShardInfo, roomTemp);
            }
            //同步楼层数据
            if (result == true && listDeleteFile.Contains(roomTemp.FileName) == true)
@@ -1428,7 +1425,7 @@
                    //如果该楼层已经删完房间了,则更新楼层
                    memberShardInfo.dicShardFloor.Remove(roomTemp.FloorId);
                    //执行上传对象
                    result = await this.DoUploadFloorObject(memberShardInfo);
                    result = this.DoUploadFloorObject(memberShardInfo);
                }
            }
@@ -1456,7 +1453,7 @@
        /// <param name="listMark">要移除的主键</param>
        /// <param name="listDeleteFile">要删除的文件(房间文件需要删除的话,必须放在最后)</param>
        /// <returns></returns>
        private async Task<bool> DoDeleteSharedContent(MemberShardInfoData memberShardInfo, Common.Room nowRoom,
        private bool DoDeleteSharedContent(MemberShardInfoData memberShardInfo, Common.Room nowRoom,
            List<string> listMark, List<string> listDeleteFile)
        {
            if (listMark.Count == 0)
@@ -1477,7 +1474,7 @@
                info.DistributedMark = markKeys;
                //执行删除
                var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/DeleteShareData", false, info);
                var result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/DeleteShareData", false, info, null, true);
                if (result == false)
                {
                    //关闭进度条
@@ -1508,7 +1505,7 @@
        /// <param name="memberShardInfo">成员的分享内容</param>
        /// <param name="listDelFile">删除的文件</param>
        /// <returns></returns>
        private async Task<bool> DoDeleteSharedContent(MemberShardInfoData memberShardInfo, List<string> listDelFile)
        private bool DoDeleteSharedContent(MemberShardInfoData memberShardInfo, List<string> listDelFile)
        {
            if (listDelFile.Count == 0)
            {
@@ -1526,7 +1523,7 @@
                info.DistributedMark = memberShardInfo.dicAllShardKeys[fileName];
                //执行删除
                var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/DeleteShareData", false, info);
                var result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/DeleteShareData", false, info, null, true);
                if (result == false)
                {
                    return false;
@@ -1552,7 +1549,7 @@
        /// <param name="memberShardInfo">成员的共享内容</param>
        /// <param name="upDateRoom">需要上传到云端的房间对象</param>
        /// <returns></returns>
        private async Task<bool> DoUploadRoomObject(MemberShardInfoData memberShardInfo, Common.Room upDateRoom)
        private bool DoUploadRoomObject(MemberShardInfoData memberShardInfo, Common.Room upDateRoom)
        {
            if (upDateRoom.Id == "Other")
            {
@@ -1566,7 +1563,7 @@
            var data = Newtonsoft.Json.JsonConvert.SerializeObject(upDateRoom);
            var byteData = System.Text.Encoding.UTF8.GetBytes(data);
            info.ShareDataBytes = byteData;
            var result = await UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/EditShareData", false, info);
            var result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/EditShareData", false, info, null, true);
            if (result == false)
            {
                return false;
@@ -1586,7 +1583,7 @@
        /// </summary>
        /// <param name="memberShardInfo">成员的共享内容</param>
        /// <returns></returns>
        private async Task<bool> DoUploadFloorObject(MemberShardInfoData memberShardInfo)
        private bool DoUploadFloorObject(MemberShardInfoData memberShardInfo)
        {
            var info = new EditorShardContent();
            info.DistributedMark = memberShardInfo.dicAllShardKeys[DirNameResourse.ShardFloorFile];
@@ -1596,7 +1593,7 @@
            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);
            var result = UserCenterLogic.GetResultStatuByRequestHttps("ZigbeeDataShare/EditShareData", false, info, null, true);
            if (result == false)
            {
                return false;