Esempio n. 1
0
 public void QueueSMSCaptcha(QueueSMSCaptchaDto captcha)
 {
     _smsServices.TemplateSmsSend(new TemplateSmsSendDto
     {
         PhoneNumber   = captcha.Mobile,
         SignName      = "测试模板",
         TemplateCode  = "SMS_196975003",
         TemplateParam = $"{{\"code\":\"{ captcha.Code }\"}}"
     });
 }
Esempio n. 2
0
        public IActionResult UseCAPTransaction()
        {
            var Db = _unitOfWork.CurrentDb();

            Db.CurrentConnectionConfig.IsAutoCloseConnection = false;

            using (IDbConnection connection = Db.Ado.Connection)
            {
                connection.Open();
                using (var trans = Db.Ado.Connection.BeginTransaction(_publisher, autoCommit: false))
                {
                    Db.Ado.Transaction = trans;

                    // 添加短信发送列队

                    QueueSMSCaptchaDto captcha = new QueueSMSCaptchaDto();
                    captcha.Mobile = "13233335555";
                    captcha.Code   = 1234;

                    _publisher.Publish("Meiam.QueueService.SMSCaptcha", captcha);

                    var id = GetGUID;

                    _testCap01Service.Add(new Test_Cap01
                    {
                        ID = id
                    });

                    // 异常之后 回滚消息队列
                    _testCap02Service.Add(new Test_Cap02
                    {
                        ID = "111111111111111111111111111111111111111111111111111111111111111111111111111"
                    });

                    trans.Commit();

                    return(toResponse(StatusCodeType.Success));
                }
            }
        }