コード例 #1
0
        private int[] GetPoint(string formName, bool isSetIntMinValue, MessageDisplay msgDisplay)
        {
            UserPointCollection allPoints = AllSettings.Current.PointSettings.UserPoints;

            int[]         points     = new int[allPoints.Count];
            StringBuilder pointNames = new StringBuilder();

            for (int i = 0; i < points.Length; i++)
            {
                UserPoint point = allPoints[i];
                if (point.Enable)
                {
                    int    value;
                    string valueString;
                    if (!GetIntValue(formName + "." + (int)point.Type, isSetIntMinValue, out value, out valueString))
                    {
                        pointNames.Append(point.Name + ",");
                    }
                    points[i] = value;
                }
                else
                {
                    points[i] = 0;
                }
            }
            if (pointNames.Length > 0)
            {
                msgDisplay.AddError(formName, new PointFormatError(formName, pointNames.ToString(0, pointNames.Length - 1), string.Empty).Message);
            }
            return(points);
        }
コード例 #2
0
        public void AllUserPointList(UserPointListTemplate template)
        {
            int i = 0;
            UserPointCollection userPoints = AllSettings.Current.PointSettings.UserPoints;

            foreach (UserPoint point in userPoints)
            {
                template(i++, point, (int)point.Type
                         , point.MaxValue == int.MaxValue ? "" : point.MaxValue.ToString()
                         , point.MinValue == int.MinValue ? "" : point.MinValue.ToString()
                         , userPoints.Count
                         );
            }
        }
コード例 #3
0
        protected string GetPoints(User user, string format, bool displayPointName)
        {
            UserPointCollection extendedPoints = AllSettings.Current.PointSettings.UserPoints;//PointManager.GetAllExtendedPoints();
            string points = string.Empty;

            for (int i = 0; i < user.ExtendedPoints.Length; i++)//i为0的 属于总积分 所以i从1开始
            {
                UserPoint extendedPoint = extendedPoints[i];

                if (extendedPoint != null && extendedPoint.Enable && extendedPoint.Display)
                {
                    points += string.Format(format, displayPointName ? extendedPoint.Name : string.Empty, user.ExtendedPoints[i].ToString(), extendedPoint.UnitName);
                }
            }
            return(points);
        }
コード例 #4
0
ファイル: PointSettings.cs プロジェクト: huchao007/bbsmax
        public PointSettings()
        {
            UserPoints = new UserPointCollection();
            ExchangeProportions = new PointExchangeProportionCollection();

            ExchangeProportions.Add(UserPointType.Point1, 10);
            ExchangeProportions.Add(UserPointType.Point2, 1);
            ExchangeProportions.Add(UserPointType.Point3, 1);
            ExchangeProportions.Add(UserPointType.Point4, 1);
            ExchangeProportions.Add(UserPointType.Point5, 1);
            ExchangeProportions.Add(UserPointType.Point6, 1);
            ExchangeProportions.Add(UserPointType.Point7, 1);
            ExchangeProportions.Add(UserPointType.Point8, 1);

            EnablePointExchange = false;
            
            EnablePointTransfer = false;

            PointRechargeRules = new PointRechargeRuleCollection();

            PointExchangeRules = new PointExchangeRuleCollection();
            PointExchangeRule rule = new PointExchangeRule();
            rule.PointType = UserPointType.Point2;
            rule.TargetPointType = UserPointType.Point1;
            rule.TaxRate = 2;
            PointExchangeRules.Add(rule);

            GeneralPointName = "总积分";
            GeneralPointExpression = "p1+p2*10";
            DisplayGeneralPoint = true;
            TradeRate = 2;

            PointTransferRules = new PointTransferRuleCollection();
            PointTransferRule tRule = new PointTransferRule();
            tRule.CanTransfer = true;
            tRule.PointType = UserPointType.Point1;
            tRule.TaxRate = 2;
            PointTransferRules.Add(tRule);

            PointIcons = new PointIconCollection();
            PointIcon icon = new PointIcon();
            icon.IconCount = 4;
            icon.IconsString = "fortune_3.gif|fortune_2.gif|fortune_1.gif";
            icon.PointType = UserPointType.Point1;
            icon.PointValue = 1000;
            PointIcons.Add(icon);
        }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!UserBO.Instance.CanEditUserPoints(My, UserID))
            {
                ShowError(new NoPermissionEditUserPointError());
                return;
            }

            m_User = UserBO.Instance.GetUser(UserID);

            if (m_User == null)
            {
                ShowError(new UserNotExistsError("id", UserID));
                return;
            }

            points = AllSettings.Current.PointSettings.EnabledUserPoints;
            if (_Request.IsClick("updatepoint"))
            {
                UpdatePoint();
            }
        }
コード例 #6
0
ファイル: user-points.aspx.cs プロジェクト: huchao007/bbsmax
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!UserBO.Instance.CanEditUserPoints(My, UserID))
            {
                ShowError(new NoPermissionEditUserPointError());
                return;
            }

            m_User = UserBO.Instance.GetUser(UserID);

            if (m_User == null)
            {
                ShowError(new UserNotExistsError("id", UserID));
                return;
            }

            points = AllSettings.Current.PointSettings.EnabledUserPoints;
            if (_Request.IsClick("updatepoint"))
            {
                UpdatePoint();
            }
        }
コード例 #7
0
ファイル: PostMark.cs プロジェクト: zhangbo27/bbsmax
        public string GetPostMarkPoints(string addPointStyle, string reducePointStyle)
        {
            UserPointCollection userPoints   = AllSettings.Current.PointSettings.UserPoints;
            StringBuilder       pointBuilder = new StringBuilder();

            for (int i = 0; i < 8; i++)
            {
                UserPoint point = userPoints[i];
                int       total = Points[i];
                if (point.Enable)
                {
                    if (total > 0)
                    {
                        pointBuilder.Append(string.Format(addPointStyle, point.Name, total));
                    }
                    else if (total < 0)
                    {
                        pointBuilder.Append(string.Format(reducePointStyle, point.Name, total));
                    }
                }
            }

            return(pointBuilder.ToString());
        }
コード例 #8
0
        private void SaveUserPoints()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("maxValue", "minValue", "InitialValue", "name");
            string         type       = _Request.Get("type", Method.Get, string.Empty);

            UserPointCollection userPoints = new UserPointCollection();
            int i = 0;

            foreach (UserPoint tempUserPoint in AllSettings.Current.PointSettings.UserPoints)
            {
                int       pointID   = (int)tempUserPoint.Type;
                UserPoint userPoint = new UserPoint();
                userPoint.Enable  = _Request.Get <bool>("enable." + pointID, Method.Post, false);
                userPoint.Display = _Request.Get <bool>("display." + pointID, Method.Post, false);
                int    value;
                string valueString = _Request.Get("maxValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.MaxValue = int.MaxValue;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.MaxValue = value;
                }
                else
                {
                    msgDisplay.AddError("maxValue", i, Lang_Error.User_UserPointMaxValueFormatError);
                }

                valueString = _Request.Get("minValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.MinValue = 0;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.MinValue = value;
                }
                else
                {
                    msgDisplay.AddError("minValue", i, Lang_Error.User_UserPointMinValueFormatError);
                }

                valueString = _Request.Get("InitialValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.InitialValue = 0;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.InitialValue = value;
                }
                else
                {
                    msgDisplay.AddError("InitialValue", i, Lang_Error.User_UserPointInitialValueFormatError);
                }

                userPoint.UnitName = _Request.Get("unitName." + pointID, Method.Post, string.Empty);
                userPoint.Name     = _Request.Get("name." + pointID, Method.Post, string.Empty);
                userPoint.Type     = tempUserPoint.Type;

                userPoints.Add(userPoint);

                i++;
            }

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


            try
            {
                using (ErrorScope errorScope = new ErrorScope())
                {
                    if (!PointActionManager.UpdateUserPointSetting(userPoints))
                    {
                        errorScope.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error.TatgetName, error.TargetLine, error.Message);
                        });
                    }
                    else
                    {
                        PostBOV5.Instance.ClearShowChargePointLinks();
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
コード例 #9
0
        private void SavepointExchangeProportions()
        {
            UserPointCollection userPoints = AllSettings.Current.PointSettings.EnabledUserPoints;

            string[] errorNames = new string[userPoints.Count];
            int      i          = 0;

            foreach (UserPoint userPoint in userPoints)
            {
                errorNames[i] = userPoint.Type.ToString();
                i++;
            }
            MessageDisplay msgDisplay = CreateMessageDisplay(errorNames);

            PointExchangeProportionCollection pointExchangeProportions = new PointExchangeProportionCollection();

            foreach (UserPoint userPoint in AllSettings.Current.PointSettings.EnabledUserPoints)
            {
                string valueString = _Request.Get("pointExchangeProportion." + (int)userPoint.Type, Method.Post, string.Empty);
                int    value;
                if (!int.TryParse(valueString, out value))
                {
                    msgDisplay.AddError(userPoint.Type.ToString(), 0, string.Format(Lang_Error.User_UserPointExchangeFormatError, userPoint.Name));
                }
                else if (value < 1)
                {
                    msgDisplay.AddError(userPoint.Type.ToString(), 0, string.Format(Lang_Error.User_UserPointExchangeFormatError, userPoint.Name));
                }
                else
                {
                    pointExchangeProportions.Add(userPoint.Type, value);
                }
            }

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

            //PointExchangeProportionCollection tempPointExchangeProportions = AllSettings.Current.UserPointSettings.ExchangeProportions;
            PointSettings setting = SettingManager.CloneSetttings <PointSettings>(AllSettings.Current.PointSettings);

            setting.ExchangeProportions = pointExchangeProportions;
            try
            {
                if (!SettingManager.SaveSettings(setting))
                {
                    CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
                else
                {
                    AllSettings.Current.PointSettings = setting;
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
コード例 #10
0
ファイル: SetupManager.cs プロジェクト: huchao007/bbsmax
        public static void ConvertPoints()
        {

            string sql = @"

IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'bbsMax_ExtendedPoints') AND EXISTS (SELECT * FROM [sysobjects] WHERE [type]='U' AND [name]='bbsMax_ExtendedPoints') BEGIN
    SELECT * FROM bbsMax_ExtendedPoints;
END
ELSE
    SELECT -9999 AS PointID;

IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'System_bbsMax_Settings') AND EXISTS (SELECT * FROM [sysobjects] WHERE [type]='U' AND [name]='System_bbsMax_Settings') BEGIN
    SELECT * FROM System_bbsMax_Settings;
END
ELSE
    SELECT '-9999' AS Catalog;

";
            PointSettings pointSetting = new PointSettings();

            UserPointCollection points = new UserPointCollection();

            Dictionary<int, bool> allowImports = new Dictionary<int, bool>();
            Dictionary<int, bool> allowExports = new Dictionary<int, bool>();
            Dictionary<int, int> ratios = new Dictionary<int, int>();

            int exchangeMinBalance = 0;
            double exchangeTax = 0.2;
            int tradePointID = 0;
            double tradingTax = 0.2;
            int transferMinBalance = 0;
            using (SqlConnection connection = new SqlConnection(Settings.Current.IConnectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(sql, connection);
                command.CommandTimeout = 60;
                try
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int pointID = reader.GetInt32(reader.GetOrdinal("PointID"));

                            if (pointID == -9999)
                                return;

                            if (pointID > 0 && pointID < 9)
                            {
                                pointID = pointID - 1;

                                if (allowExports.ContainsKey(pointID))
                                    continue;

                                UserPoint userPoint = new UserPoint();

                                allowExports.Add(pointID, reader.GetBoolean(reader.GetOrdinal("AllowExport")));
                                allowImports.Add(pointID, reader.GetBoolean(reader.GetOrdinal("AllowImport")));
                                ratios.Add(pointID, reader.GetInt32(reader.GetOrdinal("Ratio")));

                                userPoint.Type = (MaxLabs.bbsMax.Enums.UserPointType)pointID;
                                userPoint.Name = reader.GetString(reader.GetOrdinal("PointName"));
                                userPoint.UnitName = reader.GetString(reader.GetOrdinal("PointUnit"));
                                userPoint.InitialValue = reader.GetInt32(reader.GetOrdinal("DefaultPoint"));
                                userPoint.Display = reader.GetBoolean(reader.GetOrdinal("IsPublic"));
                                userPoint.Enable = reader.GetBoolean(reader.GetOrdinal("IsEnabled"));
                                userPoint.MaxValue = reader.GetInt32(reader.GetOrdinal("MaxValue"));
                                userPoint.MinValue = reader.GetInt32(reader.GetOrdinal("MinValue"));

                                points.Add(userPoint);
                            }
                        }

                        if (reader.NextResult())
                        {
                            string pointformula = string.Empty;
                            while (reader.Read())
                            {
                                string catalog = reader.GetString(reader.GetOrdinal("Catalog"));
                                if (catalog == "-9999")
                                    break;

                                if (string.Compare(catalog, "PointSetting", true) == 0)
                                {
                                    string key = reader.GetString(reader.GetOrdinal("SettingKey"));
                                    string value = reader.GetString(reader.GetOrdinal("SettingValue"));
                                    try
                                    {
                                        switch (key.ToLower())
                                        {
                                            case "exchangeminbalance": exchangeMinBalance = int.Parse(value); break;
                                            case "exchangetax": exchangeTax = double.Parse(value); break;
                                            case "tradepointid": tradePointID = int.Parse(value) - 1; break;
                                            case "tradingtax": tradingTax = double.Parse(value); break;
                                            case "transferminbalance": transferMinBalance = int.Parse(value); break;
                                            case "pointname": pointSetting.GeneralPointName = value; break;
                                            case "pointformula": pointformula = value; break;
                                            default: break;
                                        }
                                    }
                                    catch { }
                                }
                            }
                            if (string.IsNullOrEmpty(pointformula) == false)
                                pointSetting.GeneralPointExpression = GetGeneralPointExpression(pointformula);

                        }
                    }

                    pointSetting.UserPoints = points;


                    if (allowImports.Count > 0)
                    {
                        //�һ�����
                        PointExchangeProportionCollection ExchangeProportions = new PointExchangeProportionCollection();

                        for (int i = 0; i < 8; i++)
                        {
                            if (ratios.ContainsKey(i))
                            {
                                ExchangeProportions.Add((UserPointType)i, ratios[i] == 0 ? 1 : ratios[i]);
                            }
                            else
                                ExchangeProportions.Add((UserPointType)i, 1);
                        }

                        pointSetting.ExchangeProportions = ExchangeProportions;

                        //�һ�����
                        PointExchangeRuleCollection PointExchangeRules = new PointExchangeRuleCollection();

                        foreach (KeyValuePair<int, bool> pair in allowImports)
                        {
                            if (pair.Value)//�������
                            {
                                foreach (KeyValuePair<int, bool> tempPair in allowExports)
                                {
                                    if (tempPair.Key == pair.Key)
                                        continue;

                                    if (tempPair.Value)//����ҳ�
                                    {
                                        PointExchangeRule rule = new PointExchangeRule();
                                        rule.PointType = (UserPointType)tempPair.Key;
                                        rule.TargetPointType = (UserPointType)pair.Key;
                                        try
                                        {
                                            rule.TaxRate = (int)(exchangeTax * 100);
                                        }
                                        catch { }

                                        PointExchangeRules.Add(rule);
                                    }
                                }
                            }
                        }

                        pointSetting.PointExchangeRules = PointExchangeRules;
                        try
                        {
                            pointSetting.TradeRate = (int)(tradingTax * 100);
                        }
                        catch { }

                        //PointTransferRuleCollection PointTransferRules = new PointTransferRuleCollection();
                        //PointTransferRule tRule = new PointTransferRule();
                        //tRule.CanTransfer = true;
                        //try
                        //{
                        //    tRule.PointType = (UserPointType)tradePointID;
                        //}
                        //catch
                        //{
                        //}
                        //tRule.TaxRate = pointSetting.TradeRate;

                        //PointTransferRules.Add(tRule);
                        //pointSetting.PointTransferRules = PointTransferRules;

                        pointSetting.PointTransferRules = new PointTransferRuleCollection();
                        pointSetting.PointIcons = new PointIconCollection();
                    }

                    sql = @"
UPDATE bx_Settings SET [Value] = @PointString WHERE TypeName = 'MaxLabs.bbsMax.Settings.PointSettings' AND [Key] = '*';
IF @@ROWCOUNT = 0
    INSERT INTO bx_Settings ([Key], [Value], [TypeName]) VALUES ('*', @PointString, 'MaxLabs.bbsMax.Settings.PointSettings');


DROP TABLE bbsMax_ExtendedPoints;
";
                    command.CommandText = sql;

                    SqlParameter param = new SqlParameter("@PointString", SqlDbType.NText);
                    param.Value = pointSetting.ToString();
                    command.Parameters.Add(param);

                    command.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    CreateLog(ex);
                    throw new Exception("������չ��������ʧ��" + ex.Message + sql);
                }
                finally
                {
                    connection.Close();
                }
            }


        }
コード例 #11
0
        private void SaveUserPoints()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("maxValue", "minValue", "InitialValue", "name");
            string type = _Request.Get("type", Method.Get, string.Empty);

            UserPointCollection userPoints = new UserPointCollection();
            int i = 0;
            foreach (UserPoint tempUserPoint in AllSettings.Current.PointSettings.UserPoints)
            {
                int pointID = (int)tempUserPoint.Type;
                UserPoint userPoint = new UserPoint();
                userPoint.Enable = _Request.Get<bool>("enable." + pointID, Method.Post, false);
                userPoint.Display = _Request.Get<bool>("display." + pointID, Method.Post, false);
                int value;
                string valueString = _Request.Get("maxValue."+pointID,Method.Post,string.Empty);
                if(valueString == string.Empty)
                {
                    userPoint.MaxValue = int.MaxValue;
                }
                else if(int.TryParse(valueString,out value))
                {
                    userPoint.MaxValue = value;
                }
                else
                {
                    msgDisplay.AddError("maxValue", i, Lang_Error.User_UserPointMaxValueFormatError);
                }

                valueString = _Request.Get("minValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.MinValue = 0;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.MinValue = value;
                }
                else
                {
                    msgDisplay.AddError("minValue", i, Lang_Error.User_UserPointMinValueFormatError);
                }

                valueString = _Request.Get("InitialValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.InitialValue = 0;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.InitialValue = value;
                }
                else
                {
                    msgDisplay.AddError("InitialValue", i, Lang_Error.User_UserPointInitialValueFormatError);
                }

                userPoint.UnitName = _Request.Get("unitName." + pointID, Method.Post, string.Empty);
                userPoint.Name = _Request.Get("name." + pointID, Method.Post, string.Empty);
                userPoint.Type = tempUserPoint.Type;

                userPoints.Add(userPoint);

                i++;
            }

            if (msgDisplay.HasAnyError())
                return;


            try
            {
                using (ErrorScope errorScope = new ErrorScope())
                {
                    if (!PointActionManager.UpdateUserPointSetting(userPoints))
                    {
                        errorScope.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error.TatgetName, error.TargetLine, error.Message);
                        });
                    }
                    else
                    {
                        PostBOV5.Instance.ClearShowChargePointLinks(); 
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
コード例 #12
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"));
                    }
                }
            }
        }
コード例 #13
0
        /// <summary>
        /// 如果用户的积分超出积分的上限或者下限则将其更新到上限或者下限
        /// </summary>


        /// <summary>
        /// 更新扩展积分设置
        /// </summary>
        /// <param name="userPoints"></param>
        /// <returns></returns>
        public static bool UpdateUserPointSetting(UserPointCollection userPoints)
        {
            int enableCount = 0;
            int i           = 0;

            string temp = AllSettings.Current.PointSettings.GeneralPointExpression.Replace("(", "").Replace(")", "").Replace("+", "|").Replace("-", "|").Replace("*", "|").Replace("/", "|").Replace(" ", "");

            string[]      colums = temp.Split('|');
            StringBuilder cannotDisablePoints = new StringBuilder();

            foreach (UserPoint userPoint in userPoints)
            {
                if (userPoint.Enable)
                {
                    enableCount++;
                    if (string.IsNullOrEmpty(userPoint.Name))
                    {
                        Context.ThrowError <EmptyUserPointNameError>(new EmptyUserPointNameError("name", i));
                    }
                    if (userPoint.MaxValue <= userPoint.MinValue)
                    {
                        Context.ThrowError <InvalidUserPointMaxValueAndMinValueError>(new InvalidUserPointMaxValueAndMinValueError("maxValue", i));
                    }

                    if (userPoint.InitialValue > userPoint.MaxValue)
                    {
                        Context.ThrowError <UserPointInitialValueGreaterthanMaxValueError>(new UserPointInitialValueGreaterthanMaxValueError("initialValue", i));
                    }
                    else if (userPoint.InitialValue < userPoint.MinValue)
                    {
                        Context.ThrowError <UserPointInitialValueLessthanMinValueError>(new UserPointInitialValueLessthanMinValueError("initialValue", i));
                    }
                }
                else
                {
                    foreach (string colum in colums)
                    {
                        if (string.Compare(colum, "p" + ((int)userPoint.Type + 1), true) == 0)
                        {
                            cannotDisablePoints.Append("\"").Append(userPoint.Name).Append("\",");
                            break;
                        }
                    }
                }
                i++;
            }
            if (cannotDisablePoints.Length > 0)
            {
                Context.ThrowError <UserPointCanNotDisablePointsError>(new UserPointCanNotDisablePointsError(cannotDisablePoints.ToString(0, cannotDisablePoints.Length - 1)));
                return(false);
            }
            if (enableCount == 0)
            {
                Context.ThrowError <NoEnableUserPointError>(new NoEnableUserPointError("NoEnableUserPointError"));
                return(false);
            }
            if (HasUnCatchedError)
            {
                return(false);
            }
            PointSettings setting = SettingManager.CloneSetttings <PointSettings>(AllSettings.Current.PointSettings);

            setting.UserPoints = userPoints;
            if (SettingManager.SaveSettings(setting))
            {
                AllSettings.Current.PointSettings = setting;
                return(true);
            }
            return(false);
        }
コード例 #14
0
ファイル: PointSettings.cs プロジェクト: huchao007/bbsmax
        public UserPointCollection GetDefaultUserPoints()
        {
            UserPointCollection tempPoints = new UserPointCollection();
            UserPoint point = new UserPoint();
            point.Type = UserPointType.Point1;
            point.Enable = true;
            point.Display = true;
            point.Name = "金钱";
            point.InitialValue = 1000;
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point2;
            point.Enable = true;
            point.Display = true;
            point.Name = "威望";
            point.InitialValue = 100;
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point3;
            point.Enable = false;
            point.Name = "积分3";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point4;
            point.Enable = false;
            point.Name = "积分4";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point5;
            point.Enable = false;
            point.Name = "积分5";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point6;
            point.Enable = false;
            point.Name = "积分6";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point7;
            point.Enable = false;
            point.Name = "积分7";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point8;
            point.Enable = false;
            point.Name = "积分8";
            tempPoints.Add(point);
            return tempPoints;
        }