private static HtmlTag Checkbox(UIComponentContext context) { var checkbox = new CheckboxTag(context.Value<bool>()).Attr("value", "true"); var hidden = new HtmlTag("input").Attr("type", "hidden").Attr("value", "false"); checkbox.Next = hidden; return checkbox; }
public static bool HasPermission(string controllerFullName, string action, string user) { var success = false; using (var context = new UIComponentContext()) { //人员 bool successUser = context.Privileges.Any(p => (p.PrivilegeMaster_EnumValue == (int)PrivilegeMasterType.User && p.PrivilegeMasterValue == user && p.PrivilegeAccess_EnumValue == (int)PrivilegeAccessType.Operation && p.OperationFullName == controllerFullName && p.PrivilegeOperation_EnumValue == (int)PrivilegeOperationType.Enable) ); //角色 List<string> listRoles = GetRoleCodeList(user); bool successRole = false; if (listRoles.Count > 0) { successRole = context.Privileges.Any(p => ( p.PrivilegeMaster_EnumValue == (int)PrivilegeMasterType.Role && listRoles.Contains(p.PrivilegeMasterValue) && p.PrivilegeAccess_EnumValue == (int)PrivilegeAccessType.Operation && p.OperationFullName == controllerFullName && p.PrivilegeAccessValue.Contains(action) && p.PrivilegeOperation_EnumValue == (int)PrivilegeOperationType.Enable ) ); } success = successUser | successRole; } return success; }
public override void OnActionExecuted(ActionExecutedContext filterContext) { using (var context = new UIComponentContext()) { var log = new UIActionLogging() { User = filterContext.HttpContext.User.Identity.Name, Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName, Action = filterContext.ActionDescriptor.ActionName, IP = filterContext.HttpContext.Request.UserHostAddress, DateTime = filterContext.HttpContext.Timestamp }; context.UiActionLoggings.Add(log); context.SaveChanges(); } }
public IEnumerable<HtmlTagModifier> GetLabelModifiers(UIComponentContext context) { return _labelModifiers.Where(x => x.ShouldModify(context)); }
public HtmlTagBuilder GetLabelBuilder(UIComponentContext context) { return _labelBuilders.FirstOrDefault(x => x.ShouldBuild(context)) ?? _defaultLabelBuilder; }
public HtmlTagBuilder GetDisplayBuilder(UIComponentContext context) { return _displayBuilders.FirstOrDefault(x => x.ShouldBuild(context)) ?? _defaultDisplayBuilder; }
public bool ShouldBuild(UIComponentContext context) { return _buildPredicate(context); }
public HtmlTag Build(UIComponentContext context) { return _buildFunc(context); }
public bool ShouldModify(UIComponentContext context) { return _modifyPredicate(context); }
public HtmlTag Modify(UIComponentContext context, HtmlTag htmlTag) { return _modifyFunc(context, htmlTag); }