Beispiel #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            this.ChkAdminLevel("user_sms_template", DTEnums.ActionEnum.Delete.ToString());
            int          num1        = 0;
            int          num2        = 0;
            sms_template smsTemplate = new sms_template();

            for (int index = 0; index < this.rptList.Items.Count; ++index)
            {
                int int32 = Convert.ToInt32(((HiddenField)this.rptList.Items[index].FindControl("hidId")).Value);
                if (((CheckBox)this.rptList.Items[index].FindControl("chkId")).Checked)
                {
                    if (smsTemplate.Delete(int32))
                    {
                        ++num1;
                    }
                    else
                    {
                        ++num2;
                    }
                }
            }
            this.AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除短信模板成功" + (object)num1 + "条,失败" + (object)num2 + "条");
            this.JscriptMsg("删除成功" + (object)num1 + "条,失败" + (object)num2 + "条!", Utils.CombUrlTxt("sms_template_list.aspx", "keywords={0}", this.keywords));
        }
Beispiel #2
0
        private void sendNewTradePwd(string mobile, string newTradePwd, Action <int, string> callback)
        {
            if (string.IsNullOrWhiteSpace(mobile))
            {
                callback((int)HttpStatusCode.PreconditionFailed, "请先验证手机号");
                return;
            }
            // last_send_ran_trade_pwd_at : DateTime?
            // 限制发送时间间隔
            var lastSendVerifyingSMSAt = (DateTime?)SessionHelper.Get("last_send_ran_trade_pwd_at");

            if (lastSendVerifyingSMSAt != null && DateTime.Now.Subtract(lastSendVerifyingSMSAt.Value).TotalSeconds < 600)
            {
                callback(429, "发送重置交易密码的短信的间隔为 10 分钟,您刚才已经发送过啦,休息一下再来吧!");
                return;
            }
            SessionHelper.Set("last_send_ran_trade_pwd_at", DateTime.Now);

            //获得短信模版内容
            var smsModel = new sms_template().GetModel("reset_trade_pwd");

            if (smsModel == null)
            {
                callback((int)HttpStatusCode.Gone, "短信发送失败,短信模板不存在!");
                return;
            }
            //替换模板内容
            var siteConfig = new BLL.siteconfig().loadConfig();
            var msgContent = smsModel.content.Replace("{webtel}", siteConfig.webtel).Replace("{code}", newTradePwd);

            try
            {
                //发送短信
                var  tipMsg = string.Empty;
                bool result = false;

                /*if (Utils.IsDebugging())
                 * {
                 *  Debug.WriteLine("向手机 {0} 发送短信:{1}", mobile, msgContent);
                 *  result = true;
                 * }
                 * else*/
                result = SMSHelper.SendSmsCode(mobile, msgContent, out tipMsg);

                if (result)
                {
                    callback((int)HttpStatusCode.OK, "短信发送成功,请查收!");
                }
                else
                {
                    callback((int)HttpStatusCode.InternalServerError, tipMsg);
                }
            }
            catch
            {
                callback((int)HttpStatusCode.InternalServerError, "短信发送失败,请联系本站管理员!");
            }
        }
 public async Task <IActionResult> Post([FromBody] sms_template value)
 {
     value.CreatedAt = DateTime.Now;
     value.UpdatedAt = DateTime.Now;
     value.IsValid   = true;
     if (User.Identity is ClaimsIdentity identity)
     {
         value.CreatedBy = identity.Name ?? "admin";
     }
     _smsTemplateRpt.Add(value);
     _smsTemplateRpt.Commit();
     return(new OkObjectResult(value));
 }
        public async Task <IActionResult> Put(int id, [FromBody] sms_template value)
        {
            var single = _smsTemplateRpt.GetSingle(id);

            if (single == null)
            {
                return(NotFound());
            }
            ObjectCopy.Copy <sms_template>(single, value, new string[] { "tmp_name", "to_business", "tmp_content", "remark" });
            //更新字段内容
            single.UpdatedAt = DateTime.Now;
            if (User.Identity is ClaimsIdentity identity)
            {
                single.CreatedBy = identity.Name ?? "admin";
            }
            _smsTemplateRpt.Commit();
            return(new NoContentResult());
        }