📄 configstep3.cs
字号:
namespace PowerEasy.WebSite.Admin.Collection
{
using PowerEasy.Collection;
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.Web.UI.WebControls;
public class ConfigStep3 : AdminPage
{
protected Button BtnCancel1;
protected Button BtnSubmit;
protected HiddenField HdnAction;
protected Label LblItemName;
protected int m_itemId;
private int m_ModelId;
protected Repeater RptModelList;
protected ExtendedSiteMapPath SmpNavigator;
protected void BtnCancel1_Click(object sender, EventArgs e)
{
BasePage.ResponseRedirect("ConfigStep2.aspx?Action=Modify&ItemId=" + this.m_itemId);
}
protected void EBtnSubmit_Click(object sender, EventArgs e)
{
if (this.Page.IsValid)
{
bool flag = false;
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;
bool flag2 = false;
if (((field.Value != "NodeId") && (field.Value != "InfoId")) && (field.Value != "SpecialId"))
{
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.Enabled && button.Checked)
{
AdminPage.WriteErrMsg(label.Text + "是必填字段,请选择指定值或设置采集规则!");
}
if (button2.Checked)
{
infoById.RuleType = 1;
infoById.SpecialSetting = box.Text;
}
if (button3.Checked)
{
infoById.RuleType = 2;
if (string.IsNullOrEmpty(infoById.BeginCode) || string.IsNullOrEmpty(infoById.EndCode))
{
AdminPage.WriteErrMsg(label.Text + "使用采集规则,但规则为空请返回重新设置该字段采集规则!");
}
}
if (flag2)
{
flag = CollectionFieldRules.Update(infoById);
}
else
{
flag = CollectionFieldRules.Add(infoById);
}
if (!flag)
{
AdminPage.WriteErrMsg(label.Text + "保存失败!");
}
}
}
if (flag)
{
AdminPage.WriteSuccessMsg(this.LblItemName.Text + "采集项目创建完毕!", "ItemManage.aspx");
}
}
}
protected void Page_Load(object sender, EventArgs e)
{
int id = BasePage.RequestInt32("ItemId");
if (id <= 0)
{
AdminPage.WriteErrMsg("<li>ItemID不存在!");
}
CollectionItemInfo infoById = CollectionItem.GetInfoById(id);
if (infoById.IsNull)
{
AdminPage.WriteErrMsg("<li>当前采集项目不存在!");
}
this.LblItemName.Text = infoById.ItemName;
this.m_itemId = infoById.ItemId;
this.m_ModelId = infoById.ModelId;
string str = BasePage.RequestString("Action", "Add");
if (!base.IsPostBack)
{
this.RptModelList.DataSource = Field.GetFieldList(infoById.ModelId, false);
this.RptModelList.DataBind();
if (str == "Modify")
{
this.BtnCancel1.Visible = true;
}
this.SmpNavigator.CurrentNode = "<a title=\"采集项目设置\" href=\"ConfigStep1.aspx?Action=Modify&ItemID=" + id.ToString() + "\">采集项目设置</a> >> <a title=\"列表页采集设置\" href=\"ConfigStep2.aspx?Action=Modify&ItemID=" + id.ToString() + "\">列表页采集设置</a> >> <span style='color:red;'>内容页采集设置</span>";
}
this.HdnAction.Value = str;
}
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;
NumberValidator validator = e.Item.FindControl("ValrNumberValidator") as NumberValidator;
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:
validator.Visible = true;
button3.Enabled = false;
label2.Enabled = false;
break;
}
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), "')\"" });
if (BasePage.RequestString("Action", "Add") == "Modify")
{
CollectionFieldRuleInfo infoById = CollectionFieldRules.GetInfoById(this.m_itemId, field.Value);
if (!infoById.IsNull)
{
switch (infoById.RuleType)
{
case 1:
button2.Checked = true;
box.Text = infoById.SpecialSetting;
goto Label_030D;
case 2:
button3.Checked = true;
goto Label_030D;
}
}
}
else
{
if (dataItem.FieldType == FieldType.StatusType)
{
button2.Checked = true;
box.Text = "0";
}
if (dataItem.FieldName.CompareTo("PaginationType") == 0)
{
button2.Checked = true;
box.Text = "手动分页";
}
}
Label_030D:
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 + " >";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -