コード例 #1
0
 public override void Initialize()
 {
     PropBO.RegistPropType(new SetThreadUpProp());
     PropBO.RegistPropType(new ThreadStickProp());
     PropBO.RegistPropType(new ThreadHighlightProp());
     PropBO.RegistPropType(new ShowOnlineProp());
     PropBO.RegistPropType(new OnlineProtectionProp());
     PropBO.RegistPropType(new PigAvatarProp());
     PropBO.RegistPropType(new PigAvatarProtectionProp());
     PropBO.RegistPropType(new PigAvatarClearProp());
     PropBO.RegistPropType(new ChangeNameProp());
     PropBO.RegistPropType(new UserGroupProp());
     PropBO.RegistPropType(new ThreadLockProp());
     PropBO.RegistPropType(new ThreadUnLockProp());
     PropBO.RegistPropType(new SignatureProp());
 }
コード例 #2
0
ファイル: prop-buy.aspx.cs プロジェクト: zhangbo27/bbsmax
        protected void Page_Load(object sender, EventArgs e)
        {
            int?propID = _Request.Get <int>("id");

            if (propID == null)
            {
                ShowError("缺少必要的参数");
            }

            m_Prop = PropBO.Instance.GetPropByID(propID.Value);

            if (m_Prop == null)
            {
                ShowError("指定的道具不存在");
            }

            PropType propType = PropBO.GetPropType(m_Prop.PropType);

            if (propType == null)
            {
                ShowError("道具类型不存在,请联系管理员");
            }

            m_AutoUse = propType.IsAutoUse(m_Prop.PropParam);

            if (_Request.IsClick("buy"))
            {
                int count = _Request.Get <int>("count", 1);

                if (count <= 0)
                {
                    ShowError("够买数量必须大于0");
                    return;
                }

                using (ErrorScope es = new ErrorScope())
                {
                    if (m_AutoUse)
                    {
                        count = 1;
                    }

                    if (PropBO.Instance.BuyProp(My, propID.Value, count))
                    {
                        m_DisplayMessage = true;

                        if (m_AutoUse)
                        {
                            PropResult result = PropBO.Instance.UseProp(My, propID.Value, Request);

                            if (result.Type == PropResultType.Succeed)
                            {
                                ShowSuccess("道具购买并使用成功", 1);
                            }
                            else
                            {
                                ShowError("道具购买成功,但使用失败了,请联系网站管理员");
                            }
                        }
                        else
                        {
                            ShowSuccess("道具购买成功", 1);
                        }
                    }
                    else
                    {
                        m_DisplayMessage = true;

                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            ShowError(error.Message);
                        });
                    }
                }
            }
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int?id = _Request.Get <int>("id");

            m_IsEdit = id != null;

            if (m_IsEdit)
            {
                this.m_Prop = PropBO.Instance.GetPropByID(id.Value);

                this.m_PropType = PropBO.GetPropType(this.m_Prop.PropType);
            }
            else
            {
                this.m_Prop = new Prop();

                this.m_PropType = PropBO.GetPropType(_Request.Get("proptype"));
            }

            if (m_PropType == null)
            {
                ShowError("道具类型不存在");
            }

            if (_Request.IsClick("save"))
            {
                MessageDisplay md = CreateMessageDisplay(
                    "icon", "name", "description",
                    "price", "pricetype",
                    "packagesize", "totalnumber", "allowexchange",
                    "autoreplenish", "replenishnumber", "replenishtimespan"
                    );

                this.m_Prop.Icon = _Request.Get("icon");

                //默认为猪头卡的图片
                if (string.IsNullOrEmpty(this.m_Prop.Icon))
                {
                    this.m_Prop.Icon = "~/max-assets/icon-prop/4.gif";
                }

                this.m_Prop.Name = _Request.Get("name");

                if (string.IsNullOrEmpty(this.m_Prop.Name))
                {
                    md.AddError("name", "道具名称不能为空");
                }

                this.m_Prop.Description = _Request.Get("description");

                if (string.IsNullOrEmpty(this.m_Prop.Description))
                {
                    md.AddError("description", "道具描述不能为空");
                }

                int?sortOrder = _Request.Get <int>("SortOrder");

                if (sortOrder == null)
                {
                    md.AddError("SortOrder", "道具排序必须填写");
                }
                else if (sortOrder.Value < 0)
                {
                    md.AddError("SortOrder", "道具排序必须大于或等于0");
                }
                else
                {
                    this.m_Prop.SortOrder = sortOrder.Value;
                }

                int?price = _Request.Get <int>("price");

                if (price == null)
                {
                    md.AddError("price", "道具价格必须填写");
                }
                else if (price.Value <= 0)
                {
                    md.AddError("price", "道具价格必须大于0");
                }
                else
                {
                    this.m_Prop.Price = price.Value;
                }

                if (m_IsEdit == false)
                {
                    this.m_Prop.PropType = _Request.Get("proptype");
                }

                this.m_Prop.PropParam = m_PropType.GetPropParam(Request);

                int?priceType = _Request.Get <int>("pricetype");

                if (priceType == null)
                {
                    md.AddError("pricetype", "道具售价类型不能为空");
                }
                else
                {
                    this.m_Prop.PriceType = priceType.Value;
                }

                int?packageSize = _Request.Get <int>("packagesize");

                if (packageSize == null)
                {
                    md.AddError("packagesize", "道具重量必须填写");
                }
                else
                {
                    this.m_Prop.PackageSize = packageSize.Value;
                }

                int?totalNumber = _Request.Get <int>("totalnumber");

                if (totalNumber == null)
                {
                    md.AddError("totalnumber", "道具总数必须填写");
                }
                else if (totalNumber <= 0)
                {
                    md.AddError("totalnumber", "道具总数必须大于0");
                }
                else
                {
                    this.m_Prop.TotalNumber = totalNumber.Value;
                }

                bool?allowExchange = _Request.Get <bool>("allowexchange");

                if (allowExchange == null)
                {
                    md.AddError("allowexchange", "道具是否允许出售和赠送必须设置");
                }
                else
                {
                    this.m_Prop.AllowExchange = allowExchange.Value;
                }

                bool?autoReplenish = _Request.Get <bool>("autoreplenish");

                if (autoReplenish == null)
                {
                    md.AddError("autoreplenish", "道具是否自动补货必须设置");
                }
                else
                {
                    this.m_Prop.AutoReplenish = autoReplenish.Value;
                }

                int?replenishLimit = _Request.Get <int>("ReplenishLimit");

                if (replenishLimit == null)
                {
                    md.AddError("ReplenishLimit", "道具补货阀值必须设置");
                }
                else if (replenishLimit.Value < 0)
                {
                    md.AddError("ReplenishLimit", "道具补货阀值必须大于等于0");
                }
                else
                {
                    this.m_Prop.ReplenishLimit = replenishLimit.Value;
                }

                int?replenishNumber = _Request.Get <int>("replenishnumber");

                if (replenishNumber == null)
                {
                    md.AddError("replenishnumber", "道具自动补货数量必须填写");
                }
                else
                {
                    this.m_Prop.ReplenishNumber = replenishNumber.Value;
                }

                int?replenishTimespan = _Request.Get <int>("replenishtimespan");

                if (replenishTimespan == null)
                {
                    md.AddError("replenishtimespan", "道具自动补货周期必须设置");
                }
                else
                {
                    this.m_Prop.ReplenishTimeSpan = replenishTimespan.Value;
                }

                BuyPropCondition condition = new BuyPropCondition();

                this.m_Prop.BuyCondition = condition;

                condition.UserGroupIDs = StringUtil.Split2 <Guid>(_Request.Get("BuyCondition.groups", Method.Post, string.Empty));

                int?totalPoint = _Request.Get <int>("BuyCondition.totalPoint");

                if (totalPoint != null && totalPoint.Value > 0)
                {
                    condition.TotalPoint = totalPoint.Value;
                }

                UserPointCollection allPoints = AllSettings.Current.PointSettings.UserPoints;

                int[] points = new int[allPoints.Count];

                for (int i = 0; i < points.Length; i++)
                {
                    UserPoint point = allPoints[i];

                    if (point.Enable)
                    {
                        int?value = _Request.Get <int>("BuyCondition." + point.Type);

                        if (value != null)
                        {
                            points[i] = value.Value;
                        }
                        else
                        {
                            points[i] = 0;
                        }
                    }
                    else
                    {
                        points[i] = 0;
                    }
                }

                condition.Points = points;

                int?totalPosts = _Request.Get <int>("BuyCondition.totalPosts");

                if (totalPosts != null && totalPosts.Value > 0)
                {
                    condition.TotalPosts = totalPosts.Value;
                }

                int?onlineTime = _Request.Get <int>("BuyCondition.onlinetime");

                if (onlineTime != null && onlineTime.Value > 0)
                {
                    condition.OnlineTime = onlineTime.Value;
                }

                condition.ReleatedMissionIDs = StringUtil.Split2 <int>(_Request.Get("BuyCondition.releatedmissionids", Method.Post, string.Empty));

                if (md.HasAnyError())
                {
                    return;
                }

                using (ErrorScope es = new ErrorScope())
                {
                    if (m_IsEdit)
                    {
                        PropBO.Instance.UpdateProp(
                            m_Prop.PropID,
                            m_Prop.Icon,
                            m_Prop.Name,
                            price.Value,
                            priceType.Value,
                            m_Prop.PropType,
                            m_Prop.PropParam,
                            m_Prop.Description,
                            packageSize.Value,
                            totalNumber.Value,
                            allowExchange.Value,
                            autoReplenish.Value,
                            replenishNumber.Value,
                            replenishTimespan.Value,
                            replenishLimit.Value,
                            condition,
                            sortOrder.Value
                            );
                    }
                    else
                    {
                        PropBO.Instance.CreateProp(
                            m_Prop.Icon,
                            m_Prop.Name,
                            price.Value,
                            priceType.Value,
                            m_Prop.PropType,
                            m_Prop.PropParam,
                            m_Prop.Description,
                            packageSize.Value,
                            totalNumber.Value,
                            allowExchange.Value,
                            autoReplenish.Value,
                            replenishNumber.Value,
                            replenishTimespan.Value,
                            replenishLimit.Value,
                            condition,
                            sortOrder.Value
                            );
                    }

                    if (es.HasError)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            md.AddError(error);
                        });
                    }
                    else
                    {
                        JumpTo("interactive/manage-prop.aspx?page=" + _Request.Get("page"));
                    }
                }
            }
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            m_PropID = _Request.Get <int>("propid", -1);

            if (m_PropID != -1)
            {
                m_Prop = PropBO.Instance.GetUserProp(MyUserID, m_PropID);

                if (m_Prop == null)
                {
                    m_PropID = -1;
                }
                else
                {
                    PropType propType = PropBO.GetPropType(m_Prop.PropType);

                    if (propType == null)
                    {
                        m_PropID = -1;
                    }
                    else
                    {
                        m_PropHtml = propType.GetPropApplyFormHtml(Request);
                    }
                }
                if (m_Prop == null)
                {
                    ShowError("您选择的道具不存在");
                }
            }

            if (m_PropID == -1)
            {
                m_PropList = PropBO.Instance.GetUserProps(My);

                PropTypeCategory?category = _Request.Get <PropTypeCategory>("cat");

                if (category != null)
                {
                    for (int i = 0; i < m_PropList.Count;)
                    {
                        PropType type = PropBO.GetPropType(m_PropList[i].PropType);

                        if (type.Category != category.Value)
                        {
                            if (type.Category == PropTypeCategory.User && (category.Value == PropTypeCategory.Thread || category.Value == PropTypeCategory.ThreadReply))
                            {
                                i++;
                            }
                            else
                            {
                                m_PropList.RemoveAt(i);
                            }
                        }
                        else
                        {
                            i++;
                        }
                    }

                    if (m_PropList.Count == 0)
                    {
                        ShowError("在您的道具包中,没有找到适合当前场景使用的道具。");
                    }
                }
            }

            if (_Request.IsClick("use"))
            {
                using (ErrorScope es = new ErrorScope())
                {
                    PropResult result = PropBO.Instance.UseProp(My, m_PropID, Request);

                    if (result.Type == PropResultType.Succeed)
                    {
                        ShowSuccess(string.IsNullOrEmpty(result.Message) ? "道具使用成功!" : result.Message, true);
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(result.Message))
                        {
                            es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                            {
                                ShowError(error);
                            });
                        }
                        else
                        {
                            ShowError(result.Message);
                        }
                    }
                }
            }
        }