using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Utils; using SiteCore; public partial class MasterPage_SimPage : System.Web.UI.MasterPage { BasePage _bp = null; protected override void OnInit(EventArgs e) { _bp = this.Page as BasePage; if (!IsPostBack) { if (!_bp.CheckRights()) return; if (!_bp._selfCheckPermission) if (!InitPermission()) return; } string path = CommonHelper.GetPrePath(); StringBuilder str = new StringBuilder(); str.AppendFormat("", path, BasePage.SiteVer); //str.AppendFormat("", path, BasePage.SiteVer); Literal lt = new Literal(); lt.Text = str.ToString(); Page.Header.Controls.AddAt(2, lt); base.OnInit(e); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (_bp._script.Length > 0) litScript.Text = ""; } } #region 初始化权限 private bool InitPermission() { //自己检测权限 if (_bp.PmTag == "") { _bp.ShowError("您当前没有权限查看该页面"); return false; } DataTable dt = WebUser.GetPermission(_bp.PKey); System.Data.DataView dv = new System.Data.DataView(dt); dv.RowFilter = string.Format("tag='{0}' or tag like '{0}_%'", _bp.PmTag); if (dv.Count < 1) { _bp.ShowError("您当前没有权限查看该页面"); return false; } string tag; StringBuilder str = new StringBuilder(); int i = 0; foreach (DataRowView drv in dv) { tag = drv["Tag"].ToString(); if (tag.IndexOf("_") == -1) continue; tag = tag.Replace(_bp.PmTag + "_", ""); _bp._permissions.Add(tag);//加入权限 if (tag == "view") continue; //else if (!_bp._addVisible) btnAdd.Visible = false; str.Append((i > 0 ? "|" : "") + tag + "," + drv["Name"]); i++; } if (str.Length > 0) _bp.AppendScript("actionData=\"" + str.ToString() + "\";"); return true; } #endregion }