gxc
2020-02-28 66a9965c44ecc32a6696abca876ab9d1cd091584
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlShardLogic.cs
@@ -39,6 +39,11 @@
                m_Current = value;
            }
        }
        /// <summary>
        /// 分享的设备文件(key:设备主键,value:设备文件)
        /// </summary>
        private Dictionary<string, string> dicShardDeviceFile = new Dictionary<string, string>();
        #endregion
        #region ■ 获取分享文件_______________________
@@ -48,13 +53,13 @@
        /// </summary>
        /// <param name="listDistributedMark"></param>
        /// <returns></returns>
        public async Task<List<string>> SetShardFileToLocation(List<string> listDistributedMark)
        private async Task<List<string>> SetShardFileToLocation(List<string> listDistributedMark)
        {
            if (listDistributedMark.Count == 0)
            {
                return new List<string>();
            }
            ProgressBar.SetMaxValue(listDistributedMark.Count);
            int listMarkCount = listDistributedMark.Count;
            List<string> listFile = new List<string>();
            //文件夹
@@ -64,8 +69,9 @@
            Shared.Common.CommonPage.BackKeyCanClick = false;
            UserCenterResourse.Option.AppCanSignout = false;
            foreach (string keys in listDistributedMark)
            for (int i = 0; i < listDistributedMark.Count; i++)
            {
                string keys = listDistributedMark[i];
                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)
@@ -81,7 +87,7 @@
                //保存到指定文件夹下
                Global.WriteFileToDirectoryByBytes(strDir, dataResult.ShareName, dataResult.ShareDataBytes);
                //设置进度值
                ProgressBar.SetValue(1);
                ProgressFormBar.Current.SetValue(i + 1, listMarkCount);
            }
            //允许按系统的返回键
@@ -220,118 +226,10 @@
        /// </summary>
        public void ClearShardDirectory()
        {
            this.dicShardDeviceFile.Clear();
            //创建文件夹
            string strDir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadShardDirectory);
            Global.CreateEmptyDirectory(strDir, true);
        }
        #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);
                }
            }
            //设置房间里面设备的UI对象(因为这个东西是反序列化出来的,设备UI对象是不序列化对象)
            foreach (var tempRoom in memberShardInfo.dicShardRoom.Values)
            {
                //还原设备对象
                tempRoom.DeviceUIList.Clear();
                foreach (string uiPath in tempRoom.DeviceUIFilePathList)
                {
                    string deviceFile = uiPath.Replace("DeviceUI_", string.Empty);
                    //这个设备文件匹配得到房间
                    listDeviceFile.Remove(deviceFile);
                    if (this.IsFileExists(deviceFile) == false)
                    {
                        continue;
                    }
                    tempRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(uiPath));
                }
                //还原场景对象
                tempRoom.SceneUIList.Clear();
                foreach (string uiPath in tempRoom.SceneUIFilePathList)
                {
                    //这个场景文件匹配得到房间
                    listSceneFile.Remove(uiPath);
                    var byteData = this.GetShardFileContent(uiPath);
                    if (byteData == null)
                    {
                        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
@@ -387,11 +285,9 @@
            //从云端获取下来文件
            if (listAddMark.Count > 0)
            {
                //强制指定文本附加信息:共享数据同步中
                string msg = Language.StringByID(R.MyInternationalizationString.uShardDataIsSynchronizing);
                //开启进度条
                ProgressBar.Show(msg);
                ProgressBar.SetAppendText(msg);
                //开启进度条 共享数据同步中
                ProgressFormBar.Current.Start();
                ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uShardDataIsSynchronizing));
                //将分享的数据存入本地(获取的是本地没有的)
                this.ClearShardDirectory();
@@ -399,15 +295,17 @@
                if (listDbFile == null)
                {
                    //关闭
                    ProgressBar.Close();
                    ProgressFormBar.Current.Close();
                    return false;
                }
                //生成文件
                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)
                    {
                        //房间文件特殊处理
@@ -435,11 +333,9 @@
                //只有成员才有这个概念
                return true;
            }
            //强制指定文本附加信息:共享数据同步中
            string msg = Language.StringByID(R.MyInternationalizationString.uShardDataIsSynchronizing);
            //开启进度条
            ProgressBar.Show(msg);
            ProgressBar.SetAppendText(msg);
            //开启进度条  共享数据同步中
            ProgressFormBar.Current.Start();
            ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uShardDataIsSynchronizing));
            if (dicUpdateTime == null)
            {
@@ -458,7 +354,7 @@
                if (string.IsNullOrEmpty(result) == true)
                {
                    //关闭
                    ProgressBar.Close();
                    ProgressFormBar.Current.Close();
                    return false;
                }
                var listShardData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GetShardInfoResult>>(result);
@@ -473,13 +369,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);
@@ -524,7 +432,7 @@
            //保存全部分享文件的更新日期
            this.SaveAllShardFileAgoUpdateTime(dicUpdateTime);
            //关闭
            ProgressBar.Close();
            ProgressFormBar.Current.Close();
            return true;
        }
@@ -570,7 +478,6 @@
        /// <summary>
        /// 获取成员共享列表然后保存到本地(用完之后最好调用清空 ClearShardDirectory函数清空)
        /// </summary>
        /// <param name="SubAccountDistributedMark">成员列表接口返回的SubAccountDistributedMark</param>
        /// <param name="memberShardInfo">
        /// <para>成员的分享数据</para>
        /// <para>如果不知道这是什么东西,就New一个,然后缓存起来,调用其他函数都需要这个东西</para>
@@ -581,12 +488,15 @@
        {
            if (memberShardInfo.Refresh == false)
            {
                //从本地获取成员的分享列表
                this.GetMemberShardContentListFromLocal(memberShardInfo);
                return true;
            }
            memberShardInfo.Refresh = false;
            //打开进度条
            ProgressBar.Show();
            //正在获取分享数据
            ProgressFormBar.Current.Start();
            ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uShardContentGetting));
            var infoPra = new
            {
@@ -598,7 +508,7 @@
            if (result == null)
            {
                //关闭进度条
                ProgressBar.Close();
                ProgressFormBar.Current.Close();
                return false;
            }
            var listData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ReceiveShardInfoResult>>(result);
@@ -633,14 +543,163 @@
            if (listFile == null)
            {
                //关闭进度条
                ProgressBar.Close();
                ProgressFormBar.Current.Close();
                return false;
            }
            //从本地获取成员的分享列表
            this.GetMemberShardContentListFromLocal(memberShardInfo);
            //关闭进度条
            ProgressBar.Close();
            ProgressFormBar.Current.Close();
            return true;
        }
        /// <summary>
        /// 从本地获取成员的分享列表
        /// </summary>
        /// <param name="memberShardInfo">成员的分享数据的缓存(调用这个函数会刷新这个变量的信息)</param>
        private void GetMemberShardContentListFromLocal(MemberShardInfoData memberShardInfo)
        {
            memberShardInfo.dicShardRoom = new Dictionary<string, Common.Room>();
            this.dicShardDeviceFile.Clear();
            var listDeviceFile = new HashSet<string>();
            var listSceneFile = new HashSet<string>();
            var listFile = this.GetLocalAllShardFile();
            //先初始化房间
            foreach (string fileName in listFile)
            {
                try
                {
                    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)
                    {
                        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);
                    }
                    else if (fileName.StartsWith("Scene_") == true)
                    {
                        //场景文件
                        listSceneFile.Add(fileName);
                    }
                }
                catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
            }
            //设置房间里面设备的UI对象(因为这个东西是反序列化出来的,设备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);
                    //获取场景里面的全部目标(2019.11.05追加操作,有可能那个设备是由场景嵌套来的,所以它有可能不属于任何房间)
                    foreach (var data in tempUi.AddSceneMemberDataList)
                    {
                        //设备
                        if (data.Type == 0)
                        {
                            string mainkey = LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
                            if (dicShardDeviceFile.ContainsKey(mainkey) == true )
                            {
                                //这个设备文件匹配得到
                                listDeviceFile.Remove(dicShardDeviceFile[mainkey]);
                            }
                        }
                        if (data.Type == 1)
                        {
                            var temp = new SceneUI();
                            temp.Id = data.ElseScenesId;
                            //这个场景文件匹配得到
                            listSceneFile.Remove(temp.FileName);
                        }
                    }
                }
            }
            //如果存在匹配不上的文件
            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.uUnallocated);
                //还原设备对象
                foreach (string deviceFile in listDeviceFile)
                {
                    roomTemp.DeviceUIFilePathList.Add(deviceFile);
                    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
@@ -772,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
@@ -790,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;
@@ -812,8 +868,11 @@
                listFile.Add(device.FilePath);
                this.AddShardFile(device.FilePath);
                //加点缓存
                this.dicShardDeviceFile[LocalDevice.Current.GetDeviceMainKeys(device)] = device.FilePath;
                //设备的UI
                var deviceUi = $"DeviceUI_{device.FilePath}";
                var deviceUi = device.FilePath;
                if (roomTemp.DeviceUIFilePathList.Contains(deviceUi) == false)
                {
                    roomTemp.DeviceUIFilePathList.Add(deviceUi);
@@ -825,17 +884,19 @@
                //设备
                listFile.Add(device.FilePath);
                this.AddShardFile(device.FilePath);
                //加点缓存
                this.dicShardDeviceFile[LocalDevice.Current.GetDeviceMainKeys(device)] = device.FilePath;
            }
            //场景
            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);
@@ -868,7 +929,7 @@
        }
        /// <summary>
        /// 从网关获取场景的目标设备列表
        /// 获取场景的目标设备列表(这个不能从分享数据中获取)
        /// </summary>
        /// <param name="scene">场景</param>
        /// <param name="listCheck">重复检测用</param>
@@ -964,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;
                        }
@@ -1012,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;
                }
                //这里有点特殊,接口是直接返回主键回来的,而不是Jsoin
                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;
                }
@@ -1038,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");
@@ -1067,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();
@@ -1106,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
            {
@@ -1229,7 +1279,7 @@
                string deviceFileName = device.FilePath;
                //移除路径列表
                roomTemp.DeviceUIFilePathList.Remove($"DeviceUI_{device.FilePath}");
                roomTemp.DeviceUIFilePathList.Remove(device.FilePath);
                if (listHadShard.Contains(deviceFileName) == true)
                {
                    //其他场景分享有这个设备,所以不删除这个设备的根源文件,只是把房间的设备列表路径移除
@@ -1410,7 +1460,6 @@
            }
            //关闭进度条
            ProgressBar.Close();
            ;
            for (int i = 0; i < listDeleteFile.Count; i++)
            {
                string fileName = listDeleteFile[i];
@@ -1564,7 +1613,7 @@
                //设备
                foreach (var deviceUi in roomTemp.DeviceUIFilePathList)
                {
                    string deviceFile = deviceUi.Replace("DeviceUI_", string.Empty);
                    string deviceFile = deviceUi;
                    if (listDeleteFile.Contains(deviceFile) == true)
                    {
                        //因为一个回路只能分配一个区域,所以可以直接判断
@@ -1617,7 +1666,7 @@
        }
        /// <summary>
        /// 从场景对象里面获取全部的绑定目标的文件名字
        /// 从场景对象里面获取全部的绑定目标的文件名字(这里面的东西必须从分享数据中获取)
        /// </summary>
        /// <param name="scene">场景</param>
        /// <param name="listFile">文件列表(里面存的是设备UI文件和设备文件和场景文件)</param>
@@ -1629,10 +1678,10 @@
                //设备
                if (data.Type == 0)
                {
                    var device = Common.LocalDevice.Current.GetDevice(data.DeviceAddr, data.Epoint);
                    if (device != null && listFile.Contains(device.FilePath) == false)
                    string mainkey = LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
                    if (dicShardDeviceFile.ContainsKey(mainkey) == true && listFile.Contains(dicShardDeviceFile[mainkey]) == false)
                    {
                        listFile.Add(device.FilePath);
                        listFile.Add(dicShardDeviceFile[mainkey]);
                    }
                }
                if (data.Type == 1)
@@ -1644,13 +1693,10 @@
                    {
                        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)
                        {
                            dicBindScene[roomTemp.FileName] = roomTemp;
                            if (listFile.Contains(roomTemp.FileName) == false)
                            {
                                listFile.Add(roomTemp.FileName);
                            }
                            listFile.Add(roomTemp.FileName);
                        }
                    }
                }