Esempio n. 1
0
        /// <summary>
        /// 保存
        /// </summary>
        private void Save()
        {
            var fixedPhonePre  = edit_fixedphonePre.Text;
            var fixedPhoneLast = edit_fixedPhoneLast.Text;
            var fixedPhone     = string.Empty;

            if (string.IsNullOrEmpty(fixedPhonePre) || string.IsNullOrEmpty(fixedPhoneLast))
            {
                Toast.MakeText(this, "固定电话不能为空,请输入", ToastLength.Short).Show();
                return;
            }
            else
            {
                fixedPhone = fixedPhonePre + "-" + fixedPhoneLast;
                if (!EldYoungUtil.IsFixedPhone(fixedPhone))
                {
                    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 = "TelePhoneNumber", ParamValue = fixedPhone
            };

            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.TelePhoneNumber = fixedPhone;
                            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;
                    });
                }
            });
        }
Esempio n. 2
0
        /// <summary>
        /// 保存
        /// </summary>
        private void Save()
        {
            var birth = edit_birth.Text;

            if (string.IsNullOrEmpty(birth))
            {
                Toast.MakeText(this, "生日不能为空,请选择生日日期", ToastLength.Short).Show();
                return;
            }
            if (Convert.ToDateTime(birth) >= Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")))
            {
                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 = "Age", ParamValue = birth
            };

            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.Age = birth;
                            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;
                    });
                }
            });
        }
Esempio n. 3
0
        /// <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;
                    });
                }
            });
        }