private void LoadDetailData() { ProgressDialogUtil.StartProgressDialog (this, "正在加载报警详细数据..."); if (string.IsNullOrEmpty (alarmId)) { ProgressDialogUtil.StopProgressDialog (); return; } //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网路",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } alarmInfoDetailParam = new AlarmInfoDetailParam (){ AId = alarmId }; if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", alarmInfoDetailParam.Key); else requestParams ["eAId"] = alarmInfoDetailParam.Key; if (!requestParams.ContainsKey ("eAId")) requestParams.Add ("eAId",alarmInfoDetailParam.EaId); if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", alarmInfoDetailParam.Eaction); else requestParams ["eaction"] = alarmInfoDetailParam.Eaction; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", alarmInfoDetailParam.Md5); else requestParams ["md5"] = alarmInfoDetailParam.Md5; //设置restsharprequest if (restSharpRequestHelp == null) restSharpRequestHelp = new RestSharpRequestHelp (alarmInfoDetailParam.Url,requestParams); else restSharpRequestHelp.RequestParams = requestParams; //调用webservice restSharpRequestHelp.ExcuteAsync ((RestSharp.IRestResponse response) => { if(response.ResponseStatus == ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { var result = response.Content; var alarmdetailInfoJson = JsonConvert.DeserializeObject<SearchAlarmDeatilInfoJson>(result); if(alarmdetailInfoJson.statuscode =="1") { if(alarmdetailInfoJson.data.detail.Count>0) { var detail = alarmdetailInfoJson.data.detail[0]; RunOnUiThread(()=> { tv_detail_alamTime.Text = string.IsNullOrEmpty(detail.AlarmTime)?string.Empty:Convert.ToDateTime(detail.AlarmTime).ToString("yyyy-MM-dd HH:mm:ss"); tv_detail_alarmContent.Text = EldYoungUtil.FormatStrVaue(detail.AlarmContent); tv_detail_alarmDeviceId.Text = EldYoungUtil.FormatStrVaue(detail.AlarmDeviceId); tv_detail_alarmPosition.Text = EldYoungUtil.FormatStrVaue(detail.AlarmPosition); alarmPosition = EldYoungUtil.FormatStrVaue(detail.AlarmPosition); tv_detail_alarmWay.Text = EldYoungUtil.FormatStrVaue(detail.AlarmWay); tv_detail_cphoneNumberOne.Text = EldYoungUtil.FormatStrVaue(detail.CPhoneNumberOne); tv_detail_cTrueName.Text = EldYoungUtil.FormatStrVaue(detail.CTrueName); tv_detail_deviceElectricity.Text = EldYoungUtil.FormatStrVaue(detail.DeviceElectricity); tv_detail_handleUserType.Text = EldYoungUtil.FormatStrVaue(detail.HandleUserType); tv_detail_remark.Text = EldYoungUtil.FormatStrVaue(detail.Remark); tv_detail_status.Text = EldYoungUtil.FormatStrVaue(detail.Status); tv_detail_trueName.Text = EldYoungUtil.FormatStrVaue(detail.TrueName); }); } if(alarmdetailInfoJson.data.handdetail.Count>0) { var handleDetails = alarmdetailInfoJson.data.handdetail; RunOnUiThread(()=> { lv_handleDetail.Adapter = new AlarmHandleDetailInfoAdapter(this,handleDetails); }); } RunOnUiThread(()=> { ProgressDialogUtil.StopProgressDialog(); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,"获取报警详情信息错误...",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } } else if(response.ResponseStatus == 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> /// <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() { if (!requestParams.ContainsKey ("ESearchTime")) requestParams.Add ("ESearchTime", healthInfoParam.EsearchTime); else requestParams ["ESearchTime"] = healthInfoParam.EsearchTime; if (!requestParams.ContainsKey ("eUserId")) requestParams.Add ("eUserId", healthInfoParam.Eid); else requestParams ["eUserId"] = healthInfoParam.Eid; if (!requestParams.ContainsKey ("ePageIndex")) requestParams.Add ("ePageIndex", healthInfoParam.EpageIndex); else requestParams ["ePageIndex"] = healthInfoParam.EpageIndex; if (!requestParams.ContainsKey ("ePageSize")) requestParams.Add ("ePageSize", healthInfoParam.EpageSize); else requestParams ["ePageSize"] = healthInfoParam.EpageSize; if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", healthInfoParam.Eaction); else requestParams ["eaction"] = healthInfoParam.Eaction; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", healthInfoParam.Md5); else requestParams ["md5"] = healthInfoParam.Md5; if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", healthInfoParam.Key); else requestParams ["key"] = healthInfoParam.Key; //设置restsharprequest if (restSharpRequestHelp == null) restSharpRequestHelp = new RestSharpRequestHelp (healthInfoParam.Url,requestParams); else restSharpRequestHelp.RequestParams = requestParams; }
/// <summary> /// 保存 /// </summary> private void Save() { var email = edit_email.Text; if (string.IsNullOrEmpty (email)) { Toast.MakeText(this,"邮箱不能为空,请输入邮箱",ToastLength.Short).Show(); return ; } if (!EldYoungUtil.IsEmail (email)) { Toast.MakeText(this,"输入邮箱不规范",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.Guid,ParamType = "Email",ParamValue = email }; 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.Email = email; 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 SendCode() { if (!ValidInput ()) { return; } ProgressDialogUtil.StartProgressDialog(this,"正在发送验证码..."); //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网络",ToastLength.Short).Show(); btn_Send.Enabled = true; ProgressDialogUtil.StopProgressDialog(); return; } var sendCodeParam = new SendCodeParam () { PhoneNumberOne = phoneNumber,Type = sendType }; //使用restsharpApi方式 SetRestRequestSendCodeParams (sendCodeParam); var restSharpRequestHelp = new RestSharpRequestHelp(sendCodeParam.Url,requestsendcodeParams); restSharpRequestHelp.ExcuteAsync ((RestSharp.IRestResponse response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var result = response.Content; var sendCodeJson = JsonConvert.DeserializeObject<SendCodeJson>(result); if(sendCodeJson.statuscode =="1") { RunOnUiThread(()=>{ securityCode = sendCodeJson.data.ToString(); ProgressDialogUtil.StopProgressDialog(); Toast.MakeText(this,"验证码发送成功",ToastLength.Short).Show(); tv_SendCodeStatusShow.Visibility = ViewStates.Visible; mc.Start(); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,sendCodeJson.message,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); btn_Send.Enabled = true; tv_SendCodeStatusShow.Visibility = ViewStates.Invisible; return; }); } } else if(response.ResponseStatus == RestSharp.ResponseStatus.TimedOut) { RunOnUiThread(()=> { Toast.MakeText(this,"网络连接超时",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); btn_Send.Enabled = true; tv_SendCodeStatusShow.Visibility = ViewStates.Invisible; return; }); } else { RunOnUiThread(()=> { Toast.MakeText(this,response.StatusDescription,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); btn_Send.Enabled = true; tv_SendCodeStatusShow.Visibility = ViewStates.Invisible; return; }); } }); }
/// <summary> /// Reister this instance. /// </summary> private void Reister() { ProgressDialogUtil.StartProgressDialog(this,"正在注册..."); //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网路",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } //todo:调用restapi注册,将用户名、密码信息写 var registerInfoParam = new RegisterInfoParam () { PhoneNumber = phoneNum,NickName = nickName,PassWord = passWord }; //初始化参数 SetRestRequestParams (registerInfoParam); var restSharpRequestHelp = new RestSharpRequestHelp(registerInfoParam.Url,requestParams); restSharpRequestHelp.ExcuteAsync ((response) => { if(response.ResponseStatus == ResponseStatus.Completed) { //获取并解析返回resultJson获取Guid结果值 if(response.StatusCode == System.Net.HttpStatusCode.OK) { var resultJson = response.Content; var registerJson = JsonConvert.DeserializeObject<RegisterJson>(resultJson); if(registerJson.statuscode=="1") { Global.MyInfo = registerJson.data.Table[0]; var Uid = Global.MyInfo.UId; Global.Guid = Uid; //登录成功,将登录guid写入refrence文件 sp_userinfo.Edit().PutString(Global.refrence_Guid,Uid).Commit(); var guidAsAlias = Uid.Replace("-","_"); //注册用户成功,写极光推送别名,进入主界面 _jpushUtil.SetAlias(guidAsAlias); sp_userinfo.Edit().PutString(Global.refrence_UserName,nickName).Commit(); sp_userinfo.Edit().PutString(Global.refrence_Password,passWord).Commit(); sp_userinfo.Edit().PutBoolean(Global.refrence_Password_Check,true).Commit(); RunOnUiThread(()=> { //跳转到功能主界面 var intent = new Intent(this,typeof(MainActivity)); intent.SetFlags(ActivityFlags.ClearTask|ActivityFlags.NewTask); StartActivity(intent); this.Finish(); ProgressDialogUtil.StopProgressDialog(); Toast.MakeText(this,"注册成功",ToastLength.Short).Show(); OverridePendingTransition(Android.Resource.Animation.SlideInLeft,Android.Resource.Animation.SlideOutRight); }); } else { //注册失败 RunOnUiThread(()=> { Toast.MakeText(this,registerJson.message,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } } } else if(response.ResponseStatus == 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; }); } }); }
private void SetRestRequestParams() { if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", myGuardianInfoListParam.Key); else requestParams ["key"] = myGuardianInfoListParam.Key; if (!requestParams.ContainsKey ("eUserId")) requestParams.Add ("eUserId", myGuardianInfoListParam.EuserId); else requestParams ["eUserId"] = myGuardianInfoListParam.EuserId; if (!requestParams.ContainsKey ("ePageIndex")) requestParams.Add ("ePageIndex", myGuardianInfoListParam.EpageIndex); else requestParams ["ePageIndex"] = myGuardianInfoListParam.EpageIndex; if (!requestParams.ContainsKey ("ePageSize")) requestParams.Add ("ePageSize", myGuardianInfoListParam.EpageSize); else requestParams ["ePageSize"] = myGuardianInfoListParam.EpageSize; if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", myGuardianInfoListParam.Eaction); else requestParams ["eaction"] = myGuardianInfoListParam.Eaction; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", myGuardianInfoListParam.Md5); else requestParams ["md5"] = myGuardianInfoListParam.Md5; //设置restsharprequest if (restSharpRequestHelp == null) restSharpRequestHelp = new RestSharpRequestHelp (myGuardianInfoListParam.Url,requestParams); else restSharpRequestHelp.RequestParams = requestParams; }
/// <summary> /// 加载数据 /// </summary> private void loadData() { //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网络",ToastLength.Short).Show(); return; } if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", getApplyInfoParam.Key); else requestParams ["key"] = getApplyInfoParam.Key; if (!requestParams.ContainsKey ("eId")) requestParams.Add ("eId", getApplyInfoParam.Eid); else requestParams ["eId"] = getApplyInfoParam.Eid; if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", getApplyInfoParam.Eaction); else requestParams ["eaction"] = getApplyInfoParam.Eaction; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", getApplyInfoParam.Md5); else requestParams ["md5"] = getApplyInfoParam.Md5; //设置restsharprequest if (restSharpRequestHelp == null) restSharpRequestHelp = new RestSharpRequestHelp (getApplyInfoParam.Url,requestParams); else restSharpRequestHelp.RequestParams = requestParams; restSharpRequestHelp.ExcuteAsync ((RestSharp.IRestResponse response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { var result = response.Content; var getApplyInfoJson = JsonConvert.DeserializeObject<GetApplyInfoJson>(result); if(getApplyInfoJson.statuscode =="1") { RunOnUiThread(()=> { getApplyInfoAdapter.Clear();//清空所有数据 getApplyInfoAdapter.AddAll(getApplyInfoJson.data); getApplyInfoAdapter.NotifyDataSetChanged(); guardianApplyRefreshListView.OnRefreshComplete (); HasLoadedOnce = true; }); } else { RunOnUiThread(()=> { Toast.MakeText(this,"获取监护申请信息失败,稍后在试...",ToastLength.Short).Show(); guardianApplyRefreshListView.OnRefreshComplete (); return; }); } } else if(response.ResponseStatus == RestSharp.ResponseStatus.TimedOut) { RunOnUiThread(()=> { Toast.MakeText(this,"网络连接超时,稍后在试...",ToastLength.Short).Show(); guardianApplyRefreshListView.OnRefreshComplete (); return; }); } else { RunOnUiThread(()=> { Toast.MakeText(this,response.StatusDescription,ToastLength.Short).Show(); guardianApplyRefreshListView.OnRefreshComplete (); return; }); } }); }
private void LoadDetailData () { ProgressDialogUtil.StartProgressDialog (this, "正在加载用户详细数据..."); if (string.IsNullOrEmpty (UId)) return; guardianInfoDetailParam = new GuardianDetailInfoParam (){ Id = UId }; if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", guardianInfoDetailParam.Key); else requestParams ["eId"] = guardianInfoDetailParam.Key; if (!requestParams.ContainsKey ("eId")) requestParams.Add ("eId",guardianInfoDetailParam.Eid); if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", guardianInfoDetailParam.Eaction); else requestParams ["eaction"] = guardianInfoDetailParam.Eaction; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", guardianInfoDetailParam.Md5); else requestParams ["md5"] = guardianInfoDetailParam.Md5; //设置restsharprequest if (restSharpRequestHelp == null) restSharpRequestHelp = new RestSharpRequestHelp (guardianInfoDetailParam.Url,requestParams); else restSharpRequestHelp.RequestParams = requestParams; //调用监护人详情web服务 restSharpRequestHelp.ExcuteAsync ((RestSharp.IRestResponse response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { var result = response.Content; var guardianDetailInfoJson = JsonConvert.DeserializeObject<GuardianDetailInfoJson>(result); if(guardianDetailInfoJson.statuscode == "1") { if(guardianDetailInfoJson.data!=null && guardianDetailInfoJson.data.Count >0) { var detailItem = guardianDetailInfoJson.data[0]; RunOnUiThread(()=> { tv_TrueName.Text = FormartDetailResult(detailItem.TrueName); tv_Gender.Text = FormartDetailResult(detailItem.Gender); tv_Brnl.Text = FormartDetailResult(detailItem.BRNL); tv_PhoneNumberOne.Text = FormartDetailResult(detailItem.PhoneNumberOne); tv_IDNumber.Text = FormartDetailResult(detailItem.IDNumber); tv_ContactAddress.Text = FormartDetailResult(detailItem.ContactAddress); tv_TelePhoneNumber.Text =FormartDetailResult(detailItem.TelePhoneNumber); tv_Email.Text = FormartDetailResult(detailItem.Email); tv_Height.Text = FormartDetailResult(detailItem.Height); tv_Weight.Text = FormartDetailResult(detailItem.Weight); tv_HereditaryDisease.Text = FormartDetailResult(detailItem.HereditaryDisease); }); } RunOnUiThread(()=> { ProgressDialogUtil.StopProgressDialog(); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,"获取用户详情信息失败...",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; }); } }); }
private void PublishAdvice() { var adviceTitle = edit_advice_title.Text; if (string.IsNullOrEmpty (adviceTitle)) { Toast.MakeText(Activity,"留言标题不能为空,请输入标题",ToastLength.Short).Show(); return ; } var adviceContent = edit_advice_content.Text; if (string.IsNullOrEmpty (adviceContent)) { Toast.MakeText(Activity,"留言内容不能为空,请输入留言内容",ToastLength.Short).Show(); return ; } ProgressDialogUtil.StartProgressDialog(Activity,"正在保存..."); //检测网络连接 if(!EldYoungUtil.IsConnected(Activity)) { Toast.MakeText(Activity,"网络连接超时,请检测网络",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } //调用restapi注册,将用户名、密码信息写 var adviceWriteParam = new AdviceWriteParam () { UId = Global.Guid,AdviceType = _adviceType,AdviceTitle = adviceTitle,AdviceContent = adviceContent }; if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", adviceWriteParam.Key); else requestParams ["key"] = adviceWriteParam.Key; if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", adviceWriteParam.Eaction); else requestParams ["eaction"] = adviceWriteParam.Eaction; if (!requestParams.ContainsKey ("eUId")) requestParams.Add ("eUId", adviceWriteParam.Euid); else requestParams ["eUId"] = adviceWriteParam.Euid; if (!requestParams.ContainsKey ("eAdviceType")) requestParams.Add ("eAdviceType", adviceWriteParam.EadviceType); else requestParams ["eAdviceType"] = adviceWriteParam.EadviceType; if (!requestParams.ContainsKey ("ePlatformType")) requestParams.Add ("ePlatformType", adviceWriteParam.EplatformType); else requestParams ["ePlatformType"] = adviceWriteParam.EplatformType; if (!requestParams.ContainsKey ("eAdviceTitle")) requestParams.Add ("eAdviceTitle", adviceWriteParam.EadviceTitle); else requestParams ["eAdviceTitle"] = adviceWriteParam.EadviceTitle; if (!requestParams.ContainsKey ("eAdviceContent")) requestParams.Add ("eAdviceContent", adviceWriteParam.EadviceContent); else requestParams ["eAdviceContent"] = adviceWriteParam.EadviceContent; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", adviceWriteParam.Md5); else requestParams ["md5"] = adviceWriteParam.Md5; var restSharpRequestHelp = new RestSharpRequestHelp(adviceWriteParam.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 adviceWriteJson = JsonConvert.DeserializeObject<AdviceWriteJson>(result); if(adviceWriteJson.statuscode == "1") { Activity.RunOnUiThread(()=> { Toast.MakeText(Activity,"保存成功",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); }); } else { Activity.RunOnUiThread(()=> { Toast.MakeText(Activity,adviceWriteJson.message,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } } else if(response.ResponseStatus == RestSharp.ResponseStatus.TimedOut){ Activity.RunOnUiThread(()=> { Toast.MakeText(Activity,"网络连接超时,请重试",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } else { Activity.RunOnUiThread(()=> { Toast.MakeText(Activity,response.StatusDescription,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; }); } }); }
private void Login() { userNameValue = edit_userName.Text.ToString(); passwordValue = edit_userPassword.Text.ToString(); if(string.IsNullOrEmpty(userNameValue)||string.IsNullOrEmpty(passwordValue)) { Toast.MakeText(this,"用户名或密码不能为空,请填写...",ToastLength.Long).Show(); return; } if (!EldYoungUtil.IsValidUserName (userNameValue)) { Toast.MakeText (this, "请输入正确规范用户名4-20位,由中英文、数字、下划线组成", ToastLength.Short).Show (); return; } if (!EldYoungUtil.IsPassWord (passwordValue)) { Toast.MakeText (this, "请输入正确规范用户名6-20位,建议由字母、数字和符号两种以上组成", ToastLength.Short).Show (); return; } ProgressDialogUtil.StartProgressDialog(this,GetString(Resource.String.loginMsg),true); //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网络",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } //调用restapi service 登录 var loginInfoParam = new LoginInfoParam () { LoginName = userNameValue,LoginPwd = passwordValue }; //初始化请求参数 SetRestRequestParams (loginInfoParam); var restSharpRequestHelp = new RestSharpRequestHelp(loginInfoParam.Url,requestParams); restSharpRequestHelp.ExcuteAsync ((response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var resultJson = response.Content; var loginJson = JsonConvert.DeserializeObject<LoginJson>(resultJson); if(loginJson.statuscode =="1") { Global.MyInfo = loginJson.data.Table[0]; var Uid = Global.MyInfo.UId; Global.Guid = Uid; //登录成功,将登录guid写入refrence文件 sp_userinfo.Edit().PutString(Global.refrence_Guid,Uid).Commit(); var guidAsAlias = Uid.Replace("-","_");//使用用户guid作为推送别名 _jpushUtil.SetAlias(guidAsAlias); //登录成功,且记住用户密码选中,才记录 if(cb_passWord.Checked) { sp_userinfo.Edit().PutString(Global.refrence_UserName,userNameValue).Commit(); sp_userinfo.Edit().PutString(Global.refrence_Password,passwordValue).Commit(); sp_userinfo.Edit().PutBoolean(Global.refrence_Password_Check,true).Commit(); } RunOnUiThread (()=> { var funcType = Intent.GetIntExtra(Global.FuncType,0); //跳转到功能界面 var intent = new Intent(this,FuncTypeActivityFactory.CreateFuncActivityFactory(funcType)); if(funcType==(int)FuncActivityType.Main) intent.SetFlags(ActivityFlags.ClearTask|ActivityFlags.NewTask); var bundle = Intent.Extras; if (bundle != null) intent.PutExtras (bundle); StartActivity(intent); this.Finish(); OverridePendingTransition(Android.Resource.Animation.FadeIn,Android.Resource.Animation.FadeOut); Toast.MakeText(this,"登录成功",ToastLength.Short).Show(); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,loginJson.message,ToastLength.Short).Show(); }); } } else if(response.ResponseStatus == RestSharp.ResponseStatus.TimedOut) { RunOnUiThread(()=> { Toast.MakeText(this,"网络连接超时",ToastLength.Short).Show(); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,response.StatusDescription,ToastLength.Short).Show(); }); } RunOnUiThread(()=> { ProgressDialogUtil.StopProgressDialog(); return; }); }); }
/// <summary> /// 设置参数值 /// </summary> /// <param name="msgInfoParam">Message info parameter.</param> private void SetRestRequestParams() { if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", adviceRecordInfoListParam.Key); else requestParams ["key"] = adviceRecordInfoListParam.Key; if (!requestParams.ContainsKey ("eAdviceType")) requestParams.Add ("eAdviceType", adviceRecordInfoListParam.EadviceType); else requestParams ["eAdviceType"] = adviceRecordInfoListParam.EadviceType; if (!requestParams.ContainsKey ("ePlatformType")) requestParams.Add ("ePlatformType", adviceRecordInfoListParam.EplatformType); else requestParams ["ePlatformType"] = adviceRecordInfoListParam.EplatformType; if (!requestParams.ContainsKey ("eUserId")) requestParams.Add ("eUserId", adviceRecordInfoListParam.Euid); else requestParams ["eUserId"] = adviceRecordInfoListParam.Euid; if (!requestParams.ContainsKey ("ePageIndex")) requestParams.Add ("ePageIndex", adviceRecordInfoListParam.EpageIndex); else requestParams ["ePageIndex"] = adviceRecordInfoListParam.EpageIndex; if (!requestParams.ContainsKey ("ePageSize")) requestParams.Add ("ePageSize", adviceRecordInfoListParam.EpageSize); else requestParams ["ePageSize"] = adviceRecordInfoListParam.EpageSize; if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", adviceRecordInfoListParam.Eaction); else requestParams ["eaction"] = adviceRecordInfoListParam.Eaction; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", adviceRecordInfoListParam.Md5); else requestParams ["md5"] = adviceRecordInfoListParam.Md5; //设置restsharprequest if (restSharpRequestHelp == null) restSharpRequestHelp = new RestSharpRequestHelp (adviceRecordInfoListParam.Url,requestParams); else restSharpRequestHelp.RequestParams = requestParams; }
/// <summary> /// 检测是否需要更新,调用web服务 /// </summary> /// <returns><c>true</c> if this instance is update; otherwise, <c>false</c>.</returns> private bool IsUpdate() { var checkFlag = false; var returnFlag = false; // 获取本地软件版本号, localversionCode =EldYoungUtil.GetAppVersionCode(context); //localversionCode =eldyoungUtil.GetAppVersionCode; //获取webservice中android app版本号,两者比较,如果不同,返回true else false //检测网络连接 if(!EldYoungUtil.IsConnected(context)) { return returnFlag; } var getAppVersionParam = new GetAppVersionParam (); if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", getAppVersionParam.Key); else requestParams ["key"] = getAppVersionParam.Key; if (!requestParams.ContainsKey ("eappPlatform")) requestParams.Add ("eappPlatform", getAppVersionParam.EappPlatform); else requestParams ["eappPlatform"] = getAppVersionParam.EappPlatform; if (!requestParams.ContainsKey ("epackageName")) requestParams.Add ("epackageName", getAppVersionParam.EpackageName); else requestParams ["epackageName"] = getAppVersionParam.EpackageName; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", getAppVersionParam.Md5); else requestParams ["md5"] = getAppVersionParam.Md5; var restSharpRequestHelp = new RestSharpRequestHelp(getAppVersionParam.Url,requestParams); restSharpRequestHelp.ExcuteAsync ((RestSharp.IRestResponse response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var result =response.Content; if(string.IsNullOrEmpty(result)) { checkFlag = true; } else { var appVersionJson = JsonConvert.DeserializeObject<GetAppVersionJson>(result); if(appVersionJson.statuscode =="1") { var serverAppVersionCode = appVersionJson.data.AppServerVersionCode; if(localversionCode!=serverAppVersionCode) { //版本不一致有更新 Global.AppPackagePath = appVersionJson.data.AppFilePath; returnFlag = true; checkFlag=true; } else checkFlag=true; } else checkFlag = true; } } else { checkFlag=true; Log.Info("CheckAppServerVersion",string.IsNullOrEmpty(response.StatusDescription)?"":response.StatusDescription); } }); while (true) { //检测完成 if (checkFlag) { return returnFlag; } } }
/// <summary> /// 检测是否需要更新,调用web服务 /// </summary> /// <returns><c>true</c> if this instance is update; otherwise, <c>false</c>.</returns> private bool IsUpdate() { var checkFlag = false; var returnFlag = false; // 获取本地软件版本号, localversionCode = EldYoungUtil.GetAppVersionCode(context); //localversionCode =eldyoungUtil.GetAppVersionCode; //获取webservice中android app版本号,两者比较,如果不同,返回true else false //检测网络连接 if (!EldYoungUtil.IsConnected(context)) { return(returnFlag); } var getAppVersionParam = new GetAppVersionParam(); if (!requestParams.ContainsKey("key")) { requestParams.Add("key", getAppVersionParam.Key); } else { requestParams ["key"] = getAppVersionParam.Key; } if (!requestParams.ContainsKey("eappPlatform")) { requestParams.Add("eappPlatform", getAppVersionParam.EappPlatform); } else { requestParams ["eappPlatform"] = getAppVersionParam.EappPlatform; } if (!requestParams.ContainsKey("epackageName")) { requestParams.Add("epackageName", getAppVersionParam.EpackageName); } else { requestParams ["epackageName"] = getAppVersionParam.EpackageName; } if (!requestParams.ContainsKey("md5")) { requestParams.Add("md5", getAppVersionParam.Md5); } else { requestParams ["md5"] = getAppVersionParam.Md5; } var restSharpRequestHelp = new RestSharpRequestHelp(getAppVersionParam.Url, requestParams); restSharpRequestHelp.ExcuteAsync((RestSharp.IRestResponse response) => { if (response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var result = response.Content; if (string.IsNullOrEmpty(result)) { checkFlag = true; } else { var appVersionJson = JsonConvert.DeserializeObject <GetAppVersionJson>(result); if (appVersionJson.statuscode == "1") { var serverAppVersionCode = appVersionJson.data.AppServerVersionCode; if (localversionCode != serverAppVersionCode) { //版本不一致有更新 Global.AppPackagePath = appVersionJson.data.AppFilePath; returnFlag = true; checkFlag = true; } else { checkFlag = true; } } else { checkFlag = true; } } } else { checkFlag = true; Log.Info("CheckAppServerVersion", string.IsNullOrEmpty(response.StatusDescription)?"":response.StatusDescription); } }); while (true) { //检测完成 if (checkFlag) { return(returnFlag); } } }
/// <summary> /// 设置我的监护人下拉框 /// </summary> private void InitSpinner() { if (!myUserRequestParams.ContainsKey ("eUserId")) myUserRequestParams.Add ("eUserId", myUserParam.EuserId); else myUserRequestParams ["eUserId"] = myUserParam.EuserId; if (!myUserRequestParams.ContainsKey ("eaction")) myUserRequestParams.Add ("eaction", myUserParam.Eaction); else myUserRequestParams ["eaction"] = myUserParam.Eaction; if (!myUserRequestParams.ContainsKey ("md5")) myUserRequestParams.Add ("md5", myUserParam.Md5); else myUserRequestParams ["md5"] = myUserParam.Md5; if (!myUserRequestParams.ContainsKey ("key")) myUserRequestParams.Add ("key", myUserParam.Key); else myUserRequestParams ["key"] = myUserParam.Key; //设置restsharprequest if (restSharpGetMyUserRequestHelp == null) restSharpGetMyUserRequestHelp = new RestSharpRequestHelp (myUserParam.Url,myUserRequestParams); else restSharpGetMyUserRequestHelp.RequestParams = myUserRequestParams; restSharpGetMyUserRequestHelp.ExcuteAsync ((RestSharp.IRestResponse response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { var result = response.Content; var searchMyUserJson = JsonConvert.DeserializeObject<SearchAllMyUserJson>(result); if(searchMyUserJson.statuscode == "1") { myUserLists = searchMyUserJson.data; RunOnUiThread(()=> { myUserListAdapter = new ArrayAdapter<AllMyUserListItem>(this,Android.Resource.Layout.SimpleSpinnerItem,myUserLists); myUserListAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); sp_other_guardian.Adapter = myUserListAdapter; sp_other_guardian.SetSelection(0,true); }); } } }); }
/// <summary> /// Submit this instance. /// </summary> private void Submit() { passWord = edit_Pwd.Text; if (string.IsNullOrEmpty (passWord)) { Toast.MakeText(this,"密码不能为空,请输入密码",ToastLength.Short).Show(); return ; } confirmPassWord = edit_ConfirmPwd.Text; if (string.IsNullOrEmpty (confirmPassWord)) { Toast.MakeText(this,"确认密码不能为空,请输入确认密码",ToastLength.Short).Show(); return ; } if (passWord != confirmPassWord) { Toast.MakeText(this,"输入两次密码不一致,请检查",ToastLength.Short).Show(); return ; } if (!EldYoungUtil.IsPassWord (passWord)) { Toast.MakeText (this, "请输入正确规范用户名6-20位,建议由字母、数字和符号两种以上组成", ToastLength.Short).Show (); return; } ProgressDialogUtil.StartProgressDialog(this,"正在提交..."); //检测网络连接 if(!EldYoungUtil.IsConnected(this)) { Toast.MakeText(this,"网络连接超时,请检测网路",ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); return; } //调用restapi注册,将用户名、密码信息写 var modipwdParam = new ModiyPasswordParam () { Type = sendType,Password = passWord }; if (sendType == "FindPwd") modipwdParam.UId = phoneNumber; else modipwdParam.UId = Global.Guid; //初始化参数 SetRestRequestParams (modipwdParam); var restSharpRequestHelp = new RestSharpRequestHelp(modipwdParam.Url,requestsubmitParams); restSharpRequestHelp.ExcuteAsync ((RestSharp.IRestResponse response) => { if(response.ResponseStatus == RestSharp.ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { //获取并解析返回resultJson获取安全码结果值 var result = response.Content; var setpwdJson = JsonConvert.DeserializeObject<SetPasswordJson>(result); if(setpwdJson.statuscode =="1") { RunOnUiThread(()=>{ Toast.MakeText(this,setpwdJson.message,ToastLength.Short).Show(); ProgressDialogUtil.StopProgressDialog(); var intent = new Intent(this,typeof(LoginActivity)); intent.SetFlags(ActivityFlags.ClearTask|ActivityFlags.NewTask); StartActivity(intent); this.Finish(); }); } else { RunOnUiThread(()=> { Toast.MakeText(this,setpwdJson.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> /// <param name="msgInfoParam">Message info parameter.</param> private void SetRestRequestParams() { if (!requestParams.ContainsKey ("key")) requestParams.Add ("key", alarmInfoListParam.Key); else requestParams ["key"] = alarmInfoListParam.Key; if (!requestParams.ContainsKey ("eAlarmType")) requestParams.Add ("eAlarmType", alarmInfoListParam.EalarmType); else requestParams ["eAlarmType"] = alarmInfoListParam.EalarmType; if (!requestParams.ContainsKey ("eUserId")) requestParams.Add ("eUserId", alarmInfoListParam.EuserId); else requestParams ["eUserId"] = alarmInfoListParam.EuserId; if (!requestParams.ContainsKey ("eStartTime")) requestParams.Add ("eStartTime", alarmInfoListParam.EstartTime); else requestParams ["eStartTime"] = alarmInfoListParam.EstartTime; if (!requestParams.ContainsKey ("eEndTime")) requestParams.Add ("eEndTime", alarmInfoListParam.EendTime); else requestParams ["eEndTime"] = alarmInfoListParam.EendTime; if (!requestParams.ContainsKey ("ePageIndex")) requestParams.Add ("ePageIndex", alarmInfoListParam.EpageIndex); else requestParams ["ePageIndex"] = alarmInfoListParam.EpageIndex; if (!requestParams.ContainsKey ("ePageSize")) requestParams.Add ("ePageSize", alarmInfoListParam.EpageSize); else requestParams ["ePageSize"] = alarmInfoListParam.EpageSize; if (!requestParams.ContainsKey ("eaction")) requestParams.Add ("eaction", alarmInfoListParam.Eaction); else requestParams ["eaction"] = alarmInfoListParam.Eaction; if (!requestParams.ContainsKey ("md5")) requestParams.Add ("md5", alarmInfoListParam.Md5); else requestParams ["md5"] = alarmInfoListParam.Md5; //设置restsharprequest if (restSharpRequestHelp == null) restSharpRequestHelp = new RestSharpRequestHelp (alarmInfoListParam.Url,requestParams); else restSharpRequestHelp.RequestParams = requestParams; }
/// <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; }); }); }