| | |
| | | using System.IO;
|
| | | using System.Net;
|
| | | using System.Text;
|
| | | using System.Threading.Tasks;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | |
| | | /// </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)
|
| | | {
|
| | |
| | | {
|
| | | 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;
|
| | |
| | | /// <summary>
|
| | | /// 同步服务器的分享内容(里面只负责把东西存入本地)
|
| | | /// </summary>
|
| | | public async Task<bool> SynchronizeDbSharedContent()
|
| | | public bool SynchronizeDbSharedContent()
|
| | | {
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 3)
|
| | | {
|
| | |
| | |
|
| | | //获取主人分享给成员的文件列表
|
| | | 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;
|
| | |
| | |
|
| | | //将分享的数据存入本地(获取的是本地没有的)
|
| | | this.ClearShardDirectory();
|
| | | var listDbFile = await this.SetShardFileToLocation(listAddMark);
|
| | | var listDbFile = this.SetShardFileToLocation(listAddMark);
|
| | | if (listDbFile == null)
|
| | | {
|
| | | //关闭
|
| | |
| | | }
|
| | |
|
| | | //同步服务器的取消了的分享内容
|
| | | return await this.SynchronizeDeleteSharedContent(listShardFile, dicUpdateTime);
|
| | | return this.SynchronizeDeleteSharedContent(listShardFile, dicUpdateTime);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <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)
|
| | | {
|
| | |
| | | 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)
|
| | | {
|
| | | //关闭
|
| | |
| | | /// <para>New的时候记得对SubAccountDistributedMark赋值,它是成员列表接口返回的SubAccountDistributedMark</para>
|
| | | /// </param>
|
| | | /// <returns></returns>
|
| | | public async Task<bool> GetMemberShardContentListAndSetToLocation(MemberShardInfoData memberShardInfo)
|
| | | public bool GetMemberShardContentListAndSetToLocation(MemberShardInfoData memberShardInfo)
|
| | | {
|
| | | if (memberShardInfo.Refresh == false)
|
| | | {
|
| | |
| | | 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();
|
| | |
| | | }
|
| | |
|
| | | //将分享的数据存入本地,返回的是文件名字(异常时返回null)
|
| | | var listFile = await this.SetShardFileToLocation(listMark);
|
| | | var listFile = this.SetShardFileToLocation(listMark);
|
| | | if (listFile == null)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | /// <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)
|
| | |
| | | }
|
| | |
|
| | | //上传分享
|
| | | 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)
|
| | | {
|
| | |
| | | /// <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++)
|
| | |
| | | //追加共享
|
| | | 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;
|
| | | }
|
| | |
| | | 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;
|
| | |
| | | /// <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];
|
| | |
| | | }
|
| | |
|
| | | //执行移除分享数据
|
| | | 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)
|
| | |
| | | //如果该楼层已经删完房间了,则更新楼层
|
| | | memberShardInfo.dicShardFloor.Remove(roomTemp.FloorId);
|
| | | //执行上传对象
|
| | | result = await this.DoUploadFloorObject(memberShardInfo);
|
| | | result = this.DoUploadFloorObject(memberShardInfo);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | /// <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)
|
| | |
| | |
|
| | | 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)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | /// <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)
|
| | | {
|
| | |
| | |
|
| | | 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;
|
| | |
| | | /// <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")
|
| | | {
|
| | |
| | | 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;
|
| | |
| | | /// </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];
|
| | |
| | | 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;
|