Exemplo n.º 1
0
        public static bool savePermissions(RolePermisssions rolePermissions)
        {
            List <PermissionObject> permissions = rolePermissions.PermissionObjList;
            string roleId = rolePermissions.RoleId;
            bool   ret    = false;

            for (int i = 0; i < permissions.Count; i++)
            {
                PermissionObject po  = permissions[i];
                string           sql = SecurityDataScripts.SavePermissionSql(roleId, po.ObjectType, po.ObjectId, po.Permission);
                SecuritySettings.ExecuteNonQuery(sql);
            }
            ret = true;
            return(ret);
        }
Exemplo n.º 2
0
        public Dictionary <string, PermissionObject> getRolePermissionDict(string roleId, string objType)
        {
            DatabaseAdmin dba = SecuritySettings.getDBA();
            DbCommand     cmd = dba.getSqlStringCommand(SecurityDataScripts.GetPermissionObjectsSql);

            dba.addInParameter(cmd, "@roleId", DbType.String, roleId);
            dba.addInParameter(cmd, "@objType", DbType.String, objType);
            DataTable tb = dba.executeTable(cmd);

            Dictionary <string, PermissionObject> ret = new Dictionary <string, PermissionObject>();

            foreach (DataRow r in tb.Rows)
            {
                int p = 0;
                PermissionObject permObj = new PermissionObject();
                permObj.ObjectId   = r["object_id"].ToString();
                permObj.ObjectType = r["object_type"].ToString();
                int.TryParse(r["permission"].ToString(), out p);
                permObj.Permission = (PermissionTypes)p;
                ret.Add(permObj.ObjectId, permObj);
            }
            return(ret);
        }