public List <Role> GetAllRoles() { List <Role> roles = new List <Role>(); string sql = "select * from [Role]"; DataTable dt = sqlHelper.Query(sql); if (dt != null && dt.Rows.Count > 0) { PermissionLogic pl = PermissionLogic.GetInstance(); for (int i = 0; i < dt.Rows.Count; i++) { Role role = new Role(); role.ID = Convert.ToInt32(dt.Rows[i]["ID"]); role.Name = dt.Rows[i]["Name"].ToString(); role.Flag = Convert.ToBoolean(dt.Rows[i]["Flag"]); role.Permissions = Common.GetPermissions(dt.Rows[i]["Permissions"].ToString(), pl); if (dt.Rows[i]["Remark"] != null && dt.Rows[i]["Remark"] != DBNull.Value) { role.Remark = dt.Rows[i]["Remark"].ToString(); } else { role.Remark = ""; } roles.Add(role); } } return(roles); }
public static PermissionLogic GetInstance() { if (instance == null) { instance = new PermissionLogic(); } return(instance); }
public static List <int> GetPermissionIds(string pers, PermissionLogic pl = null) { List <int> perms = new List <int>(); string[] ids = pers.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (pl == null) { pl = PermissionLogic.GetInstance(); } foreach (string id in ids) { int I; if (int.TryParse(id, out I)) { perms.Add(I); } } return(perms); }
public static PermissionCollection GetPermissions(string pers, PermissionLogic pl = null) { PermissionCollection perms = new PermissionCollection(); string[] ids = pers.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (pl == null) { pl = PermissionLogic.GetInstance(); } foreach (string id in ids) { int I; if (int.TryParse(id, out I)) { Permission perm = pl.GetPermission(I); perms.Add(perm); } } return(perms); }