📄 fieldrule.cs
字号:
namespace PowerEasy.WebSite.Admin.Collection
{
using PowerEasy.Collection;
using PowerEasy.Common;
using PowerEasy.CommonModel;
using PowerEasy.Controls;
using PowerEasy.Enumerations;
using PowerEasy.Model.Collection;
using PowerEasy.Model.CommonModel;
using PowerEasy.Web.UI;
using System;
using System.Collections;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class FieldRule : AdminPage
{
protected Button BtnSubmit;
protected HiddenField HdnTestContent;
protected Label LblArrContentUrl;
protected Label LblFieldName;
protected Label LblKeyWord;
protected ListBox ListFilterRuleID;
protected ListBox ListFilterSelect;
protected string m_CodeType = "GB2312";
private string m_FieldName;
protected string m_FieldType;
private int m_ItemId;
protected string m_Url = "";
protected RadioButton RadlPaingType;
protected RadioButton RadlPaingType1;
protected RadioButton RadlPaingType2;
protected RadioButton RadlPaingType3;
protected RadioButton RadlPaingType4;
protected CheckBox SavePhoto;
protected HtmlGenericControl Tabs0;
protected HtmlGenericControl Tabs1;
protected HtmlTableCell TabTitle0;
protected HtmlTableCell TabTitle1;
protected TextBox TxtFieldBegin;
protected TextBox TxtFieldEnd;
protected TextBox TxtKeyWord;
protected TextBox TxtLinkBegin2;
protected TextBox TxtLinkEnd2;
protected TextBox TxtListPaing;
protected TextBox TxtPaingAddress;
protected TextBox TxtPaingBegin;
protected TextBox TxtPaingBegin2;
protected TextBox TxtPaingEnd;
protected TextBox TxtPaingEnd2;
protected TextBox TxtScopeBegin;
protected TextBox TxtScopeEnd;
protected TextBox TxtShowCode;
protected PowerEasy.Controls.RequiredFieldValidator ValeFieldBegin;
protected PowerEasy.Controls.RequiredFieldValidator ValeFieldEnd;
protected NumberValidator ValeKeyWord;
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)))
{
collectionFieldRuleInfo.FilterRuleId = "";
collectionFieldRuleInfo.PrivateFilter = "";
}
else
{
StringBuilder builder = new StringBuilder();
foreach (ListItem item in this.ListFilterRuleID.Items)
{
if (!item.Selected)
{
continue;
}
if (builder.Length > 0)
{
builder.Append("," + item.Value);
continue;
}
builder.Append(item.Value);
}
collectionFieldRuleInfo.FilterRuleId = builder.ToString();
StringBuilder builder2 = new StringBuilder();
foreach (ListItem item2 in this.ListFilterSelect.Items)
{
if (!item2.Selected)
{
continue;
}
if (builder2.Length > 0)
{
builder2.Append("," + item2.Value);
continue;
}
builder2.Append(item2.Value);
}
collectionFieldRuleInfo.PrivateFilter = builder2.ToString();
switch (none)
{
case FieldType.ContentType:
collectionFieldRuleInfo.SpecialSetting = this.SavePhoto.Checked.ToString();
goto Label_0322;
case FieldType.TitleType:
goto Label_0322;
case FieldType.MultiplePhotoType:
{
FieldInfo fieldInfoByFieldName = Field.GetFieldInfoByFieldName(BasePage.RequestInt32("ModelId"), collectionFieldRuleInfo.FieldName);
collectionFieldRuleInfo.SpecialSetting = fieldInfoByFieldName.Settings[2].ToString() + "$$$" + fieldInfoByFieldName.Settings[3].ToString();
goto Label_0322;
}
case FieldType.KeywordType:
collectionFieldRuleInfo.SpecialSetting = this.TxtKeyWord.Text;
goto Label_0322;
case FieldType.FileType:
{
FieldInfo info3 = Field.GetFieldInfoByFieldName(BasePage.RequestInt32("ModelId"), collectionFieldRuleInfo.FieldName);
collectionFieldRuleInfo.SpecialSetting = info3.Settings[1].ToString() + "$$$" + info3.Settings[3].ToString() + "$$$" + info3.Settings[4].ToString();
goto Label_0322;
}
}
}
Label_0322:
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 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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -