| | |
| | | //是否需要获取头像 |
| | | if (bGetHeadImage) |
| | | { |
| | | var headImageBytes = DownHeadImage(); |
| | | var imageKey = ImageUtlis.Current.GetHeadImageKey(info.memberId); |
| | | |
| | | var headImageBytes = ImageUtlis.Current.DownHeadImage(info.memberId); |
| | | |
| | | if (headImageBytes != null && headImageBytes.Length > 0) |
| | | { |
| | | UserInfo.Current.headImagePageBytes = headImageBytes; |
| | | FileStream fs = null; |
| | | try |
| | | { |
| | | UserInfo.Current.headImagePageBytes = headImageBytes; |
| | | var filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "/", "headImage.png"); |
| | | fs = new FileStream(filePath, FileMode.Create, FileAccess.Write); |
| | | fs.Write(headImageBytes, 0, headImageBytes.Length); |
| | | fs.Flush(); |
| | | UserInfo.Current.headImagePagePath = filePath; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MainPage.Log($"download headImage error : {ex.Message}"); |
| | | } |
| | | finally |
| | | { |
| | | if (fs != null) |
| | | { |
| | | fs.Close(); |
| | | } |
| | | } |
| | | |
| | | //UserInfo.Current.headImagePageBytes = headImageBytes; |
| | | UserInfo.Current.headImagePagePath = imageKey; |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 下载用户头像 |
| | | /// 获取用户头像 |
| | | /// </summary> |
| | | public byte[] DownHeadImage() |
| | | /// <param name="userId"></param> |
| | | public void GetUserHeadImage(string userId) |
| | | { |
| | | return HttpUtil.RequestHttpsDownload(NewAPI.API_POST_Head_Down, null); |
| | | var imageKey = ImageUtlis.Current.GetHeadImageKey(userId); |
| | | |
| | | var headImageBytes = ImageUtlis.Current.DownHeadImage(userId); |
| | | |
| | | if (headImageBytes != null && headImageBytes.Length > 0) |
| | | { |
| | | //UserInfo.Current.headImagePageBytes = headImageBytes; |
| | | UserInfo.Current.headImagePagePath = imageKey; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_UpdateMemberInfo, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新用户头像 |
| | | /// </summary> |
| | | /// <param name="vs"></param> |
| | | /// <returns></returns> |
| | | public string UpdataUserHeadImage(string fileName) |
| | | { |
| | | FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); |
| | | byte[] bytes = new byte[fs.Length]; |
| | | fs.Read(bytes, 0, bytes.Length); |
| | | var revertObj = HttpUtil.RequestHttpsUpload(RestSharp.Method.POST, NewAPI.API_POST_Head_Upload, bytes); |
| | | return revertObj.Code; |
| | | } |
| | | ///// <summary> |
| | | ///// 更新用户头像 |
| | | ///// </summary> |
| | | ///// <param name="vs"></param> |
| | | ///// <returns></returns> |
| | | //public string UpdataUserHeadImage(string fileName) |
| | | //{ |
| | | // byte[] bytes = Shared.IO.FileUtils.ReadFile(fileName); |
| | | // var revertObj = HttpUtil.RequestHttpsUpload(RestSharp.Method.POST, NewAPI.API_POST_Head_Upload, bytes); |
| | | // return revertObj.Code; |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 更改绑定账户的邮箱或者手机号 |
| | |
| | | /// </summary> |
| | | public string GetHomePager(HomeTypeEnum homeType = HomeTypeEnum.ALL) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new GetHomeListObj() { homeType = homeType.ToString() }); |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetHomeListObj() { homeType = homeType.ToString() }); |
| | | var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Gethomepager, requestJson); |
| | | if (resultObj.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.CurReginID)) |
| | | { |
| | | DB_ResidenceData.residenceData.CurReginID = UserInfo.Current.regionList[0].RegionID; |
| | | //恢复备份 |
| | | HDLCommon.Current.RestoreHomeBackup(DB_ResidenceData.residenceData.CurReginID); |
| | | } |
| | | else |
| | | { |
| | | var curRegion = UserInfo.Current.regionList.Find((obj) => obj.RegionID == DB_ResidenceData.residenceData.CurReginID); |
| | | if(curRegion == null) |
| | | { |
| | | DB_ResidenceData.residenceData.CurReginID = UserInfo.Current.regionList[0].RegionID; |
| | | //恢复备份 |
| | | HDLCommon.Current.RestoreHomeBackup(DB_ResidenceData.residenceData.CurReginID); |
| | | } |
| | | } |
| | | |
| | | |
| | | DB_ResidenceData.residenceData.SaveResidenceData(); |
| | | UserInfo.Current.SaveUserInfo(); |
| | | |
| | | //刷新一次住宅网关 |
| | | GetHomeGatewayList(); |
| | | } |
| | | |
| | | } |
| | |
| | | requestObj.Address = editName; |
| | | } |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Home_UpdateHome, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取刷新当前住宅网关接口 |
| | | /// 获取刷新当前住宅的网关列表 |
| | | /// </summary> |
| | | public void GetHomeGatewayList() |
| | | { |
| | | if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.residecenInfo.RegionID)) return; |
| | | var nowhomeId = DB_ResidenceData.residenceData.residecenInfo.RegionID; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeIdObj() { homeId = nowhomeId }); |
| | | var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetGatewayList, requestJson); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | try |
| | | { |
| | | var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomeGatewayInfo>>(revertObj.Data.ToString()); |
| | | if (nowhomeId == DB_ResidenceData.residenceData.residecenInfo.RegionID) |
| | | if (string.IsNullOrEmpty(DB_ResidenceData.residenceData.residecenInfo.RegionID)) return; |
| | | var nowhomeId = DB_ResidenceData.residenceData.residecenInfo.RegionID; |
| | | var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = nowhomeId }); |
| | | var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetGatewayList, requestJson); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | { |
| | | if (mHomeGatewayRes != null) |
| | | var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomeGatewayInfo>>(revertObj.Data.ToString()); |
| | | if (nowhomeId == DB_ResidenceData.residenceData.residecenInfo.RegionID) |
| | | { |
| | | if (mHomeGatewayRes.Count > 0) |
| | | if (mHomeGatewayRes != null) |
| | | { |
| | | DB_ResidenceData.residenceData.residenceGatewayMAC = mHomeGatewayRes[0].mac; |
| | | if (mHomeGatewayRes.Count > 0) |
| | | { |
| | | DB_ResidenceData.residenceData.HomeGateway = mHomeGatewayRes[0]; |
| | | DB_ResidenceData.residenceData.SaveResidenceData(); |
| | | return; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | DB_ResidenceData.residenceData.residenceGatewayMAC = ""; |
| | | |
| | | } |
| | | //其余情况清空网关信息 |
| | | DB_ResidenceData.residenceData.HomeGateway = null; |
| | | DB_ResidenceData.residenceData.SaveResidenceData(); |
| | | } |
| | | |
| | | if (mHomeGatewayRes != null) |
| | | { |
| | | //Utlis.WriteLine ("获得当前住宅网关个数:" + mHomeGatewayRes.content.Count); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //提示错误 |
| | | } |
| | | } |
| | | else |
| | | catch |
| | | { |
| | | //提示错误 |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetResidenceMemberAccount() |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeIdObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID }); |
| | | var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID }); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_FindAll, requestJson); |
| | | } |
| | | |
| | |
| | | childAccountId = subaccount.childAccountId, |
| | | homeId = subaccount.homeId |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Delete, requestJson); |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew EditSubAccountNickName(string nickName, string childAccountId) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new UpdateChildNickNameObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new UpdateChildNickNameObj() |
| | | { |
| | | homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, |
| | | childAccountId = childAccountId, |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew ChangeCreateSceneState(bool isAllow, string childAccountId) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new UpdateChildAllowCreateSceneObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new UpdateChildAllowCreateSceneObj() |
| | | { |
| | | homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, |
| | | childAccountId = childAccountId, |
| | |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Update, requestJson); |
| | | } |
| | | |
| | | #region 新数据分享 |
| | | /// <summary> |
| | | /// 获取住宅下子账号的共享数据列表 |
| | | /// 添加分享 |
| | | /// </summary> |
| | | /// <param name="addShareObj"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew AddShareData(AddShareObj addShareObj) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(addShareObj); |
| | | |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Share_Add, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 删除分享 |
| | | /// </summary> |
| | | /// <param name="deleteShareObj"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew DeleteShareData(DeleteShareObj deleteShareObj) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(deleteShareObj); |
| | | |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Share_Delete, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取分享 |
| | | /// </summary> |
| | | /// <param name="addShareObj"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetShareDataByMemberAccount(string childAccountId) |
| | | { |
| | | //Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | //d.Add("DistributedMark", memberId); |
| | | //d.Add("HouseDistributedMark", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | //return RequestHttps($"{severAddress}/ZigbeeDataShare/GetShareDataBySubAccount", jsonString, true); |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new HomeShareFindAll() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetShareObj() |
| | | { |
| | | homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, |
| | | childAccountId = childAccountId |
| | | childAccountId = childAccountId, |
| | | }); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Home_Share_FindAll, requestJson); |
| | | |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Share_GetList, requestJson); |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 下载单个分享文件 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public byte[] GetShareData(ShareData shareData) |
| | | { |
| | | //Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | //d.Add("DistributedMark", memberId); |
| | | //d.Add("HouseDistributedMark", hId); |
| | | //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | //return RequestHttps($"{severAddress}/ZigbeeDataShare/GetOneShareData", jsonString, true); |
| | | ///// <summary> |
| | | ///// 获取住宅下子账号的共享数据列表 |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //public ResponsePackNew GetShareDataByMemberAccount(string childAccountId) |
| | | //{ |
| | | // //Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | // //d.Add("DistributedMark", memberId); |
| | | // //d.Add("HouseDistributedMark", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | // //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | // //return RequestHttps($"{severAddress}/ZigbeeDataShare/GetShareDataBySubAccount", jsonString, true); |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new ShareFileDownObj() |
| | | { |
| | | homeId = shareData.homeId, |
| | | homeShareId = shareData.id |
| | | }); |
| | | var replaceToken = ""; |
| | | if (DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) |
| | | { |
| | | replaceToken = DB_ResidenceData.residenceData.MasterToken; |
| | | } |
| | | return HttpUtil.RequestHttpsDownload(NewAPI.API_POST_Home_Share_DownOne, requestJson, null, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); |
| | | // var requestJson = HttpUtil.GetSignRequestJson(new HomeShareFindAll() |
| | | // { |
| | | // homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, |
| | | // childAccountId = childAccountId |
| | | // }); |
| | | // return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Home_Share_FindAll, requestJson); |
| | | |
| | | } |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 增加共享数据列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew AddShareData(ShareData shareData) |
| | | { |
| | | //Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | //d.Add("ShareName", shareData.ShareName); |
| | | //d.Add("HouseDistributedMark", shareData.HouseDistributedMark); |
| | | //d.Add("ShareDataBytes", shareData.ShareDataBytes); |
| | | //d.Add("SubAccountDistributedMark", shareData.SubAccountDistributedMark); |
| | | //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | //return RequestHttps($"{severAddress}/ZigbeeDataShare/AddShareData", jsonString, true); |
| | | ///// <summary> |
| | | ///// 下载单个分享文件 |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //public byte[] GetShareData(ShareData shareData) |
| | | //{ |
| | | // //Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | // //d.Add("DistributedMark", memberId); |
| | | // //d.Add("HouseDistributedMark", hId); |
| | | // //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | // //return RequestHttps($"{severAddress}/ZigbeeDataShare/GetOneShareData", jsonString, true); |
| | | |
| | | var queryDic = new Dictionary<string, object>(); |
| | | queryDic.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | queryDic.Add("childAccountId", shareData.childAccountId); |
| | | queryDic.Add("fileName", shareData.fileName); |
| | | var replaceToken = ""; |
| | | if (DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) |
| | | { |
| | | replaceToken = DB_ResidenceData.residenceData.MasterToken; |
| | | } |
| | | return HttpUtil.RequestHttpsUpload(RestSharp.Method.POST, NewAPI.API_POST_Home_Share_Add, shareData.ShareDataBytes, queryDic, null, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); |
| | | } |
| | | // var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new ShareFileDownObj() |
| | | // { |
| | | // homeId = shareData.homeId, |
| | | // homeShareId = shareData.id |
| | | // }); |
| | | // var replaceToken = ""; |
| | | // if (DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) |
| | | // { |
| | | // replaceToken = DB_ResidenceData.residenceData.MasterToken; |
| | | // } |
| | | // return HttpUtil.RequestHttpsDownload(NewAPI.API_POST_Home_Share_DownOne, requestJson, null, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); |
| | | |
| | | /// <summary> |
| | | /// 增加共享数据 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew EditShareData(ShareData shareData) |
| | | { |
| | | return AddShareData(shareData); |
| | | //Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | //d.Add("DistributedMark", shareData.DistributedMark); |
| | | //d.Add("ShareName", shareData.ShareName); |
| | | //d.Add("HouseDistributedMark", shareData.HouseDistributedMark); |
| | | //d.Add("ShareDataBytes", shareData.ShareDataBytes); |
| | | //d.Add("SubAccountDistributedMark", shareData.SubAccountDistributedMark); |
| | | //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | //return RequestHttps($"{severAddress}/ZigbeeDataShare/EditShareData", jsonString, true); |
| | | } |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 删除共享数据 |
| | | /// </summary> |
| | | /// <param name="shareData"></param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew DeleteShareData(ShareData shareData) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new ShareFileDownObj() |
| | | { |
| | | homeId = shareData.homeId, |
| | | homeShareId = shareData.id |
| | | }); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Home_Share_Delete, requestJson); |
| | | //Dictionary<string, string> d = new Dictionary<string, string>(); |
| | | //d.Add("DistributedMark", shareData.DistributedMark); |
| | | //d.Add("HouseDistributedMark", shareData.HouseDistributedMark); |
| | | //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | //return RequestHttps($"{severAddress}/ZigbeeDataShare/DeleteShareData", jsonString, true); |
| | | } |
| | | ///// <summary> |
| | | ///// 增加共享数据列表 |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //public ResponsePackNew AddShareData(ShareData shareData) |
| | | //{ |
| | | // //Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | // //d.Add("ShareName", shareData.ShareName); |
| | | // //d.Add("HouseDistributedMark", shareData.HouseDistributedMark); |
| | | // //d.Add("ShareDataBytes", shareData.ShareDataBytes); |
| | | // //d.Add("SubAccountDistributedMark", shareData.SubAccountDistributedMark); |
| | | // //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | // //return RequestHttps($"{severAddress}/ZigbeeDataShare/AddShareData", jsonString, true); |
| | | |
| | | // var queryDic = new Dictionary<string, object>(); |
| | | // queryDic.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | // queryDic.Add("childAccountId", shareData.childAccountId); |
| | | // queryDic.Add("fileName", shareData.fileName); |
| | | // var replaceToken = ""; |
| | | // if (DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) |
| | | // { |
| | | // replaceToken = DB_ResidenceData.residenceData.MasterToken; |
| | | // } |
| | | // return HttpUtil.RequestHttpsUpload(RestSharp.Method.POST, NewAPI.API_POST_Home_Share_Add, shareData.ShareDataBytes, queryDic, null, DB_ResidenceData.residenceData.residecenInfo.regionUrl, replaceToken); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 增加共享数据 |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //public ResponsePackNew EditShareData(ShareData shareData) |
| | | //{ |
| | | // return AddShareData(shareData); |
| | | // //Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | // //d.Add("DistributedMark", shareData.DistributedMark); |
| | | // //d.Add("ShareName", shareData.ShareName); |
| | | // //d.Add("HouseDistributedMark", shareData.HouseDistributedMark); |
| | | // //d.Add("ShareDataBytes", shareData.ShareDataBytes); |
| | | // //d.Add("SubAccountDistributedMark", shareData.SubAccountDistributedMark); |
| | | // //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | // //return RequestHttps($"{severAddress}/ZigbeeDataShare/EditShareData", jsonString, true); |
| | | //} |
| | | |
| | | ///// <summary> |
| | | ///// 删除共享数据 |
| | | ///// </summary> |
| | | ///// <param name="shareData"></param> |
| | | ///// <returns></returns> |
| | | //public ResponsePackNew DeleteShareData(ShareData shareData) |
| | | //{ |
| | | // var requestJson = HttpUtil.GetSignRequestJson(new ShareFileDownObj() |
| | | // { |
| | | // homeId = shareData.homeId, |
| | | // homeShareId = shareData.id |
| | | // }); |
| | | // return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Home_Share_Delete, requestJson); |
| | | // //Dictionary<string, string> d = new Dictionary<string, string>(); |
| | | // //d.Add("DistributedMark", shareData.DistributedMark); |
| | | // //d.Add("HouseDistributedMark", shareData.HouseDistributedMark); |
| | | // //string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | // //return RequestHttps($"{severAddress}/ZigbeeDataShare/DeleteShareData", jsonString, true); |
| | | //} |
| | | ///// <summary> |
| | | ///// 删除子账号当前住宅的所有共享数据 |
| | | ///// </summary> |
| | |
| | | { |
| | | //添加子账号 |
| | | var requestObj = new ChildAddObj() { homeId = DB_ResidenceData.residenceData.residecenInfo.RegionID, account = subAccount, nickName = nickName }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_Child_Add, requestJson); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取住宅下的成员账号信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePack GetResidenceMemberAccountInfo(string account) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("Account", account); |
| | | string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | return RequestHttps($"{severAddress}/ZigbeeUsers/GetSubAccountInfo", jsonString, true); |
| | | } |
| | | ///// <summary> |
| | | ///// 获取住宅下的成员账号信息 |
| | | ///// </summary> |
| | | ///// <returns></returns> |
| | | //public ResponsePack GetResidenceMemberAccountInfo(string account) |
| | | //{ |
| | | // Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | // d.Add("Account", account); |
| | | // string jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | // return RequestHttps($"{severAddress}/ZigbeeUsers/GetSubAccountInfo", jsonString, true); |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 下载子账号用户头像 |
| | | /// </summary> |
| | | /// <param name="subaccoun"></param> |
| | | /// <returns></returns> |
| | | public byte[] DownChildHeadImage(ResidenceMemberInfo subaccount) |
| | | { |
| | | var requestObj = new ChildBaseObj() |
| | | { |
| | | childAccountId = subaccount.childAccountId, |
| | | homeId = subaccount.homeId |
| | | }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | var replaceToken = ""; |
| | | if (DB_ResidenceData.residenceData.residecenInfo.IsOthreShare) |
| | | { |
| | | replaceToken = DB_ResidenceData.residenceData.MasterToken; |
| | | } |
| | | return HttpUtil.RequestHttpsDownload(NewAPI.API_POST_Child_DownloadHeadImage, requestJson,null); |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion |
| | |
| | | { |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new GetMqttRemoteInfoObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetMqttRemoteInfoObj() |
| | | { |
| | | attachClientId = attachClientId, |
| | | homeType = HomeTypeEnum.BUSPRO.ToString() |
| | |
| | | #if __IOS__ |
| | | deviceType = PhoneDeviceType.IOS.ToString(); |
| | | #endif |
| | | //是否生成模式 |
| | | //是否生产模式 |
| | | bool isProduce = true; |
| | | #if DEBUG |
| | | isProduce = false; |
| | | #endif |
| | | |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushDeviceToken)) return false; |
| | | if (string.IsNullOrEmpty(UserInfo.Current.PushDeviceToken)) { |
| | | Utlis.WriteLine("PushDeviceToken 为空"); |
| | | return false; |
| | | } |
| | | |
| | | var mAddpushinfoObj = new AddpushinfoObj() |
| | | { |
| | | pushToken = OnAppConfig.Instance.PushDeviceToken, |
| | | deviceName = OnAppConfig.Instance.PhoneName, |
| | | pushToken = UserInfo.Current.PushDeviceToken, |
| | | deviceName = UserInfo.Current.PhoneName, |
| | | deviceType = deviceType, |
| | | produce = isProduce, |
| | | |
| | | }; |
| | | var mAddpushinfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(mAddpushinfoObj); |
| | | |
| | | //var mAddpushinfoJson = Newtonsoft.Json.JsonConvert.SerializeObject(mAddpushinfoObj); |
| | | var mAddpushinfoJson = HttpUtil.GetSignRequestJson(mAddpushinfoObj); |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_AddToken, mAddpushinfoJson); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | { |
| | |
| | | var pushId = revertObj.Data.ToString(); |
| | | if (!string.IsNullOrEmpty(pushId)) |
| | | { |
| | | OnAppConfig.Instance.PushId = pushId; |
| | | OnAppConfig.Instance.SaveUserConfig(); |
| | | UserInfo.Current.PushId = pushId; |
| | | UserInfo.Current.SaveUserInfo(); |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | Utlis.WriteLine("AddToken 成功"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | Utlis.WriteLine("AddToken 失败"); |
| | | //Utlis.WriteLine("AddToken 失败"); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查询推送信息列表 |
| | | /// </summary> |
| | | /// <param name="queryType">0全部 1分享与功能 2报警类 3系统信息</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew PushSerivceGetpushmessagelist() |
| | | public ResponsePackNew PushSerivceGetPushmessagelist(int queryType = 0) |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new GetMessageListObj() |
| | | string pushType = null; |
| | | |
| | | if (queryType == 1) |
| | | { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | pushType = PushType.Default.ToString(); |
| | | } |
| | | else if (queryType == 2) |
| | | { |
| | | pushType = PushType.Alarm.ToString(); |
| | | } |
| | | else if (queryType == 3) |
| | | { |
| | | pushType = PushType.Prompt.ToString(); |
| | | } |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetMessageListObj() |
| | | { |
| | | pushId = UserInfo.Current.PushId, |
| | | pushType = pushType |
| | | }); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_Getpushmessagelist, requestJson); |
| | | } |
| | |
| | | /// <returns></returns> |
| | | public bool PushSerivceClearmessagelist() |
| | | { |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false; |
| | | if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false; |
| | | |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushIdObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj() |
| | | { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | pushId = UserInfo.Current.PushId |
| | | }); |
| | | |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_Clearmessagelist, requestJson); |
| | |
| | | /// <returns></returns> |
| | | public bool PushSerivceSignOut() |
| | | { |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false; |
| | | if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false; |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushIdObj() { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj() { |
| | | pushId = UserInfo.Current.PushId |
| | | }); |
| | | |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_DeleteToken, requestJson); |
| | |
| | | /// <returns></returns> |
| | | public bool PushSerivceMarkAllMessageRead() |
| | | { |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false; |
| | | if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false; |
| | | |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushIdObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushIdObj() |
| | | { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | pushId = UserInfo.Current.PushId |
| | | }); |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_PushSerivce_ALLMarkread, requestJson); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | |
| | | /// <returns></returns> |
| | | public bool PushSerivceMarkMessageRead(string msgId) |
| | | { |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false; |
| | | if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false; |
| | | |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushMsgIdObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushMsgIdObj() |
| | | { |
| | | msgId = msgId |
| | | }); |
| | |
| | | /// <returns></returns> |
| | | public bool PushSerivceDeleteMessage(string msgId) |
| | | { |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false; |
| | | if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false; |
| | | |
| | | try |
| | | { |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(new PushMsgIdObj() |
| | | var requestJson = HttpUtil.GetSignRequestJson(new PushMsgIdObj() |
| | | { |
| | | msgId = msgId |
| | | }); |
| | |
| | | } |
| | | else |
| | | { |
| | | |
| | | IMessageCommon.Current.ShowErrorInfoAlter(revertObj.Code); |
| | | } |
| | | return false; |
| | | } |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 注册推送 |
| | | /// </summary> |
| | | public void RegisteredPush() |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var success = PushSerivceAddPushInfo(); |
| | | if (success) |
| | | { |
| | | Utlis.WriteLine("推送注册成功"); |
| | | } |
| | | else |
| | | { |
| | | Utlis.WriteLine("推送注册失败"); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 注销推送 |
| | | /// </summary> |
| | | public void SignOutPush() |
| | | { |
| | | new System.Threading.Thread(() => |
| | | { |
| | | var success = PushSerivceSignOut(); |
| | | if (success) |
| | | { |
| | | Utlis.WriteLine("推送注销成功"); |
| | | } |
| | | else |
| | | { |
| | | Utlis.WriteLine("推送注销失败"); |
| | | } |
| | | }) |
| | | { IsBackground = true }.Start(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 检测更新 |
| | |
| | | /// <returns></returns> |
| | | public ResponsePackNew CheckAppVersion() |
| | | { |
| | | var requestObj = new ForceUpdateObj() |
| | | var requestObj = new AppVersionCheckObj() |
| | | { |
| | | LanguageType = Utlis.GetPostLanguageType() |
| | | |
| | | }; |
| | | #if __IOS__ |
| | | requestObj.DeviceType = PhoneDeviceType.IOS.ToString(); |
| | | #endif |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(requestObj); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_CheckAppVersion, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetAppVersion() |
| | | { |
| | | var requestObj = new ForceUpdateObj() |
| | | { |
| | | |
| | | }; |
| | | #if __IOS__ |
| | | requestObj.DeviceType = PhoneDeviceType.IOS.ToString(); |
| | | #endif |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(requestObj); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetAppVersion, requestJson); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | |
| | | |
| | | #endregion |
| | | |
| | | #region mqtt远程连接(旧) |
| | | /// <summary> |
| | | /// 请求Mqtt数据 |
| | | /// </summary> |
| | | /// <param name="dataStringJson">请求的参数.</param> |
| | | public ResponsePack RequestMqttInfo(string dataStringJson) |
| | | { |
| | | ResponsePack revertObj = null; |
| | | |
| | | var webClient = new WebClient(); |
| | | #region |
| | | webClient.Headers.Add("CONTENT-TYPE", "application/json"); |
| | | var url = "https://global.hdlcontrol.com/ProposedProductionApi/EmqMqtt/GetConnMqttInfo"; |
| | | |
| | | byte[] bytes = null; |
| | | try |
| | | { |
| | | bytes = webClient.UploadData(url, Encoding.UTF8.GetBytes(dataStringJson)); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.Message); |
| | | revertObj = new ResponsePack() { StateCode = "Net_Error" }; |
| | | } |
| | | |
| | | string responseString = null; |
| | | if (bytes != null) |
| | | { |
| | | responseString = Encoding.UTF8.GetString(bytes); |
| | | } |
| | | |
| | | if (responseString != null) |
| | | { |
| | | try |
| | | { |
| | | revertObj = Newtonsoft.Json.JsonConvert.DeserializeObject<ResponsePack>(responseString); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.ToString()); |
| | | } |
| | | } |
| | | return revertObj; |
| | | #endregion |
| | | } |
| | | #endregion |
| | | |
| | | #region 备份部分 |
| | | ///// <summary> |