Example #1
0
        public bool saveSettings()
        {
            m_Success = false;
            MessageDisplay msgDisplay = null;

            if (_Request.Get("inheritType", Method.Post, "False").ToLower() == "true")
            {
                msgDisplay = CreateMessageDisplay();

                RateSettings tempSetting = new RateSettings();
                tempSetting.RateSets = new RateSetCollection();
                foreach (RateSet set in AllSettings.Current.RateSettings.RateSets)
                {
                    if (set.NodeID != ForumID)
                    {
                        tempSetting.RateSets.Add(set);
                    }
                }

                try
                {
                    if (!SettingManager.SaveSettings(tempSetting))
                    {
                        CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        BbsRouter.JumpToUrl(Request.RawUrl, "success=true");
                    }
                }
                catch (Exception ex)
                {
                    msgDisplay.AddError(ex.Message);
                }
                return(true);
            }

            string[] errorNames = new string[EnabledUserPointList.Count * 2];

            int i = 0;

            foreach (UserPoint point in EnabledUserPointList)
            {
                errorNames[i] = point.Type.ToString();
                i++;
                errorNames[i] = "new_" + point.Type.ToString();
                i++;
            }

            msgDisplay = CreateMessageDisplay(errorNames);

            RateSetItemCollection tempRankItems = new RateSetItemCollection();

            foreach (UserPoint point in EnabledUserPointList)
            {
                int[]      tempIds   = StringUtil.Split <int>(_Request.Get("id_" + point.Type.ToString(), Method.Post, string.Empty));
                List <int> sortOrdes = new List <int>();

                RateSetItem item;

                foreach (int id in tempIds)
                {
                    item = GetRankSetItem(point.Type, id, false, msgDisplay);
                    if (item != null)
                    {
                        if (id != 0 && sortOrdes.Contains(item.RoleSortOrder) && msgDisplay.HasAnyError() == false)
                        {
                            msgDisplay.AddError(point.Type.ToString(), id, "排序数字不能重复");
                        }
                        else
                        {
                            if (id != 0)
                            {
                                sortOrdes.Add(item.RoleSortOrder);
                            }
                            tempRankItems.Add(item);
                        }
                    }
                }
                item = GetRankSetItem(point.Type, 0, true, msgDisplay);
                if (item != null)
                {
                    if (sortOrdes.Contains(item.RoleSortOrder) && msgDisplay.HasAnyError() == false)
                    {
                        msgDisplay.AddError("new_" + point.Type.ToString(), "排序数字不能重复");
                    }
                    tempRankItems.Add(item);
                }
            }

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

            RateSet rateSet = new RateSet();

            rateSet.NodeID    = ForumID;
            rateSet.RateItems = tempRankItems;

            RateSettings setting = new RateSettings();

            setting.RateSets = new RateSetCollection();

            foreach (RateSet set in AllSettings.Current.RateSettings.RateSets)
            {
                if (set.NodeID != ForumID)
                {
                    setting.RateSets.Add(set);
                }
            }

            setting.RateSets.Add(rateSet);

            try
            {
                if (!SettingManager.SaveSettings(setting))
                {
                    CatchError <ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
                else
                {
                    BbsRouter.JumpToUrl(Request.RawUrl, "success=true");
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
            return(true);
        }
Example #2
0
        protected RateSetItemCollection GetRateSetItems(UserPointType pointType)
        {
            RateSetItemCollection rankItems = CurrentRateSet.GetRateItems(pointType);

            return(rankItems);
        }
Example #3
0
        public bool saveSettings()
        {
            m_Success = false;
            MessageDisplay msgDisplay = null;

            if (_Request.Get("inheritType", Method.Post, "False").ToLower() == "true")
            {
                msgDisplay = CreateMessageDisplay();

                RateSettings tempSetting = new RateSettings();
                tempSetting.RateSets = new RateSetCollection();
                foreach (RateSet set in AllSettings.Current.RateSettings.RateSets)
                {
                    if (set.NodeID != ForumID)
                    {
                        tempSetting.RateSets.Add(set);
                    }
                }

                try
                {
                    if (!SettingManager.SaveSettings(tempSetting))
                    {
                        CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                        BbsRouter.JumpToUrl(Request.RawUrl, "success=true");
                }
                catch (Exception ex)
                {
                    msgDisplay.AddError(ex.Message);
                }
                return true;
            }

            string[] errorNames = new string[EnabledUserPointList.Count * 2];

            int i = 0;
            foreach(UserPoint point in EnabledUserPointList)
            {
                errorNames[i] = point.Type.ToString();
                i++;
                errorNames[i] = "new_" + point.Type.ToString();
                i++;
            }

            msgDisplay = CreateMessageDisplay(errorNames);

            RateSetItemCollection tempRankItems = new RateSetItemCollection();

            foreach (UserPoint point in EnabledUserPointList)
            {
                int[] tempIds = StringUtil.Split<int>(_Request.Get("id_" + point.Type.ToString(), Method.Post, string.Empty));
                List<int> sortOrdes = new List<int>();

                RateSetItem item;

                foreach (int id in tempIds)
                {
                    item = GetRankSetItem(point.Type, id, false, msgDisplay);
                    if (item != null)
                    {
                        if (id != 0 && sortOrdes.Contains(item.RoleSortOrder) && msgDisplay.HasAnyError() == false)
                        {
                            msgDisplay.AddError(point.Type.ToString(), id, "排序数字不能重复");
                        }
                        else
                        {
                            if (id != 0)
                            {
                                sortOrdes.Add(item.RoleSortOrder);
                            }
                            tempRankItems.Add(item);
                        }
                    }
                }
                item = GetRankSetItem(point.Type, 0, true, msgDisplay);
                if (item != null)
                {
                    if (sortOrdes.Contains(item.RoleSortOrder) && msgDisplay.HasAnyError() == false)
                    {
                        msgDisplay.AddError("new_" + point.Type.ToString(), "排序数字不能重复");
                    }
                    tempRankItems.Add(item);
                }
            }

            if (msgDisplay.HasAnyError())
                return false;

            RateSet rateSet = new RateSet();
            rateSet.NodeID = ForumID;
            rateSet.RateItems = tempRankItems;

            RateSettings setting = new RateSettings();

            setting.RateSets = new RateSetCollection();

            foreach (RateSet set in AllSettings.Current.RateSettings.RateSets)
            {
                if (set.NodeID != ForumID)
                    setting.RateSets.Add(set);
            }

            setting.RateSets.Add(rateSet);

            try
            {
                if (!SettingManager.SaveSettings(setting))
                {
                    CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
                else
                    BbsRouter.JumpToUrl(Request.RawUrl, "success=true");
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
            return true;
        }