Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                #region 权限读取

                List <Int32> nodes = new List <Int32>();
                var          list  = new List <T_AccessControlEntity>();
                if (IsEdit)
                {
                    list = Access.FindAll(a => { return(Admin.IsSuper | ActionTypeHelper.IsCreat(a.ActionType) | ActionTypeHelper.IsEdit(a.ActionType)); });
                }
                else
                {
                    list = Access.FindAll(a => { return(Admin.IsSuper | ActionTypeHelper.IsCreat(a.ActionType)); });
                }
                foreach (var item in list)
                {
                    nodes.Add(item.Node);
                }

                #endregion

                #region 绑定分类数据

                ListItem root = new ListItem("选择分类", "0");
                root.Selected = true;
                GroupId.Items.Add(root);
                List <T_GroupEntity> treenodes = T_GroupHelper.Groups.FindAll(a => { return(a.TableName == "t_news" & (Admin.IsSuper || nodes.Contains(a.ID))); });
                foreach (var item in treenodes)
                {
                    ListItem el = new ListItem(item.GroupName, item.ID.ToString());
                    el.Attributes.Add("pid", item.ParentID.ToString());
                    GroupId.Items.Add(el);
                }

                #endregion

                if (IsEdit)
                {
                    LoadData();
                }
                else
                {
                    //通过IE右键收藏网页数据
                    if (Request["by"] == "ie")
                    {
                        @title.Text   = HttpUtility.UrlDecode(Request["title"]);
                        @content.Text = HttpUtility.UrlDecode(Request["content"]);
                        @Url.Value    = HttpUtility.UrlDecode(Request["url"]);
                    }
                }
            }
        }
 /// <summary>
 /// 新闻权限绑定
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         DataRowView           dv  = e.Item.DataItem as DataRowView;
         Int32                 id  = Convert.ToInt32(dv["id"]);
         T_AccessControlEntity acl = data.Find(a => { return(a.Node == id && a.TableName == "t_group"); });
         if (acl != null)
         {
             ((CheckBox)e.Item.FindControl("CheckBox1")).Checked = ActionTypeHelper.IsCreat(acl.ActionType);
             ((CheckBox)e.Item.FindControl("CheckBox2")).Checked = ActionTypeHelper.IsView(acl.ActionType);
             ((CheckBox)e.Item.FindControl("CheckBox3")).Checked = ActionTypeHelper.IsEdit(acl.ActionType);
             ((CheckBox)e.Item.FindControl("CheckBox4")).Checked = ActionTypeHelper.IsDelete(acl.ActionType);
             ((CheckBox)e.Item.FindControl("CheckBox5")).Checked = ActionTypeHelper.IsSetting(acl.ActionType);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            T_NewsEntity data = (T_NewsEntity)ViewState["data"];

            data = this.GetFormValue <T_NewsEntity>(data);
            CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT;

            data.EditDate = DateTime.Now;
            if (!IsEdit)
            {
                data.PubDate = DateTime.Now;
            }

            T_AccessControlEntity acl = Access.Find(a => { return(a.Node == data.GroupId); });

            if (ActionTypeHelper.IsCreat(acl.ActionType) || (IsEdit && ActionTypeHelper.IsEdit(acl.ActionType)))
            {
                #region 网络图片采集

                HtmlDocument xml = new HtmlDocument();
                xml.LoadHtml(data.Content);

                var html  = xml.DocumentNode;
                var nodes = html.CssSelect("img[src^='http:']");
                foreach (HtmlNode n in nodes)
                {
                    HtmlAttribute src = n.Attributes["src"];
                    src.Value = DownloadImage(src.Value);
                }
                data.Content = xml.DocumentNode.WriteTo();
                content.Text = data.Content;

                #endregion

                if (db.ExecuteCommand <T_NewsEntity>(data, cmd))
                {
                    if (!IsEdit)
                    {
                        this.ClearFromValue();
                    }
                    Alert(Label1, "保存成功!", "line1px_3");
                }
            }
        }