/// <summary> /// 保存 /// </summary> private void Save() { var trueName = edit_trueName.Text; if (string.IsNullOrEmpty (trueName)) { Toast.MakeText(this,"真实姓名不能为空,请输入真实姓名",ToastLength.Short).Show(); return ; } if (!EldYoungUtil.IsTrueName (trueName)) { Toast.MakeText(this,"真实姓名不可包含字母、数字、特殊符号和非法词汇[2~8个汉字]\n",ToastLength.Short).Show(); return ; } ProgressDialogUtil.StartProgressDialog(this,"正在保存..."); //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网络",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } //调用restapi注册,将用户名、密码信息写 var updateMyInfoParam = new UpdateMyInfoParam () { Uid = Global.MyInfo.UId,ParamType = "TrueName",ParamValue = edit_trueName.Text }; if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", updateMyInfoParam.Key); else requestParams ["key"] = updateMyInfoParam.Key; if (!requestParams.ContainsKey ("eUId")) requestParams.Add ("eUId", updateMyInfoParam.Euid); else requestParams ["eUId"] = updateMyInfoParam.Euid; if (!requestParams.ContainsKey ("eparamType")) requestParams.Add ("eparamType", updateMyInfoParam.EparamType); else requestParams ["eparamType"] = updateMyInfoParam.EparamType; if (!requestParams.ContainsKey ("eparamValue")) requestParams.Add ("eparamValue", updateMyInfoParam.EparamValue); else requestParams ["eparamValue"] = updateMyInfoParam.EparamValue; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", updateMyInfoParam.Md5); else requestParams ["md5"] = updateMyInfoParam.Md5; var restSharpRequestHelp = new RestSharpRequestHelp(updateMyInfoParam.Url,requestParams); restSharpRequestHelp.ExcuteAsync((RestSharp.IRestResponse response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var result = response.Content; var updateMyInfoJson = JsonConvert.DeserializeObject<UpdateMyInfoJson>(result); if(updateMyInfoJson.statuscode == "1") { RunOnUiThread(()=> { Toast.MakeText(this,"保存成功",ToastLength.Short).Show(); Global.MyInfo.TrueName = edit_trueName.Text; ProgressDialogUtil.StopProgressDialog(); this.Finish(); OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,updateMyInfoJson.message,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } } else if(response.ResponseStatus == RestSharp.ResponseStatus.TimedOut){ RunOnUiThread(()=> { Toast.MakeText(this,"网络连接超时,请重试",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } else { RunOnUiThread(()=> { Toast.MakeText(this,response.StatusDescription,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } }); }
/// <summary> /// 保存 /// </summary> private void Save() { var locationthreelevel = edit_locationthreelevel.Text;//todo:采用选择框赋值 var locationdetail = edit_locationdeatil.Text; if (string.IsNullOrEmpty (locationthreelevel) || string.IsNullOrEmpty (locationdetail)) { Toast.MakeText(this,"省市区或实际地址不能为空,请输入",ToastLength.Short).Show(); return ; } var contactAddress = locationthreelevel + locationdetail; ProgressDialogUtil.StartProgressDialog(this,"正在保存..."); //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网络",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } var updateMyInfoParam = new UpdateMyInfoParam () { Uid = Global.MyInfo.UId,ParamType = "ContactAddress",ParamValue = contactAddress }; if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", updateMyInfoParam.Key); else requestParams ["key"] = updateMyInfoParam.Key; if (!requestParams.ContainsKey ("eUId")) requestParams.Add ("eUId", updateMyInfoParam.Euid); else requestParams ["eUId"] = updateMyInfoParam.Euid; if (!requestParams.ContainsKey ("eparamType")) requestParams.Add ("eparamType", updateMyInfoParam.EparamType); else requestParams ["eparamType"] = updateMyInfoParam.EparamType; if (!requestParams.ContainsKey ("eparamValue")) requestParams.Add ("eparamValue", updateMyInfoParam.EparamValue); else requestParams ["eparamValue"] = updateMyInfoParam.EparamValue; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", updateMyInfoParam.Md5); else requestParams ["md5"] = updateMyInfoParam.Md5; var restSharpRequestHelp = new RestSharpRequestHelp(updateMyInfoParam.Url,requestParams); restSharpRequestHelp.ExcuteAsync((RestSharp.IRestResponse response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var result = response.Content; var updateMyInfoJson = JsonConvert.DeserializeObject<UpdateMyInfoJson>(result); if(updateMyInfoJson.statuscode == "1") { RunOnUiThread(()=> { Toast.MakeText(this,"保存成功",ToastLength.Short).Show(); Global.MyInfo.ContactAddress = contactAddress; ProgressDialogUtil.StopProgressDialog(); this.Finish(); OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,updateMyInfoJson.message,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } } else if(response.ResponseStatus == RestSharp.ResponseStatus.TimedOut){ RunOnUiThread(()=> { Toast.MakeText(this,"网络连接超时,请重试",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } else { RunOnUiThread(()=> { Toast.MakeText(this,response.StatusDescription,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } }); }