| | |
| | | m_Current = value;
|
| | | }
|
| | | }
|
| | | /// <summary>
|
| | | /// 分享的设备文件(key:设备主键,value:设备文件)
|
| | | /// </summary>
|
| | | private Dictionary<string, string> dicShardDeviceFile = new Dictionary<string, string>();
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取分享文件_______________________
|
| | |
| | | /// </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>();
|
| | | //文件夹
|
| | |
| | | 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)
|
| | |
| | | //保存到指定文件夹下
|
| | | Global.WriteFileToDirectoryByBytes(strDir, dataResult.ShareName, dataResult.ShareDataBytes);
|
| | | //设置进度值
|
| | | ProgressBar.SetValue(1);
|
| | | ProgressFormBar.Current.SetValue(i + 1, listMarkCount);
|
| | | }
|
| | |
|
| | | //允许按系统的返回键
|
| | |
| | | /// </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();
|
| | | 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
|
| | |
| | | //从云端获取下来文件
|
| | | 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();
|
| | |
| | | if (listDbFile == null)
|
| | | {
|
| | | //关闭
|
| | | ProgressBar.Close();
|
| | | ProgressFormBar.Current.Close();
|
| | | return false;
|
| | | }
|
| | |
|
| | |
| | | //只有成员才有这个概念
|
| | | 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)
|
| | | {
|
| | |
| | | if (string.IsNullOrEmpty(result) == true)
|
| | | {
|
| | | //关闭
|
| | | ProgressBar.Close();
|
| | | ProgressFormBar.Current.Close();
|
| | | return false;
|
| | | }
|
| | | var listShardData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<GetShardInfoResult>>(result);
|
| | |
| | | //保存全部分享文件的更新日期
|
| | | this.SaveAllShardFileAgoUpdateTime(dicUpdateTime);
|
| | | //关闭
|
| | | ProgressBar.Close();
|
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | /// <summary>
|
| | | /// 获取成员共享列表然后保存到本地(用完之后最好调用清空 ClearShardDirectory函数清空)
|
| | | /// </summary>
|
| | | /// <param name="SubAccountDistributedMark">成员列表接口返回的SubAccountDistributedMark</param>
|
| | | /// <param name="memberShardInfo">
|
| | | /// <para>成员的分享数据</para>
|
| | | /// <para>如果不知道这是什么东西,就New一个,然后缓存起来,调用其他函数都需要这个东西</para>
|
| | |
| | | {
|
| | | 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
|
| | | {
|
| | |
| | | if (result == null)
|
| | | {
|
| | | //关闭进度条
|
| | | ProgressBar.Close();
|
| | | ProgressFormBar.Current.Close();
|
| | | return false;
|
| | | }
|
| | | var listData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ReceiveShardInfoResult>>(result);
|
| | |
| | | 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
|
| | |
|
| | |
| | | //克隆一个对象
|
| | | 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
|
| | |
| | | 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;
|
| | |
| | | //设备
|
| | | listFile.Add(device.FilePath);
|
| | | this.AddShardFile(device.FilePath);
|
| | |
|
| | | //加点缓存
|
| | | this.dicShardDeviceFile[LocalDevice.Current.GetDeviceMainKeys(device)] = device.FilePath;
|
| | |
|
| | | //设备的UI
|
| | | var deviceUi = device.FilePath;
|
| | |
| | | //设备
|
| | | 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);
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 从网关获取场景的目标设备列表
|
| | | /// 获取场景的目标设备列表(这个不能从分享数据中获取)
|
| | | /// </summary>
|
| | | /// <param name="scene">场景</param>
|
| | | /// <param name="listCheck">重复检测用</param>
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | /// <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");
|
| | |
| | | wr.Method = "POST";
|
| | | wr.KeepAlive = true;
|
| | | wr.Credentials = System.Net.CredentialCache.DefaultCredentials;
|
| | |
|
| | | wr.Headers.Add(HttpRequestHeader.Authorization, Config.Instance.Token);
|
| | |
|
| | | var rs = wr.GetRequestStream();
|
| | |
|
| | |
| | | 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
|
| | | {
|
| | |
| | | }
|
| | | //关闭进度条
|
| | | ProgressBar.Close();
|
| | | ;
|
| | | for (int i = 0; i < listDeleteFile.Count; i++)
|
| | | {
|
| | | string fileName = listDeleteFile[i];
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 从场景对象里面获取全部的绑定目标的文件名字
|
| | | /// 从场景对象里面获取全部的绑定目标的文件名字(这里面的东西必须从分享数据中获取)
|
| | | /// </summary>
|
| | | /// <param name="scene">场景</param>
|
| | | /// <param name="listFile">文件列表(里面存的是设备UI文件和设备文件和场景文件)</param>
|
| | |
| | | //设备
|
| | | 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)
|
| | |
| | | {
|
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|