| | |
| | | public ResponsePackNew GetRegionByAccount(string account) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new RegionByAccountObj() { account = account }); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetRegionByAccount, requestJson); |
| | | return HttpUtil.RequestHttpsPost(NewAPI.API_POST_GetRegionByAccount, requestJson, HttpUtil.GlobalRequestHttpsHost); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | //是否需要获取头像 |
| | | 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) |
| | | { |
| | | 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> |
| | | ///// <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> |
| | | /// 更改绑定账户的邮箱或者手机号 |
| | |
| | | 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(); |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | /// <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 |
| | |
| | | isProduce = false; |
| | | #endif |
| | | |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushDeviceToken)) { |
| | | 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 pushId = revertObj.Data.ToString(); |
| | | if (!string.IsNullOrEmpty(pushId)) |
| | | { |
| | | OnAppConfig.Instance.PushId = pushId; |
| | | OnAppConfig.Instance.SaveUserConfig(); |
| | | UserInfo.Current.PushId = pushId; |
| | | UserInfo.Current.SaveUserInfo(); |
| | | Utlis.WriteLine("PushId: " + pushId); |
| | | |
| | | return true; |
| | | } |
| | |
| | | /// <summary> |
| | | /// 查询推送信息列表 |
| | | /// </summary> |
| | | /// <param name="queryType"></param> |
| | | /// <param name="queryType">0全部 1分享与功能 2报警类 3系统信息</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew PushSerivceGetPushmessagelist(int queryType = 0) |
| | | { |
| | | var pushType = ""; |
| | | string pushType = null; |
| | | |
| | | if (queryType == 1) |
| | | { |
| | | pushType = PushType.Default.ToString(); |
| | | } else if (queryType == 1) |
| | | } |
| | | else if (queryType == 2) |
| | | { |
| | | pushType = PushType.Alarm.ToString(); |
| | | } |
| | | else if (queryType == 2) |
| | | else if (queryType == 3) |
| | | { |
| | | pushType = PushType.Prompt.ToString(); |
| | | } |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetMessageListObj() |
| | | { |
| | | pushId = OnAppConfig.Instance.PushId, |
| | | 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 = 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 = HttpUtil.GetSignRequestJson(new PushIdObj() { |
| | | pushId = OnAppConfig.Instance.PushId |
| | | 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 = 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 |
| | | { |
| | |
| | | /// <returns></returns> |
| | | public bool PushSerivceDeleteMessage(string msgId) |
| | | { |
| | | if (string.IsNullOrEmpty(OnAppConfig.Instance.PushId)) return false; |
| | | if (string.IsNullOrEmpty(UserInfo.Current.PushId)) return false; |
| | | |
| | | try |
| | | { |
| | |
| | | |
| | | #region 获取天气部分 |
| | | /// <summary> |
| | | /// /// <summary> |
| | | /// 获取指定经纬度的城市信息 |
| | | /// </summary> |
| | | /// </summary> |
| | | /// <param name="lon">经度</param> |
| | | /// <param name="lat">纬度</param> |
| | | public void GetCityInfo(string lon, string lat) |
| | | { |
| | | System.Threading.Tasks.Task.Run(() => |
| | |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetDevcieInfoList, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 刷新设备状态 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew RefreshDeviceStatus(List<string> functionIds) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | d.Add("deviceIds", functionIds); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_RefreshDeviceStatus, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 控制设备 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | d.Add("gatewayId", DriverLayer.Control.Ins.GatewayId); |
| | | d.Add("gatewayId", DB_ResidenceData.residenceData.HomeGateway.gatewayId);//DriverLayer.Control.Ins.GatewayId); |
| | | d.Add("actions", actionObjs); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_ControlDevice, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 编辑设备信息 |
| | | /// 绑定关系、名称、收藏 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public ResponsePackNew UpdataDevcieInfo(Function function) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | d.Add("deviceId", function.deviceId); |
| | | d.Add("name", function.name); |
| | | d.Add("collect", function.collect); |
| | | d.Add("roomIds", function.roomIds); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDevice, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 设备绑定房间 |
| | |
| | | /// <summary> |
| | | /// 收藏设备 |
| | | /// </summary> |
| | | public string CollectDevice(string deviceId) |
| | | public ResponsePackNew CollectDevice(string deviceId) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | d.Add("deviceId",new List<string>() { deviceId }); |
| | | d.Add("deviceIds",new List<string>() { deviceId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CollectDevice, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CollectDevice, requestJson); |
| | | } |
| | | /// <summary> |
| | | /// 取消收藏设备 |
| | | /// </summary> |
| | | public string CancelCollectDevice(string deviceId) |
| | | public ResponsePackNew CancelCollectDevice(string deviceId) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.residenceData.residecenInfo.RegionID); |
| | | d.Add("deviceId", new List<string>() { deviceId }); |
| | | d.Add("deviceIds", new List<string>() { deviceId }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CancelCollectDevice, requestJson).Code; |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_CancelCollectDevice, requestJson); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_AddRoom, requestJson); |
| | | var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SpatialInfo>>(pack.Data.ToString()); |
| | | if (revData != null) |
| | | { |
| | | SpatialInfo.CurrentSpatial.UpdateSpatialList(revData, OptionType.Update); |
| | | } |
| | | //var revData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SpatialInfo>>(pack.Data.ToString()); |
| | | //if (revData != null) |
| | | //{ |
| | | // SpatialInfo.CurrentSpatial.UpdateSpatialList(revData, OptionType.Update); |
| | | //} |
| | | return pack; |
| | | } |
| | | /// <summary> |