using System.Collections; using System.Collections.Generic; using QMAPP.Common; using QMFrameWork.WebUI.Util; using QMAPP.Common.Web.Controllers; using QMAPP.Common.Web.Util; namespace QMAPP.Common.Web { /// /// 权限级别 /// public enum SystemLimitType { /// /// admin /// admin, /// /// 特殊 /// special, /// /// 受控制 /// Control } /// /// 系统权限 /// public class SystemLimit { private static List Limits = new List(); public SystemLimitType LimitType { get; set; } /// /// 特殊条件匹配 /// public string SpecialControl { get; set; } public void AddLimit(ControllerActionLimit pLimit) { Limits.Add(pLimit); } /// /// 受控制 /// /// /// public bool IsLimit(ControllerActionLimit pLimit) { return Limits.Contains(pLimit); } /// /// 特殊条件匹配; /// /// /// /// public bool IsSpecialLimit(ControllerActionLimit pLimit, string strSpecial) { if (SpecialControl == strSpecial && Limits.Contains(pLimit)) { return true; } else { return false; } } /// /// 校验权限 /// /// /// /// public static bool isLimt(string controler, string action) { //验证当前请求是否有登录信息 if (AccountController.IsLogin() == false) { return false; } if (AccountController.GetLoginInfo().LoginUserID.ToLower() == "admin") { return true; } Hashtable actionList = AccountController.GetLimit(); bool flag = actionList.ContainsValue(controler + "/" + action); return flag; } /// /// 显示控制委托 /// /// 实体名 /// 字段名 /// 是否显示 public static bool IsDisplay(string modelName, string itemName) { QMAPP.Common.Web.Models.QueryTemplateModel model = SessionHelper.GetSession("QueryTemplate") as QMAPP.Common.Web.Models.QueryTemplateModel; if (model != null && model.ModelName.Substring(model.ModelName.LastIndexOf(".")+1) == modelName) { bool display=model.Wheres.Exists(p=>p.QUERYCOLUMN==itemName&&p.ISDISPLAY=="1"); return display; } else { SessionHelper.SetSession("QueryTemplate", null); return true; } } } }