File was renamed from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlCheckLogic.cs |
| | |
| | | using System.Text; |
| | | using System.Text.RegularExpressions; |
| | | |
| | | namespace Shared.Phone.UserCenter |
| | | namespace Shared.Phone |
| | | { |
| | | public class HdlCheckLogic |
| | | { |
| | |
| | | /// <returns></returns> |
| | | public bool CheckEmail(string email) |
| | | { |
| | | Regex reg = new Regex(CommonPage.EmailRegexStr); |
| | | string emailRegexStr = "^\\s*([A-Za-z0-9_-]+(\\.\\w+)*@(\\w+\\.)+\\w{2,5})\\s*$"; |
| | | Regex reg = new Regex(emailRegexStr); |
| | | return reg.IsMatch(email); |
| | | } |
| | | |
| | |
| | | //校验外国手机号 |
| | | if (areaCode != "86") |
| | | { |
| | | Regex reg = new Regex(CommonPage.PhoneForForeignRegexStr); |
| | | Regex reg = new Regex("^[0-9]*$"); |
| | | return reg.IsMatch(phoneNumber); |
| | | } |
| | | |
| | |
| | | } |
| | | else if (phoneNumber.Length == 11) |
| | | { |
| | | Regex reg = new Regex(CommonPage.PhoneRegexStr); |
| | | Regex reg = new Regex("^[1][0-9]{10}$"); |
| | | return reg.IsMatch(phoneNumber); |
| | | } |
| | | else |
| | |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检查密码长度合法性 |
| | | /// </summary> |
| | | /// <param name="password"></param> |
| | | /// <returns></returns> |
| | | public bool CheckPwdLength(string password) |
| | | { |
| | | if (password.Trim().Length >= 6 && password.Trim().Length <= 13) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 检测网关共通错误状态码_____________ |
| | | #region ■ 检测网关错误状态码_________________ |
| | | |
| | | /// <summary> |
| | | /// <para>检测网关返回的共通错误状态码(返回null则代表没有错误),支持状态码为</para> |
| | |
| | | /// </summary> |
| | | /// <param name="resultData">网关返回的resultData,里面有【errorResponData】这个东西的那种对象</param> |
| | | /// <returns></returns> |
| | | public string CheckCommonErrorCode(object resultData) |
| | | public string CheckGatewayErrorCode(object resultData) |
| | | { |
| | | if (resultData == null) |
| | | { |
| | |
| | | var code = type.InvokeMember("Error", System.Reflection.BindingFlags.GetField, null, errorObj, null); |
| | | int errorCode = Convert.ToInt32(code); |
| | | |
| | | return CheckCommonErrorCode(errorCode); |
| | | return CheckGatewayErrorCode(errorCode); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="errorCode">错误代码</param> |
| | | /// <returns></returns> |
| | | public string CheckCommonErrorCode(int errorCode) |
| | | public string CheckGatewayErrorCode(int errorCode) |
| | | { |
| | | if (errorCode == 1) |
| | | { |
| | |
| | | else if (errorCode == 2) |
| | | { |
| | | //协调器正在升级或备份或恢复数据中 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uCoordinatorIsUpOrBackupOrRecovering); |
| | | return Language.StringByID(R.MyInternationalizationString.uCoordinatorIsUpOrBackupOrRecovering); |
| | | } |
| | | else if (errorCode == 3) |
| | | { |
| | | //目标设备不存在 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uTargetDeviceIsNotExsit); |
| | | return Language.StringByID(R.MyInternationalizationString.uTargetDeviceIsNotExsit); |
| | | } |
| | | else if (errorCode == 4) |
| | | { |
| | | //出现未知错误,请稍后再试 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndResetAgain); |
| | | return Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndResetAgain); |
| | | } |
| | | else if (errorCode == 5) |
| | | { |
| | | //数据传输错误,请稍后再试 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDataTransmissionFailAndResetAgain); |
| | | return Language.StringByID(R.MyInternationalizationString.uDataTransmissionFailAndResetAgain); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 检测接口返回的状态码_______________ |
| | | |
| | | /// <summary> |
| | | /// 检测接口返回的状态码 |
| | | /// </summary> |
| | | /// <param name="i_response">云端返回的东西</param> |
| | | /// <param name="i_mode">是否显示访问接口失败的tip消息</param> |
| | | /// <returns></returns> |
| | | public bool CheckNetCode(ResponsePack i_response, ShowNetCodeMode i_mode) |
| | | { |
| | | //为了节省代码,这样整而已 |
| | | if (i_response == null) |
| | | { |
| | | //网关连接失败,请确认网络 |
| | | HdlMessageLogic.Current.ShowNotNetTipMsg(i_mode); |
| | | return false; |
| | | } |
| | | if (i_response.Code != HttpMessageEnum.A成功) |
| | | { |
| | | HdlMessageLogic.Current.ShowNetCodeTipMsg(i_mode, i_response); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | #endregion |
| | |
| | | TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent = null; |
| | | |
| | | TouchIDUtils.TouchIDSupperType type = TouchIDUtils.getTouchIDSupperType(); |
| | | if (type == TouchIDUtils.TouchIDSupperType.TouchID && UserCenterResourse.AccountOption.FingerprintAuthentication == true) |
| | | if (type == TouchIDUtils.TouchIDSupperType.TouchID && HdlUserCenterResourse.AccountOption.FingerprintAuthentication == true) |
| | | { |
| | | //Touch ID验证 |
| | | TouchIDUtils.Instance.OnHDLTouchIDStateBackEvent += (sender2, e2) => |
| | |
| | | else if (e2 == TouchIDUtils.TouchIDState.InputPassword) |
| | | { |
| | | //密码验证 |
| | | if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) |
| | | if (string.IsNullOrEmpty(HdlUserCenterResourse.AccountOption.PswAuthentication) == false) |
| | | { |
| | | var form = new PswSecondarySecurityForm(); |
| | | form.AddForm(i_TouchText, i_PasswordText, i_GestureText, SuccessAction); |
| | | } |
| | | //手势验证 |
| | | else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) |
| | | else if (string.IsNullOrEmpty(HdlUserCenterResourse.AccountOption.GestureAuthentication) == false) |
| | | { |
| | | var form = new PswGestureSecirityForm(); |
| | | form.AddForm(i_TouchText, i_PasswordText, i_GestureText, SuccessAction); |
| | |
| | | TouchIDUtils.Instance.showTouchIDWithDescribe(null, null); |
| | | NotSettionAction = null; |
| | | } |
| | | else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.PswAuthentication) == false) |
| | | else if (string.IsNullOrEmpty(HdlUserCenterResourse.AccountOption.PswAuthentication) == false) |
| | | { |
| | | //密码验证 |
| | | var form = new PswSecondarySecurityForm(); |
| | | form.AddForm(i_TouchText, i_PasswordText, i_GestureText, SuccessAction); |
| | | NotSettionAction = null; |
| | | } |
| | | else if (string.IsNullOrEmpty(UserCenterResourse.AccountOption.GestureAuthentication) == false) |
| | | else if (string.IsNullOrEmpty(HdlUserCenterResourse.AccountOption.GestureAuthentication) == false) |
| | | { |
| | | //手势验证 |
| | | var form = new PswGestureSecirityForm(); |