private void save() { var grants = PrivilegeList.Where(p => p.IsGrant).Select(p => p.ActionType).ToDictionary(p => (int)p, p => true); var denies = PrivilegeList.Where(p => !p.IsGrant).Select(p => p.ActionType).ToDictionary(p => (int)p, p => false); foreach (int k in denies.Keys) { if (!grants.Keys.Contains(k)) { grants.Add(k, denies[k]); } } if (!IsGroup) { userService.UpdateUserAccess((res, exp) => appController.BeginInvokeOnDispatcher(() => { if (exp != null) { appController.HandleException(exp); } else { OnRequestClose(); } }), Party.PartyName, grants); } //appController.Publish(new UpdatePartyCustomActionsArgs(grants,Party.PartyName)); //OnRequestClose(); }
private void setPartyCustomActions(bool isgroup, string groupId) { userService.GetAllUserActionTypes((res, exp) => appController.BeginInvokeOnDispatcher(() => { HideBusyIndicator(); if (exp == null) { res.ForEach(c => { UserActions.Add((int)c, true); }); PrivilegeList.Where(all => UserActions.Where(c => c.Value).Select(c => c.Key).Contains((int)all.ActionType)) .ToList().ForEach(p => p.IsGrant = true); PrivilegeList.Where(all => UserActions.Where(c => !c.Value).Select(c => c.Key).Contains((int)all.ActionType)) .ToList().ForEach(p => p.IsGrant = false); } else { appController.HandleException(exp); } }), Party.PartyName, isgroup, groupId); //PrivilegeList.Where(all => Party.CustomActions.Where(c => c.Value).Select(c => c.Key).Contains(all.ActionType.Id)) // .ToList().ForEach(p => p.IsGrant = true); // PrivilegeList.Where(all => Party.CustomActions.Where(c => !c.Value).Select(c => c.Key).Contains(all.ActionType.Id)) // .ToList().ForEach(p => p.IsDeny = true); }
/// <summary> /// 显示列表 /// </summary> public void ShowPrivilegeTable() { foreach (var model in GetPrivilegeList()) { PrivilegeList.Add(model); } ShowPrivilegeList(); }
public IActionResult GetAllPrivileges() { int[] values = (int[])Enum.GetValues(typeof(PrivilegeList)); var result = new Dictionary <int, string>(); foreach (int val in values) { PrivilegeList privilege = (PrivilegeList)val; result[val] = privilege.ToString(); } return(Ok(result)); }
public static bool hasPrivilege(string username, ElevationLevels minElevation, PrivilegeList priv = PrivilegeList.NONE) { if (staticIdentities == null) { reloadIdentities(); } if (username == String.Empty) { return(false); } FerrousIdentity id = staticIdentities.FirstOrDefault(m => m.username == username); if (id == null) { return(false); } if (id.elevation <= (int)minElevation) { return(true); } if (priv != PrivilegeList.NONE && id.privileges.Contains((int)priv)) { return(true); } return(false); }
public Authorization(ElevationLevels elevationLevel, PrivilegeList privilege) { _elevationLevel = elevationLevel; _privilege = privilege; }