Exemplo n.º 1
0
        public ReturnValue <bool> CheckPhone(string phone)
        {
            if (string.IsNullOrEmpty(phone))
            {
                throw new BusinessException("手机号不能为空");
            }

            USR_CustomerMod m_user = USR_CustomerBll.GetInstance().CheckPhone(phone);

            if (m_user.SysNo != -999999)
            {
                throw new BusinessException("该手机号已注册");
            }
            else
            {
                //生成6位随机验证码
                string[] arr       = ("1,2,3,4,5,6,7,8,9,0").Split(',');
                string   Password  = "";
                int      randValue = -1;
                Random   rand      = new Random(unchecked ((int)DateTime.Now.Ticks));
                for (int i = 0; i < 6; i++)
                {
                    randValue = rand.Next(0, arr.Length - 1);
                    Password += arr[randValue];
                }
                #region 发送短信

                //Password = "******";    //测试验证码为111111
                SYS_SMSMod m_sms = new SYS_SMSMod();
                m_sms.Content  = AppConst.RegisterPhoneCode.Replace("@code", Password);
                m_sms.PhoneNum = phone;
                m_sms.Status   = (int)AppEnum.SMSStatus.sending;
                m_sms.TS       = DateTime.Now;
                m_sms.Type     = (int)AppEnum.SMSType.Register;
                m_sms.SysNo    = SYS_SMSBll.GetInstance().Add(m_sms);
                SYS_SMSBll.GetInstance().SendSMS(m_sms);
                XMS.Core.Container.CacheService.LocalCache.SetItem(AppConst.APIRegionName, "SMSVerifyCode" + phone, Password, 1000);
                return(ReturnValue <bool> .Get200OK(true));

                #endregion
            }
        }
Exemplo n.º 2
0
        public void SendSMS(SYS_SMSMod m_sms)
        {
            string strRet    = null;
            string url       = @"http://utf8.sms.webchinese.cn/?Uid=ssqian&Key=be1bc83c52a767a15d1d&smsMob=" + m_sms.PhoneNum + @"&smsText=" + HttpUtility.UrlEncode(m_sms.Content);
            string targeturl = url.Trim().ToString();

            try
            {
                HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(targeturl);
                hr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
                hr.Method    = "GET";
                hr.Timeout   = 30 * 60 * 1000;
                WebResponse  hs  = hr.GetResponse();
                Stream       sr  = hs.GetResponseStream();
                StreamReader ser = new StreamReader(sr, Encoding.UTF8);
                strRet = ser.ReadToEnd();
            }
            catch (Exception ex)
            {
                strRet = null;
            }
            if (strRet != null)
            {
                if (int.Parse(strRet) > 0)
                {
                    m_sms.Status = (int)AppEnum.SMSStatus.sended;
                }
                else
                {
                    m_sms.Status = (int)AppEnum.SMSStatus.failed;
                }
                m_sms.ReturnCode = int.Parse(strRet);
                m_sms.SendTime   = DateTime.Now;
            }
            else
            {
                m_sms.Status = (int)AppEnum.SMSStatus.failed;
            }
            Update(m_sms);
        }
Exemplo n.º 3
0
 public void SendSMS(SYS_SMSMod m_sms)
 {
     string strRet = null;
     string url = @"http://utf8.sms.webchinese.cn/?Uid=ssqian&Key=be1bc83c52a767a15d1d&smsMob=" + m_sms.PhoneNum + @"&smsText=" + HttpUtility.UrlEncode(m_sms.Content);
     string targeturl = url.Trim().ToString();
     try
     {
         HttpWebRequest hr = (HttpWebRequest)WebRequest.Create(targeturl);
         hr.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
         hr.Method = "GET";
         hr.Timeout = 30 * 60 * 1000;
         WebResponse hs = hr.GetResponse();
         Stream sr = hs.GetResponseStream();
         StreamReader ser = new StreamReader(sr, Encoding.UTF8);
         strRet = ser.ReadToEnd();
     }
     catch (Exception ex)
     {
         strRet = null;
     }
     if (strRet != null)
     {
         if (int.Parse(strRet) > 0)
         {
             m_sms.Status = (int)AppEnum.SMSStatus.sended;
         }
         else
         {
             m_sms.Status = (int)AppEnum.SMSStatus.failed;
         }
         m_sms.ReturnCode = int.Parse(strRet);
         m_sms.SendTime = DateTime.Now;
     }
     else
     {
         m_sms.Status = (int)AppEnum.SMSStatus.failed;
     }
     Update(m_sms);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SYS_SMSMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SYS_SMS(");
            strSql.Append("Content,TS,Status,ReturnCode,CustomerSysNo,Type,PhoneNum,SendTime)");
            strSql.Append(" values (");
            strSql.Append("@Content,@TS,@Status,@ReturnCode,@CustomerSysNo,@Type,@PhoneNum,@SendTime)");
            strSql.Append(";select @@IDENTITY");
            SqlCommand cmd = new SqlCommand(strSql.ToString());

            SqlParameter[] parameters =
            {
                new SqlParameter("@Content",       SqlDbType.NVarChar,  600),
                new SqlParameter("@TS",            SqlDbType.DateTime),
                new SqlParameter("@Status",        SqlDbType.Int,         4),
                new SqlParameter("@ReturnCode",    SqlDbType.Int,         4),
                new SqlParameter("@CustomerSysNo", SqlDbType.Int,         4),
                new SqlParameter("@Type",          SqlDbType.Int,         4),
                new SqlParameter("@PhoneNum",      SqlDbType.VarChar,    50),
                new SqlParameter("@SendTime",      SqlDbType.DateTime),
            };
            if (model.Content != AppConst.StringNull)
            {
                parameters[0].Value = model.Content;
            }
            else
            {
                parameters[0].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[0]);
            if (model.TS != AppConst.DateTimeNull)
            {
                parameters[1].Value = model.TS;
            }
            else
            {
                parameters[1].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[1]);
            if (model.Status != AppConst.IntNull)
            {
                parameters[2].Value = model.Status;
            }
            else
            {
                parameters[2].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[2]);
            if (model.ReturnCode != AppConst.IntNull)
            {
                parameters[3].Value = model.ReturnCode;
            }
            else
            {
                parameters[3].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[3]);
            if (model.CustomerSysNo != AppConst.IntNull)
            {
                parameters[4].Value = model.CustomerSysNo;
            }
            else
            {
                parameters[4].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[4]);
            if (model.Type != AppConst.IntNull)
            {
                parameters[5].Value = model.Type;
            }
            else
            {
                parameters[5].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[5]);
            if (model.PhoneNum != AppConst.StringNull)
            {
                parameters[6].Value = model.PhoneNum;
            }
            else
            {
                parameters[6].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[6]);
            if (model.SendTime != AppConst.DateTimeNull)
            {
                parameters[7].Value = model.SendTime;
            }
            else
            {
                parameters[7].Value = System.DBNull.Value;
            }
            cmd.Parameters.Add(parameters[7]);

            return(Convert.ToInt32(SqlHelper.ExecuteScalar(cmd, parameters)));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(SYS_SMSMod model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SYS_SMS set ");
            SqlCommand cmd = new SqlCommand();

            if (model.SysNo != AppConst.IntNull)
            {
                SqlParameter param = new SqlParameter("@SysNo", SqlDbType.Int, 4);
                param.Value = model.SysNo;
                cmd.Parameters.Add(param);
            }
            if (model.Content != AppConst.StringNull)
            {
                strSql.Append("Content=@Content,");
                SqlParameter param = new SqlParameter("@Content", SqlDbType.NVarChar, 600);
                param.Value = model.Content;
                cmd.Parameters.Add(param);
            }
            if (model.TS != AppConst.DateTimeNull)
            {
                strSql.Append("TS=@TS,");
                SqlParameter param = new SqlParameter("@TS", SqlDbType.DateTime);
                param.Value = model.TS;
                cmd.Parameters.Add(param);
            }
            if (model.Status != AppConst.IntNull)
            {
                strSql.Append("Status=@Status,");
                SqlParameter param = new SqlParameter("@Status", SqlDbType.Int, 4);
                param.Value = model.Status;
                cmd.Parameters.Add(param);
            }
            if (model.ReturnCode != AppConst.IntNull)
            {
                strSql.Append("ReturnCode=@ReturnCode,");
                SqlParameter param = new SqlParameter("@ReturnCode", SqlDbType.Int, 4);
                param.Value = model.ReturnCode;
                cmd.Parameters.Add(param);
            }
            if (model.CustomerSysNo != AppConst.IntNull)
            {
                strSql.Append("CustomerSysNo=@CustomerSysNo,");
                SqlParameter param = new SqlParameter("@CustomerSysNo", SqlDbType.Int, 4);
                param.Value = model.CustomerSysNo;
                cmd.Parameters.Add(param);
            }
            if (model.Type != AppConst.IntNull)
            {
                strSql.Append("Type=@Type,");
                SqlParameter param = new SqlParameter("@Type", SqlDbType.Int, 4);
                param.Value = model.Type;
                cmd.Parameters.Add(param);
            }
            if (model.PhoneNum != AppConst.StringNull)
            {
                strSql.Append("PhoneNum=@PhoneNum,");
                SqlParameter param = new SqlParameter("@PhoneNum", SqlDbType.VarChar, 50);
                param.Value = model.PhoneNum;
                cmd.Parameters.Add(param);
            }
            if (model.SendTime != AppConst.DateTimeNull)
            {
                strSql.Append("SendTime=@SendTime,");
                SqlParameter param = new SqlParameter("@SendTime", SqlDbType.DateTime);
                param.Value = model.SendTime;
                cmd.Parameters.Add(param);
            }
            strSql.Remove(strSql.Length - 1, 1);
            strSql.Append(" where SysNo=@SysNo ");
            cmd.CommandText = strSql.ToString();
            return(SqlHelper.ExecuteNonQuery(cmd, null));
        }
Exemplo n.º 6
0
        public ReturnValue<bool> CheckPhone(string phone)
        {
            if (string.IsNullOrEmpty(phone))
            {
                throw new BusinessException("手机号不能为空");
            }

            USR_CustomerMod m_user = USR_CustomerBll.GetInstance().CheckPhone(phone);
            if (m_user.SysNo != -999999)
            {
                throw new BusinessException("该手机号已注册");
            }
            else
            {
                //生成6位随机验证码
                string[] arr = ("1,2,3,4,5,6,7,8,9,0").Split(',');
                string Password = "";
                int randValue = -1;
                Random rand = new Random(unchecked((int)DateTime.Now.Ticks));
                for (int i = 0; i < 6; i++)
                {
                    randValue = rand.Next(0, arr.Length - 1);
                    Password += arr[randValue];
                }
                #region 发送短信

                //Password = "******";    //测试验证码为111111
                SYS_SMSMod m_sms = new SYS_SMSMod();
                m_sms.Content = AppConst.RegisterPhoneCode.Replace("@code",Password);
                m_sms.PhoneNum = phone;
                m_sms.Status = (int)AppEnum.SMSStatus.sending;
                m_sms.TS = DateTime.Now;
                m_sms.Type = (int)AppEnum.SMSType.Register;
                m_sms.SysNo = SYS_SMSBll.GetInstance().Add(m_sms);
                SYS_SMSBll.GetInstance().SendSMS(m_sms);
                XMS.Core.Container.CacheService.LocalCache.SetItem(AppConst.APIRegionName, "SMSVerifyCode" + phone, Password, 1000);
                return ReturnValue<bool>.Get200OK(true);

                #endregion
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>

        public void Update(SYS_SMSMod model)
        {
            dal.Update(model);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>

        public int Add(SYS_SMSMod model)
        {
            return(dal.Add(model));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SYS_SMSMod model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into SYS_SMS(");
            strSql.Append("Content,TS,Status,ReturnCode,CustomerSysNo,Type,PhoneNum,SendTime)");
            strSql.Append(" values (");
            strSql.Append("@Content,@TS,@Status,@ReturnCode,@CustomerSysNo,@Type,@PhoneNum,@SendTime)");
            strSql.Append(";select @@IDENTITY");
            SqlCommand cmd = new SqlCommand(strSql.ToString());
            SqlParameter[] parameters = {
                 new SqlParameter("@Content",SqlDbType.NVarChar,600),
                 new SqlParameter("@TS",SqlDbType.DateTime),
                 new SqlParameter("@Status",SqlDbType.Int,4),
                 new SqlParameter("@ReturnCode",SqlDbType.Int,4),
                 new SqlParameter("@CustomerSysNo",SqlDbType.Int,4),
                 new SqlParameter("@Type",SqlDbType.Int,4),
                 new SqlParameter("@PhoneNum",SqlDbType.VarChar,50),
                 new SqlParameter("@SendTime",SqlDbType.DateTime),
             };
            if (model.Content != AppConst.StringNull)
                parameters[0].Value = model.Content;
            else
                parameters[0].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[0]);
            if (model.TS != AppConst.DateTimeNull)
                parameters[1].Value = model.TS;
            else
                parameters[1].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[1]);
            if (model.Status != AppConst.IntNull)
                parameters[2].Value = model.Status;
            else
                parameters[2].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[2]);
            if (model.ReturnCode != AppConst.IntNull)
                parameters[3].Value = model.ReturnCode;
            else
                parameters[3].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[3]);
            if (model.CustomerSysNo != AppConst.IntNull)
                parameters[4].Value = model.CustomerSysNo;
            else
                parameters[4].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[4]);
            if (model.Type != AppConst.IntNull)
                parameters[5].Value = model.Type;
            else
                parameters[5].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[5]);
            if (model.PhoneNum != AppConst.StringNull)
                parameters[6].Value = model.PhoneNum;
            else
                parameters[6].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[6]);
            if (model.SendTime != AppConst.DateTimeNull)
                parameters[7].Value = model.SendTime;
            else
                parameters[7].Value = System.DBNull.Value;
            cmd.Parameters.Add(parameters[7]);

            return Convert.ToInt32(SqlHelper.ExecuteScalar(cmd, parameters));
        }
Exemplo n.º 10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(SYS_SMSMod model)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("update SYS_SMS set ");
     SqlCommand cmd = new SqlCommand();
     if (model.SysNo != AppConst.IntNull)
     {
         SqlParameter param = new SqlParameter("@SysNo", SqlDbType.Int, 4);
         param.Value = model.SysNo;
         cmd.Parameters.Add(param);
     }
     if (model.Content != AppConst.StringNull)
     {
         strSql.Append("Content=@Content,");
         SqlParameter param = new SqlParameter("@Content", SqlDbType.NVarChar, 600);
         param.Value = model.Content;
         cmd.Parameters.Add(param);
     }
     if (model.TS != AppConst.DateTimeNull)
     {
         strSql.Append("TS=@TS,");
         SqlParameter param = new SqlParameter("@TS", SqlDbType.DateTime);
         param.Value = model.TS;
         cmd.Parameters.Add(param);
     }
     if (model.Status != AppConst.IntNull)
     {
         strSql.Append("Status=@Status,");
         SqlParameter param = new SqlParameter("@Status", SqlDbType.Int, 4);
         param.Value = model.Status;
         cmd.Parameters.Add(param);
     }
     if (model.ReturnCode != AppConst.IntNull)
     {
         strSql.Append("ReturnCode=@ReturnCode,");
         SqlParameter param = new SqlParameter("@ReturnCode", SqlDbType.Int, 4);
         param.Value = model.ReturnCode;
         cmd.Parameters.Add(param);
     }
     if (model.CustomerSysNo != AppConst.IntNull)
     {
         strSql.Append("CustomerSysNo=@CustomerSysNo,");
         SqlParameter param = new SqlParameter("@CustomerSysNo", SqlDbType.Int, 4);
         param.Value = model.CustomerSysNo;
         cmd.Parameters.Add(param);
     }
     if (model.Type != AppConst.IntNull)
     {
         strSql.Append("Type=@Type,");
         SqlParameter param = new SqlParameter("@Type", SqlDbType.Int, 4);
         param.Value = model.Type;
         cmd.Parameters.Add(param);
     }
     if (model.PhoneNum != AppConst.StringNull)
     {
         strSql.Append("PhoneNum=@PhoneNum,");
         SqlParameter param = new SqlParameter("@PhoneNum", SqlDbType.VarChar, 50);
         param.Value = model.PhoneNum;
         cmd.Parameters.Add(param);
     }
     if (model.SendTime != AppConst.DateTimeNull)
     {
         strSql.Append("SendTime=@SendTime,");
         SqlParameter param = new SqlParameter("@SendTime", SqlDbType.DateTime);
         param.Value = model.SendTime;
         cmd.Parameters.Add(param);
     }
     strSql.Remove(strSql.Length - 1, 1);
     strSql.Append(" where SysNo=@SysNo ");
     cmd.CommandText = strSql.ToString();
     return SqlHelper.ExecuteNonQuery(cmd, null);
 }
Exemplo n.º 11
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public SYS_SMSMod GetModel(int SysNo)
 {
     StringBuilder strSql = new StringBuilder();
     strSql.Append("select SysNo, Content, TS, Status, ReturnCode, CustomerSysNo, Type, PhoneNum, SendTime from  dbo.SYS_SMS");
     strSql.Append(" where SysNo=@SysNo ");
     SqlParameter[] parameters = {
     new SqlParameter("@SysNo", SqlDbType.Int,4 )
      		};
     parameters[0].Value = SysNo;
     SYS_SMSMod model = new SYS_SMSMod();
     DataSet ds = SqlHelper.ExecuteDataSet(strSql.ToString(), parameters);
     if (ds.Tables[0].Rows.Count > 0)
     {
         if (ds.Tables[0].Rows[0]["SysNo"].ToString() != "")
         {
             model.SysNo = int.Parse(ds.Tables[0].Rows[0]["SysNo"].ToString());
         }
         model.Content = ds.Tables[0].Rows[0]["Content"].ToString();
         if (ds.Tables[0].Rows[0]["TS"].ToString() != "")
         {
             model.TS = DateTime.Parse(ds.Tables[0].Rows[0]["TS"].ToString());
         }
         if (ds.Tables[0].Rows[0]["Status"].ToString() != "")
         {
             model.Status = int.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
         }
         if (ds.Tables[0].Rows[0]["ReturnCode"].ToString() != "")
         {
             model.ReturnCode = int.Parse(ds.Tables[0].Rows[0]["ReturnCode"].ToString());
         }
         if (ds.Tables[0].Rows[0]["CustomerSysNo"].ToString() != "")
         {
             model.CustomerSysNo = int.Parse(ds.Tables[0].Rows[0]["CustomerSysNo"].ToString());
         }
         if (ds.Tables[0].Rows[0]["Type"].ToString() != "")
         {
             model.Type = int.Parse(ds.Tables[0].Rows[0]["Type"].ToString());
         }
         model.PhoneNum = ds.Tables[0].Rows[0]["PhoneNum"].ToString();
         if (ds.Tables[0].Rows[0]["SendTime"].ToString() != "")
         {
             model.SendTime = DateTime.Parse(ds.Tables[0].Rows[0]["SendTime"].ToString());
         }
         return model;
     }
     else
     {
         return null;
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(SYS_SMSMod model)
 {
     return dal.Add(model);
 }
Exemplo n.º 13
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(SYS_SMSMod model)
 {
     dal.Update(model);
 }