コード例 #1
0
 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;
 }
コード例 #2
0
ファイル: AuthManager.cs プロジェクト: wangchunlei/MyGit
        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;
        }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
 public IEnumerable<HtmlTagModifier> GetLabelModifiers(UIComponentContext context)
 {
     return _labelModifiers.Where(x => x.ShouldModify(context));
 }
コード例 #5
0
 public HtmlTagBuilder GetLabelBuilder(UIComponentContext context)
 {
     return _labelBuilders.FirstOrDefault(x => x.ShouldBuild(context)) ?? _defaultLabelBuilder;
 }
コード例 #6
0
 public HtmlTagBuilder GetDisplayBuilder(UIComponentContext context)
 {
     return _displayBuilders.FirstOrDefault(x => x.ShouldBuild(context)) ?? _defaultDisplayBuilder;
 }
コード例 #7
0
 public bool ShouldBuild(UIComponentContext context)
 {
     return _buildPredicate(context);
 }
コード例 #8
0
 public HtmlTag Build(UIComponentContext context)
 {
     return _buildFunc(context);
 }
コード例 #9
0
 public bool ShouldModify(UIComponentContext context)
 {
     return _modifyPredicate(context);
 }
コード例 #10
0
 public HtmlTag Modify(UIComponentContext context, HtmlTag htmlTag)
 {
     return _modifyFunc(context, htmlTag);
 }