public static List <action> getUserAction(string username, int type, string owner = "")//获取指定用户的特定类型和属主的动作列表,会含有重复项 { List <action> rr = new List <action>(); List <role> rolelist = IocModule.GetEntity <IuserRoleEx>().getRole(username); if (rolelist.Count > 0) { IroleActionEx _roleActionEx = IocModule.GetEntity <IroleActionEx>(); foreach (var e in rolelist) { rr.AddRange(_roleActionEx.getRoleAction(e.id, type, owner)); } rr = rr.Where((x, i) => rr.FindIndex(z => z.id == x.id) == i).ToList();//Lambda表达式去重 } return(rr); }
/// <summary> /// 获取指定用户的特定类型和属主的动作列表,会含有重复项 /// </summary> /// <param name="username">用户名</param> /// <param name="type">动作类型</param> /// <param name="owner">上级</param> /// <returns></returns> public static List <action> getUserAction(string username, int type, role currentrole, string owner = "") { List <action> rr = new List <action>(); IroleActionEx _roleActionEx = IocModule.GetEntity <IroleActionEx>(); if (currentrole != null) { rr.AddRange(_roleActionEx.getRoleAllAction(currentrole.id, owner)); } else { List <role> rolelist = IocModule.GetEntity <IuserRoleEx>().getRole(username); if (rolelist.Count > 0) { foreach (var e in rolelist) { rr.AddRange(_roleActionEx.getRoleAction(e.id, type, owner)); } } } rr = rr.Where((x, i) => rr.FindIndex(z => z.id == x.id) == i).ToList();//Lambda表达式去重 return(rr); }