Example #1
0
        public static void SendEmailExcuteService(SysConsumer sysConsumer)
        {
            using (SqlConnection connection = DBConnectionMgr.GetUserConnection())
            {
                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        //如果消息记录状态显示已经消费,跳出函数
                        if (sysConsumer.Status == SysConsumerService.SysMQ_CostStatus_Consumed)
                        {
                            return;
                        }

                        //业务执行消费
                        SysUserWelfare userWelware = new SysUserWelfare()
                        {
                            UserID     = sysConsumer.MsgCont,
                            WelfareNum = 10
                        };
                        SysUserWelfareDbSvc dbSvc = new SysUserWelfareDbSvc(connection);
                        dbSvc.Insert(userWelware, transaction);

                        //修改数据库消费状态为已消费。
                        SysConsumerDbSvc consumberDbSvc = new SysConsumerDbSvc(connection);
                        consumberDbSvc.UpdateStatus(sysConsumer.Id, SysConsumerService.SysMQ_CostStatus_Consumed, transaction);
                        transaction.Commit();
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                    }
                }
            }
        }
Example #2
0
 public void Insert(SysUserWelfare info, SqlTransaction transaction)
 {
     using (EnsureUserConnection())
     {
         DbConnection.Execute(@"Insert SysUserWelfare(UserID, WelfareNum, CreatedDate)
                                     values (@UserID, @WelfareNum, @CreatedDate)",
                              info, transaction);
     }
 }
Example #3
0
 public void Update(SysUserWelfare info)
 {
     using (EnsureUserConnection())
     {
         DbConnection.Execute(@"Update SysUserWelfare Set 
                                     WelfareNum = @WelfareNum,
                                     CreatedDate = @CreatedDate 
                                     Where Id = @Id",
                              new
         {
             Id          = info.Id,
             WelfareNum  = info.WelfareNum,
             CreatedDate = info.CreatedDate
         });
     }
 }