Exemple #1
0
        /// <summary>
        /// 够买邀请码
        /// </summary>
        private void BuySerial()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay();
            int            buyCount;

            buyCount = _Request.Get <int>("buyCount", MaxLabs.WebEngine.Method.Post, 0);
            try
            {
                InviteBO.Instance.BuyInviteSerial(My, buyCount);

                if (HasUnCatchedError)
                {
                    CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        if (error is UserPointOverMinValueError || error is UserPointOverMaxValueError)
                        {
                            UserPointOverMinValueError tempError = (UserPointOverMinValueError)error;
                            ErrorInfo pointError = new BuyInviteSerialPointError(tempError.UserPoint.Name, tempError.GetType());
                            msgDisplay.AddError(pointError.Message);
                        }
                        else
                        {
                            msgDisplay.AddError(error);
                        }
                    });
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddException(ex);
            }
        }
Exemple #2
0
        private void CreatePointShow()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("price", "pointcount");

            string content = _Request.Get("pointshowOath", Method.Post, string.Empty);
            int    point   = _Request.Get <int>("pointcount", Method.Post, 0);
            int    price   = _Request.Get <int>("price", Method.Post, 0);

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

                try
                {
                    success = PointShowBO.Instance.CreatePointShow(My, point, price, content, out m_myPointShowInfo);
                }
                catch (Exception ex)
                {
                    msgDisplay.AddException(ex);
                }

                if (!success)
                {
                    es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        if (error is UserPointOverMinValueError)
                        {
                            UserPointOverMinValueError e = (UserPointOverMinValueError)error;
                            msgDisplay.AddError(error.TatgetName, "您的积分不足,最多只能再增加竞价" + e.CanReduceValue);
                        }
                        else if (error is UserPointTradeMinValueError)
                        {
                            UserPointTradeMinValueError e = (UserPointTradeMinValueError)error;
                            msgDisplay.AddError(error.TatgetName, "竞价最少必须增加" + e.MinValue);
                        }
                        else if (error is UserPointTradeMaxValueError)
                        {
                            UserPointTradeMaxValueError e = (UserPointTradeMaxValueError)error;
                            msgDisplay.AddError(error.TatgetName, "竞价最多只能增加" + e.MaxValue);
                        }
                        else if (error is UserPointTradeRemainingError)
                        {
                            UserPointTradeRemainingError e = (UserPointTradeRemainingError)error;
                            msgDisplay.AddError(error.TatgetName, "您的积分不足,增加竞价后,您的" + e.PointName + "小于系统允许的最小剩余值:" + e.MinRemainingValue);
                        }
                        else
                        {
                            msgDisplay.AddError(error);
                        }
                    });

                    this.m_IsPointShowUser = false;
                }
                else
                {
                    this.m_IsPointShowUser = true;
                    ShowSuccess(false, string.Format("上榜成功, 您当前的排名是:<font color=\"red\">{0}</font>", m_myPointShowInfo.Rank));
                    //BbsRouter.JumpToCurrentUrl("page=1&succeed=1");
                }
            }
        }
Exemple #3
0
        private void RatePost()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("point");

            if (Post == null)
            {
                msgDisplay.AddError(new InvalidParamError("postid").Message);
                return;
            }

            int[] points = new int[8];

            int total = 0;

            foreach (UserPoint userPoint in AllSettings.Current.PointSettings.EnabledUserPoints)
            {
                string valueString = _Request.Get("point_" + userPoint.Type.ToString(), Method.Post, string.Empty);
                int    value       = 0;

                if (valueString != string.Empty)
                {
                    if (int.TryParse(valueString, out value) == false)
                    {
                        long temp;
                        if (long.TryParse(valueString, out temp))
                        {
                            msgDisplay.AddError("point", "您评的" + userPoint.Name + "已超出系统允许的最大值");
                            return;
                        }

                        msgDisplay.AddError("point", userPoint.Name + "必须为整数");
                        return;
                    }
                }

                points[(int)userPoint.Type] = value;

                total += value;
            }

            if (total == 0)
            {
                msgDisplay.AddError("point", "请填写积分值");
                return;
            }

            string reason = _Request.Get("actionReasonText", Method.Post);

            bool sendMessage = _Request.Get("cbsendMessage", Method.Post, "0") == "1";


            try
            {
                if (!PostBOV5.Instance.RatePost(My, Post.UserID, Post, points, reason, sendMessage))
                {
                    CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        if (error is UserPointOverMaxValueError)
                        {
                            UserPointOverMaxValueError maxValueError = (UserPointOverMaxValueError)error;

                            string info;
                            if (maxValueError.CanAddValue == 0)
                            {
                                info = "您已经不能再给TA评分";
                            }
                            else
                            {
                                info = "您最多只能给TA加“+" + maxValueError.CanAddValue + "”";
                            }


                            msgDisplay.AddError("出错啦!评分后,用户“" + Post.Username + "”的“" + maxValueError.UserPoint.Name + "”已经超过系统允许的最大值," + info);
                        }
                        else if (error is UserPointOverMinValueError)
                        {
                            UserPointOverMinValueError minValueError = (UserPointOverMinValueError)error;

                            string info;
                            if (minValueError.CanReduceValue == 0)
                            {
                                info = "您已经不能再给TA评分";
                            }
                            else
                            {
                                info = "您最多只能给TA加“-" + minValueError.CanReduceValue + "”";
                            }

                            msgDisplay.AddError("出错啦!评分后,用户“" + Post.Username + "”的“" + minValueError.UserPoint.Name + "”已经超过系统允许的最小值," + info);
                        }
                        else
                        {
                            msgDisplay.AddError(error);
                        }
                    });
                }
                else
                {
                    Return(true);
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
Exemple #4
0
        private void ProcessBuyThread()
        {
            BasicThread thread = PostBOV5.Instance.GetThread(threadID);

            bool success;

            if (IsLogin == false)
            {
                ShowError("您还没有登陆,不能购买!");
            }
            else if (thread.Price < 1)
            {
                ShowError("该主题不需要购买");
            }
            else if (thread.PostUserID == MyUserID)
            {
                ShowError("自己的主题不需要购买");
            }
            else if (thread.IsBuyed(My))
            {
                ShowError("您已经购买过该主题");
            }
            else
            {
                UserPoint tradePoint = ForumPointAction.Instance.GetUserPoint(thread.PostUserID, ForumPointValueType.SellThread, thread.ForumID);
                if (tradePoint == null)
                {
                    ShowError("系统没有设置交易积分!");
                }

                using (ErrorScope es = new ErrorScope())
                {
                    success = UserBO.Instance.TradePoint(MyUserID, thread.PostUserID, thread.Price, tradePoint.Type, false, true, null);
                    if (success == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            if (error is UserPointOverMinValueError)
                            {
                                UserPointOverMinValueError tempError            = (UserPointOverMinValueError)error;
                                NotEnoughPointBuyThread notEnoughPointBuyThread = new NotEnoughPointBuyThread("", tempError.UserPoint, thread.Price, My.ExtendedPoints[(int)tempError.UserPoint.Type]);
                                ShowError(notEnoughPointBuyThread);
                            }
                            else
                            {
                                ShowError(error.Message);
                            }
                        });
                    }
                    else
                    {
                        try
                        {
                            success = PostBOV5.Instance.CreateThreadExchange(thread.ThreadID, MyUserID, thread.Price);
                            if (success)
                            {
                                PostBOV5.Instance.SetThreadBuyedInCache(My, threadID, true);
                            }
                            else
                            {
                                ShowError("创建交易记录失败!");
                            }
                        }
                        catch (Exception ex)
                        {
                            ShowError(ex.Message);
                        }
                    }

                    if (success)
                    {
                        ShowSuccess("购买成功!", true);
                    }
                }
            }
        }
        private void ProcessBuyAttachment()
        {
            if (IsLogin == false)
            {
                ShowError("您还没有登陆,不能购买附件!");
            }
            else
            {
                Attachment tempAttachment = null;
                MaxLabs.bbsMax.FileSystem.PhysicalFile phyFile = null;
                if (tempAttachmentID <= 0)
                {
                    ShowError(new InvalidParamError("attachmentID"));
                }
                else
                {
                    tempAttachment = PostBOV5.Instance.GetAttachment(tempAttachmentID);

                    if (tempAttachment == null)
                    {
                        ShowError("该附件不存在,可能被移动或被删除!");
                    }
                    //diskFile = zzbird.Common.Disk.DiskManager.GetDiskFile(tempAttachment.DiskFileID);
                    phyFile = FileManager.GetFile(tempAttachment.FileID);
                }
                if (phyFile == null)
                {
                    ShowError("该附件不存在,可能被移动或被删除!");
                }

                if (MyUserID == tempAttachment.UserID || tempAttachment.Price == 0)
                {
                    ShowError("该附件您不需要购买!");
                }
                if (!tempAttachment.IsBuyed(My))//没购买过
                {
                    int trade = Math.Abs(tempAttachment.Price);

                    PostV5 post = PostBOV5.Instance.GetPost(tempAttachment.PostID, false);
                    if (post == null)
                    {
                        ShowError("该附件不存在,可能被移动或被删除!");
                    }

                    UserPoint tradePoint = ForumPointAction.Instance.GetUserPoint(tempAttachment.UserID, ForumPointValueType.SellAttachment, post.ForumID);

                    if (tradePoint == null)
                    {
                        ShowError("系统交易积分错误!");
                    }

                    using (ErrorScope es = new ErrorScope())
                    {
                        bool success = UserBO.Instance.TradePoint(MyUserID, tempAttachment.UserID, tempAttachment.Price, tradePoint.Type, false, true, null);
                        if (success == false)
                        {
                            es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                            {
                                if (error is UserPointOverMinValueError)
                                {
                                    UserPointOverMinValueError tempError = (UserPointOverMinValueError)error;
                                    NotEnoughPointBuyAttachment notEnoughPointBuyAttachment = new NotEnoughPointBuyAttachment("", tempError.UserPoint, tempAttachment.Price, My.ExtendedPoints[(int)tempError.UserPoint.Type]);
                                    ShowError(notEnoughPointBuyAttachment);
                                }
                                else
                                {
                                    ShowError(error.Message);
                                }
                            });
                        }
                        else
                        {
                            //创建交易记录
                            if (!PostBOV5.Instance.CreateAttachmentExchange(tempAttachment.AttachmentID, MyUserID, tempAttachment.Price))
                            {
                                ShowError("购买成功,创建交易记录失败!");
                            }
                            else
                            {
                                //下载
                                //更新userprofile
                                if (My.BuyedAttachments.ContainsKey(tempAttachment.AttachmentID))
                                {
                                    My.BuyedAttachments[tempAttachment.AttachmentID] = true;
                                }

                                //Thread.FirstPost = null;
                                ShowSuccess("购买成功,现在可以查看、下载或收藏!", true);
                            }
                        }
                    }
                }
                else
                {
                    ShowError("您已经购买此附件,无需再次购买!");
                }
            }
        }