asp.net忘记密码功能

//调用接口 post

 public string GetResponseByPost(string mobile, string messcode, string values, string utype)
        {
            HttpWebRequest webRequest = null;
            StreamReader responseReader = null;
            try
            {
                //ashx Url
                string getGscUserUrl = "http://124.232.150.194:8120/SMS/SMSPost.ashx";
                //加入参数,用于更新请求
                string urlHandler = getGscUserUrl + "?mobile=" + mobile + "&messcode=" + messcode + "&values=" + values + "&utype=" + utype;
                webRequest = (HttpWebRequest)HttpWebRequest.Create(urlHandler);
                webRequest.Timeout = 3000;//3秒超时
                //调用ashx,并取值
                responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
                string currentUserGulid = responseReader.ReadToEnd();
                return currentUserGulid.Trim();
            }
            catch
            {
                return "";
            }
            finally
            {
                responseReader.Close();
                responseReader.Dispose();
            }
        }

//发送短信按钮(获取验证码)

 protected void SendSMS_CallBack_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e)
        {
            int i=4;
            TUSERBll bll = new TUSERBll();
            string mobile = tb_ForgetUtel.Text.Trim();  // 手机号
            string userno = tb_ForgetUname.Text.Trim();  //用户名
            string strRight = mobile.Substring(mobile.Length - i, i);  //手机尾号
            string messcode = "1002";   //模板编号
            string codes = bll.Get_GetGenMescode(userno, mobile);
            string values = codes + "," + strRight;  //模板拼接参数
            string utype = "0";
            string result = GetResponseByPost(mobile, messcode, values, utype);

            //System.Collections.Hashtable hs = new System.Collections.Hashtable();
            //hs.Add("code", codes);   //存验证码
            //hs.Add("codetime",DateTime.Now.AddMinutes(15));  //验证码有效期15分钟
            DateTime codetime=new DateTime();
            codetime = DateTime.Now.AddMinutes(15);
            Session["codes"] = codes;  //取验证码
            Session["codetime"] = codetime;

            //if (Session["codes"] != null)
            //{
            //    System.Collections.Hashtable ht = new System.Collections.Hashtable();
            //    ht = Session["codes"] as System.Collections.Hashtable;
            //    DateTime dd = Convert.ToDateTime(ht["codetime"]);  //发送验证码的时间
               

            //    //判断验证码是否过期
            //    if (Convert.ToDateTime(ht["codetime"]) == DateTime.Now)
            //    {

            //    }
            //}
            //json返回值
            MSG t = JsonConvert.DeserializeObject<MSG>(result);
            string s_result = t.result;
           
            //判断输入的手机号码与用户名是否匹配
            if(codes=="000000")
            {
                SendSMS_CallBack.JSProperties["cpFlag"] = "-1";
            }
            else
            {
                SendSMS_CallBack.JSProperties["cpFlag"] = s_result; //短信发送返回值
            }
        }

 //立即重置按钮

  protected void get_rechargeCallBack_Callback(object source, DevExpress.Web.ASPxCallback.CallbackEventArgs e)
        {
            string username = tb_ForgetUname.Text.Trim();
            
            TUSERBll bll = new TUSERBll();
            string s_coude = Convert.ToString(Session["codes"]);  // 获取验证码
            string ForgetUCodes = tb_ForgetUCodes.Text.Trim();
            DateTime time = new DateTime();
            time = Convert.ToDateTime(Session["codetime"]);  //获取时间
           
            if (s_coude!="")
            {
                string i = bll.Get_CheckMescode(ForgetUCodes);
                if (time == DateTime.Now)
                {
                    get_rechargeCallBack.JSProperties["cpFlag"] ="-2222";
                }
                else if (tb_ForgetUCodes.Text != s_coude)
                {
                   get_rechargeCallBack.JSProperties["cpFlag"] = "-1111";
                }
                else if(i=="1")
                {
                    get_rechargeCallBack.JSProperties["cpFlag"] = i;
                    //tb_ForgetUname2.Text = username;  //用户名称
                  
                    Session["codes"] = null;
                    Session.Remove("codes");
                    Session["codetime"] = null;
                    Session.Remove("codetime");
                  
                    
                }
                else
                {
                    get_rechargeCallBack.JSProperties["cpFlag"] = i;
                }
               
            }
            else if(tb_ForgetUCodes.Text != s_coude)
            {
                get_rechargeCallBack.JSProperties["cpFlag"] = "-1";
            }
            else
            {
                get_rechargeCallBack.JSProperties["cpFlag"] = "-1";
            }
            


            
        }

 

posted @ 2016-06-27 10:41  小鹿的无名书  阅读(1044)  评论(0编辑  收藏  举报