Example #1
0
        private void Delete()
        {
            m_Success = false;
            MessageDisplay msgDisplay = CreateMessageDisplay();

            int nodeID = _Request.Get<int>("nodeID", Method.Get, 0);
            if (CurrentRateSet.NodeID != nodeID)
            {
                msgDisplay.AddError("当前版块评分设置继承至上级版块,不能进行删除操作,如要修改请修改上级版块评分设置或者把评分设置设为自定义");
                return;
            }

            if (PointType == null)
            {
                msgDisplay.AddError(new InvalidParamError("pointtype"));
                return;
            }

            int sortOrder = _Request.Get<int>("sortorder", Method.Get, 0);


            RateSettings setting = new RateSettings();

            setting.RateSets = new RateSetCollection();

            foreach (RateSet set in AllSettings.Current.RateSettings.RateSets)
            {
                if (set.NodeID != nodeID)
                    setting.RateSets.Add(set);
                else
                {
                    RateSet tempSet = new RateSet();
                    tempSet.NodeID = nodeID;
                    tempSet.RateItems = new RateSetItemCollection();

                    for (int i = 0; i < set.RateItems.Count; i++)
                    {
                        RateSetItem item = set.RateItems[i];
                        if (item.PointType == PointType.Value && sortOrder == item.RoleSortOrder && item.RoleID != Guid.Empty)
                        {
                        }
                        else
                            tempSet.RateItems.Add(item);
                    }

                    setting.RateSets.Add(tempSet);
                }
            }
            
            try
            {
                if (!SettingManager.SaveSettings(setting))
                {
                    CatchError<ErrorInfo>(delegate(ErrorInfo error)
                    {
                        msgDisplay.AddError(error);
                    });
                }
                else
                {
                    string urlRef = Request.UrlReferrer.ToString();
                    string query;
                    int index = urlRef.IndexOf('?');
                    if (index > 0)
                        query = urlRef.Substring(index + 1);
                    else
                        query = string.Empty;

                    string url = Request.RawUrl;
                    if (url.IndexOf('?') > -1)
                        url = url.Substring(0, url.IndexOf('?'));

                    url = url + "?" + query;

                    BbsRouter.JumpToUrl(url, "success=true");
                }
                    //Response.Redirect(Request.UrlReferrer.ToString());
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }

        }
Example #2
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;
        }