コード例 #1
0
        public override int UpdatePointShow(int userId, int addPoints, int price, string content, out PointShow showinfo)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_UpdatePointShowPrice";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter <int>("@Price", price, SqlDbType.Int);
                query.CreateParameter <int>("@UserID", userId, SqlDbType.Int);
                query.CreateParameter <int>("@AddPoints", addPoints, SqlDbType.Int);
                query.CreateParameter <string>("@Content", content, SqlDbType.NVarChar, 500);

                SqlParameter parameter = query.CreateParameter <int>("@ReturnValue", SqlDbType.Int, ParameterDirection.ReturnValue);
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    showinfo = null;
                    while (reader.Next)
                    {
                        showinfo = new PointShow(reader);
                    }
                }

                return((int)parameter.Value);
            }
        }
コード例 #2
0
        public override PointShow GetMyPointShowInfo(int userID)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetMyPointShowInfo";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter <int>("@UserID", userID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    PointShow showinfo = null;
                    while (reader.Next)
                    {
                        showinfo = new PointShow(reader);
                    }
                    return(showinfo);
                }
            }
        }
コード例 #3
0
ファイル: PointShowDao.cs プロジェクト: huchao007/bbsmax
        public override PointShow GetMyPointShowInfo(int userID)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetMyPointShowInfo";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    PointShow showinfo = null;
                    while (reader.Next)
                    {
                        showinfo = new PointShow(reader);
                    }
                    return showinfo;
                }

            }
        }
コード例 #4
0
        public override PointShow CreatePointShow(int userID, int point, int price, string content)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_CreatePointShow";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter <int>("@Points", point, SqlDbType.Int);
                query.CreateParameter <int>("@UserID", userID, SqlDbType.Int);
                query.CreateParameter <int>("@Price", price, SqlDbType.Int);
                query.CreateParameter <string>("@Content", content, SqlDbType.NVarChar, 100);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    PointShow pointShowInfo = null;
                    while (reader.Next)
                    {
                        pointShowInfo = new PointShow(reader);
                    }
                    return(pointShowInfo);
                }
            }
        }
コード例 #5
0
ファイル: PointShowBO.cs プロジェクト: zhangbo27/bbsmax
        /// <summary>
        /// 充值
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="points"></param>
        /// <returns></returns>
        public bool UpdatePointShow(AuthUser operatorUser, int addPoints, int price, string content, out PointShow pointShowInfo)
        {
            PointShowSettings settings = AllSettings.Current.PointShowSettings;

            pointShowInfo = null;

            int updateState = 4;

            if (addPoints < 0)
            {
                ThrowError(new CustomError("addPoints", "充值积分值不能小于0"));
                return(false);
            }

            if (price <= 0)
            {
                ThrowError(new InvalidPriceError("price", price.ToString()));
                return(false);
            }
            else
            {
                int price1, price2;
                price1 = settings.MinPrice;
                price2 = settings.MaxPrice;
                if (price < price1 || price > price2)
                {
                    ThrowError(new CustomError("price", string.Format("单价必须在{0}~{1}之间", price1, price2)));
                    return(false);
                }
            }

            if (addPoints > 0)
            {
                int userPointValue = operatorUser.ExtendedPoints[(int)settings.UsePointType];

                if (userPointValue - addPoints < settings.PointBalance)
                {
                    ThrowError(new PointBalanceLowError("addpoint",
                                                        AllSettings.Current.PointSettings.GetUserPoint(settings.UsePointType).Name
                                                        , settings.PointBalance));
                    return(false);
                }
            }

            if (addPoints > 0)
            {
                lock (operatorUser.UpdateUserPointLocker)
                {
                    int[] Points = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };

                    Points[(int)AllSettings.Current.PointShowSettings.UsePointType] = -Math.Abs(addPoints);

                    if (!UserBO.Instance.UpdateUserPoint(operatorUser.UserID, true, true, Points, "竞价排名", "竞价排名充值"))
                    {
                        return(false);
                    }
                }
            }
            updateState = PointShowDao.Instance.UpdatePointShow(operatorUser.UserID, addPoints, price, content, out pointShowInfo);

            if (updateState == -1)
            {
                ThrowError(new UserNotExistInPointShowError());
            }
            else if (updateState == 1)
            {
                ThrowError(new InvalidPriceError("price", price.ToString()));
            }

            if (updateState == 0)
            {
                ClearTopUserShowsCache();
            }

            return(updateState == 0);
        }
コード例 #6
0
ファイル: PointShowBO.cs プロジェクト: zhangbo27/bbsmax
        public bool CreatePointShow(AuthUser operatorUser, int pointcount, int price, string content, out PointShow pointShowInfo)
        {
            PointShowSettings settings = AllSettings.Current.PointShowSettings;

            pointShowInfo = null;

            if (pointcount <= 0)
            {
                ThrowError(new InvalidPointError("pointcount", pointcount.ToString()));
                return(false);
            }

            if (price <= 0 || price > pointcount)
            {
                ThrowError(new InvalidPriceError("price", price.ToString()));
                return(false);
            }
            else
            {
                int price1, price2;
                price1 = settings.MinPrice;
                price2 = settings.MaxPrice;
                if (price < price1 || price > price2)
                {
                    ThrowError(new  CustomError("price", string.Format("单价必须在{0}~{1}之间", price1, price2)));
                    return(false);
                }
            }

            string bannedWord = string.Empty;

            if (AllSettings.Current.ContentKeywordSettings.BannedKeywords.IsMatch(content, out bannedWord))
            {
                ThrowError(new CustomError("content", string.Format("上榜宣言包含被禁止的关键词:{0}", bannedWord)));
                return(false);
            }

            using (new ErrorScope())
            {
                bool success = false;

                lock (operatorUser.UpdateUserPointLocker)
                {
                    int userPointValue = operatorUser.ExtendedPoints[(int)settings.UsePointType];

                    if (userPointValue - pointcount < settings.PointBalance)
                    {
                        ThrowError(new PointBalanceLowError("pointcount",
                                                            AllSettings.Current.PointSettings.GetUserPoint(settings.UsePointType).Name
                                                            , settings.PointBalance));
                        return(false);
                    }

                    int[] Points = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };

                    Points[(int)AllSettings.Current.PointShowSettings.UsePointType] = -Math.Abs(pointcount);

                    success = UserBO.Instance.UpdateUserPoint(operatorUser.UserID, true, true, Points, "竞价排行", "竞价排名充值");
                }
                if (success)
                {
                    pointShowInfo = PointShowDao.Instance.CreatePointShow(operatorUser.UserID, pointcount, price, content);
                    if (pointShowInfo != null)
                    {
                        FeedBO.Instance.CreateBidUpSelfFeed(operatorUser.UserID, pointcount, content);
                    }

                    ClearTopUserShowsCache();
                }

                return(success);


                //bool success = PointShowPointAction.Instance.UpdateUserPointValue(userID, PointShowType.AddPointShow, -pointcount, delegate(PointActionManager.TryUpdateUserPointState state)
                //{
                //    if (state == PointActionManager.TryUpdateUserPointState.CheckSucceed)
                //    {

                //    }
                //    else
                //        return false;
                //});
            }
        }
コード例 #7
0
ファイル: PointShowDao.cs プロジェクト: huchao007/bbsmax
        public override PointShow CreatePointShow(int userID, int point, int price, string content)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_CreatePointShow";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@Points", point, SqlDbType.Int);
                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);
                query.CreateParameter<int>("@Price", price, SqlDbType.Int);
                query.CreateParameter<string>("@Content", content, SqlDbType.NVarChar, 100);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    PointShow pointShowInfo = null;
                    while (reader.Next)
                    {
                        pointShowInfo = new PointShow(reader);
                    }
                    return pointShowInfo;
                }
            }
        }
コード例 #8
0
ファイル: PointShowDao.cs プロジェクト: huchao007/bbsmax
        public override int UpdatePointShow(int userId, int addPoints, int price, string content, out PointShow showinfo)
        {
            using (SqlQuery query = new SqlQuery())
            {

                query.CommandText = "bx_UpdatePointShowPrice";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@Price", price, SqlDbType.Int);
                query.CreateParameter<int>("@UserID", userId, SqlDbType.Int);
                query.CreateParameter<int>("@AddPoints", addPoints, SqlDbType.Int);
                query.CreateParameter<string>("@Content", content, SqlDbType.NVarChar, 500);

                SqlParameter parameter = query.CreateParameter<int>("@ReturnValue", SqlDbType.Int, ParameterDirection.ReturnValue);
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    showinfo = null;
                    while (reader.Next)
                    {
                        showinfo = new PointShow(reader);
                    }
                }

                return (int)parameter.Value;
            }
        }
コード例 #9
0
ファイル: ShowDao.cs プロジェクト: zhangbo27/bbsmax
 public abstract int UpdatePointShow(int userId, int addPoints, int price, string content, out PointShow pointShowInfo);