コード例 #1
0
ファイル: setting-chat.aspx.cs プロジェクト: huchao007/bbsmax
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            if (property.Name == "EnableDefaultEmoticon" || property.Name == "EnableUserEmoticon")
            {
                property.SetValue(setting, _Request.Get<bool>(property.Name, MaxLabs.WebEngine.Method.Post, false), null);
                return true;
            }
            else if (property.Name == "SaveMessageDays")
            {
                property.SetValue(setting, _Request.Get<int>("SaveDays", 0), null);
                return true;

            }
            else if (property.Name == "SaveMessageRows")
            {
                property.SetValue(setting, _Request.Get<int>("SaveRows", 0), null);
                return true;
            }
            else if (property.Name == "DataClearMode")
            {
                if (_Request.Get<bool>("IsCombin",false))
                {
                    property.SetValue(setting, JobDataClearMode.CombinMode, null);
                    return true;
                }
            }

            return base.SetSettingItemValue(setting, property);
        }
コード例 #2
0
        /// <summary>
        /// 保存设置,注意使用此方法必须保证Setting的类型和属性名保持一致
        /// </summary>
        /// <param name="settings">设置对象</param>
        public static bool SaveSettings(SettingBase settings)
        {
            FieldInfo property = typeof(AllSettings).GetField(settings.GetType().Name);

            if (property == null)
            {
                Context.ThrowError(new AllSettingsLostPropertyError(settings.GetType()));
                return(false);

                //NOTE:最终用户不应该遇到此异常。
                //当遇到此异常时,说明新增加的设置类型没有对应到AllSettings类的一个同名属性
                //比如ForumSettings类,对应AllSettings类的ForumSettings属性
                //throw new Exception(error.Text);
            }

            SettingDao.Instance.SaveSettings(settings);

            //重新创建一个新的设置实例,以避免由于值变更导致的局部变量不同步等问题
            SettingBase newSettings = (SettingBase)Activator.CreateInstance(settings.GetType());

            //给新的设置实例赋值
            newSettings.Parse(settings.ToString());

            //保存完毕后更新AllSettings对象中对应的设置
            AllSettings.Current.SetSettingFieldValue(property, newSettings);

            return(true);
        }
コード例 #3
0
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            if (property.Name == "IntiveSerialPoint")
            {
                int value = _Request.Get<int>("IntiveSerialPoint", Method.Post,0);
                UserPointType type = _Request.Get<UserPointType>("PointFieldIndex", Method.Post, UserPointType.Point1);
                UserPoint point = AllSettings.Current.PointSettings.GetUserPoint(type);

                if (point.MaxValue < value)
                {
                    ThrowError(new CustomError("IntiveSerialPoint", "超出" + point.Name + "允许的最大值"));
                    return false;
                }

                if (value <= 0)
                {
                    ThrowError(new CustomError("IntiveSerialPoint", "所需的积分值不能小于等于0"));
                    return false;
                }
            }
             if (property.Name == "ShowRegisterInviteInput")
            {
                bool value = _Request.Get<bool>("ShowRegisterInviteInput", Method.Post, true);
                InvitationSettings temp = (InvitationSettings)setting;
                temp.ShowRegisterInviteInput = value;
                return true;
            }

             return base.SetSettingItemValue(setting, property);
        }
コード例 #4
0
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            if (property.Name == "RolesInOnline")
            {
                OnlineSettings temp = (OnlineSettings)setting;
                temp.RolesInOnline = OnlineSettings.RolesInOnline;
                return true;
            }
            else if (property.Name == "DefaultOpen")
            {
                OnlineSettings temp = (OnlineSettings)setting;

                string name = null;
                string checkedValue = _Request.Get("OnlineMemberShow", Method.Post, string.Empty);
                if (checkedValue == "ShowAll")
                {
                    name = "DefaultOpen1";
                }
                else if (checkedValue == "ShowMember")
                {
                    name = "DefaultOpen2";
                }
                if (name != null)
                    temp.DefaultOpen = _Request.Get(name, Method.Post, "").ToLower() == "true";
                return true;
            }
            else
                return base.SetSettingItemValue(setting, property);
        }
コード例 #5
0
ファイル: setting-site.aspx.cs プロジェクト: huchao007/bbsmax
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            if (property.Name == "ViewIPFields")
            {
                SiteSettings temp = (SiteSettings)setting;
                MessageDisplay msgDisplay = CreateMessageDisplay("ViewIPFields", "new_ViewIPFields");
                temp.ViewIPFields = new ExceptableSetting.ExceptableItem_Int().GetExceptable("ViewIPFields", msgDisplay);

                if (msgDisplay.HasAnyError())
                {
                    ThrowError<Errors.CustomError>(new Errors.CustomError("",""));
                    return false;
                }
                return true;
            }
            else if (property.Name == "ScopeList")
            {
                SiteSettings temp = (SiteSettings)setting;
                temp.ScopeList = SiteSettings.ScopeList;
                return true;
            }
               
            else
                return base.SetSettingItemValue(setting, property);
        }
コード例 #6
0
ファイル: SettingDao.cs プロジェクト: huchao007/bbsmax
 public override void SaveSettings(SettingBase settings)
 {
     if (settings.Serializable)
         SaveSerializableSettings(settings);
     else
         SaveUnSerializableSettings(settings);
 }
コード例 #7
0
 protected override bool SetSettingItemValue(SettingBase setting, PropertyInfo property)
 {
     if (property.Name == "FeedSendItems")
     {
         PrivacySettings temp = (PrivacySettings)setting;
         temp.FeedSendItems = GetFeedSendItems();
         return true;
     }
     else
         return base.SetSettingItemValue(setting, property);
 }
コード例 #8
0
 protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
 {
     if (property.Name == "ScopeList")
     {
         RegisterSettings temp = (RegisterSettings)setting;
         temp.ScopeList = RegisterSettings.ScopeList;
         return true;
     }
     else
         return base.SetSettingItemValue(setting, property);
 }
コード例 #9
0
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            if (property.Name == "MinPrice")
            {
                int minPrice = _Request.Get<int>("minprice", Method.Post, 0);
                if (minPrice < 1)
                {
                    ThrowError(new CustomError("minprice", "最低上榜价格不能低于1"));
                    return false;
                }
            }
            else if (property.Name == "MaxPrice")
            {
                int maxrice = _Request.Get<int>("maxprice", Method.Post, 0);
                if (maxrice < 1)
                {
                    ThrowError(new CustomError("maxprice", "最高上榜价格不能低于1"));
                    return false;
                }
            }
            else if (property.Name == "IpClickCountInDay")
            {
                int val = _Request.Get<int>("IpClickCountInDay", Method.Post, 0);
                if (val < 0)
                {
                    ThrowError(new CustomError("IpClickCountInDay", "不能小于0"));
                    return false;
                }
            }
            else if (property.Name == "ClickInterval")
            {
                int interval = _Request.Get<int>("interval", Method.Post, 0);
                int timeunit = _Request.Get<int>("timeunit", Method.Post, 1);
                int trueValue = interval * timeunit;

                if (trueValue < 0)
                {
                    ThrowError(new CustomError("ClickInterval", "有效时间间隔不能小于0"));

                    return false;
                }

                property.SetValue(setting, trueValue, null);

                return true;
            }

            return base.SetSettingItemValue(setting, property);
        }
コード例 #10
0
ファイル: SettingDao.cs プロジェクト: huchao007/bbsmax
        private void SaveSerializableSettings(SettingBase settings)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = @"
IF EXISTS(SELECT * FROM [bx_Settings] WHERE [TypeName] = @TypeName)
	UPDATE [bx_Settings] SET [Value] = @Value WHERE [TypeName] = @TypeName;
ELSE
	INSERT [bx_Settings] ([TypeName], [Value]) VALUES (@TypeName, @Value);";

                query.CreateParameter<string>("@Value", settings.ToString(), SqlDbType.NText);
                query.CreateParameter<string>("@TypeName", settings.GetType().FullName, SqlDbType.NVarChar, 200);

                query.ExecuteNonQuery();
            }
        }
コード例 #11
0
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            if (property.Name == "BannedSpiders")
            {

                ShieldSpiderSettings spiderSettings = (ShieldSpiderSettings)setting;
                string bannedSpiderNamesString = _Request.Get("BannedSpiders", Method.Post);

                string[] bannedSpiders = StringUtil.Split(bannedSpiderNamesString);

                spiderSettings.BannedSpiders.SetBannedSpiders(bannedSpiders);

                return true;
            }
            else
                return base.SetSettingItemValue(setting, property);
        }
コード例 #12
0
ファイル: setting-bbs.aspx.cs プロジェクト: huchao007/bbsmax
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            MessageDisplay msgDisplay = MsgDisplayForSaveSettings;

            if (property.Name == "DisplaySignature")
            {
                BbsSettings temp = (BbsSettings)setting;
                temp.DisplaySignature = new ExceptableSetting.ExceptableItem_bool().GetExceptable("DisplaySignature", msgDisplay);

                if (msgDisplay.HasAnyError())
                {
                    //ThrowError<Errors.CustomError>(new Errors.CustomError("", ""));
                    return false;
                }
                return true;
            }
            else if (property.Name == "MaxAttachmentCountInDay")
            {
                BbsSettings temp = (BbsSettings)setting;
                temp.MaxAttachmentCountInDay = new ExceptableSetting.ExceptableItem_Int().GetExceptable("MaxAttachmentCountInDay", msgDisplay);

                if (msgDisplay.HasAnyError())
                {
                    //ThrowError<Errors.CustomError>(new Errors.CustomError("", ""));
                    return false;
                }
                return true;
            }
            else if (property.Name == "MaxTotalAttachmentsSizeInDay")
            {
                BbsSettings temp = (BbsSettings)setting;
                temp.MaxTotalAttachmentsSizeInDay = new ExceptableSetting.ExceptableItem_FileSize().GetExceptable("MaxTotalAttachmentsSizeInDay", msgDisplay);

                if (msgDisplay.HasAnyError())
                {
                    //ThrowError<Errors.CustomError>(new Errors.CustomError("", ""));
                    return false;
                }
                return true;
            }
            else
                return base.SetSettingItemValue(setting, property);
        }
コード例 #13
0
 protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
 {
     bool result = base.SetSettingItemValue(setting, property);
     if (property.Name == "BannedKeywords")
     {
         ContentKeywordSettings keywordSettings = (ContentKeywordSettings)setting;
         keywordSettings.BannedKeywords.SetValue(SecurityUtil.Base64Decode(keywordSettings.BannedKeywords.GetValue()));
     }
     else if (property.Name == "ReplaceKeywords")
     {
         ContentKeywordSettings keywordSettings = (ContentKeywordSettings)setting;
         keywordSettings.ReplaceKeywords.SetValue(SecurityUtil.Base64Decode(keywordSettings.ReplaceKeywords.GetValue()));
     }
     else if (property.Name == "ApprovedKeywords")
     {
         ContentKeywordSettings keywordSettings = (ContentKeywordSettings)setting;
         keywordSettings.ApprovedKeywords.SetValue(SecurityUtil.Base64Decode(keywordSettings.ApprovedKeywords.GetValue()));
     }
     return result;
 }
コード例 #14
0
    protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
    {
        if (property.Name == "AllNotify")
        {
            NotifySettingItemCollection items = new NotifySettingItemCollection();

            NotifySettingItem newItem;

            foreach ( NotifyType nt in NotifyBO.AllNotifyTypes)
            {
                newItem = new NotifySettingItem();

                newItem.NotifyType = nt.TypeID;                               
                newItem.OpenState = _Request.Get<NotifyState>( string.Format("{0}_OpenState",nt.TypeID), Method.Post, NotifyState.DefaultOpen);
                items.Add( newItem );
            }

            ((NotifySettings)setting).AllNotify = items;
            return true;
        }
        else if (property.Name == "NotifySaveDays")
        {
            property.SetValue(setting, _Request.Get<int>("saveDays", 0), null);
            return true;
        }
        else if (property.Name == "NotifySaveRows")
        {
            property.SetValue(setting, _Request.Get<int>("SaveRows", 0), null);
            return true;
        }
        else if (property.Name == "DataClearMode")
        {
            if (_Request.Get<bool>("IsCombin",false))
            {
                property.SetValue(setting, JobDataClearMode.CombinMode, null);
            }
        }

        return base.SetSettingItemValue(setting, property);
    }
コード例 #15
0
ファイル: SettingDao.cs プロジェクト: huchao007/bbsmax
        private void SaveUnSerializableSettings(SettingBase settings)
        {
			using(SqlQuery query = new SqlQuery(QueryMode.Prepare))
			{
				query.CommandText = @"

				IF EXISTS (SELECT * FROM [bx_Settings] WHERE [TypeName] = @TypeName AND [Key] = @Key)
					UPDATE [bx_Settings] SET [Value] = @Value WHERE [TypeName] = @TypeName AND [Key] = @Key;
				ELSE
					INSERT [bx_Settings] ([TypeName], [Key], [Value]) VALUES (@TypeName, @Key, @Value);";

                foreach (PropertyInfo property in settings.GetType().GetProperties())
                {
                    if (property.IsDefined(typeof(SettingItemAttribute), true))
                    {
                        query.CreateParameter<string>("@TypeName", settings.GetType().FullName, SqlDbType.NVarChar, 200);
                        query.CreateParameter<string>("@Key", property.Name, SqlDbType.NVarChar, 100);
                        query.CreateParameter<string>("@Value", settings.GetPropertyValue(property), SqlDbType.NText);

                        query.ExecuteNonQuery();
                    }
                }
			}
        }
コード例 #16
0
ファイル: AllSettings.cs プロジェクト: zhangbo27/bbsmax
 public void SetSettingFieldValue(FieldInfo field, SettingBase value)
 {
     field.SetValue(this, value);
 }
コード例 #17
0
ファイル: AllSettings.cs プロジェクト: huchao007/bbsmax
 public void SetSettingFieldValue(FieldInfo field, SettingBase value)
 {
     field.SetValue(this, value);
 }
コード例 #18
0
ファイル: SettingDao.cs プロジェクト: zhangbo27/bbsmax
 /// <summary>
 /// 保存设置
 /// </summary>
 /// <param name="settings">设置对象</param>
 public abstract void SaveSettings(SettingBase settings);
コード例 #19
0
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            if (property.Name == "SearchType")
            {
                SearchType searchType = _Request.Get<SearchType>("SearchType", Method.Post, SearchType.LikeStatement);

                if (searchType != AllSettings.Current.SearchSettings.SearchType)
                {
                    if (searchType == SearchType.FullTextIndex)
                    {
                        if (false == PostBOV5.Instance.StartPostFullTextIndex())
                        {
                            MsgDisplayForSaveSettings.AddError("开启全文索引失败,可能由于您没有足够的数据库权限");
                            return false;
                        }
                    }
                    else
                    {
                        if (false == PostBOV5.Instance.StopPostFullTextIndex())
                        {
                            MsgDisplayForSaveSettings.AddError("关闭全文索引失败,可能由于您没有足够的数据库权限");
                            return false;
                        }
                    }
                }
            }
            else if (property.Name == "EnableSearch")
            {
                SearchSettings temp = (SearchSettings)setting;
                temp.EnableSearch = new ExceptableSetting.ExceptableItem_bool().GetExceptable("EnableSearch", MsgDisplayForSaveSettings);

                if (MsgDisplayForSaveSettings.HasAnyError())
                {
                    return false;
                }
                return true;
            }

            else if (property.Name == "CanSearchTopicContent")
            {
                SearchSettings temp = (SearchSettings)setting;
                temp.CanSearchTopicContent = new ExceptableSetting.ExceptableItem_bool().GetExceptable("CanSearchTopicContent", MsgDisplayForSaveSettings);

                if (MsgDisplayForSaveSettings.HasAnyError())
                {
                    return false;
                }
                return true;
            }

            else if (property.Name == "CanSearchAllPost")
            {
                SearchSettings temp = (SearchSettings)setting;
                temp.CanSearchAllPost = new ExceptableSetting.ExceptableItem_bool().GetExceptable("CanSearchAllPost", MsgDisplayForSaveSettings);

                if (MsgDisplayForSaveSettings.HasAnyError())
                {
                    return false;
                }
                return true;
            }

            else if (property.Name == "CanSearchUserTopic")
            {
                SearchSettings temp = (SearchSettings)setting;
                temp.CanSearchUserTopic = new ExceptableSetting.ExceptableItem_bool().GetExceptable("CanSearchUserTopic", MsgDisplayForSaveSettings);

                if (MsgDisplayForSaveSettings.HasAnyError())
                {
                    return false;
                }
                return true;
            }

            else if (property.Name == "CanSearchUserPost")
            {
                SearchSettings temp = (SearchSettings)setting;
                temp.CanSearchUserPost = new ExceptableSetting.ExceptableItem_bool().GetExceptable("CanSearchUserPost", MsgDisplayForSaveSettings);

                if (MsgDisplayForSaveSettings.HasAnyError())
                {
                    return false;
                }
                return true;
            }

            else if (property.Name == "MaxResultCount")
            {
                SearchSettings temp = (SearchSettings)setting;
                temp.MaxResultCount = new ExceptableSetting.ExceptableItem_Int_MoreThenZero().GetExceptable("MaxResultCount", MsgDisplayForSaveSettings);

                if (MsgDisplayForSaveSettings.HasAnyError())
                {
                    return false;
                }
                return true;
            }

            else if (property.Name == "SearchTime")
            {
                SearchSettings temp = (SearchSettings)setting;
                temp.SearchTime = new ExceptableSetting.ExceptableItem_Int_MoreThenZero().GetExceptable("SearchTime", MsgDisplayForSaveSettings);

                if (MsgDisplayForSaveSettings.HasAnyError())
                {
                    return false;
                }
                return true;
            }

            return base.SetSettingItemValue(setting, property);
        }
コード例 #20
0
        protected override bool SetSettingItemValue(SettingBase setting, System.Reflection.PropertyInfo property)
        {
            bool enablePassport =  _Request.Get<bool>("EnablePassport", Method.Post, false);

            if (enablePassport == false)
                return true;

            if (property.Name == "ClientID" && registerClient)
            {
                if (newClientID > 0)
                {
                    property.SetValue(setting, newClientID, null);
                    return true;
                }
                else
                {
                    MsgDisplayForSaveSettings.AddError("注册Passport客户端失败:未知原因!");
                    return false;
                }
            }
            else if (property.Name == "PassportRoot")
            {
                
                string address = _Request.Get("passportroot", Method.Post);
                if (string.IsNullOrEmpty(address))
                {
                    ThrowError<CustomError>(new CustomError("passportroot", "请填写Passport服务器地址。"));
                    return false;
                }
            }
            else if (property.Name == "AccessKey")
            {
                if (registerClient)
                {
                    if (string.IsNullOrEmpty(accessKey) || accessKey.Length < 10)
                    {
                        ThrowError<CustomError>(new CustomError("", "通讯密钥长度不能少于10位"));
                        return false;
                    }
                    else
                    {
                        property.SetValue(setting, accessKey, null);
                        return true;
                    }
                }
            }

            return base.SetSettingItemValue(setting, property);
        }