Beispiel #1
0
        public int Insert(LotteryLogInfo lotteryLogInfo)
        {
            var lotteryLogId = 0;

            IDataParameter[] parms = null;

            var sqlInsert = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(lotteryLogInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        lotteryLogId = ExecuteNonQueryAndReturnId(trans, sqlInsert, parms);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(lotteryLogId);
        }
Beispiel #2
0
        public void AddCount(int publishmentSystemID, int lotteryID, string cookieSN, string wxOpenID, string userName, int maxCount, int maxDailyCount, out bool isMaxCount, out bool isMaxDailyCount)
        {
            isMaxCount      = false;
            isMaxDailyCount = false;

            var logInfo = GetLogInfo(lotteryID, cookieSN, wxOpenID, userName);

            if (logInfo == null)
            {
                logInfo = new LotteryLogInfo {
                    PublishmentSystemID = publishmentSystemID, LotteryID = lotteryID, CookieSN = cookieSN, WXOpenID = wxOpenID, UserName = userName, LotteryCount = 1, LotteryDailyCount = 1, LastLotteryDate = DateTime.Now
                };

                IDataParameter[] parms = null;

                var SQL_INSERT = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(logInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

                ExecuteNonQuery(SQL_INSERT, parms);
            }
            else
            {
                if (maxCount > 0 && logInfo.LotteryCount >= maxCount)
                {
                    isMaxCount = true;
                }
                else
                {
                    var theSameDay = DateUtils.IsTheSameDay(DateTime.Now, logInfo.LastLotteryDate);
                    if (theSameDay)
                    {
                        if (maxDailyCount > 0 && logInfo.LotteryDailyCount >= maxDailyCount)
                        {
                            isMaxDailyCount = true;
                        }
                    }

                    if (!isMaxDailyCount)
                    {
                        string sqlString =
                            $"UPDATE {TABLE_NAME} SET {LotteryLogAttribute.LotteryCount} = {LotteryLogAttribute.LotteryCount} + 1, {LotteryLogAttribute.LotteryDailyCount} = 1, {LotteryLogAttribute.LastLotteryDate} = getdate() WHERE ID = {logInfo.ID}";
                        if (theSameDay)
                        {
                            sqlString =
                                $"UPDATE {TABLE_NAME} SET {LotteryLogAttribute.LotteryCount} = {LotteryLogAttribute.LotteryCount} + 1, {LotteryLogAttribute.LotteryDailyCount} = {LotteryLogAttribute.LotteryDailyCount} + 1, {LotteryLogAttribute.LastLotteryDate} = getdate() WHERE ID = {logInfo.ID}";
                        }
                        ExecuteNonQuery(sqlString);
                    }
                }
            }
        }
Beispiel #3
0
        public int Insert(LotteryLogInfo lotteryLogInfo)
        {
            var lotteryLogID = 0;

            IDataParameter[] parms = null;

            var SQL_INSERT = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(lotteryLogInfo.ToNameValueCollection(), ConnectionString, TABLE_NAME, out parms);

            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        ExecuteNonQuery(trans, SQL_INSERT, parms);

                        lotteryLogID = BaiRongDataProvider.DatabaseDao.GetSequence(trans, TABLE_NAME);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(lotteryLogID);
        }