public static int AddPrivilegeInRoles(int roleId, string strPermissions) { string[] array = strPermissions.Split(','); RolesPrivilegeDao rolesPrivilegeDao = new RolesPrivilegeDao(); RolesPrivilegeInfo rolesPrivilegeInfo = null; int num = 0; string[] array2 = array; foreach (string s in array2) { rolesPrivilegeInfo = new RolesPrivilegeInfo(); rolesPrivilegeInfo.RoleId = roleId; rolesPrivilegeInfo.Privilege = int.Parse(s); if (rolesPrivilegeDao.Add(rolesPrivilegeInfo, null) > 0) { num++; } } return(num); }
private static IList <int> GetUserPrivileges(int userId) { string key = $"DataCache-ManagerPrivileges-{userId}"; IList <int> list = HiCache.Get <List <int> >(key); if (list == null) { try { ManagerInfo manager = Users.GetManager(userId); if (manager == null) { return(null); } list = new RolesPrivilegeDao().GetRolesPrivilegeByRoleId(manager.RoleId); HiCache.Insert(key, list, 360); } catch { HttpContext.Current.Response.Redirect("/"); } } return(list); }