public XElement Serialize() { return(new XElement(UblNames.Cac + nameof(EconomicOperatorRole), RoleCode.Serialize(nameof(RoleCode)), RoleDescription.Serialize(nameof(RoleDescription)) )); }
public static string GetRoleName(RoleCode roleCode) { var db = PrepareDb(); int roleid = (int)roleCode; SysRole role = db.SysRole.FirstOrDefault(r => r.RoleID == roleid); return(role == null ? "" : role.Code); }
public static bool HasRole(this ClaimsPrincipal claimsPrincipal, RoleCode roleCode) { var permissionsClaims = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == JwtClaimTypes.Role); if (permissionsClaims == null) { return(false); } return(permissionsClaims.Value.Contains(";" + roleCode.GetHashCode() + ";")); }
/// <summary> /// 根据角色获取该角色下所有的用户信息 /// </summary> /// <param name="roleCode"></param> /// <returns></returns> public static List <SimpleEmployee> GetEmployeesByRole(RoleCode roleCode) { var db = PrepareDb(); string rolename = GetRoleName(roleCode); var items = db.Database.SqlQuery <SimpleEmployee>(string.Format(@" select e.Code, e.NameZHCN,e.NameENUS,e.PositionCode,e.PositionZHCN, '{1}' as PositionENUS,e.Mail,e.Phone,e.Mobile from Employee e where e.Code <> '' AND e.Status = 1 AND C_OldId in( select UserID from Position where PositionID in ( SELECT PositionID FROM SysRolePositionMap where RoleID ={0}))", (int)roleCode, rolename)).ToList(); return(items); }
protected bool AuthorizeCore(IEmployee _emp, ActionExecutingContext context) { if (string.IsNullOrWhiteSpace(context.HttpContext.User.Identity.Name)) { return(false); } else { if (RoleCode != null && RoleCode.Length > 0) { return(RoleCode.Contains(_emp.RoleCode)); } if (PositionCode != null && PositionCode.Length > 0) { return(PositionCode.Contains(_emp.PositionCode)); } return(_emp.CheckProgramAuthority(_emp.EmpNo, ProgramID)); } }
private static string GetFileNameByRole(string defaultName) { string fileName = string.Empty; if (RoleName.IsNotEmpty()) { fileName = RoleName; } else if (RoleCode.IsNotEmpty()) { fileName = RoleCode; } if (fileName.IsNullOrEmpty()) { fileName = defaultName; } return(fileName); }
protected static void ExportOpenXmlSpreadsheet() { SOARole role = null; if (AppCode.IsNotEmpty() && RoleCode.IsNotEmpty()) { role = new SOARole(AppCode + ":" + RoleCode); } else { SOARolePropertyDefinitionCollection definitions = SOARolePropertyDefinitionAdapter.Instance.LoadByRoleID(ExportRoleProperty.DefinitionID); role = new SOARole(definitions) { ID = RoleID }; } WorkBook workBook = role.ToExcelWorkBook(); workBook.Save(HttpContext.Current.Response.OutputStream); HttpContext.Current.Response.AppendExcelOpenXmlHeader(GetFileNameByRole(RoleID)); HttpContext.Current.Response.End(); }
/// <summary> /// 根据角色名称获取用户-简单用户对象 /// </summary> /// <param name="storeCode"></param> /// <param name="roleCode">Role Code是常量,直接在RoleCode枚举类中取值,如RoleCode.Asset_Mgr</param> /// <returns></returns> public static List <SimpleEmployee> GetStoreEmployeesByRole(string storeCode, RoleCode roleCode) { //是否是Market Asset Mgr, 如果是,即从当前Store中制定的Asset Mgr中获取 //if (roleCode == RoleCode.Market_Asset_Mgr) // return GetStoreAssetRepMgrByStoreCode(storeCode); RoleCode[] specialCodes = new RoleCode[] { RoleCode.IT, RoleCode.CDO, RoleCode.CFO, RoleCode.MCCL_Asset_Director }; if (specialCodes.Contains(roleCode)) { return(GetEmployeesByRole(roleCode)); } var db = PrepareDb(); string rolename = GetRoleName(roleCode); var items = db.Database.SqlQuery <SimpleEmployee>(string.Format(@" select e.Code, e.NameZHCN,e.NameENUS,e.PositionCode,e.PositionZHCN, '{2}' as PositionENUS,e.Mail,e.Phone,e.Mobile from StoreBasicInfo s join SysUserMMMap m on s.MMCode=m.MMCode join SysRolePositionMap rp on m.PositionID=rp.PositionID join SysRole r on r.RoleID=rp.RoleID join Position p on p.PositionID=rp.PositionID join Employee e on p.UserID=e.C_OldId where s.StoreCode='{0}' and r.RoleId={1} and e.Code <> '' AND e.Status = 1", storeCode, (int)roleCode, rolename)).ToList(); return(items); }
public ChangeMemberRoleValidator() { RuleFor(changeMemberRole => changeMemberRole.mail).NotNull().NotEmpty().WithMessage("修改用户邮箱不能为空").EmailAddress().WithMessage("修改用户邮箱格式不正确"); RuleFor(changeMemberRole => changeMemberRole.roleCode).NotNull().NotEmpty().WithMessage("角色码不能为空") .Must(roleCode => RoleCode.CheckCode(roleCode)).WithMessage("不存在当前角色码"); }
/// <summary> /// 获取指定角色的特定通知用户 /// </summary> public static string GetNotifyDialogUserByRole(string strProjectId, string strFlowCode, RoleCode roleCode) { string eid = string.Empty; switch (roleCode) { case RoleCode.MCCL_Asset_Mgr: var approveUser = FirstOrDefault(e => e.ProjectId.Equals(strProjectId) && e.FlowCode.Equals(strFlowCode)); if (approveUser != null) { eid = approveUser.MCCLAssetMgrCode; } break; default: break; } return(eid); }