[AX2012 R3]关于Named user license report

Named user license报表是用来统计各类受权类型用户数的,这里来看看报表数据具体是如何来的。这是一个SSRS的报表,最主要的数据源是来自于类SysUserLicenseCountReport定义的RDP,在SysUserLicenseCountReport的方法processReport中使用SysUserLicenseMiner::fillUserLicenseCountTmpTbl()填充一个临时表,最核心的部分就是这个方法:数据库

public static void fillUserLicenseCountTmpTbl(SysUserLicenseCountTmp _userLicCountTblTmp, date _reportStateDate)
{
    SysUserLicenseCount sulcTbl;
    SysUserLicenseList sullTbl;
    SecurityUserRole surTbl;
    SecurityRole rTbl;
    SysRoleLicenseType userRoleLicense;
    delete_from _userLicCountTblTmp;

    ttsbegin;

    while select validTimeState(_reportStateDate, _reportStateDate) * from sulcTbl
        outer join sullTbl
        outer join User, SecurityRole from surTbl
        join SecurityRole, UserLicenseType from userRoleLicense
        join RecId, Name from rTbl
        order by sulcTbl.UserLicenseType desc
        where (sulcTbl.RecId == sullTbl.SysUserLicenseCount
                && sullTbl.UserName == surTbl.User && userRoleLicense.SecurityRole ==surTbl.SecurityRole
                && rTbl.RecId == surTbl.SecurityRole)
    {
        _userLicCountTblTmp.UserLicenseType = sulcTbl.UserLicenseType;
        _userLicCountTblTmp.LicensedCount = sulcTbl.LicensedCount;
        _userLicCountTblTmp.ActualCount = sulcTbl.ActualCount;
        _userLicCountTblTmp.ValidFor = sulcTbl.ValidFrom;
        _userLicCountTblTmp.NetworkDomain =sullTbl.NetworkDomain;
        _userLicCountTblTmp.NetworkAlias =sullTbl.NetworkAlias;
        _userLicCountTblTmp.Username =sullTbl.UserName;
        _userLicCountTblTmp.SecurityRole = rTbl.Name;
        _userLicCountTblTmp.SecurityRoleLicenseType = userRoleLicense.UserLicenseType;
        _userLicCountTblTmp.insert();
    }

    ttscommit;
}

这里用到好几个表,SysUserLicenseCount保存的是四种用户受权类型(枚举UserLicenseType:Enterprise,Functional,Task,Self serve)相应的用户数;SysUserLicenseList保存的是每一个用户的受权记录,其SysUserLicenseCount记录的是表SysUserLicenseCount的recId;SecurityUserRole表不在AOT中,查看数据库得知保存的是每一个用户对应的Role,若是一个用户被指定了多个Role,每一个Role在这表中对应一条记录,列SecurityRole保存的是具体Role的ID;SecurityRole既不在AOT,连SQL数据库中也没有这个表,好在上面的代码中能够推测是AOT中全部Security roles的列表,这里用到的只是Role的名称;SysRoleLicenseType也不在AOT,可是在SQL数据库中,重要的是SecurityRole和UserlicenseType两个字段,前者记录的是每种Role的ID,后者则是这个Role相应的用户受权类型,每一个Role只有一种用户受权类型。网络

所以上面的代码完成的就是构建一个临时表来记录每一个用户的名称、网络别名、对应的每一个角色、角色对应的用户受权类型、用户受权类型的受权用户数、用户受权类型的当前使用数。须要注意的是角色“System administrator”和“System user”在表SysRoleLicenseType是没有记录的,若是一个用户只有这两种角色,这个用户不会出如今报表中,可是System administrator仍然会占用一个Enterprise受权,仅仅是System user是不会影响到受权数的。spa

运行报表老是获得空白的结果,仔细查看发现上面的代码中有一行是有问题的(R3 CU8的系统),“&& sullTbl.UserName == surTbl.User”,查看数据库表SecurityUserRole,User一列实际上保存的是用户的网络别名,更改成“&& sullTbl.NetworkAlias == surTbl.User”后运行报表获得结果,相似:code

还须要注意必须切换到DAT公司下才会有数据,用到的表SysUserLicenseCount等等是不保存公司信息的,按照个人理解应该无论在哪一个公司下都应该获得相同的结果,可实际上只有切换到DAT公司报表才有数据。 blog

接下来的问题相关表中的数据又是哪里来的呢?在部署系统的时候系统会自动为咱们建立一个名为“Named user license count reports processing”的批处理任务,由它更新数据到这些表中,默认一周运行一次。这个批处理任务具体执行的是SysUserLicenseMiner类,run方法调用SysUserLicenseMiner::GenerateUserLicenseCountReportInfo(),咱们直接调用这个方法也是能够更新受权数数据的。若是你在批处理列表中找不到这个job,能够调用SysUserLicenseMiner::createBatchJob()为你建立一个。而具体是如何更新的呢?答案天然也是在 SysUserLicenseMiner中,这里就不翻代码了,就别的地方看到的总结一下。AOT中打开一个Menu item,有两个属性是和受权相关的,ViewUserLicense和MaintainUserLicense,前者是查看须要的受权,后者是维护数据须要的受权,它们的值都是前面提到的枚举UserLicenseType。SysUserLicenseMiner的工做就是遍历全部Menu item,找出相应的用户受权,接着遍历用户用户角色,找出每一个用户角色对应的用户受权类型,最后遍历每一个用户,找出用户的最高用户受权类型(Enterprise最高)。因此问题的核心在于菜单项的用户受权类型,若是咱们新建一个本身的菜单项会怎样?默认ViewUserLicense和MaintainUserLicense都是NONE,是不影响受权数的,固然你能够闲着没事修改这两个属性成其余数值。咱们能够duplicate系统自带的菜单项,而后修改这两个属性为NONE,后面就不细说了。部署

最后要说的是这个报表的格式,不管我是否选中“show list of users per access license type ”结果都是同样,Report的design也只有上面图中的一个,有知道缘由的朋友请告诉我为何...it

相关文章
相关标签/搜索