天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

128 lines
3.4 KiB

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
{
/// <summary>
/// 权限级别
/// </summary>
public enum SystemLimitType
{
/// <summary>
/// admin
/// </summary>
admin,
/// <summary>
/// 特殊
/// </summary>
special,
/// <summary>
/// 受控制
/// </summary>
Control
}
/// <summary>
/// 系统权限
/// </summary>
public class SystemLimit
{
private static List<ControllerActionLimit> Limits = new List<ControllerActionLimit>();
public SystemLimitType LimitType { get; set; }
/// <summary>
/// 特殊条件匹配
/// </summary>
public string SpecialControl { get; set; }
public void AddLimit(ControllerActionLimit pLimit)
{
Limits.Add(pLimit);
}
/// <summary>
/// 受控制
/// </summary>
/// <param name="pLimit"></param>
/// <returns></returns>
public bool IsLimit(ControllerActionLimit pLimit)
{
return Limits.Contains(pLimit);
}
/// <summary>
/// 特殊条件匹配;
/// </summary>
/// <param name="pLimit"></param>
/// <param name="strSpecial"></param>
/// <returns></returns>
public bool IsSpecialLimit(ControllerActionLimit pLimit, string strSpecial)
{
if (SpecialControl == strSpecial && Limits.Contains(pLimit))
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 校验权限
/// </summary>
/// <param name="Controler"></param>
/// <param name="Action"></param>
/// <returns></returns>
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;
}
/// <summary>
/// 显示控制委托
/// </summary>
/// <param name="modelName">实体名</param>
/// <param name="itemName">字段名</param>
/// <returns>是否显示</returns>
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;
}
}
}
}