New file |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | using Shared.Common; |
| | | |
| | | namespace Shared.Phone |
| | | { |
| | | /// <summary> |
| | | /// 登陆界面的逻辑 |
| | | /// </summary> |
| | | public class HdlAccountLogic |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// 登陆界面的逻辑 |
| | | /// </summary> |
| | | private static HdlAccountLogic m_Current; |
| | | /// <summary> |
| | | /// 登陆界面的逻辑 |
| | | /// </summary> |
| | | public static HdlAccountLogic Current |
| | | { |
| | | get |
| | | { |
| | | if (m_Current == null) |
| | | { |
| | | m_Current = new HdlAccountLogic(); |
| | | } |
| | | return m_Current; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 账号注册___________________________ |
| | | |
| | | /// <summary> |
| | | /// 注册账号,并返回已翻译的错误信息(返回null代表成功) |
| | | /// </summary> |
| | | /// <param name="i_account">手机号或者邮箱</param> |
| | | /// <param name="i_password">密码</param> |
| | | /// <param name="i_verifyCode">验证码</param> |
| | | /// <returns></returns> |
| | | public string RegisterAccount(string i_account, string i_password, string i_verifyCode) |
| | | { |
| | | string accountName = i_account.Contains("@") == true ? "memberEmail" : "memberPhone"; |
| | | var dicBody = new Dictionary<string, string>(); |
| | | dicBody["memberName"] = i_account; |
| | | dicBody[accountName] = i_account; |
| | | dicBody["loginPwd"] = i_password; |
| | | dicBody["verifyCode"] = i_verifyCode; |
| | | |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/oauth/register", RestSharp.Method.POST, dicBody, null, null, CheckMode.A不检测, false, 5, true); |
| | | if (result == null) |
| | | { |
| | | //注册失败 |
| | | return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10017); |
| | | } |
| | | if (result.Code == HttpMessageEnum.A成功) |
| | | { |
| | | return null; |
| | | } |
| | | //获取翻译 |
| | | string errorMsg = HdlMessageLogic.Current.TranslateHttpCode(result.Code); |
| | | if (errorMsg == null) |
| | | { |
| | | //注册失败 |
| | | return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10017); |
| | | } |
| | | return errorMsg; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 发送验证码_________________________ |
| | | |
| | | /// <summary> |
| | | /// 发送验证码到邮箱,并返回已翻译的错误信息(返回null代表成功) |
| | | /// </summary> |
| | | /// <param name="i_email">邮箱</param> |
| | | /// <param name="codeType">验证码的类型</param> |
| | | /// <param name="i_codeTime">验证码过期时间(秒)</param> |
| | | /// <returns></returns> |
| | | public string SendVeriCodeToEmail(string i_email, VerCodeType codeType, int i_codeTime = 300) |
| | | { |
| | | //去获取它的区域地址(null:无法联网 空字符串:账号不存在 非空:正常获取) |
| | | var strUrl = this.GetAccoutRegionInfo(i_email); |
| | | if (strUrl == null) |
| | | { |
| | | //发送验证码失败 |
| | | return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10210); |
| | | } |
| | | //检测接口返回的账号的Url是否有问题 |
| | | var errorMsg = this.CheckAccoutRegionUrlByCodeType(strUrl, codeType); |
| | | if (errorMsg != null) |
| | | { |
| | | return errorMsg; |
| | | } |
| | | var pra = new { mail = i_email, verifyType = (int)codeType, expireSecond = i_codeTime }; |
| | | //请求Url的完成路径(发送验证码需要另外获取地址) |
| | | var fullUrl = strUrl + "/smart-footstone/verification/message/send"; |
| | | |
| | | var result = HdlHttpLogic.Current.DoRequestZigbeeHttps(fullUrl, Config.Instance.Token, RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, 3, true); |
| | | //转换数据 |
| | | var respone = HdlHttpLogic.Current.ConvertData(result); |
| | | if (respone == null) |
| | | { |
| | | //发送验证码失败 |
| | | return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10210); |
| | | } |
| | | if (respone.Code == HttpMessageEnum.A成功) |
| | | { |
| | | return null; |
| | | } |
| | | //获取翻译 |
| | | errorMsg = HdlMessageLogic.Current.TranslateHttpCode(respone.Code); |
| | | if (errorMsg == null) |
| | | { |
| | | //发送验证码失败 |
| | | return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10210); |
| | | } |
| | | return errorMsg; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发送验证码到手机,并返回已翻译的错误信息(返回null代表成功) |
| | | /// </summary> |
| | | /// <param name="i_areaCode">地区码</param> |
| | | /// <param name="i_phone">手机号</param> |
| | | /// <param name="codeType">验证码的类型</param> |
| | | /// <param name="i_lanType">CHINESE or ENGLISH,当不指定时,默认使用底层变量</param> |
| | | /// <param name="i_codeTime">验证码过期时间(秒)</param> |
| | | /// <returns></returns> |
| | | public string SendVeriCodeToPhone(string i_areaCode, string i_phone, VerCodeType codeType, string i_lanType = null, int i_codeTime = 300) |
| | | { |
| | | //去获取它的区域地址(null:无法联网 空字符串:账号不存在 非空:正常获取) |
| | | var strUrl = this.GetAccoutRegionInfo(i_phone); |
| | | if (strUrl == null) |
| | | { |
| | | //发送验证码失败 |
| | | return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10210); |
| | | } |
| | | //检测接口返回的账号的Url是否有问题 |
| | | var errorMsg = this.CheckAccoutRegionUrlByCodeType(strUrl, codeType); |
| | | if (errorMsg != null) |
| | | { |
| | | return errorMsg; |
| | | } |
| | | |
| | | if (i_lanType == null) |
| | | { |
| | | i_lanType = Config.Instance.HttpLanguage; |
| | | } |
| | | var pra = new { phone = i_phone, phonePrefix = i_areaCode, languageType = i_lanType, verifyType = (int)codeType, expireSecond = i_codeTime }; |
| | | |
| | | //请求Url的完成路径(发送验证码需要另外获取地址) |
| | | var fullUrl = strUrl + "/smart-footstone/verification/message/send"; |
| | | |
| | | var result = HdlHttpLogic.Current.DoRequestZigbeeHttps(fullUrl, Config.Instance.Token, RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, 3, true); |
| | | //转换数据 |
| | | var respone = HdlHttpLogic.Current.ConvertData(result); |
| | | if (respone == null) |
| | | { |
| | | //发送验证码失败 |
| | | return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10210); |
| | | } |
| | | if (respone.Code == HttpMessageEnum.A成功) |
| | | { |
| | | return null; |
| | | } |
| | | //获取翻译 |
| | | errorMsg = HdlMessageLogic.Current.TranslateHttpCode(respone.Code); |
| | | if (errorMsg == null) |
| | | { |
| | | //发送验证码失败 |
| | | return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10210); |
| | | } |
| | | return errorMsg; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 校验验证码 |
| | | /// </summary> |
| | | /// <param name="i_account">手机号或者邮箱</param> |
| | | /// <param name="codeType">验证码的类型</param> |
| | | /// <param name="i_verifyCode">验证码</param> |
| | | /// <returns></returns> |
| | | public bool CheckVeriCode(string i_account, VerCodeType codeType, string i_verifyCode) |
| | | { |
| | | //去获取它的区域地址(null:无法联网 空字符串:账号不存在 非空:正常获取) |
| | | var strUrl = this.GetAccoutRegionInfo(i_account); |
| | | if (strUrl == null) |
| | | { |
| | | //发送验证码失败 |
| | | return false; |
| | | } |
| | | //检测接口返回的账号的Url是否有问题 |
| | | var errorMsg = this.CheckAccoutRegionUrlByCodeType(strUrl, codeType); |
| | | if (errorMsg != null) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | string accountName = i_account.Contains("@") == true ? "mail" : "phone"; |
| | | var dicBody = new Dictionary<string, string>(); |
| | | dicBody[accountName] = i_account; |
| | | dicBody["verifyType"] = ((int)codeType).ToString(); |
| | | dicBody["verifyCode"] = i_verifyCode; |
| | | |
| | | //请求Url的完成路径(校验验证码需要另外获取地址) |
| | | var fullUrl = strUrl + "/smart-footstone/verification/message/check"; |
| | | |
| | | var result = HdlHttpLogic.Current.DoRequestZigbeeHttps(fullUrl, Config.Instance.Token, RestSharp.Method.POST, dicBody, null, null, CheckMode.A不检测, 3, true); |
| | | //转换数据 |
| | | var respone = HdlHttpLogic.Current.ConvertData(result); |
| | | if (respone == null) |
| | | { |
| | | return false; |
| | | } |
| | | return respone.Code == HttpMessageEnum.A成功; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检测接口返回的账号的Url是否有问题(null:没问题 非null:已经翻译了的错误信息) |
| | | /// </summary> |
| | | /// <param name="i_url">接口返回的账号的Url(null的话不要调用)</param> |
| | | /// <param name="codeType">验证码类型</param> |
| | | /// <returns></returns> |
| | | private string CheckAccoutRegionUrlByCodeType(string i_url, VerCodeType codeType) |
| | | { |
| | | if (codeType == VerCodeType.A注册) |
| | | { |
| | | //账号已经注册 |
| | | if (i_url != string.Empty) { return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10016); } |
| | | } |
| | | else if (codeType == VerCodeType.A找回密码) |
| | | { |
| | | //账号不存在 |
| | | if (i_url == string.Empty) { return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10010); } |
| | | } |
| | | else if (codeType == VerCodeType.A登陆) |
| | | { |
| | | //账号不存在 |
| | | if (i_url == string.Empty) { return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10010); } |
| | | } |
| | | else if (codeType == VerCodeType.A绑定) |
| | | { |
| | | //账号已经注册 |
| | | if (i_url != string.Empty) { return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10016); } |
| | | } |
| | | else if (codeType == VerCodeType.A其他) |
| | | { |
| | | //账号不存在 |
| | | if (i_url == string.Empty) { return HdlMessageLogic.Current.TranslateHttpCode(HttpMessageEnum.A10010); } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 账号密码登陆_______________________ |
| | | |
| | | /// <summary> |
| | | /// 自动登陆(可能状态码:Sucess PswError NotNetWork OtherError) |
| | | /// </summary> |
| | | public AccountStatu AutoLoginByRefreshToken() |
| | | { |
| | | //初始化账号所在的区域地址(-1:获取不到,云端上没这个账号 1:正常 2:无网) |
| | | var result = this.InitAccoutRegionInfo(Config.Instance.Account); |
| | | if (result != AccountStatu.Sucess) |
| | | { |
| | | //没网,或者账号不存在,都不用往下走 |
| | | return result; |
| | | } |
| | | |
| | | result = AccountStatu.OtherError; |
| | | //登陆 |
| | | var revertObj = this.LoginByRefreshToken(); |
| | | if (revertObj == null) |
| | | { |
| | | //没有网络 |
| | | result = AccountStatu.NotNetWork; |
| | | } |
| | | else if (revertObj.Code == HttpMessageEnum.A成功) |
| | | { |
| | | //上报设备ID |
| | | this.PushDeviceIdToDB(); |
| | | result = AccountStatu.Sucess; |
| | | } |
| | | |
| | | //没网,或者是有网并且登陆成功时,刷新个人信息 |
| | | if (result == AccountStatu.Sucess || result == AccountStatu.NotNetWork) |
| | | { |
| | | //初始化登陆账号的信息(登陆的,这里成不成功都无所谓) |
| | | this.InitUserAccoutInfo(true, result == AccountStatu.Sucess); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 账号密码登陆(成功时,自动刷新Config) |
| | | /// </summary> |
| | | /// <param name="i_account">账号</param> |
| | | /// <param name="i_password">密码</param> |
| | | public ResponsePack LoginByPassword(string i_account, string i_password) |
| | | { |
| | | //初始化账号所在的区域地址(可能状态码:Sucess NotAccount NotNetWork) |
| | | var result = this.InitAccoutRegionInfo(i_account); |
| | | if (result == AccountStatu.NotAccount) |
| | | { |
| | | //账号不存在 |
| | | return new ResponsePack { Code = HttpMessageEnum.A10010 }; |
| | | } |
| | | if (result == AccountStatu.NotNetWork) |
| | | { |
| | | //没网,不用往下走 |
| | | return null; |
| | | } |
| | | |
| | | //登陆 |
| | | var pra = new { grantType = "password", account = i_account, loginPwd = i_password }; |
| | | var revertObj = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/oauth/login", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 3, true); |
| | | |
| | | if (revertObj != null && revertObj.Code == HttpMessageEnum.A成功) |
| | | { |
| | | //云端不再返回账号字段 |
| | | Config.Instance.Account = i_account; |
| | | //根据登陆之后,云端返回的数据,刷新Config |
| | | this.RefreshConfigDataByLoginData(revertObj); |
| | | |
| | | //初始化登陆账号的信息(登陆的,这里成不成功都无所谓) |
| | | this.InitUserAccoutInfo(true, true); |
| | | } |
| | | |
| | | return revertObj; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 验证码登陆(成功时,自动刷新Config) |
| | | /// </summary> |
| | | /// <param name="i_account">手机或者邮箱</param> |
| | | /// <param name="i_verifyCode">验证码</param> |
| | | public ResponsePack LoginByVerifyCode(string i_account, string i_verifyCode) |
| | | { |
| | | //初始化账号所在的区域地址(-1:获取不到,云端上没这个账号 1:正常 2:无网) |
| | | var result = this.InitAccoutRegionInfo(i_account); |
| | | if (result == AccountStatu.NotAccount) |
| | | { |
| | | //账号不存在 |
| | | return new ResponsePack { Code = HttpMessageEnum.A10010 }; |
| | | } |
| | | if (result == AccountStatu.NotNetWork) |
| | | { |
| | | //没网,不用往下走 |
| | | return null; |
| | | } |
| | | |
| | | var pra = new { grantType = "verify", account = i_account, verifyCode = i_verifyCode }; |
| | | //登陆接口特殊,需要快一点访问,设置3秒超时 |
| | | var revertObj = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/oauth/login", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 3, true); |
| | | |
| | | if (revertObj != null && revertObj.Code == HttpMessageEnum.A成功) |
| | | { |
| | | //根据登陆之后,云端返回的数据,刷新Config |
| | | this.RefreshConfigDataByLoginData(revertObj); |
| | | |
| | | //初始化登陆账号的信息 -1:无网 1:正常 2:登陆不进去 3:权限变更了 |
| | | this.InitUserAccoutInfo(true, true); |
| | | } |
| | | |
| | | return revertObj; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 用【刷新Token】登陆(成功时,自动刷新Config) |
| | | /// </summary> |
| | | public ResponsePack LoginByRefreshToken() |
| | | { |
| | | var pra = new { grantType = "refresh_token", refreshToken = Config.Instance.RefreshToken }; |
| | | //登陆接口特殊,需要快一点访问,设置3秒超时 |
| | | var revertObj = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/oauth/login", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 3, true); |
| | | |
| | | if (revertObj != null && revertObj.Code == HttpMessageEnum.A成功) |
| | | { |
| | | //根据登陆之后,云端返回的数据,刷新Config |
| | | this.RefreshConfigDataByLoginData(revertObj); |
| | | } |
| | | |
| | | return revertObj; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据登陆之后,云端返回的数据,刷新Config |
| | | /// </summary> |
| | | /// <param name="i_response">根据登陆之后,云端返回的数据</param> |
| | | private void RefreshConfigDataByLoginData(ResponsePack i_response) |
| | | { |
| | | //存储数据 |
| | | var result = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(i_response.Data.ToString()); |
| | | |
| | | //标记上一次是不是同一个账号登陆 |
| | | Config.Instance.TheSameLoginAccount = Config.Instance.Guid == result.UserId; |
| | | Config.Instance.Guid = result.UserId; |
| | | Config.Instance.LoginDateTime = DateTime.Now; |
| | | Config.Instance.Token = result.AccessToken; |
| | | Config.Instance.RefreshToken = result.RefreshToken; |
| | | Config.Instance.HeaderPrefix = result.HeaderPrefix; |
| | | Config.Instance.Save(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 绑定账号___________________________ |
| | | |
| | | /// <summary> |
| | | /// 绑定账号,并返回已翻译的错误信息(返回null代表成功) |
| | | /// </summary> |
| | | /// <param name="i_account">邮箱或者手机</param> |
| | | /// <param name="i_veriCode">验证码</param> |
| | | /// <returns></returns> |
| | | public string BindAccount(string i_account, string i_veriCode) |
| | | { |
| | | bool isEmail = i_account.Contains("@"); |
| | | string keyValue = isEmail == true ? "memberMail" : "memberPhone"; |
| | | var pra = new Dictionary<string, string>(); |
| | | pra[keyValue] = i_account; |
| | | pra["verifyCode"] = i_veriCode; |
| | | |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/memberInfo/bindWithAccount", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 3, true); |
| | | if (result == null) |
| | | { |
| | | if (isEmail == true) |
| | | { |
| | | //绑定邮箱失败 |
| | | return Language.StringByID(R.MyInternationalizationString.uBindEmailFail); |
| | | } |
| | | else |
| | | { |
| | | //绑定手机失败 |
| | | return Language.StringByID(R.MyInternationalizationString.uBindPhoneFail); |
| | | } |
| | | } |
| | | if (result.Code == HttpMessageEnum.A成功) |
| | | { |
| | | return null; |
| | | } |
| | | //获取翻译 |
| | | string errorMsg = HdlMessageLogic.Current.TranslateHttpCode(result.Code); |
| | | if (errorMsg == null) |
| | | { |
| | | if (isEmail == true) |
| | | { |
| | | //绑定邮箱失败 |
| | | return Language.StringByID(R.MyInternationalizationString.uBindEmailFail); |
| | | } |
| | | else |
| | | { |
| | | //绑定手机失败 |
| | | return Language.StringByID(R.MyInternationalizationString.uBindPhoneFail); |
| | | } |
| | | } |
| | | return errorMsg; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 修改密码___________________________ |
| | | |
| | | /// <summary> |
| | | /// 修改密码 |
| | | /// </summary> |
| | | /// <param name="i_oldPsw">旧密码</param> |
| | | /// <param name="i_newPsw">新密码</param> |
| | | /// <returns></returns> |
| | | public bool EditorPassword(string i_oldPsw, string i_newPsw) |
| | | { |
| | | var pra = new { loginPwd = i_oldPsw, loginNewPwd = i_newPsw }; |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/memberInfo/updatePwd", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 5, true); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, ShowNetCodeMode.YES) == false) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 重置密码___________________________ |
| | | |
| | | /// <summary> |
| | | /// 重置密码,并返回已翻译的错误信息(返回null代表成功) |
| | | /// </summary> |
| | | /// <param name="i_account">邮箱或者手机号</param> |
| | | /// <param name="i_newPsw">新密码</param> |
| | | /// <param name="i_verifyCode">验证码</param> |
| | | /// <returns></returns> |
| | | public string ResetPassword(string i_account, string i_newPsw, string i_verifyCode) |
| | | { |
| | | string accountName = i_account.Contains("@") == true ? "memberEmail" : "memberPhone"; |
| | | var dicBody = new Dictionary<string, string>(); |
| | | dicBody[accountName] = i_account; |
| | | dicBody["loginPwd"] = i_newPsw; |
| | | dicBody["verifyCode"] = i_verifyCode; |
| | | |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/oauth/forgetPwd", RestSharp.Method.POST, dicBody, null, null, CheckMode.A不检测, false, 5, true); |
| | | if (result == null) |
| | | { |
| | | //重置密码失败 |
| | | return Language.StringByID(R.MyInternationalizationString.uReSetPasswordFail); |
| | | } |
| | | if (result.Code == HttpMessageEnum.A成功) |
| | | { |
| | | return null; |
| | | } |
| | | //获取翻译 |
| | | string errorMsg = HdlMessageLogic.Current.TranslateHttpCode(result.Code); |
| | | if (errorMsg == null) |
| | | { |
| | | //重置密码失败 |
| | | return Language.StringByID(R.MyInternationalizationString.uReSetPasswordFail); |
| | | } |
| | | return errorMsg; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 重新登录___________________________ |
| | | |
| | | /// <summary> |
| | | /// 重新登录 |
| | | /// </summary> |
| | | /// <param name="account">账号</param> |
| | | /// <param name="noticeDb">是否通知云端</param> |
| | | public void ReLoginAgain(string account = "", bool noticeDb = true) |
| | | { |
| | | if (Config.Instance.Home.IsVirtually == true) |
| | | { |
| | | //如果是虚拟住宅 |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | //设定一个时间 |
| | | Config.Instance.LoginDateTime = new DateTime(1970, 1, 1); |
| | | Config.Instance.Save(); |
| | | //清空当前住宅id |
| | | Config.Instance.HomeId = string.Empty; |
| | | //收起左菜单 |
| | | CommonPage.Instance.CloseLeftMenu(); |
| | | //关闭全部弹窗 |
| | | ShowMsgControl.CloseAllMsgDialog(); |
| | | //关闭所有打开了的界面 |
| | | HdlFormLogic.Current.CloseAllOpenForm(null, false); |
| | | |
| | | //显示登陆画面 |
| | | var formLogin = new Login.AccountLoginForm(); |
| | | Shared.Common.CommonPage.Instance.AddChidren(formLogin); |
| | | formLogin.ShowForm(account); |
| | | }); |
| | | return; |
| | | } |
| | | //关闭所有接收 |
| | | HdlGatewayReceiveLogic.Current.RemoveAllEvent(); |
| | | //清除升级列表 |
| | | HdlFirmwareUpdateResourse.dicUpdateList.Clear(); |
| | | |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | | //检测APP是否能够退出 |
| | | while (HdlUserCenterResourse.AccountOption.AppCanSignout == false) |
| | | { |
| | | System.Threading.Thread.Sleep(500); |
| | | } |
| | | //设定一个时间 |
| | | Config.Instance.LoginDateTime = new DateTime(1970, 1, 1); |
| | | Config.Instance.Save(); |
| | | |
| | | //清空当前住宅id |
| | | Config.Instance.HomeId = string.Empty; |
| | | HdlGatewayLogic.Current.ClearAllRealGatewayConection(false); |
| | | |
| | | //断开远程Mqtt连接 |
| | | HdlThreadLogic.Current.RunThread(async () => |
| | | { |
| | | await ZigBee.Device.ZbGateway.CloseRemoteConnectionOnForce(); |
| | | }, ShowErrorMode.NO); |
| | | |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | //收起左菜单 |
| | | CommonPage.Instance.CloseLeftMenu(); |
| | | //关闭所有打开了的界面 |
| | | HdlFormLogic.Current.CloseAllOpenForm(null, false); |
| | | |
| | | //显示登陆画面 |
| | | var formLogin = new Login.AccountLoginForm(); |
| | | Shared.Common.CommonPage.Instance.AddChidren(formLogin); |
| | | formLogin.ShowForm(account); |
| | | }); |
| | | |
| | | if (noticeDb == true) |
| | | { |
| | | //通知云端,已经退出登陆 |
| | | this.SignOutClearData(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 上传头像___________________________ |
| | | |
| | | /// <summary> |
| | | /// 上传头像 |
| | | /// </summary> |
| | | /// <param name="byteData">图像的byte数据</param> |
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | /// <returns></returns> |
| | | public bool UpLoadUserIconImage(byte[] byteData, ShowNetCodeMode mode = ShowNetCodeMode.YES) |
| | | { |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/head/portrait/upload", RestSharp.Method.POST, byteData); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 编辑用户名称_______________________ |
| | | |
| | | /// <summary> |
| | | /// 编辑用户昵称 |
| | | /// </summary> |
| | | /// <param name="i_nikeName">用户昵称</param> |
| | | /// <param name="mode">失败时是否显示tip消息</param> |
| | | /// <returns></returns> |
| | | public bool EditorUserNikeName(string i_nikeName, ShowNetCodeMode mode = ShowNetCodeMode.YES) |
| | | { |
| | | var pra = new { memberName = i_nikeName }; |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/memberInfo/updateMemberInfo", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 3, true); |
| | | //检测状态码 |
| | | if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false) |
| | | { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化登陆账号的信息_______________ |
| | | |
| | | /// <summary> |
| | | /// 初始化登陆账号的信息(可能的状态码:Sucess NotNetWork) |
| | | /// </summary> |
| | | /// <param name="reLoad">是否从新从本地加载(重新初始化登陆账号的信息,不需要重新加载)</param> |
| | | /// <param name="tryHttp">是否尝试访问网络</param> |
| | | /// <returns></returns> |
| | | private AccountStatu InitUserAccoutInfo(bool reLoad, bool tryHttp) |
| | | { |
| | | //预创建用户信息【文件夹】 |
| | | HdlFileLogic.Current.CreateDirectory(HdlFileNameResourse.AccountDirectory); |
| | | HdlFileLogic.Current.CreateDirectory(HdlFileNameResourse.UserPictrueDirectory); |
| | | |
| | | //加载账号配置信息 |
| | | HdlUserCenterResourse.AccountOption = HdlUserCenterResourse.AccountOption.Load(); |
| | | |
| | | if (reLoad == true) |
| | | { |
| | | //获取本地记录的用户信息 |
| | | HdlUserCenterResourse.UserInfo = GetUserInformationFromLocation(); |
| | | } |
| | | |
| | | var netStatu = tryHttp == true ? AccountStatu.Sucess : AccountStatu.NotNetWork; |
| | | //只要能联网,就去获取它的账号信息 |
| | | if (netStatu == AccountStatu.Sucess) |
| | | { |
| | | //访问接口 |
| | | var resultData = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/memberInfo/getMemberInfo", RestSharp.Method.POST, null, null, null, CheckMode.A不检测, false, 3, true); |
| | | if (resultData != null && resultData.Code == HttpMessageEnum.A成功) |
| | | { |
| | | var persionData = Newtonsoft.Json.JsonConvert.DeserializeObject<PersionInfoResult>(resultData.Data.ToString()); |
| | | //赋值 |
| | | HdlUserCenterResourse.UserInfo.NickName = persionData.MemberName; |
| | | HdlUserCenterResourse.UserInfo.PhoneAreaCode = persionData.MemberPhonePrefix; |
| | | HdlUserCenterResourse.UserInfo.UserPhone = persionData.MemberPhone; |
| | | HdlUserCenterResourse.UserInfo.UserEmail = persionData.MemberEmail; |
| | | |
| | | //初始化数字和手势密码 |
| | | this.InitNumberAndGesturePassword(); |
| | | } |
| | | else |
| | | { |
| | | netStatu = AccountStatu.NotNetWork; |
| | | } |
| | | } |
| | | HdlUserCenterResourse.UserInfo.Account = Config.Instance.Account; |
| | | |
| | | if (string.IsNullOrEmpty(HdlUserCenterResourse.UserInfo.NickName) == true) |
| | | { |
| | | //没有昵称的时候,把账号作为昵称 |
| | | HdlUserCenterResourse.UserInfo.NickName = Config.Instance.Account; |
| | | } |
| | | |
| | | if (netStatu != AccountStatu.NotNetWork) |
| | | { |
| | | //保存缓存 |
| | | HdlUserCenterResourse.AccountOption.Save(); |
| | | } |
| | | |
| | | //保存用户的登陆信息到本地 |
| | | this.SaveUserInformationToLocation(); |
| | | |
| | | //后台去下载账号的头像 |
| | | if (netStatu == AccountStatu.Sucess) |
| | | { |
| | | HdlThreadLogic.Current.RunThread(() => |
| | | { |
| | | //下载头像 |
| | | var imageData = this.DownLoadAccountPictrue(Config.Instance.Account); |
| | | if (imageData != null && imageData.Length > 0) |
| | | { |
| | | //写入头像内容 |
| | | HdlFileLogic.Current.SaveByteToFile(HdlFileNameResourse.UserHeadIconFile, imageData); |
| | | } |
| | | |
| | | }, ShowErrorMode.NO); |
| | | } |
| | | |
| | | return netStatu; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重新初始化登陆账号的信息(网络变更的时候调用 可能的状态码:Sucess NotNetWork AuthorityChangd TokenTimeOunt) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public AccountStatu ReInitUserAccoutInfo() |
| | | { |
| | | if (Config.Instance.Home.Id == string.Empty) |
| | | { |
| | | //如果处在登陆界面时 |
| | | return AccountStatu.NotNetWork; |
| | | } |
| | | //重新刷新Token |
| | | var respone = this.LoginByRefreshToken(); |
| | | if (respone == null) { return AccountStatu.NotNetWork; } |
| | | |
| | | if (respone.Code != HttpMessageEnum.A成功) |
| | | { |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | //登陆Token已经过期,请重新登陆 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uLoginTokenIsTimeOutPleaseLoginAgain); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); |
| | | |
| | | this.ReLoginAgain(HdlUserCenterResourse.UserInfo.Account, false); |
| | | }); |
| | | return AccountStatu.TokenTimeOunt; |
| | | } |
| | | |
| | | //重新获取住宅列表 |
| | | var listHouse = HdlResidenceLogic.Current.GetHomeListsFromDb(ShowNetCodeMode.No); |
| | | if (listHouse == null) |
| | | { |
| | | //断网,获取不到住宅 |
| | | return AccountStatu.NotNetWork; |
| | | } |
| | | |
| | | //检测当前这个住宅还在吗 |
| | | bool houseIsEsixt = false; |
| | | foreach (var houseInfo in listHouse) |
| | | { |
| | | //刷新住宅信息 |
| | | HdlResidenceLogic.Current.RefreshResidenceMemory(houseInfo); |
| | | if (houseInfo.Id == Config.Instance.Home.Id) |
| | | { |
| | | houseIsEsixt = true; |
| | | } |
| | | } |
| | | if (houseIsEsixt == false) |
| | | { |
| | | //当前这个住宅不见了,让他重新登陆 |
| | | return AccountStatu.TokenTimeOunt; |
| | | } |
| | | |
| | | //刷新账号的权限(可能的状态码:Sucess AuthorityChangd) |
| | | var result22 = this.RefreshAccountAuthority(); |
| | | if (result22 == AccountStatu.AuthorityChangd) |
| | | { |
| | | HdlThreadLogic.Current.RunMain(() => |
| | | { |
| | | //您的权限已经变更,请重新登陆 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uYouAccessHadChangedPleaseTakeToAdmin); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); |
| | | |
| | | this.ReLoginAgain(HdlUserCenterResourse.UserInfo.Account, false); |
| | | }); |
| | | return result22; |
| | | } |
| | | //重新初始化主人的token(管理员专用) |
| | | var success = this.InitMasterToken(); |
| | | if (success == false) |
| | | { |
| | | return AccountStatu.NotNetWork; |
| | | } |
| | | |
| | | //重新初始化账号信息 |
| | | var result = InitUserAccoutInfo(false, true); |
| | | if (result == AccountStatu.Sucess) |
| | | { |
| | | //如果有网关没有绑定,则去绑定网关 |
| | | HdlGatewayLogic.Current.ResetComandToBindBackupGateway(); |
| | | |
| | | //同步云端的网关id,如果本地拥有云端不存在的id,则表示应该被换绑了,直接删除 |
| | | HdlGatewayLogic.Current.SynchronizeDbGateway(); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 刷新账号的权限(可能的状态码:Sucess AuthorityChangd) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public AccountStatu RefreshAccountAuthority() |
| | | { |
| | | //取当前旧值 |
| | | int oldAuthorityNo = HdlUserCenterResourse.ResidenceOption.OldAuthorityNo; |
| | | |
| | | if (Config.Instance.Home.IsOtherShare == false) |
| | | { |
| | | //身份:管理员 |
| | | HdlUserCenterResourse.ResidenceOption.AuthorityNo = 1; |
| | | HdlUserCenterResourse.ResidenceOption.AuthorityText = Language.StringByID(R.MyInternationalizationString.Administrator); |
| | | } |
| | | else if (Config.Instance.Home.AccountType == 1) |
| | | { |
| | | //身份:成员(拥有管理员权限) |
| | | HdlUserCenterResourse.ResidenceOption.AuthorityNo = 2; |
| | | HdlUserCenterResourse.ResidenceOption.AuthorityText = Language.StringByID(R.MyInternationalizationString.uMemberHadActionAuthority); |
| | | } |
| | | else |
| | | { |
| | | //身份:成员 |
| | | HdlUserCenterResourse.ResidenceOption.AuthorityNo = 3; |
| | | HdlUserCenterResourse.ResidenceOption.AuthorityText = Language.StringByID(R.MyInternationalizationString.uMember); |
| | | } |
| | | //保存 |
| | | HdlUserCenterResourse.ResidenceOption.Save(); |
| | | |
| | | //然后值盖过去 |
| | | HdlUserCenterResourse.ResidenceOption.OldAuthorityNo = HdlUserCenterResourse.ResidenceOption.AuthorityNo; |
| | | |
| | | //UserInfo.OldAuthorityNo==0代表本地还没有生成文件,这个时候不需要处理 |
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != oldAuthorityNo |
| | | && oldAuthorityNo != 0) |
| | | { |
| | | //切换网络时,需要对这个值进行踢人下线 |
| | | return AccountStatu.AuthorityChangd; |
| | | } |
| | | return AccountStatu.Sucess; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化账号的Url区域地址(可能状态码:Sucess NotAccount NotNetWork) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private AccountStatu InitAccoutRegionInfo(string i_account) |
| | | { |
| | | var regionUrl = this.GetAccoutRegionInfo(i_account); |
| | | if (regionUrl == null) |
| | | { |
| | | return AccountStatu.NotNetWork; |
| | | } |
| | | if (regionUrl == string.Empty) |
| | | { |
| | | return AccountStatu.NotAccount; |
| | | } |
| | | //变更地址 |
| | | HdlHttpLogic.Current.RequestHttpsHost = regionUrl; |
| | | |
| | | return AccountStatu.Sucess; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取账号的区域信息(null:无法联网 空字符串:账号不存在 非空:正常获取) |
| | | /// </summary> |
| | | /// <param name="i_account">手机或者邮箱</param> |
| | | /// <returns></returns> |
| | | private string GetAccoutRegionInfo(string i_account) |
| | | { |
| | | var pra = new { account = i_account }; |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/region/regionByAccount", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 3, true); |
| | | if (result == null) |
| | | { |
| | | return null; |
| | | } |
| | | if (result.Code != HttpMessageEnum.A成功) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | var info = Newtonsoft.Json.JsonConvert.DeserializeObject<AccoutRegionInfo>(result.Data.ToString()); |
| | | |
| | | return info.RegionUrl; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保存用户的登陆信息到本地 |
| | | /// </summary> |
| | | private void SaveUserInformationToLocation() |
| | | { |
| | | //写入内容 |
| | | HdlFileLogic.Current.SaveFileContent(HdlFileNameResourse.UserInfoFile, HdlUserCenterResourse.UserInfo); |
| | | |
| | | string iconFile = HdlFileNameResourse.UserHeadIconFile; |
| | | if (System.IO.File.Exists(iconFile) == false) |
| | | { |
| | | //搞一下主人的默认头像 |
| | | string defultFile = IO.FileUtils.GetImageFilePath("Center/Admin.png"); |
| | | if (defultFile == string.Empty) |
| | | { |
| | | return; |
| | | } |
| | | //复制过去 |
| | | System.IO.File.Copy(defultFile, iconFile); |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 从本地获取用户的登陆信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private UserInformation GetUserInformationFromLocation() |
| | | { |
| | | var value = HdlFileLogic.Current.ReadFileTextContent(HdlFileNameResourse.UserInfoFile); |
| | | if (value == null) |
| | | { |
| | | return new UserInformation(); |
| | | } |
| | | var info = Newtonsoft.Json.JsonConvert.DeserializeObject<UserInformation>(value); |
| | | return info; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 账号的区域地址信息 |
| | | /// </summary> |
| | | private class AccoutRegionInfo |
| | | { |
| | | /// <summary> |
| | | /// 账号的区域地址(如果为空,代表账号不存在) |
| | | /// </summary> |
| | | public string RegionUrl = string.Empty; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化主人的Token__________________ |
| | | |
| | | /// <summary> |
| | | /// 初始化主人的token |
| | | /// </summary> |
| | | public bool InitMasterToken() |
| | | { |
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 2) |
| | | { |
| | | //此接口只能管理员调用 |
| | | return true; |
| | | } |
| | | var pra = new { homeId = Config.Instance.Home.Id }; |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/app/child/account/debug", RestSharp.Method.POST, pra); |
| | | if (result == null || result.Code != HttpMessageEnum.A成功) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | var data = Newtonsoft.Json.JsonConvert.DeserializeObject<UserLoginRes>(result.Data.ToString()); |
| | | //记录起这两个token |
| | | Config.Instance.MasterToken = data.AccessToken; |
| | | |
| | | return true; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化数字和手势密码_______________ |
| | | |
| | | /// <summary> |
| | | /// 初始化数字和手势密码 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private bool InitNumberAndGesturePassword() |
| | | { |
| | | //读取云端数据 |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/memberInfo/getLockCode", RestSharp.Method.POST, null, null, null, CheckMode.A不检测, false, 3, true); |
| | | if (result != null) |
| | | { |
| | | if (result.Code == HttpMessageEnum.A成功) |
| | | { |
| | | var info = Newtonsoft.Json.JsonConvert.DeserializeObject<NumberAndGesturePasswordInfo>(result.Data.ToString()); |
| | | //手势密码 |
| | | HdlUserCenterResourse.AccountOption.GestureAuthentication = info.GestureCode; |
| | | //密码验证 |
| | | HdlUserCenterResourse.AccountOption.PswAuthentication = info.DigitCode; |
| | | |
| | | return true; |
| | | } |
| | | //未配置 则清空 |
| | | else if (result.Code == HttpMessageEnum.A11005) |
| | | { |
| | | //手势密码 |
| | | HdlUserCenterResourse.AccountOption.GestureAuthentication = string.Empty; |
| | | //密码验证 |
| | | HdlUserCenterResourse.AccountOption.PswAuthentication = string.Empty; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 编辑数字和手势密码 |
| | | /// </summary> |
| | | /// <param name="i_numPsw">数字密码,如果不更新,请置为null</param> |
| | | /// <param name="i_gesturePsw">手势密码,如果不更新,请置为null</param> |
| | | /// <returns></returns> |
| | | public bool EditorNumberAndGesturePassword(string i_numPsw, string i_gesturePsw) |
| | | { |
| | | var pra = new Dictionary<string, string>(); |
| | | if (i_numPsw != null) { pra["digitCode"] = i_numPsw; } |
| | | if (i_gesturePsw != null) { pra["gestureCode"] = i_gesturePsw; } |
| | | |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/member/memberInfo/setLockCode", RestSharp.Method.POST, pra, null, null, CheckMode.A不检测, false, 3, true); |
| | | if (result != null && result.Code == HttpMessageEnum.A成功) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 数字和手势密码 |
| | | /// </summary> |
| | | private class NumberAndGesturePasswordInfo |
| | | { |
| | | /// <summary> |
| | | /// 手势密码 |
| | | /// </summary> |
| | | public string GestureCode = string.Empty; |
| | | /// <summary> |
| | | /// 数字 |
| | | /// </summary> |
| | | public string DigitCode = string.Empty; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 下载指定账号的头像_________________ |
| | | |
| | | /// <summary> |
| | | /// 下载指定账号的头像 |
| | | /// </summary> |
| | | /// <param name="i_account">邮箱或者手机号</param> |
| | | /// <returns></returns> |
| | | public byte[] DownLoadAccountPictrue(string i_account) |
| | | { |
| | | var pra = new { account = i_account }; |
| | | var result = HdlHttpLogic.Current.RequestByteFromZigbeeHttps("home-wisdom/app/head/portrait/downWithAccount", RestSharp.Method.POST, pra); |
| | | if (result != null && result.Length == 0) |
| | | { |
| | | result = null; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 退出登录时调用,清除推送数据 |
| | | /// </summary> |
| | | public void SignOutClearData() |
| | | { |
| | | //通知云端,已经退出登陆 |
| | | var pra = new { pushId = Config.Instance.PushId }; |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/app/push-information/delete", RestSharp.Method.POST, pra); |
| | | if (result == null) |
| | | { |
| | | //调试:记录极光ID |
| | | HdlLogLogic.Current.WriteOtherText(HdlFileNameResourse.JiguangFile, "SignOut:" + Config.Instance.RegistrationID + " fail,receive obj is null", false, true); |
| | | } |
| | | else |
| | | { |
| | | //调试:记录极光ID |
| | | HdlLogLogic.Current.WriteOtherText(HdlFileNameResourse.JiguangFile, "SignOut:" + Config.Instance.RegistrationID + " result:" + result.Code, false, true); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 登录成功后上报设备id等相关信息给后端 |
| | | /// </summary> |
| | | /// <returns>返回状态码</returns> |
| | | public string PushDeviceIdToDB() |
| | | { |
| | | try |
| | | { |
| | | string deviceAlias; |
| | | string deviceType; |
| | | #if iOS |
| | | deviceAlias = UIKit.UIDevice.CurrentDevice.Name; |
| | | deviceType = "IOS"; |
| | | #elif Android |
| | | deviceAlias = Android.OS.Build.Manufacturer; |
| | | deviceType = "Android"; |
| | | #endif |
| | | var pra = new { deviceName = deviceAlias, deviceType = deviceType, produce = false, pushToken = Config.Instance.RegistrationID, software = "Evoyo" }; |
| | | var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("smart-footstone/app/push-information/add", RestSharp.Method.POST, pra); |
| | | |
| | | if (result == null) |
| | | { |
| | | //调试:记录极光ID |
| | | HdlLogLogic.Current.WriteOtherText(HdlFileNameResourse.JiguangFile, "send:" + Config.Instance.RegistrationID + " fail,receive obj is null", false, true); |
| | | return null; |
| | | } |
| | | //调试:记录极光ID |
| | | HdlLogLogic.Current.WriteOtherText(HdlFileNameResourse.JiguangFile, "send:" + Config.Instance.RegistrationID + " result:" + result.Code, false, true); |
| | | if (result.Code == HttpMessageEnum.A成功) |
| | | { |
| | | Config.Instance.PushId = result.Data.ToString(); |
| | | Config.Instance.Save(); |
| | | } |
| | | |
| | | return result.Code; |
| | | } |
| | | catch |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 结构体_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 个人信息 |
| | | /// </summary> |
| | | private class PersionInfoResult |
| | | { |
| | | /// <summary> |
| | | /// 昵称 |
| | | /// </summary> |
| | | public string MemberName = string.Empty; |
| | | /// <summary> |
| | | /// 邮箱 |
| | | /// </summary> |
| | | public string MemberEmail = string.Empty; |
| | | /// <summary> |
| | | /// 手机 |
| | | /// </summary> |
| | | public string MemberPhone = string.Empty; |
| | | /// <summary> |
| | | /// 手机的地区码 |
| | | /// </summary> |
| | | public string MemberPhonePrefix = string.Empty; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 登陆结果 |
| | | /// </summary> |
| | | private class UserLoginRes |
| | | { |
| | | /// <summary> |
| | | /// 账号 |
| | | /// </summary> |
| | | public string Account = string.Empty; |
| | | /// <summary> |
| | | /// 令牌类型,没啥用 |
| | | /// </summary> |
| | | public string TokenType = string.Empty; |
| | | /// <summary> |
| | | /// 这个是新接口的Guid,也是账号id |
| | | /// </summary> |
| | | public string UserId = string.Empty; |
| | | /// <summary> |
| | | /// 添加到Token头部的东西(不要理它,只给底层使用) |
| | | /// </summary> |
| | | public string HeaderPrefix = string.Empty; |
| | | /// <summary> |
| | | /// Token(不用记录什么有效期,如果登陆失败,就拿RefreshToken去刷新) |
| | | /// </summary> |
| | | public string AccessToken = string.Empty; |
| | | /// <summary> |
| | | /// 刷新accessToken用的token(不用记录什么有效期,如果刷新失败,就踢人即可) |
| | | /// </summary> |
| | | public string RefreshToken = string.Empty; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |