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); }
protected void EBtnSubmit_Click(object sender, EventArgs e) { bool flag; CollectionFilterRuleInfo collectionFilterRuleInfo = new CollectionFilterRuleInfo(); collectionFilterRuleInfo.FilterName = this.TxtFilterName.Text; bool flag2 = false; if (this.HdnFilter.Value == "Modify") { collectionFilterRuleInfo.FilterRuleId = BasePage.RequestInt32("FilterRuleID"); if (collectionFilterRuleInfo.FilterName == this.HdnFilterName.Value) { flag = false; } else { flag = CollectionFilterRules.Exists(collectionFilterRuleInfo.FilterName); } } else { flag = CollectionFilterRules.Exists(collectionFilterRuleInfo.FilterName); } if (flag) { AdminPage.WriteErrMsg("<li>数据库中已经存在此采集过滤!</li>"); } collectionFilterRuleInfo.BeginCode = this.TxtFilterBegin.Text; if (this.RadFilterType1.Checked) { collectionFilterRuleInfo.FilterType = 1; } else { collectionFilterRuleInfo.FilterType = 2; collectionFilterRuleInfo.EndCode = this.TxtFilterEnd.Text; } collectionFilterRuleInfo.Replace = this.TxtReplace.Text; if (this.HdnFilter.Value == "Modify") { flag2 = CollectionFilterRules.Update(collectionFilterRuleInfo); } else { flag2 = CollectionFilterRules.Add(collectionFilterRuleInfo); } if (flag2) { AdminPage.WriteSuccessMsg("保存采集过滤成功!", "CollectionFilterManage.aspx"); } else { AdminPage.WriteErrMsg("保存采集过滤失败!"); } }
protected void BtnBatchDelete_Click(object sender, EventArgs e) { StringBuilder builder = new StringBuilder(""); if (CollectionFilterRules.Delete(this.EgvFilterRules.SelectList.ToString())) { AdminPage.WriteSuccessMsg("<li>删除指定的采集过滤成功!</li>", "CollectionFilterManage.aspx"); } else { AdminPage.WriteErrMsg("<li>删除失败!</li>"); } }
protected void Page_Load(object sender, EventArgs e) { this.m_ItemId = BasePage.RequestInt32("ItemId"); this.m_FieldName = BasePage.RequestString("FieldName"); this.m_FieldType = BasePage.RequestString("FieldType"); string str = BasePage.RequestString("FieldAlias"); if (this.m_ItemId <= 0) { AdminPage.WriteErrMsg("<li>ItemID不存在!"); } if (string.IsNullOrEmpty(this.m_FieldName)) { AdminPage.WriteErrMsg("<li>字段名称不存在!"); } if (string.IsNullOrEmpty(this.m_FieldType)) { AdminPage.WriteErrMsg("<li>字段类型不能为空!"); } this.LblFieldName.Text = str + "[" + this.m_FieldType + "]"; FieldType none = FieldType.None; if (Enum.IsDefined(typeof(FieldType), this.m_FieldType)) { none = (FieldType)Enum.Parse(typeof(FieldType), this.m_FieldType); } else { AdminPage.WriteErrMsg("<li>不是系统字段类型!"); } CollectionItemInfo infoById = CollectionItem.GetInfoById(this.m_ItemId); if (infoById.IsNull) { AdminPage.WriteErrMsg("<li>当前采集项目不存在!"); } CollectionListRuleInfo info2 = CollectionListRules.GetInfoById(infoById.ItemId); if (info2.IsNull) { AdminPage.WriteErrMsg("<li>隶属于" + infoById.ItemName + "采集项目的列表规则不存在!"); } CollectionCommon common = new CollectionCommon(); Uri url = new Uri(infoById.Url); string httpPage = common.GetHttpPage(url, infoById.CodeType); string code = common.GetInterceptionString(httpPage, info2.ListBeginCode, info2.ListEndCode); try { ArrayList list = common.GetArray(code, info2.LinkBeginCode, info2.LinkEndCode); if ((this.Session["ShowCode"] != null) && !string.IsNullOrEmpty(this.Session["ShowCode"].ToString())) { this.TxtShowCode.Text = this.Session["ShowCode"].ToString(); } else { Uri uri2 = new Uri(common.ConvertToAbsluteUrl(list[0].ToString(), infoById.Url)); this.TxtShowCode.Text = common.GetHttpPage(uri2, infoById.CodeType); this.Session["ShowCode"] = this.TxtShowCode.Text; } this.HdnTestContent.Value = this.TxtShowCode.Text; StringBuilder builder = new StringBuilder(); builder.Append("<select name='ArrContentUrl' onchange=\"testContentLink(this.options[this.selectedIndex].value)\">"); string str4 = ""; for (int i = 0; i < list.Count; i++) { str4 = common.ConvertToAbsluteUrl(list[i].ToString(), url.ToString()); builder.Append(" <option value='" + str4 + "'>" + str4 + "</option>"); } this.m_Url = common.ConvertToAbsluteUrl(list[0].ToString(), url.ToString()); builder.Append("</select> <a href='" + this.m_Url + "' id='contentLink' target='_blank' >查看原始网页</a>"); this.LblArrContentUrl.Text = builder.ToString(); this.m_CodeType = infoById.CodeType; } catch (ArgumentOutOfRangeException exception) { AdminPage.WriteErrMsg("<li>" + exception.Message + "</li>"); } this.ListFilterRuleID.Items.Add(new ListItem("不设置过滤", "0")); this.ListFilterRuleID.AppendDataBoundItems = true; this.ListFilterRuleID.DataSource = CollectionFilterRules.GetList(0, 0); this.ListFilterRuleID.DataBind(); if (!base.IsPostBack) { CollectionFieldRuleInfo info3 = CollectionFieldRules.GetInfoById(infoById.ItemId, this.m_FieldName); if (!info3.IsNull) { this.TxtFieldBegin.Text = info3.BeginCode; this.TxtFieldEnd.Text = info3.EndCode; this.TxtKeyWord.Text = info3.SpecialSetting; this.SavePhoto.Checked = DataConverter.CBoolean(info3.SpecialSetting); foreach (ListItem item in this.ListFilterRuleID.Items) { if (StringHelper.FoundCharInArr(info3.FilterRuleId, item.Value)) { item.Selected = true; } } foreach (ListItem item2 in this.ListFilterSelect.Items) { if (StringHelper.FoundCharInArr(info3.PrivateFilter, item2.Value)) { item2.Selected = true; } } } FieldType type2 = none; if (type2 == FieldType.KeywordType) { this.LblKeyWord.Visible = true; this.TxtKeyWord.Visible = true; this.ValeKeyWord.Visible = true; } else if (type2 == FieldType.ContentType) { this.TabTitle1.Visible = true; this.SavePhoto.Visible = true; this.RadlPaingType.Attributes.Add("onclick", "javascript:ListPaing(0);"); this.RadlPaingType1.Attributes.Add("onclick", "javascript:ListPaing(1);"); this.RadlPaingType2.Attributes.Add("onclick", "javascript:ListPaing(2);"); this.RadlPaingType3.Attributes.Add("onclick", "javascript:ListPaing(3);"); this.RadlPaingType4.Attributes.Add("onclick", "javascript:ListPaing(4);"); if (info3.UsePaging) { CollectionPagingRuleInfo info4 = CollectionPagingRules.GetInfoById(infoById.ItemId, 1); this.TxtPaingBegin.Text = info4.PagingBeginCode; this.TxtPaingEnd.Text = info4.PagingEndCode; switch (info4.PagingType) { case 0: this.RadlPaingType.Checked = true; break; case 1: this.RadlPaingType1.Checked = true; break; case 2: this.RadlPaingType2.Checked = true; break; case 3: this.RadlPaingType3.Checked = true; break; case 4: this.RadlPaingType4.Checked = true; break; default: this.RadlPaingType.Checked = true; break; } this.TxtPaingAddress.Text = info4.DesignatedUrl; this.TxtScopeBegin.Text = info4.ScopeBegin.ToString(); this.TxtScopeEnd.Text = info4.ScopeEnd.ToString(); this.TxtListPaing.Text = info4.PagingUrlList; this.TxtPaingBegin2.Text = info4.PagingBeginCode; this.TxtPaingEnd2.Text = info4.PagingEndCode; this.TxtLinkBegin2.Text = info4.LinkBeginCode; this.TxtLinkEnd2.Text = info4.LinkEndCode; this.Page.ClientScript.RegisterStartupScript(base.GetType(), "Init", "<script type='text/javascript'>ListPaing(" + DataConverter.CLng(info4.PagingType).ToString() + ");</script>"); } } this.ShowExclosionList(info3.ExclosionId, none); } }
protected void Page_Load(object sender, EventArgs e) { if ((!base.IsPostBack && (BasePage.RequestString("Action") == "Delete")) && CollectionFilterRules.Delete(BasePage.RequestInt32("FilterRuleID"))) { AdminPage.WriteSuccessMsg("<li>删除指定的采集过滤成功!</li>", "CollectionFilterManage.aspx"); } }