| | |
| | | /// 刷新Token |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public bool RefreshToken() |
| | | public string RefreshToken() |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new RefreshTokenObj() |
| | | { |
| | |
| | | UserInfo.Current.RefreshToken = revertData.refreshToken; |
| | | UserInfo.Current.LastTime = DateTime.Now; |
| | | UserInfo.Current.SaveUserInfo(); |
| | | return true; |
| | | } |
| | | return false; |
| | | return revertObj.Code; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | /// 获取用户信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public void GetUserInfo(bool bGetHeadImage = true) |
| | | public string GetUserInfo(bool bGetHeadImage = true) |
| | | { |
| | | var requestJson = HttpUtil.GetSignRequestJson(new NullObj()); |
| | | var resultObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_Member_GetMemberInfo, requestJson); |
| | |
| | | UserInfo.Current.SaveUserInfo(); |
| | | MainPage.Log("获取用户信息成功。"); |
| | | } |
| | | |
| | | |
| | | // Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | //var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(d); |
| | | //var revertObj = RequestHttps($"{severAddress}/ZigbeeUsers/GetAccountInfo", requestJson, true); |
| | | |
| | | //if (revertObj.StateCode.ToUpper() == StateCode.SUCCESS) |
| | | //{ |
| | | // var dataStr = JObject.FromObject(revertObj.ResponseData); |
| | | // //"DistributedMark": "96439601-fd26-4768-8440-1d9dfa32c109", < !--帐号Id-- > |
| | | // UserInfo.Current.userEmailInfo = dataStr.GetValue("Email").ToString(); |
| | | // UserInfo.Current.userMobileInfo = dataStr.GetValue("Phone").ToString(); |
| | | // FileStream fs = null; |
| | | // try |
| | | // { |
| | | // var headImageString = dataStr.GetValue("HeadImage").ToString(); |
| | | // if (!string.IsNullOrEmpty(headImageString)) |
| | | // { |
| | | // var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(headImageString); |
| | | // var headImageBytes = Newtonsoft.Json.JsonConvert.DeserializeObject<byte[]>(jsonString); |
| | | // 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(); |
| | | // } |
| | | // } |
| | | // // "GesturePwd": null, < !--手势密码-- > |
| | | // // "StringPwd": null , < !--字符串密码-- > |
| | | // UserInfo.Current.userName = dataStr.GetValue("UserName").ToString(); |
| | | |
| | | // Application.RunOnMainThread(() => |
| | | // { |
| | | // }); |
| | | |
| | | // UserInfo.Current.SaveUserInfo(); |
| | | // MainPage.Log("获取用户信息成功。"); |
| | | //} |
| | | |
| | | return resultObj.Code; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | UserInfo.Current.SaveUserInfo(); |
| | | Action action = () => |
| | | { |
| | | MainPage.GoUserPage(); |
| | | MainPage.GoUserPage(true); |
| | | }; |
| | | new UI.PublicAssmebly().TipMsg(StringId.Tip, StringId.ResidenceDeletedSwitchToAnotherResidence, action); |
| | | }); |
| | |
| | | /// <summary> |
| | | /// 获取刷新当前住宅的网关列表 |
| | | /// </summary> |
| | | public void GetHomeGatewayList() |
| | | public string GetHomeGatewayList() |
| | | { |
| | | try |
| | | { |
| | | if (string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.RegionID)) return; |
| | | if (string.IsNullOrEmpty(DB_ResidenceData.Instance.CurrentRegion.RegionID)) return ""; |
| | | var nowhomeId = DB_ResidenceData.Instance.CurrentRegion.RegionID; |
| | | var requestJson = HttpUtil.GetSignRequestJson(new HomeIdObj() { homeId = nowhomeId }); |
| | | var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetGatewayList, requestJson); |
| | |
| | | if (mHomeGatewayRes.Count > 0) |
| | | { |
| | | DB_ResidenceData.Instance.HomeGateway = mHomeGatewayRes[0]; |
| | | if(mHomeGatewayRes[0].gatewayStatus) |
| | | { |
| | | //DriverLayer.Control.Ins.IsRemote = true; |
| | | DriverLayer.Control.Ins.GatewayOnline = true; |
| | | } |
| | | else |
| | | { |
| | | DriverLayer.Control.Ins.GatewayOnline = false; |
| | | } |
| | | //if (mHomeGatewayRes[0].gatewayStatus) |
| | | //{ |
| | | // DriverLayer.Control.Ins.GatewayOnline = true; |
| | | //} |
| | | //else |
| | | //{ |
| | | // DriverLayer.Control.Ins.GatewayOnline = false; |
| | | //} |
| | | DB_ResidenceData.Instance.SaveResidenceData(); |
| | | return; |
| | | return revertObj.Code; |
| | | } |
| | | } |
| | | //其余情况清空网关信息 |
| | |
| | | { |
| | | //提示错误 |
| | | } |
| | | return revertObj.Code; |
| | | } |
| | | catch |
| | | { |
| | | |
| | | return ""; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 获取网关信息 |
| | | /// </summary> |
| | | public string GetGatewayInfo() |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID); |
| | | d.Add("gatewayId", DB_ResidenceData.Instance.HomeGateway.gatewayId); |
| | | var jsonString = HttpUtil.GetSignRequestJson(d); |
| | | var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetGatewayInfo, jsonString); |
| | | if (revertObj.Code == StateCode.SUCCESS) |
| | | { |
| | | var mHomeGatewayRes = Newtonsoft.Json.JsonConvert.DeserializeObject<HomeGatewayInfo>(revertObj.Data.ToString()); |
| | | if (mHomeGatewayRes != null) |
| | | { |
| | | if(mHomeGatewayRes.gatewayStatus) |
| | | { |
| | | DriverLayer.Control.Ins.GatewayOnline = true; |
| | | } |
| | | } |
| | | } |
| | | return revertObj.Code; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | d.Add("deviceIds", functionIds); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | MainPage.Log($"读取设备状态:{requestJson}"); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_RefreshDeviceStatus, requestJson); |
| | | } |
| | | |
| | |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID); |
| | | d.Add("deviceId", function.deviceId);//DriverLayer.Control.Ins.GatewayId); |
| | | 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> |
| | | /// <returns></returns> |
| | | public ResponsePackNew UpdataDevcieBindRoomInfo(Function function) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("homeId", DB_ResidenceData.Instance.CurrentRegion.RegionID); |
| | | d.Add("deviceId", function.deviceId); |
| | | d.Add("roomIds", function.roomIds); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_EditDevice, requestJson); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 设备绑定房间 |
| | | /// </summary> |
| | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取场景详情列表 |
| | | /// </summary> |
| | | /// <param name="seceneId">场景ID</param> |
| | | /// <returns></returns> |
| | | public ResponsePackNew GetSceneListInfo(List<string> seceneIds) |
| | | { |
| | | Dictionary<string, object> d = new Dictionary<string, object>(); |
| | | d.Add("userSceneIds", seceneIds); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_GetSecneInfo, requestJson); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加场景 |
| | | /// </summary> |
| | |
| | | d.Add("scenes", new List<Scene>() { scene }); |
| | | |
| | | var requestJson = HttpUtil.GetSignRequestJson(d); |
| | | return HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_AddSecne, requestJson); |
| | | var pack = HttpUtil.RequestHttpsPostFroHome(NewAPI.Api_Post_AddSecne, requestJson); |
| | | |
| | | MainPage.Log($"{pack.Data}"); |
| | | |
| | | return pack; |
| | | } |
| | | /// <summary> |
| | | /// 编辑场景 |