protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { string str = BasePage.RequestString("Action", "Add"); if (str == "Modify") { CollectionFilterRuleInfo infoById = new CollectionFilterRuleInfo(); infoById = CollectionFilterRules.GetInfoById(BasePage.RequestInt32("FilterRuleID")); this.TxtFilterName.Text = infoById.FilterName; switch (infoById.FilterType) { case 1: this.PnlFilterEnd.Visible = false; this.RadFilterType1.Checked = true; this.TxtFilterBegin.Text = infoById.BeginCode; this.TxtReplace.Text = infoById.Replace; break; case 2: this.PnlFilterEnd.Visible = true; this.RadFilterType2.Checked = true; this.TxtFilterBegin.Text = infoById.BeginCode; this.TxtFilterEnd.Text = infoById.EndCode; this.TxtReplace.Text = infoById.Replace; break; } this.HdnFilter.Value = str; this.HdnFilterName.Value = infoById.FilterName; } } }
private static string FilterRule(int filterRuleId, CollectionCommon collectionCommon, string testContent) { if (filterRuleId > 0) { CollectionFilterRuleInfo infoById = CollectionFilterRules.GetInfoById(filterRuleId); if (!infoById.IsNull) { switch (infoById.FilterType) { case 1: if (!string.IsNullOrEmpty(infoById.BeginCode)) { testContent = testContent.Replace(infoById.BeginCode, infoById.Replace); } return(testContent); case 2: { string str = collectionCommon.GetInterceptionString(testContent, infoById.BeginCode, infoById.EndCode, true, true); if (!string.IsNullOrEmpty(str)) { testContent = testContent.Replace(str, ""); } return(testContent); } } } } return(testContent); }