private void ShowWin <T>(RightEnum rightEnum) { if (Constants.Login.CheckRight(rightEnum)) { var VM = IoC.Get <T>(); windowManager.ShowDialog(VM); } else { var msg = new MessageWin("权限不足"); this.View.ShowHint(msg); } }
public RightList_Control() { InitializeComponent(); var list = this.GetControls <CheckBox>(); var rights = Enum.GetValues(typeof(RightEnum)); for (int i = 0; i < list.Count; i++) { var item = list[i]; RightEnum rightEnum = (RightEnum)rights.GetValue(i); item.Tag = rightEnum; item.Content = rightEnum.GetDescription(); item.Click += CheckBox_Click; } }
/// <summary> ///校验权限是否有权限 /// </summary> /// <param name="functionCode"></param> /// <param name="type"> 0 系统,1 模块,2 菜单,3 功能点</param> /// <returns></returns> public static bool ValidFuncPermission(string functionCode, RightEnum type) { UserInfo loginUser = UserManager.GetCurrentUserInfo(); if (loginUser.IsAdmin) { return(true); } else { var parameters = new { UserID = loginUser.UserID, FuncMenuCode = functionCode }; var sql = @"SELECT COUNT(*) FROM ( SELECT ItemID FROM dbo.KH_StationRight st INNER JOIN ( SELECT StationID,EmployeeID FROM dbo.KH_StationUser WHERE SchoolID=@SchoolID UNION SELECT DefaultStationID,EmployeeID FROM dbo.KH_Employee WHERE SchoolID=@SchoolID ) sr ON sr.StationID = st.StationID WHERE sr.EmployeeID=@UserID AND st.ItemType=@ItemType UNION SELECT ItemID FROM dbo.KH_UserRight WHERE UserID=@UserID AND ItemType=@ItemType UNION SELECT ItemID FROM dbo.KH_RoleRight WHERE ItemType =@ItemType AND RoleID IN (SELECT RoleID FROM dbo.KH_RoleUser WHERE UserID=@UserID) )m INNER JOIN ( SELECT NodeID AS ItemID FROM dbo.PDRZ_SystemModule WHERE NodeCode=@FunctionCode UNION SELECT MenuID FROM dbo.PDRZ_Menu WHERE MenuCode=@FunctionCode UNION SELECT FunctionID FROM dbo.PDRZ_MenuFunction WHERE FunctionCode=@FunctionCode ) n ON n.ItemID = m.ItemID"; return(CPQuery.From(sql, new { SchoolID = loginUser.SchoolID, UserID = loginUser.UserID, ItemType = type, FunctionCode = functionCode }).ExecuteScalar <int>() > 0); } }
/// <summary> /// Donne les utilisateurs (dans une liste de UserSetUser) chargé d'un droit par rapport aux CriteriaValues passés en paramétre. /// </summary> /// <param name="criteriaValues">Liste de criteriaValues</param> /// <param name="dataSetId">Id du DataSet</param> /// <param name="right">Droit recherché</param> /// <returns>Liste des utilisateurs.</returns> /// <remarks>La liste de UserSetUser peut contenir 0, 1 ou n utilisateurs (non distinct).</remarks> public async Task <IEnumerable <UserSetUser> > GetUsersByRight(IEnumerable <IEnumerable <CriteriaValues> > criteriaValues, long dataSetId, RightEnum right) { Dictionary <long, DataSetDimension> dimIds = await DataSetDimensionDomain.GetDimensionColumns(dataSetId); Dictionary <long, IEnumerable <CriteriaValues> > dico = CriteriaValuesDomain.GetCriteriaValuesByDimension(criteriaValues); List <Expression <Func <UserSetUser, bool> > > where = new List <Expression <Func <UserSetUser, bool> > >(); foreach (long dimensionId in dico.Keys) { string nomDimension = dimIds.Values.Where(d => d.Dimension.Id == dimensionId).Select(d => d.ColumnName).FirstOrDefault(); IEnumerable <string> values = dico[dimensionId].Select(cv => cv.Value); if (values.Count() > 1) { where.Add(GetFilterByDimension(nomDimension, values)); } else if (values.Count() == 1) { where.Add(GetFilterByDimension(nomDimension, values.ElementAt(0))); } } IQueryable <UserSetUser> dbQuery = UnitOfWork.GetDbContext().Set <UserSetUser>(); IEnumerable <UserSetUser> lstUsu = await where .Aggregate(dbQuery, (current, predicate) => current.Where(predicate)) .Where(usu => (usu.Right & right) == right) .Include(usu => usu.User) .Include(usu => usu.UserSet) .AsNoTracking() .ToAsyncEnumerable() .ToList(); return(lstUsu); }
public bool HasUserRight(RightEnum right) { return HasUserRight(false, right); }
public async Task <RightNavigation?> GetOneRightNavigationByName(RightEnum name) { var right = await _context.Rights.FirstOrDefaultAsync(r => r.Name == name); return(right is null ? null : ToRightNavigation(right)); }