Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private LotteryLogInfo GetLogInfo(int lotteryID, string cookieSN, string wxOpenID, string userName)
        {
            LotteryLogInfo logInfo = null;

            string SQL_WHERE =
                $"WHERE {LotteryLogAttribute.LotteryID} = {lotteryID} AND {LotteryLogAttribute.CookieSN} = '{cookieSN}'";

            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                if (rdr.Read())
                {
                    logInfo = new LotteryLogInfo(rdr);
                }
                rdr.Close();
            }

            return(logInfo);
        }
Exemplo n.º 5
0
        private LotteryLogInfo GetLogInfo(int lotteryId, string cookieSn, string wxOpenId, string userName)
        {
            LotteryLogInfo logInfo = null;

            string sqlWhere =
                $"WHERE {LotteryLogAttribute.LotteryId} = {lotteryId} AND {LotteryLogAttribute.CookieSn} = '{cookieSn}'";

            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                if (rdr.Read())
                {
                    logInfo = new LotteryLogInfo(rdr);
                }
                rdr.Close();
            }

            return(logInfo);
        }
Exemplo n.º 6
0
        public List <LotteryLogInfo> GetLotteryLogInfoList(int publishmentSystemID, int lotteryID)
        {
            var lotteryLogInfoList = new List <LotteryLogInfo>();

            string SQL_WHERE =
                $"WHERE {LotteryLogAttribute.PublishmentSystemID} = {publishmentSystemID} AND {LotteryLogAttribute.LotteryID} = {lotteryID}";

            var SQL_SELECT = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TABLE_NAME, 0, SqlUtils.Asterisk, SQL_WHERE, null);

            using (var rdr = ExecuteReader(SQL_SELECT))
            {
                while (rdr.Read())
                {
                    var lotteryLogInfo = new LotteryLogInfo(rdr);
                    lotteryLogInfoList.Add(lotteryLogInfo);
                }
                rdr.Close();
            }

            return(lotteryLogInfoList);
        }
Exemplo n.º 7
0
        public List <LotteryLogInfo> GetLotteryLogInfoList(int publishmentSystemId, int lotteryId)
        {
            var lotteryLogInfoList = new List <LotteryLogInfo>();

            string sqlWhere =
                $"WHERE {LotteryLogAttribute.PublishmentSystemId} = {publishmentSystemId} AND {LotteryLogAttribute.LotteryId} = {lotteryId}";

            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var lotteryLogInfo = new LotteryLogInfo(rdr);
                    lotteryLogInfoList.Add(lotteryLogInfo);
                }
                rdr.Close();
            }

            return(lotteryLogInfoList);
        }