⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configstep1.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
字号:
namespace PowerEasy.WebSite.Admin.Collection
{
    using PowerEasy.Collection;
    using PowerEasy.Common;
    using PowerEasy.CommonModel;
    using PowerEasy.Contents;
    using PowerEasy.Controls;
    using PowerEasy.Model.Collection;
    using PowerEasy.Model.CommonModel;
    using PowerEasy.Model.Contents;
    using PowerEasy.Web.UI;
    using System;
    using System.Collections.Generic;
    using System.Web.UI.WebControls;

    public class ConfigStep1 : AdminPage
    {
        protected Button BtnSubmit;
        protected DropDownList DropModelId;
        protected DropDownList DropNodeId;
        protected HiddenField HdnAction;
        protected HiddenField HdnItemName;
        protected HiddenField HiddenModel;
        protected AlternateLiteral LblTitle;
        protected RadioButtonList RadlCodeType;
        protected RadioButtonList RadOrderType;
        protected ExtendedSiteMapPath SmpNavigator;
        protected TextBox TxtIntro;
        protected TextBox TxtItemName;
        protected TextBox TxtMaxNum;
        protected TextBox TxtUrl;
        protected TextBox TxtWebSite;
        protected PowerEasy.Controls.RequiredFieldValidator ValeItemName;
        protected PowerEasy.Controls.RequiredFieldValidator ValeModelId;
        protected PowerEasy.Controls.RequiredFieldValidator ValeNodeId;
        protected PowerEasy.Controls.RequiredFieldValidator ValeUrl;

        protected void DropNode_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.SetModelList(DataConverter.CLng(this.DropNodeId.SelectedValue));
        }

        protected void EBtnSubmit_Click(object sender, EventArgs e)
        {
            if (this.Page.IsValid)
            {
                if (string.IsNullOrEmpty(this.TxtUrl.Text))
                {
                    AdminPage.WriteErrMsg("采集URL地址不能为空!");
                }
                else if (this.TxtUrl.Text.Substring(0, 7) != "http://")
                {
                    AdminPage.WriteErrMsg("采集URL不是有效的URL地址!");
                }
                else
                {
                    bool flag;
                    CollectionItemInfo collectionItemInfo = new CollectionItemInfo();
                    collectionItemInfo.ItemName = this.TxtItemName.Text;
                    collectionItemInfo.NodeId = DataConverter.CLng(this.DropNodeId.SelectedValue);
                    collectionItemInfo.ModelId = DataConverter.CLng(this.DropModelId.SelectedValue);
                    collectionItemInfo.Url = this.TxtUrl.Text;
                    collectionItemInfo.UrlName = this.TxtWebSite.Text;
                    collectionItemInfo.CodeType = this.RadlCodeType.SelectedValue;
                    collectionItemInfo.MaxNum = DataConverter.CLng(this.TxtMaxNum.Text);
                    collectionItemInfo.OrderType = DataConverter.CLng(this.RadOrderType.SelectedValue);
                    collectionItemInfo.Intro = this.TxtIntro.Text;
                    collectionItemInfo.Detection = false;
                    bool flag2 = false;
                    if (this.HdnAction.Value == "Modify")
                    {
                        collectionItemInfo.ItemId = BasePage.RequestInt32("ItemID");
                        if (collectionItemInfo.ItemName == this.HdnItemName.Value)
                        {
                            flag = false;
                        }
                        else
                        {
                            flag = CollectionItem.Exists(collectionItemInfo.ItemName);
                        }
                    }
                    else
                    {
                        flag = CollectionItem.Exists(collectionItemInfo.ItemName);
                    }
                    if (flag)
                    {
                        AdminPage.WriteErrMsg("<li>数据库中已经存在此采集项目!</li>");
                    }
                    if (this.HdnAction.Value == "Modify")
                    {
                        if (collectionItemInfo.ModelId != DataConverter.CLng(this.HiddenModel.Value))
                        {
                            CollectionFieldRules.DeleteItem(collectionItemInfo.ItemId);
                        }
                        flag2 = CollectionItem.Update(collectionItemInfo);
                    }
                    else
                    {
                        flag2 = CollectionItem.Add(collectionItemInfo);
                    }
                    if (flag2)
                    {
                        BasePage.ResponseRedirect("ConfigStep2.aspx?Action=" + this.HdnAction.Value + "&ItemId=" + collectionItemInfo.ItemId.ToString());
                    }
                    else
                    {
                        AdminPage.WriteErrMsg("保存采集配置第一步失败!");
                    }
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            string str = BasePage.RequestString("Action", "Add");
            if (!base.IsPostBack)
            {
                this.DropNodeId.Items.Clear();
                IList<NodeInfo> nodeNameForContainerItems = Nodes.GetNodeNameForContainerItems();
                this.DropNodeId.DataSource = nodeNameForContainerItems;
                this.DropNodeId.DataBind();
                if (str == "Modify")
                {
                    int id = BasePage.RequestInt32("ItemId");
                    if (id <= 0)
                    {
                        AdminPage.WriteErrMsg("<li>ItemID不存在!");
                    }
                    CollectionItemInfo infoById = CollectionItem.GetInfoById(id);
                    if (infoById.IsNull)
                    {
                        AdminPage.WriteErrMsg("<li>采集项目规则不存在!");
                    }
                    if (!infoById.IsNull)
                    {
                        this.TxtItemName.Text = infoById.ItemName;
                        this.DropNodeId.SelectedValue = infoById.NodeId.ToString();
                        this.TxtWebSite.Text = infoById.UrlName;
                        this.TxtUrl.Text = infoById.Url;
                        this.RadlCodeType.SelectedValue = infoById.CodeType;
                        this.TxtMaxNum.Text = infoById.MaxNum.ToString();
                        this.RadOrderType.SelectedValue = infoById.OrderType.ToString();
                        this.TxtIntro.Text = infoById.Intro;
                        this.SetModelList(infoById.NodeId);
                        this.DropModelId.SelectedValue = infoById.ModelId.ToString();
                        this.HdnAction.Value = str;
                        this.HdnItemName.Value = infoById.ItemName;
                        this.HiddenModel.Value = infoById.ModelId.ToString();
                    }
                    else
                    {
                        this.SetModelList(DataConverter.CLng(this.DropNodeId.Items[0].Value));
                    }
                    this.SmpNavigator.CurrentNode = "<span style='color:red;'>采集项目设置</span> >> <a title=\"列表页采集设置\" href=\"ConfigStep2.aspx?Action=Modify&amp;ItemID=" + id.ToString() + "\">列表页采集设置</a> >> <a title=\"内容页采集设置\" href=\"ConfigStep3.aspx?Action=Modify&amp;ItemID=" + id.ToString() + "\">内容页采集设置</a>";
                }
                else
                {
                    this.SetModelList(DataConverter.CLng(this.DropNodeId.Items[0].Value));
                }
            }
        }

        protected void SetModelList(int nodeId)
        {
            this.DropModelId.Items.Clear();
            foreach (NodesModelTemplateRelationShipInfo info2 in ModelManager.GetNodesModelTemplateList(nodeId))
            {
                ModelInfo cacheModelById = ModelManager.GetCacheModelById(info2.ModelId);
                if (!cacheModelById.IsNull)
                {
                    this.DropModelId.Items.Add(new ListItem(cacheModelById.ModelName, cacheModelById.ModelId.ToString()));
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -