Beispiel #1
0
        public JsonResult AddPrivileges(Privileges model)
        {
            if (string.IsNullOrWhiteSpace(model.Name))
            {
                return(Json(new Result(false, "权限名称不能为空"), JsonRequestBehavior.AllowGet));
            }

            if (string.IsNullOrWhiteSpace(model.Code))
            {
                return(Json(new Result(false, "权限代码不能为空"), JsonRequestBehavior.AllowGet));
            }

            if (ServiceHelper.GetPrivilegesService.Exists(t => t.Code == model.Code))
            {
                return(Json(new Result(false, "权限代码已经存在,请修改"), JsonRequestBehavior.AllowGet));
            }
            model.CreateTime   = DateTime.Now;
            model.CreateUserID = CurrentInfo.CurrentUser.ID;
            //moduleID有设置关联,不允许为0
            if (model.ModuleID == 0)
            {
                model.ModuleID = null;
            }
            var success = model.Add() != null;

            return(Json(new Result(success, ResultType.Add), JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
 internal static void Init()
 {
     //
     // Allow Init to be called multiple times for TAEF support
     if (TestCategorizer.Initialized == false)
     {
         Debug.Assert(Privileges.Count == 0);
         foreach (MinTpmNecessaryPrivileges priv in NecessaryPrivileges)
         {
             Privileges.Add(priv.CommandCode, priv);
         }
         foreach (CommandThreadSafety safe in ThreadInfo)
         {
             ThreadSafety.Add(safe.CommandCode, safe.ThreadSafe);
         }
         TestCategorizer.Initialized = true;
     }
 }
Beispiel #3
0
 public static void BuildPrivilege(string name, bool active = true)
 {
     Privileges.Add(new Privilege(name, active));
 }