| | |
| | | using System; |
| | | using service.hdlcontrol.com_push; |
| | | //using service.hdlcontrol.com_push; |
| | | |
| | | namespace Shared.SimpleControl.Phone |
| | | { |
| | |
| | | } else { |
| | | string oldPassword = etCurPassword.Text.Trim (); |
| | | string newPassword = etNewPassword.Text.Trim (); |
| | | try { |
| | | var requestObj = new UpdatePasswordObj () { OldPassword = oldPassword, NewPassword = newPassword }; |
| | | var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject (requestObj); |
| | | var revertObj = MainPage.RequestHttps (API.UpdatePassword, requestJson); |
| | | if (revertObj.StateCode.ToUpper() == "SUCCESS") { |
| | | MainPage.LoginUser.Password = newPassword; |
| | | MainPage.LoginUser.SaveUserInfo (); |
| | | Application.RunOnMainThread (() => { |
| | | this.RemoveFromParent (); |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.PasswordModificationSuccess), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } else { |
| | | ShowErrorInfo (revertObj.StateCode); |
| | | } |
| | | |
| | | } catch { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.FailureToServer), |
| | | Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | ModifyPassword (oldPassword, newPassword); |
| | | } |
| | | } catch (Exception ex) { |
| | | new Alert ("", Language.StringByID (R.MyInternationalizationString.CheckInternet), |
| | |
| | | |
| | | } |
| | | |
| | | void ShowErrorInfo (string stateCodeStr) |
| | | /// <summary> |
| | | /// 修改密码 |
| | | /// </summary> |
| | | /// <param name="oldPassword"></param> |
| | | /// <param name="newPassword"></param> |
| | | void ModifyPassword (string oldPassword, string newPassword) |
| | | { |
| | | string mes = ""; |
| | | if (stateCodeStr == "NewPasswordAndOldPasswordEqual") { |
| | | //原密码和新密码相同 |
| | | mes = ErrorCode.NewPasswordAndOldPasswordEqual; |
| | | } else if (stateCodeStr == "OldPwdNoYes") { |
| | | //原密码错误 |
| | | mes = ErrorCode.OldPwdNoYes; |
| | | } else if (stateCodeStr == "AccountNoExists") { |
| | | //用户不存在 |
| | | mes = ErrorCode.ACCOUNTNOEXISTS; |
| | | } else if (stateCodeStr == "Fail") { |
| | | // 操作失败 |
| | | mes = ErrorCode.OperationFailed; |
| | | } else if (stateCodeStr == ErrorCode.NetworkError) { |
| | | mes = ErrorCode.NetworkError; |
| | | } else { |
| | | mes = ErrorCode.OperationFailed + ErrorCode.Reason + stateCodeStr; |
| | | |
| | | } |
| | | if (!string.IsNullOrEmpty (mes)) { |
| | | Application.RunOnMainThread (() => { |
| | | new Alert ("", mes, Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } |
| | | |
| | | |
| | | MainPage.Loading.Start (""); |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | try { |
| | | var revertObj = HttpServerRequest.Current.ModifyPassword (oldPassword, newPassword); |
| | | if (revertObj.Code == StateCode.SUCCESS) { |
| | | //var md5Password = Utlis.MD5Encrypt (newPassword); |
| | | MainPage.LoginUser.Password = newPassword; |
| | | MainPage.LoginUser.SaveUserInfo (); |
| | | Application.RunOnMainThread (() => { |
| | | this.RemoveFromParent (); |
| | | Utlis.ShowAlertOnMainThread (Language.StringByID (R.MyInternationalizationString.PasswordModificationSuccess)); |
| | | //new Alert (Language.StringByID (R.MyInternationalizationString.Tip), Language.StringByID (R.MyInternationalizationString.PasswordModificationSuccess), Language.StringByID (R.MyInternationalizationString.Close)).Show (); |
| | | }); |
| | | } else { |
| | | //提示错误 |
| | | IMessageCommon.Current.ShowErrorInfoAlter (revertObj.Code); |
| | | } |
| | | } catch { |
| | | MainPage.FailureToServer (); |
| | | } finally { |
| | | Application.RunOnMainThread (() => { |
| | | MainPage.Loading.Hide (); |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | } |