📄 adminpage.cs
字号:
namespace PowerEasy.Web.UI
{
using PowerEasy.AccessManage;
using PowerEasy.Components;
using PowerEasy.Enumerations;
using PowerEasy.Model.UserManage;
using PowerEasy.UserManage;
using PowerEasy.Web;
using PowerEasy.Web.Configuration;
using System;
using System.Globalization;
using System.IO;
using System.Web;
using System.Web.Caching;
using System.Web.Configuration;
using System.Xml;
public class AdminPage : BasePage
{
private static CheckSecurityCodeElement m_CheckSecurityCodeElement;
private const string StyleSheetThemeSessionName = "AdminPage_StyleSheetTheme";
private const string ThemesDirectoryName = "App_Themes";
public AdminPage()
{
base.Refreshed += new EventHandler(this.AdminPage_Refreshed);
}
private void AdminPage_Refreshed(object sender, EventArgs e)
{
throw new CustomException(PEExceptionType.RefreshedError);
}
public static string AppendSecurityCode(string currenturl)
{
return Utility.AppendSecurityCode(currenturl);
}
private void CheckPagePermission()
{
bool flag = false;
string str = base.Request.AppRelativeCurrentExecutionFilePath.ToLower(CultureInfo.CurrentCulture).Replace("~/admin/", "");
string strA = "";
XmlDocument document = SiteCache.Get("CK_System_XmlDocument_FilePermissionConfig") as XmlDocument;
if (document == null)
{
string str3;
document = new XmlDocument();
HttpContext current = HttpContext.Current;
if (current != null)
{
str3 = current.Server.MapPath("~/Config/Security.config");
}
else
{
str3 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config/Security.config");
}
try
{
document.Load(str3);
}
catch (XmlException exception)
{
WriteErrMsg("Security.config配置文件不符合XML规范,具体错误信息:" + exception.Message);
}
SiteCache.Insert("CK_System_XmlDocument_FilePermissionConfig", document, new CacheDependency(str3));
}
XmlNode xmlNode = document.SelectSingleNode("security/checkPermissions");
if (xmlNode == null)
{
WriteErrMsg("Security.config配置文件不存在checkPermissions根元素");
}
string attributeValue = GetAttributeValue(xmlNode, "mode");
XmlNodeList list = document.SelectNodes("//*[@url='" + str + "']");
if ((string.Compare(attributeValue, "All") == 0) && (list.Count <= 0))
{
WriteErrMsg("<li>对不起,您没有当前页面的访问权限!</li>");
}
if (list.Count > 0)
{
foreach (XmlNode node2 in list)
{
string[] strArray4;
strA = GetAttributeValue(node2, "operateCode");
if (string.Compare(strA, "None") >= 0)
{
flag = true;
break;
}
if (!strA.Contains(","))
{
goto Label_0218;
}
string[] strArray = strA.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
string str7 = GetAttributeValue(node2, "checkType");
if (str7 != null)
{
if (!(str7 == "or"))
{
if (str7 == "and")
{
goto Label_01EB;
}
}
else
{
foreach (string str5 in strArray)
{
if (RolePermissions.AccessCheck(str5))
{
flag = true;
break;
}
}
}
}
goto Label_0222;
Label_01EB:
strArray4 = strArray;
for (int i = 0; i < strArray4.Length; i++)
{
string operateCode = strArray4[i];
if (!RolePermissions.AccessCheck(operateCode))
{
flag = false;
break;
}
}
goto Label_0222;
Label_0218:
if (RolePermissions.AccessCheck(strA))
{
flag = true;
}
Label_0222:
if (flag)
{
break;
}
}
if (!flag)
{
WriteErrMsg("<li>对不起,您没有当前页面的访问权限!</li>");
}
}
}
private static string GetAttributeValue(XmlNode xmlNode, string attributeName)
{
string str = "";
if (xmlNode != null)
{
XmlAttribute attribute = xmlNode.Attributes[attributeName];
if (attribute != null)
{
str = attribute.Value;
}
}
return str;
}
private static void InitCheckSecurityCodeElement()
{
if (m_CheckSecurityCodeElement == null)
{
SecuritySection section = (SecuritySection) WebConfigurationManager.GetSection("powereasy.web/security");
m_CheckSecurityCodeElement = section.CheckSecurityCode;
}
}
protected virtual void InitializeSiteMapPath()
{
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (HttpContext.Current.Session != null)
{
base.ViewStateUserKey = this.Session.SessionID;
if (!this.IsValidSecurityCode)
{
WriteErrMsg("页面安全码校验失败!");
}
}
this.CheckPagePermission();
}
protected override void OnLoadComplete(EventArgs e)
{
base.OnLoadComplete(e);
this.InitializeSiteMapPath();
}
public static void WriteErrMsg(string errorMessage)
{
WriteErrMsg(errorMessage, string.Empty);
}
public static void WriteErrMsg(string errorMessage, string returnurl)
{
Utility.WriteErrMsg(errorMessage, returnurl);
}
public static void WriteSuccessMsg(string successMessage)
{
WriteSuccessMsg(successMessage, string.Empty);
}
public static void WriteSuccessMsg(string successMessage, string returnurl)
{
Utility.WriteSuccessMsg(successMessage, returnurl);
}
private bool IsValidSecurityCode
{
get
{
InitCheckSecurityCodeElement();
bool flag = true;
string filePath = base.AppRelativePageurlWithAction.ToLower(CultureInfo.CurrentCulture);
if ((m_CheckSecurityCodeElement.Page[filePath] != null) && (Utility.GetSecurityCode(filePath) != BasePage.RequestString("sid")))
{
flag = false;
}
return flag;
}
}
public string StyleSheetPath
{
get
{
return (base.BasePath + "App_Themes/" + this.StyleSheetTheme + "/");
}
}
public override string StyleSheetTheme
{
get
{
if (HttpContext.Current.Session == null)
{
return base.StyleSheetTheme;
}
if (this.Session["AdminPage_StyleSheetTheme"] == null)
{
AdminProfileInfo adminProfile = AdminProfile.GetAdminProfile(PEContext.Current.Admin.AdminName);
if (adminProfile.IsNull || string.IsNullOrEmpty(adminProfile.Theme))
{
PagesSection section = (PagesSection) WebConfigurationManager.GetSection("system.web/pages");
if (!string.IsNullOrEmpty(section.StyleSheetTheme) && !section.StyleSheetTheme.StartsWith("User"))
{
return section.StyleSheetTheme;
}
return "AdminDefaultTheme";
}
this.Session.Add("AdminPage_StyleSheetTheme", adminProfile.Theme);
}
return (string) this.Session["AdminPage_StyleSheetTheme"];
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -