protected void EBtnSubmit_Click(object sender, EventArgs e) { CollectionFieldRuleInfo collectionFieldRuleInfo = new CollectionFieldRuleInfo(); collectionFieldRuleInfo.ItemId = BasePage.RequestInt32("ItemId"); collectionFieldRuleInfo.FieldName = BasePage.RequestString("FieldName"); collectionFieldRuleInfo.FieldType = BasePage.RequestString("FieldType"); collectionFieldRuleInfo.RuleType = 2; collectionFieldRuleInfo.BeginCode = this.TxtFieldBegin.Text; collectionFieldRuleInfo.EndCode = this.TxtFieldEnd.Text; if (!this.RadlPaingType.Checked) { collectionFieldRuleInfo.UsePaging = true; } FieldType none = FieldType.None; if (Enum.IsDefined(typeof(FieldType), collectionFieldRuleInfo.FieldType)) { none = (FieldType)Enum.Parse(typeof(FieldType), collectionFieldRuleInfo.FieldType); } if (((none != FieldType.BoolType) || (none != FieldType.NumberType)) || ((none != FieldType.MoneyType) || (none != FieldType.DateTimeType))) { StringBuilder builder = new StringBuilder(); foreach (ListItem item in this.ListFilterRuleID.Items) { if (item.Selected) { if (builder.Length > 0) { builder.Append("," + item.Value); } else { builder.Append(item.Value); } } } collectionFieldRuleInfo.FilterRuleId = builder.ToString(); StringBuilder builder2 = new StringBuilder(); foreach (ListItem item2 in this.ListFilterSelect.Items) { if (item2.Selected) { if (builder2.Length > 0) { builder2.Append("," + item2.Value); } else { builder2.Append(item2.Value); } } } collectionFieldRuleInfo.PrivateFilter = builder2.ToString(); switch (none) { case FieldType.FileType: { FieldInfo fieldInfoByFieldName = Field.GetFieldInfoByFieldName(BasePage.RequestInt32("ModelId"), collectionFieldRuleInfo.FieldName); collectionFieldRuleInfo.SpecialSetting = fieldInfoByFieldName.Settings[1].ToString() + "$$$" + fieldInfoByFieldName.Settings[3].ToString() + "$$$" + fieldInfoByFieldName.Settings[4].ToString(); goto Label_02BF; } case FieldType.KeywordType: collectionFieldRuleInfo.SpecialSetting = this.TxtKeyWord.Text; break; case FieldType.ContentType: collectionFieldRuleInfo.SpecialSetting = this.SavePhoto.Checked.ToString(); goto Label_02BF; } } else { collectionFieldRuleInfo.FilterRuleId = ""; collectionFieldRuleInfo.PrivateFilter = ""; } Label_02BF: collectionFieldRuleInfo.ExclosionId = DataConverter.CLng(this.DropExclosionId.SelectedValue); if (CollectionFieldRules.Exists(this.m_ItemId, this.m_FieldName)) { CollectionFieldRules.Update(collectionFieldRuleInfo); } else { CollectionFieldRules.Add(collectionFieldRuleInfo); } if (none == FieldType.ContentType) { this.SavePaing(); } this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "windowsclose", "<script type='text/javascript'>window.close();</script>"); }
protected void EBtnSubmit_Click(object sender, EventArgs e) { if (this.Page.IsValid) { bool flag = false; this.Session["ShowCode"] = null; string fieldName = ""; foreach (RepeaterItem item in this.RptModelList.Items) { RadioButton button = item.FindControl("RadDefault") as RadioButton; RadioButton button2 = item.FindControl("RadDesignated") as RadioButton; RadioButton button3 = item.FindControl("RadSet") as RadioButton; TextBox box = item.FindControl("TxtDesignated") as TextBox; Label label = item.FindControl("LblFieldName") as Label; HiddenField field = item.FindControl("HdnFieldName") as HiddenField; HiddenField field2 = item.FindControl("HdnFieldType") as HiddenField; DropDownList list = item.FindControl("DropStatusType") as DropDownList; bool flag2 = false; if (((field.Value != "NodeId") && (field.Value != "InfoId")) && ((field.Value != "SpecialId") && (field.Value != "DefaultPicUrl"))) { CollectionFieldRuleInfo infoById = CollectionFieldRules.GetInfoById(this.m_itemId, field.Value); if (!infoById.IsNull) { flag2 = true; } else { infoById = new CollectionFieldRuleInfo(); } infoById.FieldName = field.Value; infoById.FieldType = field2.Value; infoById.RuleType = 0; infoById.ItemId = this.m_itemId; if ((!button.Checked && !button2.Checked) && !button3.Checked) { AdminPage.WriteErrMsg(label.Text + "没有选择规则类型!"); } if (button.Checked) { FieldInfo fieldInfoByFieldName = Field.GetFieldInfoByFieldName(this.m_ModelId, infoById.FieldName); if (fieldInfoByFieldName.IsNull) { AdminPage.WriteErrMsg("<li>没有" + infoById.FieldName + "字段,请检查模型!"); } infoById.SpecialSetting = fieldInfoByFieldName.DefaultValue; } if (button2.Checked) { infoById.RuleType = 1; if (field.Value == "Status") { infoById.SpecialSetting = list.SelectedValue; } else { infoById.SpecialSetting = box.Text; } } if (button3.Checked) { infoById.RuleType = 2; if (string.IsNullOrEmpty(infoById.BeginCode) || string.IsNullOrEmpty(infoById.EndCode)) { AdminPage.WriteErrMsg(label.Text + "使用采集规则,但规则为空请返回重新设置该字段采集规则!"); } } if (string.IsNullOrEmpty(fieldName)) { fieldName = infoById.FieldName; } else { fieldName = fieldName + "," + infoById.FieldName; } if (flag2) { flag = CollectionFieldRules.Update(infoById); } else { flag = CollectionFieldRules.Add(infoById); } if (!flag) { AdminPage.WriteErrMsg(label.Text + "保存失败!"); } } } if (!string.IsNullOrEmpty(fieldName)) { IList <CollectionFieldRuleInfo> list2 = CollectionFieldRules.GetList(this.m_ModelId); string str2 = ""; foreach (CollectionFieldRuleInfo info3 in list2) { if (string.IsNullOrEmpty(str2)) { str2 = info3.FieldName; } else { str2 = str2 + "," + info3.FieldName; } } foreach (string str3 in str2.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries)) { if (!StringHelper.FoundCharInArr(fieldName, str3)) { CollectionFieldRules.DeleteFieldName(this.m_itemId, str3); } } } if (flag) { AdminPage.WriteSuccessMsg(this.LblItemName.Text + "采集项目创建完毕!", "ItemManage.aspx"); } } }
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 RptModelList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if ((e.Item.ItemType != ListItemType.Item) && (e.Item.ItemType != ListItemType.AlternatingItem)) { return; } RadioButton button = e.Item.FindControl("RadDefault") as RadioButton; RadioButton button2 = e.Item.FindControl("RadDesignated") as RadioButton; RadioButton button3 = e.Item.FindControl("RadSet") as RadioButton; Label label = e.Item.FindControl("LblFieldName") as Label; Label label2 = e.Item.FindControl("LblSetField") as Label; HiddenField field = e.Item.FindControl("HdnFieldName") as HiddenField; HiddenField field2 = e.Item.FindControl("HdnFieldType") as HiddenField; TextBox box = e.Item.FindControl("TxtDesignated") as TextBox; e.Item.FindControl("ValrNumberValidator"); DropDownList list = e.Item.FindControl("DropStatusType") as DropDownList; FieldInfo dataItem = (FieldInfo)e.Item.DataItem; label.Text = dataItem.FieldAlias; button2.GroupName = dataItem.FieldName; button.GroupName = dataItem.FieldName; button3.GroupName = dataItem.FieldName; field.Value = dataItem.FieldName; switch (dataItem.FieldType) { case FieldType.NodeType: case FieldType.InfoType: case FieldType.SpecialType: e.Item.Visible = false; break; case FieldType.StatusType: list.Visible = true; box.Visible = false; button3.Enabled = false; label2.Enabled = false; break; } if (dataItem.FieldName == "DefaultPicUrl") { e.Item.Visible = false; } string s = dataItem.FieldType.ToString(); string str2 = string.Concat(new object[] { "onclick=\"SetField(", this.m_ModelId, ",", this.m_itemId, ",'", base.Server.UrlEncode(field.Value), "','", base.Server.UrlEncode(s), "','", base.Server.UrlEncode(dataItem.FieldAlias), "')\"" }); string str3 = BasePage.RequestString("Action", "Add"); if (dataItem.FieldType == FieldType.StatusType) { button2.Checked = true; list.DataSource = Status.GetStatusList(); list.DataTextField = "StatusName"; list.DataValueField = "StatusCode"; list.DataBind(); } if (!(str3 == "Modify")) { if (dataItem.FieldName.CompareTo("PaginationType") == 0) { button2.Checked = true; box.Text = "手动分页"; } } else { CollectionFieldRuleInfo infoById = CollectionFieldRules.GetInfoById(this.m_itemId, field.Value); if (!infoById.IsNull) { switch (infoById.RuleType) { case 0: box.Text = infoById.SpecialSetting; goto Label_0394; case 1: button2.Checked = true; if (dataItem.FieldType != FieldType.StatusType) { box.Text = infoById.SpecialSetting; } else { list.SelectedValue = infoById.SpecialSetting; } goto Label_0394; case 2: button3.Checked = true; goto Label_0394; } } } Label_0394: if (dataItem.EnableNull) { button.Checked = false; if (!button3.Checked && !button2.Checked) { button2.Checked = true; box.Text = dataItem.DefaultValue; } } field2.Value = s; if (dataItem.FieldType == FieldType.StatusType) { str2 = " disabled='disabled' "; } label2.Text = "<input type='button' value='设置采集规则' " + str2 + " >"; }