Exemplo n.º 1
0
        public JsonResult GetPhoneCode(string tel)
        {
            string PHONECODE_CACHE = string.Empty;

            PHONECODE_CACHE = string.Format("PHONECODE_CACHE_{0}", tel);
            Random random  = new Random();
            string strCode = random.Next(100000, 999999) + "";

            Session["Phone_Code" + tel] = strCode;
            if (System.Web.HttpContext.Current.Cache[PHONECODE_CACHE] == null)//重复发送验证
            {
                string smsContent = System.Configuration.ConfigurationManager.AppSettings["yzmContent"];



                var sendResult = noticeBll.SendUserCode(tel, strCode);

                SendsmsLog sendsmsLog = new SendsmsLog();
                sendsmsLog.Tel        = tel;
                sendsmsLog.SmsContent = string.Format(smsContent, strCode);
                sendsmsLog.Sender     = "住家帮小秘";
                sendsmsLog.SendTime   = DateTime.Now;
                sendsmsLog.SendResult = sendResult;
                ncBase.CurrentEntities.AddToSendsmsLog(sendsmsLog);
                ncBase.CurrentEntities.SaveChanges();

                System.Web.HttpContext.Current.Cache.Insert(PHONECODE_CACHE, tel, null, DateTime.Now.AddMinutes(2), System.Web.Caching.Cache.NoSlidingExpiration);

                return(Json(new { status = 0 }));
            }
            else
            {
                return(Json(new { status = 0 }));
            }
        }
Exemplo n.º 2
0
        public ActionResult Sendsms(FormCollection form)
        {
            string tels    = form["tel"];
            string content = form["content"];
            var    name    = this.GetLoginUser().Name;

            if (!string.IsNullOrEmpty(tels))
            {
                string[] arrs = tels.Split(',');


                for (int i = 0; i < arrs.LongLength; i++)
                {
                    SendResult sendResult = smsApi.SendSms(arrs[i], content, (Purpose)8, "【房产盒子】");
                    //SendResult sendResult= new SendResult();
                    sendResult.Status = Status.Success;
                    SendsmsLog sendsmsLog = new SendsmsLog();
                    sendsmsLog.Tel        = arrs[i];
                    sendsmsLog.SmsContent = content;
                    sendsmsLog.Sender     = name;
                    sendsmsLog.SendTime   = DateTime.Now;
                    sendsmsLog.SendResult = sendResult.Status.ToString();
                    ncBase.CurrentEntities.AddToSendsmsLog(sendsmsLog);
                    ncBase.CurrentEntities.SaveChanges();
                }
            }


            return(RedirectToAction("Sendsms"));
        }