/// <summary> /// 发送消息 /// </summary> /// <param name="phoneNum">Phone number.</param> private void SendSMS(string _phoneNumber) { ProgressDialogUtil.StartProgressDialog(this,"正在发送验证码..."); //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网路",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } var smsInfoParam = new SmsInfoParam () { PhoneNumber = phoneNumber,NickName = nickName,PassWord = passWord }; //使用restsharpApi方式 SetRestRequestParams (smsInfoParam); var restSharpRequestHelp = new RestSharpRequestHelp(smsInfoParam.Url,requestParams); restSharpRequestHelp.ExcuteAsync ((resoponse) => { if(resoponse.ResponseStatus == ResponseStatus.Completed && resoponse.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var result= resoponse.Content; var smsJson = JsonConvert.DeserializeObject<SmsJson>(result); if(smsJson.statuscode =="1") { RunOnUiThread(()=>{ Intent intent = new Intent(this,typeof(RegisterResultActivity)); var bundle = new Bundle(); bundle.PutString("phoneNum",phoneNumber); bundle.PutString("nickName",nickName); bundle.PutString("passWord",passWord); bundle.PutString("securityCode",smsJson.data.ToString()); intent.PutExtras(bundle); StartActivity(intent); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,smsJson.message,ToastLength.Short).Show(); }); } } else if(resoponse.ResponseStatus == ResponseStatus.TimedOut) { RunOnUiThread(()=> { Toast.MakeText(this,"网络连接超时",ToastLength.Short).Show(); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,resoponse.StatusDescription,ToastLength.Short).Show(); }); } RunOnUiThread(()=> { ProgressDialogUtil.StopProgressDialog(); return; }); }); }
/// <summary> /// 设置参数值 /// </summary> /// <param name="msgInfoParam">Message info parameter.</param> private void SetRestRequestParams(SmsInfoParam smsInfoParam) { if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", smsInfoParam.Key); else requestParams ["key"] = smsInfoParam.Key; if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", smsInfoParam.Eaction); else requestParams ["eaction"] = smsInfoParam.Eaction; if (!requestParams.ContainsKey ("ePhoneNumber")) requestParams.Add ("ePhoneNumber", smsInfoParam.EphoneNumber); else requestParams ["ePhoneNumber"] = smsInfoParam.EphoneNumber; if (!requestParams.ContainsKey ("ePassword")) requestParams.Add ("ePassword", smsInfoParam.EpassWord); else requestParams ["ePassword"] = smsInfoParam.EpassWord; if (!requestParams.ContainsKey ("eNickName")) requestParams.Add ("eNickName", smsInfoParam.EnickName); else requestParams ["eNickName"] = smsInfoParam.EnickName; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", smsInfoParam.Md5); else requestParams ["md5"] = smsInfoParam.Md5; }
/// <summary> /// 发送消息 /// </summary> /// <param name="phoneNum">Phone number.</param> private void SendSMS(string _phoneNumber) { ProgressDialogUtil.StartProgressDialog(this,"正在发送验证码..."); //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网路",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } var smsInfoParam = new SmsInfoParam () { PhoneNumber = phoneNum,NickName = nickName,PassWord = passWord }; //使用restsharpApi方式 SetRestRequestParams (smsInfoParam); var restSharpRequestHelp = new RestSharpRequestHelp(smsInfoParam.Url,requestSmsParams); restSharpRequestHelp.ExcuteAsync ((response) => { if(response.ResponseStatus == ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var resultJson = response.Content; var smsJson = JsonConvert.DeserializeObject<SmsJson>(resultJson); if(smsJson.statuscode =="1") { RunOnUiThread(()=>{ securityCode = smsJson.data.ToString(); mc.Start(); tv_SendCodeStatusShow.Visibility = ViewStates.Visible; }); } else { RunOnUiThread(()=> { tv_SendCodeStatusShow.Visibility = ViewStates.Invisible; Toast.MakeText(this,smsJson.message,ToastLength.Short).Show(); }); } } else if(response.ResponseStatus == ResponseStatus.TimedOut) { RunOnUiThread(()=> { tv_SendCodeStatusShow.Visibility = ViewStates.Invisible; Toast.MakeText(this,"网络连接超时",ToastLength.Short).Show(); }); } else { RunOnUiThread(()=> { tv_SendCodeStatusShow.Visibility = ViewStates.Invisible; Toast.MakeText(this,response.StatusDescription,ToastLength.Short).Show(); }); } RunOnUiThread(()=> { ProgressDialogUtil.StopProgressDialog(); return; }); }); }