Home computer programming, dynamics ax, others ax2012-how to find list of enterprise user license
computer programmingdynamics axothers

ax2012-how to find list of enterprise user license

ax enterprise license is tough, we should beware about licensing ax, there is huge price difference between ax license,

this source below is jobs to get ax license enterprise list

static void Gabungan5_ronnytes(Args _args)
{
 //created by ronny, 2013-01-04
   //fungsi table lisensi aktif
    SysUserLicenseCount uc;
    container con;
    int i;
        
    SysSecRoleEntryPointsTmp srepTbl;
    SysUserLicenseMetadataTmp slsaTmp;
    SecurityRole securityRole;
    TextIo file;
    Filename filename = @"c:\ronny-lic.txt";
    FileIOPermission permission;
    #File
    ;
    //fungsi meng generate user license
    //SysUserLicenseMiner::generateUserLicenseCountReportInfo();
        
    //fungsi meload lisensi data
    print("siap proses, tekan ok");
    
    try{
        permission = new FileIOPermission(filename,#io_write);
        permission.assert();
        file = new TextIo(filename,#io_write);
        
        if(!file)
                throw Exception::Error;
        
        file.outRecordDelimiter(#delimiterCRLF);
        file.outFieldDelimiter(";");
        con= conNull();
        i = 1;
        con = conIns(con,i,strfmt("Jenis lisensi|Bayar|Pakai\n"));
        while select uc
        {
            i++;
            con = conIns(con,i,strfmt("%1|%2|%3\n",uc.UserLicenseType,uc.LicensedCount,uc.ActualCount));            
        }
        i++;
        con = conIns(con,i,"\n\n");
        //pause;
    
        //info("done");

        
        delete_from srepTbl;
        delete_from slsaTmp;
        SysUserLicenseMiner::BuildLicenseMetadataTable(slsaTmp);
        //pause;
        SysUserLicenseMiner::BuildRoleToUserTypeInfo(slsaTmp, srepTbl);
        //pause;
        while select securityRole where securityRole.AotName like "HPG_*"
        {
            i++;
        
            //select srepTbl where srepTbl.RoleRecId==securityRole.RecId;
            //print(strFmt("%1;%2;\n", securityRole.AotName,srepTbl.UserLicType));
            select maxOf(UserLicType) from srepTbl
                where srepTbl.RoleRecId == securityRole.RecId;
            con = conIns(con,i, strFmt(strFmt("%1;%2;%3\n", securityRole.RecId, securityRole.AotName, srepTbl.UserLicType)));
            i++;
            while select srepTbl
                where srepTbl.RoleRecId==securityRole.RecId
            {
                con = conIns(con,i, strFmt("--%1;%2;%3\n", srepTbl.EntryPointType,  srepTbl.EntryPointName, srepTbl.UserLicType));
                i++;
            }
            
        }        
        
        file.writeExp(con);
        info("done");
    }
    catch(Exception::Error)
    {
        error("masalah");
    }
    
    CodeAccessPermission::revertAssert();
}

static void checkLicenseTypeByRoleEntryPoint(Args _args)
{
    SysSecRoleEntryPointsTmp    srepTbl;
    SysUserLicenseMetadataTmp   slsaTmp;
    SecurityRole                securityRole;
    CommaTextIo                 commaTextIo;
    FileIOPermission            permission;
    MenuFunction                menuFunction;
    str                         menuLabel;
    str                         fileName = @"C:\ronny-licver2.csv";
    FromTime                    startTime = timeNow();
    #File
 
    delete_from srepTbl;
    delete_from slsaTmp;
 
    SysUserLicenseMiner::BuildLicenseMetadataTable(slsaTmp);
    SysUserLicenseMiner::BuildRoleToUserTypeInfo(slsaTmp, srepTbl);
 
    permission = new FileIOPermission(fileName,#io_write);
    permission.assert();
    commaTextIo = new CommaTextIo(fileName,#io_write);
 
    //Header
    commaTextIo.write(
        "Entry type",
        "Entry point AOT name",
        "Entry point label",
        "Role AOT name",
        "Role name",
        "License type");
 
    while select srepTbl
        join securityRole
        where securityRole.RecId == srepTbl.RoleRecId
    {
        menuFunction    = null;
        menuLabel       = '';
        switch (srepTbl.EntryPointType)
        {
            case EntryPointType::MenuItemAction:
                menuFunction = new MenuFunction(srepTbl.EntryPointName, MenuItemType::Action);
                break;
 
            case EntryPointType::MenuItemDisplay:
                menuFunction = new MenuFunction(srepTbl.EntryPointName, MenuItemType::Display);
                break;
 
            case EntryPointType::MenuItemOutput:
                menuFunction = new MenuFunction(srepTbl.EntryPointName, MenuItemType::Output);
                break;
        }
 
        if (menuFunction)
        {
            menuLabel = menuFunction.label();
        }
 
        commaTextIo.write(
            strFmt("%1",srepTbl.EntryPointType),
            srepTbl.EntryPointName,
            menuLabel,
            srepTbl.RoleAotName,
            SysLabel::labelId2String(securityRole.Name),
            strFmt("%1",srepTbl.UserLicType));
    }
    CodeAccessPermission::revertAssert();
 
    info(strFmt("Total time: %1", timeConsumed(startTime, timeNow())));
}

please noted, the source creating a huge csv files, around 130mb in my case,

Author

Ronny

Leave a Reply