using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI.WebControls; /// ///ManagePage 的摘要说明 /// /// namespace Basic { public class ManagePage : System.Web.UI.Page { protected internal Model.siteconfig siteConfig; public ManagePage() { this.Load += new EventHandler(ManagePage_Load); siteConfig = new BLL.siteconfig().loadConfig(Basic.Tools.Utils.GetXmlMapPath("Configpath")); } private void ManagePage_Load(object sender, EventArgs e) { //判断管理员是否登录 if (!IsAdminLogin()) { Response.Write(""); Response.End(); } } #region 管理员============================================ /// /// 判断管理员是否已经登录(解决Session超时问题) /// public bool IsAdminLogin() { //如果Session为Null if (Session[Keys.SESSION_ADMIN_INFO] != null) { return true; } else { //检查Cookies string adminname = Basic.Tools.Utils.GetCookie("AdminName", "str_key"); //解密用户名 string adminpwd = Basic.Tools.Utils.GetCookie("AdminPwd", "str_key"); if (adminname != "" && adminpwd != "") { DAL.manager dal = new DAL.manager(); Model.manager model = dal.GetModel(adminname, adminpwd); if (model != null) { Session[Keys.SESSION_ADMIN_INFO] = model; return true; } } } return false; } /// /// 取得管理员信息 /// public Model.manager GetAdminInfo() { if (IsAdminLogin()) { Model.manager model = Session[Keys.SESSION_ADMIN_INFO] as Model.manager; if (model != null) { return model; } } return null; } /// /// 检查管理员权限 /// /// 频道ID /// 操作类型 public void ChkAdminLevel(int channel_id, string action_type) { Model.manager model = GetAdminInfo(); BLL.manager_role bll = new BLL.manager_role(); bool result = bll.Exists(model.role_id, channel_id, action_type); if (!result) { string msbox = "parent.f_errorTab(\"错误提示\", \"您没有管理该页面的权限,请勿尝试非法进入!\")"; //ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox.ToString(), true); //修正BUG Response.Write(""); Response.End(); } } /// /// 检查管理员权限 /// /// 栏目名称 /// 操作类型 public void ChkAdminLevel(string channel_name, string action_type) { Model.manager model = GetAdminInfo(); BLL.manager_role bll = new BLL.manager_role(); bool result = bll.Exists(model.role_id, channel_name, action_type); if (!result) { if (Basic.Tools.WebInfo.LoginResult != model.user_pwd) { string msbox = "parent.f_errorTab(\"错误提示\", \"您没有管理该页面的权限,请勿尝试非法进入!\")"; //ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox.ToString(), true); //修正BUG Response.Write(""); Response.End(); } } } /// /// 检查是否有该专营店的操作权限 /// /// ShopId /// ShopId2 public void ChkShopId(int ShopId, int ShopId2) { if (ShopId != ShopId2) { string msbox = "parent.f_errorTab(\"错误提示\", \"您没有管理该页面的权限,请勿尝试非法进入!\")"; //ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox.ToString(), true); //修正BUG Response.Write(""); Response.End(); } } #endregion /// /// 操作成功 /// /// 结果 /// 标题 /// 内容 protected void JsShowMsg(string result, string msgtitle, string msgcss) { string msbox = "parent.f_errorTab(\"" + msgtitle + "\", \"" + msgcss + "\")"; if (result == "success") msbox = "parent.f_successTab(\"" + msgtitle + "\", \"" + msgcss + "\")"; Response.Write(""); Response.End(); } /// /// 添加编辑删除提示 /// /// 提示文字 /// 返回地址 /// CSS样式 protected void JscriptMsg(string msgtitle, string url, string msgcss) { string msbox = "parent.jsprint(\"" + msgtitle + "\", \"" + url + "\", \"" + msgcss + "\")"; ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox, true); } /// /// 带回传函数的添加编辑删除提示 /// /// 提示文字 /// 返回地址 /// CSS样式 /// JS回调函数 protected void JscriptMsg(string msgtitle, string url, string msgcss, string callback) { string msbox = "parent.jsprint(\"" + msgtitle + "\", \"" + url + "\", \"" + msgcss + "\", " + callback + ")"; ClientScript.RegisterClientScriptBlock(Page.GetType(), "JsPrint", msbox, true); } /// /// 检查字段权限 /// /// 字段名称 /// 操作类型 public bool ChkField(string field, string action_type) { Model.manager model = GetAdminInfo(); DAL.manager dal = new DAL.manager(); Model.manager model1 = dal.GetModel(model.user_name); if (model1.role_type == 1) return false; BLL.manager_role bll = new BLL.manager_role(); bool result = bll.Exists(model.role_id, field, action_type); return result; } /// /// 检查字段权限 /// /// 字段名称 /// 操作类型 public bool ChkFieldStatistics(string field, string action_type) { Model.manager model = GetAdminInfo(); DAL.manager dal = new DAL.manager(); Model.manager model1 = dal.GetModel(model.user_name); if (model1.role_type == 1) return true; BLL.manager_role bll = new BLL.manager_role(); bool result = bll.Exists(model.role_id, field, action_type); return result; } /// /// 检查管理员统计分析权限 /// /// 栏目名称 /// 操作类型 public bool ChkStatistics(string channel_name, string action_type) { Model.manager model = GetAdminInfo(); BLL.manager_role bll = new BLL.manager_role(); bool result = bll.Exists(model.role_id, channel_name, action_type); return result; } } }