Search This Blog

Monday, July 17, 2017

Read xml file with namespace

static void krishh_samplexmlread(Args _args)
{
     XmlNode root;
     XmlNode book;
     XmlNodeList books;
     XmlNamespaceManager nsmgr;

     XmlDocument doc = new XmlDocument();
      int i=1;
      doc.Load(@"C:\Temp\book.xml");

      //Create an XmlNamespaceManager for resolving namespaces.
      nsmgr = new XmlNamespaceManager(doc.NameTable());
      nsmgr.AddNamespace("bk", "urn:samples");

      //Select the book node with the matching attribute value.


      root = doc.DocumentElement();

      books = root.selectNodes("descendant::book", nsmgr);
      for (i = 0; i < books.length(); i++)
      {
           book = books.item(i);
              info(book.selectSingleNode("bk:first-name").text());
              info(book.selectSingleNode("bk:last-name").text());


      }

}

//<?xml version="1.0"?>
//
//<!-- A fragment of a book store inventory database -->
//
//-<bookstore xmlns:bk="urn:samples">
//
//
//-<book bk:ISBN="1-861001-57-8" publicationdate="1997" genre="novel">
//
//<title>Pride And Prejudice</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>24.95</price>
//
//</book>
//
//
//-<book bk:ISBN="1-861002-30-1" publicationdate="1992" genre="novel">
//
//<title>The Handmaid's Tale</title>
//
//
//-<author>
//
//<first-name>Margaret</first-name>
//
//<last-name>Atwood</last-name>
//
//</author>
//
//<price>29.95</price>
//
//</book>
//
//
//-<book bk:ISBN="1-861001-57-6" publicationdate="1991" genre="novel">
//
//<title>Emma</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>19.95</price>
//
//</book>


//-<book bk:ISBN="1-861001-45-3" publicationdate="1982" genre="novel">
//
//<title>Sense and Sensibility</title>
//
//
//-<author>
//
//<first-name>Jane</first-name>
//
//<last-name>Austen</last-name>
//
//</author>
//
//<price>19.95</price>
//
//</book>
//
//</bookstore>

Thursday, April 20, 2017

AX2012 Run AIF Single Message manually

Execute single message for inbound without executing all inbound ports.

class Krishh_InboundParallelMsgProcessPerMsgId extends AifInboundParallelMsgProcess
{
    RecId                   gatewayQueueRecId;
    DialogField             dlgfRecId;
    AifMessageId            messageId;
}

protected Object dialog()
{
    DialogRunbase       dialogRunbase;

    dialogRunbase   = super();
    dialogRunbase.caption(AifInboundParallelMsgProcess::description());

    dialogRunbase.addText("Runbase framework doesnt allow Guid type fields");
    dialogRunbase.addText("reference field shows the gatewayqueue record");

    dlgfRecId   = dialogRunbase.addField(extendedTypeStr(AifGatewayQueueRecId));
    dlgfRecId.lookupButton(2);

    return dialogRunbase;
}

public AifGatewayQueue findGatewayQueue(RecId  _recId)
{
    AifGatewayQueue     aifGatewayQueue;

    select aifGatewayQueue
        where aifGatewayQueue.RecId == _recId;

    return aifGatewayQueue;
}

public boolean getFromDialog()
{
    boolean ret;

    ret = super();

    gateWayQueueRecId = dlgfRecId.value();

    return ret;
}

public AifMessageId parmMessageId(AifMessageId _messageId = messageId)
{
    messageId = _messageId;

    return messageId;
}

public void run()
{
    if (gatewayQueueRecId != 0 && messageId == emptyGuid())
    {
        messageId = this.findGatewayQueue(gateWayQueueRecId).MessageId;
    }

    try
    {
        ttsBegin;

        if (messageId != emptyGuid())
        {
            this.runSingleMsgId(messageId);
            AifQueueManager::createQueueManagerData();
        }
        else
        {
            throw error ("invalid message id please enter valid messageid");
        }

        ttsCommit;
    }
    catch
    {
        throw error("process has been aborted");
    }
}

private void runSingleMsgId(AifMessageId    _messageId)
{
    AifGatewayQueue         gatewayQueue;
    AifInboundMsgProcess    inboundMsgProcess;
    AifResourceLockId       resourceLockId;
    ;

    setprefix(classstr(InboundParallelMsgProcessPerMsgId) + '-' + methodstr(Krishh_InboundParallelMsgProcessPerMsgId , run));

    select firstOnly gatewayQueue
        where gatewayQueue.MessageId == _messageId;

    if (gatewayQueue)
    {
        resourceLockId = AifResourceLock::lockResource(guid2str(gatewayQueue.MessageId),
                                                       AifResourceType::Message,
                                                       AifResourceLockType::DocumentService);

        // Process message only if lock is created.
        if(resourceLockId)
        {
            AifResourceIdMap::createMsgResourceMap(guid2str(gatewayQueue.MessageId), gatewayQueue.MessageId);

            // remember selected record
            inboundMsgProcess = new AifInboundMsgProcess(gatewayQueue.data(), resourceLockId);

         

            inboundMsgProcess.run();
        }
    }
}

public boolean validate(Object calledFrom = null)
{
    boolean             ret;

    ret = super(calledFrom);

    if (this.findGatewayQueue(gateWayQueueRecId).RecId == 0)
    {
        throw error("Queue not found");
    }

    return ret;
}

public static Krishh_InboundParallelMsgProcessPerMsgId construct()
{
    return new Krishh_InboundParallelMsgProcessPerMsgId ();
}

public static void main(Args args)
{
    Krishh_InboundParallelMsgProcessPerMsgId inboundParallelMsgProcessPerMsgId;

    inboundParallelMsgProcessPerMsgId = Krishh_InboundParallelMsgProcessPerMsgId ::construct();

    if (inboundParallelMsgProcessPerMsgId.prompt())
    {
        inboundParallelMsgProcessPerMsgId.run();
    }
}

AX2012 Actiavte/Deactivate Ports using X++

create enum 1. AIFPortActivorDeactive  with Acivate,Decativate as enumvalues.
                    2. AIF portType with inbound and Outbound as enumvalues.

class krishhAIFPortsUtil extends RunBaseBatch
{
    Map serviceStatusMap;
    Map portWsdlUrlMap;
    AIFPortActivorDeactive portActiveorDeactive;
    AIFPortType aifPortType;


    DialogField     dlgActiveorDeactive;
    DialogField     dlgaifPortType;

    #define.CurrentVersion(1)
    #define.Version1(1)
    #localmacro.CurrentList
        portActiveorDeactive,
        aifPortType
    #endmacro
}

private void deployInboundPort(AifInboundPort port)
{
        startLengthyOperation();
        AifPortManager::deployPort(port.Name);
        this.updateServiceHostStatus();
        endLengthyOperation();
}

private void deployOutboundPort(AifOutboundPort port)
{
    startLengthyOperation();
    AifPortManager::deployPort(port.Name);
    endLengthyOperation();
}


public Object dialog()
{
    DialogRunbase       dialog = super();
    #resAppl
;

    dlgActiveorDeactive=dialog.addField(enumStr(AIFPortActivorDeactive), "Activate/Deactivate");
    dlgaifPortType=dialog.addField(enumStr(AIFPortType), "PortType");
    return dialog;
}

public boolean getFromDialog()
{
;
    portActiveorDeactive=dlgActiveorDeactive.value();
    aifPortType=dlgaifPortType.value();
    return super();
}

str getPortRuntimeError(AifInboundPort port)
{
    str serviceTypeName, status;
    boolean isPortStarted = false;
#Aif

    if (port.Deployed)
    {
        serviceTypeName = strFmt('%1.%2', #DotNetServiceNamespace, port.Name);

        if (!serviceStatusMap)
        {
            // If the map is null, then the IL appDomain does not exist and services are not available
            status = strFmt("@SYS345108");
        }
        else if (serviceStatusMap.exists(serviceTypeName))
        {
            status = serviceStatusMap.lookup(serviceTypeName);
            isPortStarted = strStartsWith(status, #WcfCommunicationState_Opened);
        }
    }

    return isPortStarted?"":status;
}

// BP deviation documented
str getPortWsdlUrl(AifInboundPort port)
{
    str wsdlUrl = '';
    AifPortName portName;
    AifWcfAdapter wcfAdapter;

    if (port.Deployed)
    {
        portName = port.Name;

        if (portWsdlUrlMap.exists(portName))
        {
            wsdlUrl = portWsdlUrlMap.lookup(portName);
        }
        else
        {
            wcfAdapter = AifWcfAdapter::getWcfAdapterForPort(port);

            if (wcfAdapter != null)
            {
                wsdlUrl = wcfAdapter.getWsdlUrl(port.ChannelId, port.Name);
            }

            portWsdlUrlMap.insert(portName, wsdlUrl);
        }
    }

    return wsdlUrl;
}

// BP deviation documented
boolean isPortRunning(AifInboundPort port)
{
    str serviceTypeName, status;
    boolean isPortStarted = false;
#Aif

    if (port.Deployed)
    {
        serviceTypeName = strFmt('%1.%2', #DotNetServiceNamespace, port.Name);

        // If the map is null, then the IL appDomain does not exist and services are not available
        if (serviceStatusMap && serviceStatusMap.exists(serviceTypeName))
        {
            status = serviceStatusMap.lookup(serviceTypeName);
            isPortStarted = strStartsWith(status, #WcfCommunicationState_Opened);
        }
    }

    return isPortStarted;
}

public container pack()
{
    return [#CurrentVersion,#CurrentList];
}

public boolean unpack(container packedClass)
{
    Version version = RunBase::getVersion(packedClass);
;
    switch (version)
    {
        case #CurrentVersion:
            [version,#CurrentList] = packedClass;
            break;
        default:
            return false;
    }

    return true;
}

public AIFPortType parmAifPortType(AIFPortType _aifPortType = aifPortType)
{
    aifPortType = _aifPortType;

    return aifPortType;
}

public AIFPortActivorDeactive parmPortActiveorDeactive(AIFPortActivorDeactive _portActiveorDeactive = portActiveorDeactive)
{
    portActiveorDeactive = _portActiveorDeactive;

    return portActiveorDeactive;
}

public void portinit()
{
    AifSetup::initialize();
    // Register out of the box adapters
    AifSetup::registerOutOfTheBoxAdapters();

    portWsdlUrlMap = new Map(Types::String, Types::String);
}

/// <summary>
///    Contains the code that does the actual job of the class.
/// </summary>
public void run()
{
    #OCCRetryCount
    AifInboundPort AifInboundPort;

    AifOutboundPort AifOutboundPort;

    try
    {
        this.updateServiceHostStatus();
        switch (aifPortType)
        {
            case AIFPortType::Inbound:
                if(AIFPortActivorDeactive::Activate==portActiveorDeactive)
                {
                    while select AifInboundPort //where AifInboundPort.PortCategory==AifPortCategory::Enhanced
                    {

                          if(this.isPortRunning(AifInboundPort))
                          {
                              this.portinit();
                              this.deployInboundPort(AifInboundPort);
                              if(this.getPortRuntimeError(AifInboundPort)!="")
                              {
                                  info(strFmt("@krishh1896",AifInboundPort.Name,this.getPortRuntimeError(AifInboundPort)));
                              }
                          }
                    }
                }
                else
                {
                    while select AifInboundPort where AifInboundPort.PortCategory==AifPortCategory::Enhanced
                    {
                          this.portinit();
                          this.undeployInboundPort(AifInboundPort);
                    }
                }
             break;
            case AIFPortType::OutBound:
                if(IFPortActivorDeactive::Activate==portActiveorDeactive)
                {
                    while select AifOutboundPort
                    {
                              this.portinit();
                              this.deployOutboundPort(AifOutboundPort);

                    }
                }
                else
                {
                    while select AifOutboundPort
                    {
                          this.portinit();
                          this.unDeployOutboundPort(AifOutboundPort);
                    }
                }
            break;
            default:
            throw error(strfmt("@SYS12580",aifPortType));



        }
    }
    catch (Exception::Deadlock)
    {
        retry;
    }
    catch (Exception::UpdateConflict)
    {
        if (appl.ttsLevel() == 0)
        {
            if (xSession::currentRetryCount() >= #RetryNum)
            {
                throw Exception::UpdateConflictNotRecovered;
            }
            else
            {
                retry;
            }
        }
        else
        {
            throw Exception::UpdateConflict;
        }
    }

}

private void undeployInboundPort(AifInboundPort port)
{
        startLengthyOperation();
        AifPortManager::undeployPort(port.Name);
        this.updateServiceHostStatus();
        //this.clearPortWsdlUrl(port);
        endLengthyOperation();
}

private void unDeployOutboundPort(AifOutboundPort port)
{
    startLengthyOperation();
    AifPortManager::undeployPort(port.Name);
    endLengthyOperation();
}
public void updateServiceHostStatus()
{
    // If the map is null, then the IL appDomain does not exist and services are not available
    serviceStatusMap = appl.getServiceHostStatus();
}

static krishhAIFPortsUtil construct()
{
    return new krishhAIFPortsUtil();
}
public static void main(Args _args)
{
    krishhAIFPortsUtil  krishhAIFPortsUtil ;
;
    krishhAIFPortsUtil = krishhAIFPortsUtil  ::construct();

    if (krishhAIFPortsUtil .prompt())
        krishhAIFPortsUtil .run();
}

public static void mainAutoRun(str _args)
{
    krishhAIFPortsUtil aifPortsUtil;
    ;
    aifPortsUtil = krishhAIFPortsUtil ::construct();

    if (!_args)
        return;

    switch(_args)
    {
        case('activate') :
            {
                aifPortsUtil.parmPortActiveorDeactive(AIFPortActivorDeactive::Activate);
            }

        case('deactivate') :
            {
                aifPortsUtil.parmPortActiveorDeactive(AIFPortActivorDeactive::Deactivate);
            }
    }

    aifPortsUtil.run();
}

AX2012 Export ActiveDirectory Data to file.


Created the framework class called ADReader which reads the data from ActiveDirectory of current domains in the nework that connected.

static void krishh_ADExportToCSV(Args _args)
{
    AxaptaUserManager mgr;
    container domainNames;
    int i;
    int domainCount;
    str name;
    System.Collections.ArrayList domains = new System.Collections.ArrayList();

    TextIo          ioData;
    FileIOPermission permission;
    str filename = "c:\\temp\\tmotest_"+FileUtil::createFilenameTimeStamp()+".csv";

    ADReader    adReader = new ADReader();
    map costcenter = new Map(types::String, types::String);
    str key;

    #File

    permission = new FileIOPermission(filename,  #io_write);
    permission.assert();

    // Open file for writing
    ioData = new TextIo(filename, #io_write);

    // Check file open status
    if (!ioData)
    {
        // File '%1' could not be opened.
        throw error(strfmt("@SYS19312", filename));
    }

    // Set file delimiters
    ioData.outRecordDelimiter('\r\n');
    ioData.outFieldDelimiter(';');
    ioData.write(
        [
          "Domain"
        , "Company"
        , "Country"
        , "DepartmentNumber"
        , "EmployeeType"
        , "Mail"
        , "Manager"
        , "Manager_Converted"
        , "GivenName"
        , "Sn"
        , "TelephoneNumber"
        , "UserId"
        , "samAccountName"
        , "EmployeeNumber"
        , "EmployeeNumber_Converted"
        , "Disabled"
        , "MemberOf"
        , "ADGroups"
        ]);


    mgr = new AxaptaUserManager();
    // Get the names of the domains from the kernel class
    domainNames = mgr.enumerateDomains('');
    if(domainNames)
    {
        domainCount = conLen(domainNames);
        // Add all the domain names to the domains combo box
        // dual loop to sort the domains alphabetically using the default comparator
        if(domainCount > 0)
        {
            domains.Clear();
            for(i = 0; i < domainCount; i++)
            {
                if (conPeek(domainNames, i+1) == "Krishhdax.com")
                {
                    adReader.reset();
                    adReader.parmSelectedDomainName(conPeek(domainNames, i+1));

                    while(adReader.next())
                    {
                        if (   adReader.getEmployeeType() == "Employee Master Account"
                            || adReader.getEmployeeType() == "Consultant Master Account")
                        {
                            ioData.write(
                            [
                              adReader.parmSelectedDomainName()
                            , adReader.getCompany()
                            , adReader.getCountry()
                            , adReader.getDepartmentNumber()
                            , adReader.getEmployeeType()
                            , adReader.getMail()
                            , adReader.getManager()
                            , subStr(adReader.getManager()
                                     , strfind(adReader.getManager(), "CN=", 1, strLen(adReader.getManager()))+3
                                     , strfind(adReader.getManager(), ",", strfind(adReader.getManager(), "CN=", 1, strLen(adReader.getManager())), strLen(adReader.getManager())) - strfind(adReader.getManager(), "CN=",1 , strLen(adReader.getManager())) - 3
                                    )
                            , adReader.getGivenName()
                            , adReader.getSn()
                            , adReader.getTelephoneNumber()
                            , adReader.getUserId()
                            , adReader.getsamAccountName()
                            , adReader.getEmployeeNumber()
                            , subStr(adReader.getEmployeeNumber(), 4, 255)
                            , adReader.getDisabled()
                            , con2Str(adReader.getMemberOf())
                            , con2Str(adReader.getADGroups())
                            ]);
                        }
                    }
                }
            }
        }
    }

    CodeAccessPermission::revertAssert();
}




class ADReader
{
    System.DirectoryServices.DirectorySearcher          directorySearcher;
    System.DirectoryServices.SearchResultCollection     searchResultCollection;
    System.DirectoryServices.SearchResult               searchResult;
    System.DirectoryServices.DirectoryEntry             entry;
    System.DirectoryServices.PropertyValueCollection    propertyValueCollection;
    System.DirectoryServices.SearchScope                searchScope;
    str                                                 selectedDomainName;
    str                                                 prefix;
    str                                                 criteria;
    Filename            filename;

    System.Collections.Specialized.StringCollection  propertyList;
    System.DirectoryServices.PropertyCollection      propertyCollection;
    int                                              numberOfUsers, currentUserNumber;

    NetworkAlias                                    networkAlias;
    Description                                     company;
    Description                                     department;
    Description                                     title;
    Email                                           mail;
    Name                                            givenName;
    str                                             manager, departmentNumber, telephoneNumber, userId, sn, employeeType, employeeNumber, country, samAccountName;
    container                                       memberOf, adGroups;
    Integer                                         userAccountControl;

}
public container getADGroups()
{
    str memberOfStr, searchStr;
    Counter pos, posCount;

    Counter posFrom, posTo, searchStrLen;


    if (!ADGroups)
    {
        searchStr = 'CN=';
        searchStrLen = strLen(searchStr);

        posCount = conlen(memberOf);
        for (Pos=1; pos<=posCount;pos++)
        {
            memberOfStr = conpeek(memberOf, pos);

            posTo = 0;
            posFrom = strScan(memberOfStr, searchStr, posTo, strLen(memberOfStr));
            while (posFrom)
            {
                posTo = strScan(memberOfStr, ',', posFrom, strLen(memberOfStr));
                ADGroups += [subStr(memberOfStr, posFrom+searchStrLen, posTo-posFrom-searchStrLen)];
                posFrom = strScan(memberOfStr, searchStr, posTo, strLen(memberOfStr));
            }
        }
    }

    return ADGroups;
}
private void setSearchPropertyList(System.DirectoryServices.DirectorySearcher _directorySearcher)
{
    propertyList = _directorySearcher.get_PropertiesToLoad();
    propertyList.Add('samaccountname');
    propertyList.Add('company');
    propertyList.Add('department');
    propertyList.Add('title');
    propertyList.Add('displayName');
    propertyList.Add('distinguishedName');
    propertyList.Add('objectClass');
    propertyList.Add('member');
    propertyList.Add('manager');
    propertyList.Add('mail');
    propertyList.Add('telephoneNumber');
    propertyList.Add('Userid');
    propertyList.Add('sn');
    propertyList.Add('EmployeeType');
    propertyList.Add('employeeNumber');
    propertyList.Add('c');
    propertyList.Add('samAccountName');
}


public boolean next()
{
    Counter pos, posCount;
    str memberOfStr;
    CLRObject clrenumerator;

    networkAlias        = "";
    company             = "";
    department          = "";
    title               = "";
    mail                = "";
    givenName           = "";
    manager             = "";
    departmentNumber    = "";
    telephoneNumber     = "";
    userId              = "";
    sn                  = "";
    employeeType        = "";
    adGroups            = conNull();
    memberOf            = conNull();

    try
    {
        if (currentUserNumber == 0 && searchResultCollection == null)
        {
            prefix = 'LDAP://';
            searchScope = System.DirectoryServices.SearchScope::Subtree;

            entry = new System.DirectoryServices.DirectoryEntry(prefix+selectedDomainName);

            directorySearcher = new System.DirectoryServices.DirectorySearcher(entry);

            directorySearcher.set_PageSize(65535);
            directorySearcher.set_CacheResults(false);
            directorySearcher.set_SearchScope(searchScope);

            directorySearcher.set_Filter(strFmt('(&(objectClass=user)(objectCategory=person)%1(userAccountControl:1.2.840.113556.1.4.803:=512))', criteria));
            this.setSearchPropertyList(directorySearcher);

            searchResultCollection = directorySearcher.FindAll();
            numberOfUsers = searchResultCollection.get_Count();
        }

        do
        {
            currentUserNumber++;

            if (currentUserNumber > numberOfUsers)
            {
                return false;
            }

            searchResult = searchResultCollection.get_Item(currentUserNumber-1);
            entry = searchResult.GetDirectoryEntry();

            if (entry)
            {
                PropertyCollection = entry.get_Properties();
            }

            if (!PropertyCollection)
            {
                entry.Dispose();
            }
        }
        while (!PropertyCollection);

        propertyValueCollection = PropertyCollection.get_Item('samaccountname');

        if (PropertyValueCollection)
        {
            if (PropertyValueCollection.get_Value())
            {
                NetworkAlias = PropertyValueCollection.get_Value();
            }
        }


        propertyValueCollection  = PropertyCollection.get_Item('company');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                company = PropertyValueCollection.get_Value();
            }
        }

        propertyValueCollection  = PropertyCollection.get_Item('telephoneNumber');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                telephoneNumber = PropertyValueCollection.get_Value();
                telephoneNumber = telephoneNumber; //str2int(telephoneNumber)==0 ? "" : telephoneNumber;
            }
        }

        PropertyValueCollection = propertyCollection.get_Item('department');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                department = PropertyValueCollection.get_Value();
            }
        }

        PropertyValueCollection = propertyCollection.get_Item('departmentNumber');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                departmentNumber = PropertyValueCollection.get_Value();
            }
        }

        PropertyValueCollection = propertyCollection.get_Item('title');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {
                title = PropertyValueCollection.get_Value();
            }
        }

        PropertyValueCollection = propertyCollection.get_Item('mail');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {
                mail = PropertyValueCollection.get_Value();
            }
        }


        PropertyValueCollection = propertyCollection.get_Item('givenName');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                givenName = PropertyValueCollection.get_Value();
            }
        }

        PropertyValueCollection = propertyCollection.get_Item('Userid');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                UserId = PropertyValueCollection.get_Value();
            }
        }

        PropertyValueCollection = propertyCollection.get_Item('EmployeeNumber');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                employeeNumber = PropertyValueCollection.get_Value();
            }
        }

        PropertyValueCollection = propertyCollection.get_Item('sn');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                sn = PropertyValueCollection.get_Value();
            }
        }

        PropertyValueCollection = propertyCollection.get_Item('EmployeeType');

        if (PropertyValueCollection && PropertyValueCollection.get_Count())
        {
            if (PropertyValueCollection.get_Value())
            {

                employeeType = PropertyValueCollection.get_Value();
            }
        }

        propertyValueCollection = PropertyCollection.get_Item('manager');

        if (PropertyValueCollection)
        {
            if (PropertyValueCollection.get_Value())
            {
                manager = PropertyValueCollection.get_Value();
            }
        }

        propertyValueCollection = PropertyCollection.get_Item('c');

        if (PropertyValueCollection)
        {
            if (PropertyValueCollection.get_Value())
            {
                country = PropertyValueCollection.get_Value();
            }
        }

        propertyValueCollection = PropertyCollection.get_Item('samAccountName');

        if (PropertyValueCollection)
        {
            if (PropertyValueCollection.get_Value())
            {
                samAccountName = PropertyValueCollection.get_Value();
            }
        }

        propertyValueCollection = PropertyCollection.get_Item('userAccountControl');

        if (PropertyValueCollection)
        {
            if (PropertyValueCollection.get_Value())
            {
                userAccountControl = PropertyValueCollection.get_Value();
            }
        }

        propertyValueCollection = PropertyCollection.get_Item('memberOf');

        if (PropertyValueCollection)
        {
            if (PropertyValueCollection.get_Value())
            {
                clrenumerator = PropertyValueCollection.GetEnumerator();
                while (clrenumerator.MoveNext())
                {
                    memberOfStr = clrenumerator.get_Current();
                    memberOf += [memberOfStr];
                }
                //posCount = PropertyValueCollection.get_Count();
                //for (Pos=0; pos<posCount;pos++)
                //{
                    //memberOfStr = PropertyValueCollection.get_Item(pos);
                    //memberOf += [memberOfStr];
                //}
            }
        }
    }
    catch (Exception::CLRError)
    {
        //SRSProxy::handleClrException(Exception::Warning);
        //warning(strFmt("@SYS117734"));
        curext();
    }


    return true;
}



public str getCompany()
{
    return company;
}
public str getCountry()
{
    return country;
}
public str getDepartmentNumber()
{
    return departmentNumber;
}

public boolean getDisabled()
{
   
    // Added new conditions for when a user should be seen as disabled.
    boolean ret;
    ;
    //ACCOUNTDISABLE    0x0002    2
    ret =  bitTest(userAccountControl, 1 << 1);

    if (!ret && title == 'SLUTAT')
        ret = true;

    if (!ret && (strLen(departmentNumber) > 0 && !strRem(departmentNumber,'0')) && (strLen(employeeNumber) > 0 && !strRem(employeeNumber,'0')))
        ret = true;

    return ret;
   
}

public str getEmployeeNumber()
{
    return employeeNumber;
}

public str getEmployeeType()
{
    return EmployeeType;
}
public str getGivenName()
{
    return givenName;
}

public email getMail()
{
    return mail;
}

public str getManager()
{
    return subStr(manager
                  , strfind(manager, 'CN=', 1, strLen(manager))+3
                  , strfind(manager, ',', strfind(manager, 'CN=', 1, strLen(manager)), strLen(manager)) - strfind(manager, 'CN=',1 , strLen(manager)) - 3
              );
}

public container getMemberOf()
{
    return memberOf;
}

public str getSamAccountName()
{
    return samAccountName;
}

public str getSn()
{
    return sn;
}

public str getTelephoneNumber()
{
    return telephoneNumber;
}

public str getUserId()
{
    return UserId;
}

public int parmCurrentUserNumber(int _currentUserNumber = currentUserNumber)
{

    currentUserNumber = _currentUserNumber;

    return currentUserNumber;
}

public str parmFileName(Filename _filename = filename)
{
    filename  = _filename;

    return filename;
}

public str parmselectedDomainName(str _selectedDomainName = selectedDomainName)
{
    selectedDomainName  = _selectedDomainName;

    return selectedDomainName;
}

public void reset()
{
    currentUserNumber = 0;
}

AX2012 Import CostCenter Owner


static void Krishh_ImportCostCenterOwner(Args _args)
{
    #File
    #AviFiles
    #OCCRetryCount

    Dialog                      dialog = new dialog("Import cost center owners");
    DialogField                 dlgFileNameOpen, dlgFirstRowsIsHeader;
    Filename                    fileName;
    NoYesId                     firstRowIsHeader;
    container                   readcon;
    CommaIO                     file;
    FileIoPermission            permission;
    SysOperationProgress        progressbar = new SysOperationProgress();
    Counter                     fileRowsRead;
    OMOperatingUnit             oMOperatingUnit;
    DimensionAttribute          dimensionAttributeValue;
    HcmWorkerRecId              hcmWorkerRecId;

    dlgFileNameOpen         = dialog.addField(extendedTypeStr(FilenameOpen));
    dlgFirstRowsIsHeader    = dialog.addField(extendedTypeStr(NoYesId), "First row is header");

    if (dialog.run())
    {
        fileName            = dlgFileNameOpen.value();
        firstRowIsHeader    = dlgFirstRowsIsHeader.value();

        if (!fileName)
            throw error("File name must be specified");

        permission = new FileIoPermission(filename,'r');
        permission.assert();

        file = new CommaIo(filename, 'r');
        file.inFieldDelimiter(';');

        if (!file)
            throw error(strFmt("Error opening file", fileName));

        progressbar.setCaption("Importing cost center owners");
        progressbar.setAnimation(#AviUpdate);

        try
        {
            ttsBegin;

            while (file.status() == IO_Status::OK)
            {
                readCon = file.read();
                fileRowsRead++;

                if (fileRowsRead > firstRowIsHeader && readCon && conPeek(readcon, 1))
                {
                    oMOperatingUnit = OMOperatingUnit::findName(conPeek(readcon, 1), OMOperatingUnitType::OMCostCenter);

                    if (!oMOperatingUnit)
                        warning(strFmt("Cost center %1 not found."));
                    else
                    {
                        // Find worker from user id
                        hcmWorkerRecId = HcmWorker::userId2Worker(conPeek(readcon, 2));

                        if (!hcmWorkerRecId)
                            warning(strFmt("User id %1 not found as worker in AX."));
                        else
                        {
                            // Find and update dimensionAttributeValue with worker as owner
                        }

                    }
                }

                progressbar.setText(strfmt("@SYS136776", fileRowsRead));
                progressbar.update();
            }

            ttsCommit;

            info(strFmt("%1 rows read from file", fileRowsRead));

        }
        catch (Exception::Error)
        {
            error("Error");
        }
        catch (Exception::Deadlock)
        {
            retry;
        }
        catch (Exception::UpdateConflict)
        {
            if (appl.ttsLevel() == 0)
            {
                if (xSession::currentRetryCount() >= #RetryNum)
                {
                    throw Exception::UpdateConflictNotRecovered;
                }
                else
                {
                    retry;
                }
            }
            else
            {
                throw Exception::UpdateConflict;
            }
        }
    }
}

AX2012 Export Account Structures


static void Krishh_AcctStructureExport(Args _args)
{
    DimensionHierarchy                  dimensionHierarchy;
    DimensionHierarchyLevel             dimensionHierarchyLevel;
    DimensionAttribute                  dimensionAttribute;
    DimensionConstraintNode             dimensionConstraintNode;
    DimensionConstraintNodeCriteria     dimensionConstraintNodeCriteria;
    FileIOPermission                    fileIoPermission;
    CommaIO                             csvFile;
    container                           writecon;
    Dialog                              dialog;
    DialogField                         dfFileName;
    FileName                            fileName;
    boolean                             firstRow = true;
    Counter                             countRows;
    #File

    dialog = new Dialog("Export account structure text file");
    dfFileName = dialog.addField(extendedTypeStr(FileNameSave));
    dialog.filenameLookupFilter(["CSV files", #AllFilesName+#CSV, "All files", #AllFiles]);

    if (dialog.run())
        filename =  dfFileName.value();
    else
        throw error("Export cancelled");

    fileIoPermission = new FileIOPermission(filename ,'W');
    fileIoPermission.assert();

    csvFile = new CommaIO(filename, 'w');
    csvFile.outFieldDelimiter(';');

    while select dimensionHierarchy order by dimensionHierarchy.Name, dimensionHierarchyLevel.Level, dimensionConstraintNodeCriteria.RangeFrom, dimensionConstraintNodeCriteria.RangeTo, dimensionConstraintNodeCriteria.WildCardString
        where !dimensionHierarchy.IsSystemGenerated
        join dimensionHierarchyLevel
            where   dimensionHierarchyLevel.DimensionHierarchy == dimensionHierarchy.RecId
            join dimensionAttribute
                where   dimensionAttribute.RecId == dimensionHierarchylevel.DimensionAttribute
            join dimensionConstraintNode
                where   dimensionConstraintNode.DimensionHierarchyLevel == dimensionHierarchyLevel.RecId
                join dimensionConstraintNodeCriteria
                    where   dimensionConstraintNodeCriteria.DimensionConstraintNode == dimensionConstraintNode.RecId
    {
        if (firstRow)
        {
            writeCon = [    "Account structure",
                            "Level",
                            "Dimension",
                            "From",
                            "To",
                            "Wildcard"];

            csvFile.write(writecon);
            firstRow = false;
        }

        writeCon = [    dimensionHierarchy.Name,
                        int2str(dimensionHierarchyLevel.Level),
                        dimensionAttribute.Name,
                        dimensionConstraintNodeCriteria.RangeFrom,
                        dimensionConstraintNodeCriteria.RangeTo,
                        dimensionConstraintNodeCriteria.WildCardString];

        csvFile.write(writecon);
        countRows++;
    }

    CodeAccessPermission::revertAssert();

    info(strFmt("%1 rows written to %2.", countRows, fileName));
}

AX2012 finding AIF menuItems and write to file

Traverse the Menu Node in AOT and find AIF menuItems and write to a file.

static void krishh_verifyAifInMenu(Args _args)
{
    // Dialog
    dialog      dialog = new dialog('verifyAifInMenu');
    dialogField dlgFileName, dlgAction;
    FileName    fileName;
    int         action;
    container   saved;

    // File
    #File
    TextIo          ioData;
    FileIOPermission permission;

    Treenode treenode = TreeNode::findNode(@'\Menus\KrishhTest\Periodic');
    //Treenode treenode = TreeNode::findNode(@'\Menus\KrishhTest\Periodic');
    //Treenode treenode = TreeNode::findNode(@'\Menus\KrishhTest\Periodic');
    //Treenode treenode = TreeNode::findNode(@'\Menus\KrishhTest\Periodic');
    TreeNodeTraverser traverser = new TreeNodeTraverser(treenode);
    TreeNode node, menuTypeNode;
    UtilElements    ue;

    MenuItem        mi;
    DictClass       dc;
    className       cn, scn;


    Counter         i,j;
    SysDictMethod   sdm;
    Source          s;

    Str1260         sLable, sClass, sMenuItem, sClassMethodName, sMethod, sAIFPort, sDirection, sEnabled, sActionAddedToPort, sFolderName;

    System.Text.RegularExpressions.Match regExMatch;
    boolean                              isValid;
    Int                                  position, posStart, posEnd;

    DictTable       dt;
    RecId           recId;
    boolean         aifFound;
    AifPort             aifPort;

    AifChannel          aifChannel;
    AifPortActionPolicy aifPortActionPolicy;
    AifActionId         aifActionId;

    #Properties
    #AOT
    #AIF

    #localmacro.PortInfo
           any2str(%1)
         + ","
         + any2str(%2)
         + ","
         + any2str(%3)
         + ","
         + any2str(%4)
         + ","
         + any2str(%5)
         + ","
         + any2str(%6)
         , "Goto method", SysInfoAction_Editor::newOpen(%7)
    #EndMacro

    saved = xSysLastValue::getValue(curExt(),curUserId(),UtilElementType::Class,'verifyAifInMenu','fileName');
    if (saved)
    {
        fileName = conpeek(saved,1);
    }

    dlgFileName = dialog.addFieldValue(extendedTypeStr(FilenameOpen),fileName,'Filename','File to save result.');
    //dlgAction = dialog.addFieldValue(extendedTypeStr(NumberOf),0,'Action','1=Save, 2=Undeploy, 3=Deploy');

    if (dialog.run())
    {
        fileName = dlgFileName.value();
        saved = [fileName];
        xSysLastValue::putValue(saved,curExt(),curUserId(),UtilElementType::Class,'verifyAifInMenu','fileName');

        permission = new FileIOPermission(fileName,  #io_write);
        permission.assert();

        // Open file for writing
        ioData = new TextIo(filename, #io_write);

        // Check file open status
        if (!ioData)
        {
            // File '%1' could not be opened.
            throw error(strfmt("@SYS19312", filename));
        }

        // Set file delimiters
        ioData.outRecordDelimiter('\r\n');
        ioData.outFieldDelimiter(';');

        ioData.write(
            [
                "Menu label"
              , "Menu item"
              , "Class"
              , "AIF Port"
              , "Direction"
              , "Enabled"
              , "Methode"
              , "ActionAddedToPort"
              , "Folder name"
            ]);

        setPrefix("Services");
        while (traverser.next())
        {
            node = traverser.currentNode();
            if  (node.AOTgetProperty('MenuItemName')!= '')
            {
                menuTypeNode = TreeNode::findNode(#MenuItemsPath +"\\Action\\" + findProperty(node.AOTgetProperties(),#PropertyMenuItemName));
                mi = traverser.currentNode();

                // Is menuitem object a class
                if (findProperty(menuTypeNode.AOTgetProperties(),#PropertyObjectType) == enum2Value(MenuItemObjectType::Class))
                {
                    // Find Class
                    if (findProperty(menuTypeNode.AOTgetProperties(),#PropertyObject) == 'SysOperationServiceController')
                    {
                        dc = new DictClass(className2Id(subStr(findProperty(menuTypeNode.AOTgetProperties(),#PropertyParameters), 1, strScan(findProperty(menuTypeNode.AOTgetProperties(),#PropertyParameters), '.', 1, 1000)-1)));
                    }
                    else
                    {
                        dc = new DictClass(className2Id(findProperty(menuTypeNode.AOTgetProperties(),#PropertyObject)));
                    }

                    sLable      = mi.label();
                    sMenuItem   = #MenuItemsPath +"\\Action\\" + findProperty(node.AOTgetProperties(),#PropertyMenuItemName);//node.treeNodePath();
                    sClass      = dc.name();
                    setPrefix(strFmt("%1, %2, %3, %4", node.treeNodePath(), sLable, sMenuItem, sClass));

                    aifFound = false;
                    // Find the methode in the class where AxdDocumentParameters is used
                    for (i=1;i<=dc.objectMethodCnt()+dc.staticMethodCnt();i++)
                    {
                        // Instance method else Static method
                        if (i<=dc.objectMethodCnt())
                        {
                            sdm = new SysDictMethod(UtilElementType::ClassInstanceMethod, dc.id(), dc.objectMethod(i));
                        }
                        else
                        {
                            sdm = new SysDictMethod(UtilElementType::ClassStaticMethod, dc.id(), dc.staticMethod(i-dc.objectMethodCnt()));
                        }
                        sMethod = sdm.path();
                        s = sdm.getSource();

                        // Find port from AxdDocumentParameters
                        regExMatch = System.Text.RegularExpressions.Regex::Match(s, @'(?i)AxdDocumentParameters::find\(\).krishh.{1,22}Port');
                        isValid = regExMatch.get_Success();
                        regExMatch = System.Text.RegularExpressions.Regex::Match(s, @'(?i)AifSendService::submitFrom');
                        isValid = isValid && regExMatch.get_Success();

                        setPrefix("Port");
                        if (isValid)
                        {
                            dt = new DictTable(tableNum(AxdDocumentParameters));

                            // Get AIFPort from AxdDocumentParameters used in code
                            for (j=1;j<=dt.fieldCnt();j++)
                            {
                                if (strScan(dt.fieldName(dt.fieldCnt2Id(j)), 'krishh', 1, 100) && strScan(dt.fieldName(dt.fieldCnt2Id(j)), 'Port', 1, 100))
                                {
                                    regExMatch = System.Text.RegularExpressions.Regex::Match(s, strFmt(@'(?i)%1', dt.fieldName(dt.fieldCnt2Id(j))));
                                    isValid = regExMatch.get_Success();
                                    if (isValid)
                                    {
                                        recId =    AxdDocumentParameters::find().(dt.fieldCnt2Id(j));

                                        // Find Port
                                        if (recId)
                                        {
                                            select firstOnly aifPort
                                                where aifPort.RecId == recId
                                                join aifChannel
                                                    where aifChannel.ChannelId == aifPort.ChannelId;
                                            sDirection  = enum2Value(aifChannel.Direction);
                                            sEnabled    = enum2Value(aifChannel.Enabled);
                                            sFolderName = aifChannel.TransportAddress;
                                            aifFound = true;
                                        }

                                        if (aifFound)
                                        {
                                            // Find action
                                            sActionAddedToPort = "";
                                            regExMatch = System.Text.RegularExpressions.Regex::Match(s, strFmt(@'(?i)AifSendActionType::'));
                                            isValid = regExMatch.get_Success();
                                            if (isValid)
                                            {
                                                // Calculate position of the portaction
                                                position    = regExMatch.get_Index();
                                                posStart    = position+1+strLen('AifSendActionType::');
                                                posEnd      = strScan(s, ')', position, strLen(s));

                                                // Convet actiontype to actionId-searchstring
                                                switch (subStr(s, posStart, posEnd-posStart))
                                                {
                                                    case "SendByQuery":
                                                        aifActionId = "*.find";
                                                        break;
                                                    case "SendByKey":
                                                        aifActionId = "*.read";
                                                        break;
                                                }

                                                // Find portaction
                                                while select AifPortActionPolicy
                                                        where AifPortActionPolicy.ActionId like aifActionId
                                                           && AifPortActionPolicy.Port == recId
                                                {
                                                    // Get the serviceclassname
                                                    scn = subStr(AifPortActionPolicy.ActionId, 1, strLen(AifPortActionPolicy.ActionId) - (strLen(aifActionId)-1));
                                                    regExMatch = System.Text.RegularExpressions.Regex::Match(s, strFmt(@'(?i)classnum\(%1', scn));
                                                    isValid = regExMatch.get_Success();
                                                    if (isValid)
                                                    {
                                                        // Create a portaction exm. serviceclassname.action
                                                        sActionAddedToPort = scn+subStr(aifActionId, 2, strLen(aifActionId));
                                                        break;
                                                    }
                                                }
                                            }
                                        }

                                        // Output Port info
                                        if (sEnabled && sActionAddedToPort)
                                        {
                                            info(#PortInfo(aifPort.Name, sDirection, sEnabled, sMethod, sActionAddedToPort, sFolderName, sdm.path()));
                                        }
                                        else
                                        {
                                            error(#PortInfo(aifPort.Name, sDirection, sEnabled, sMethod, sActionAddedToPort, sFolderName, sdm.path()));
                                        }

                                        ioData.write(
                                            [
                                                  sLable
                                                , sMenuItem
                                                , sClass
                                                , aifPort.Name
                                                , sDirection
                                                , sEnabled
                                                , sMethod
                                                , sActionAddedToPort, sFolderName
                                            ]);
                                    }
                                }
                            }
                        }

                        // Find port from AifOutboundPort::find
                        recId = 0;
                        regExMatch = System.Text.RegularExpressions.Regex::Match(s, @'(?i)AifSendService::submitFrom');
                        isValid = regExMatch.get_Success();
                        regExMatch = System.Text.RegularExpressions.Regex::Match(s, @'(?i)AifOutboundPort::find\(');
                        isValid = isValid && regExMatch.get_Success();

                        if (isValid)
                        {
                            // Calculate position of the portClass
                            position    = regExMatch.get_Index();
                            posStart    = position+2+strLen('AifOutboundPort::find\(');
                            posEnd      = strScan(s, ');', position, strLen(s))-1;

                            // Convet actiontype to actionId-searchstring
                            scn = subStr(s, posStart, posEnd-posStart);

                            // Find Port
                            if (scn)
                            {
                                select firstOnly aifPort
                                    where aifPort.Name == scn
                                    join aifChannel
                                        where aifChannel.ChannelId == aifPort.ChannelId;
                                sDirection  = enum2Value(aifChannel.Direction);
                                sEnabled    = enum2Value(aifChannel.Enabled);
                                sFolderName = aifChannel.TransportAddress;

                                recId = aifPort.RecId;
                                aifFound = true;
                            }

                            if (recId)
                            {
                                // Find action
                                sActionAddedToPort = "";
                                regExMatch = System.Text.RegularExpressions.Regex::Match(s, strFmt(@'(?i)AifSendActionType::'));
                                isValid = regExMatch.get_Success();
                                if (isValid)
                                {
                                    // Calculate position of the portaction
                                    position    = regExMatch.get_Index();
                                    posStart    = position+1+strLen('AifSendActionType::');
                                    posEnd      = strScan(s, ')', position, strLen(s));

                                    // Convet actiontype to actionId-searchstring
                                    switch (subStr(s, posStart, posEnd-posStart))
                                    {
                                        case "SendByQuery":
                                            aifActionId = "*.find";
                                            break;
                                        case "SendByKey":
                                            aifActionId = "*.read";
                                            break;
                                    }

                                    // Find portaction
                                    while select AifPortActionPolicy
                                            where AifPortActionPolicy.ActionId like aifActionId
                                                && AifPortActionPolicy.Port == recId
                                    {
                                        // Get the serviceclassname
                                        scn = subStr(AifPortActionPolicy.ActionId, 1, strLen(AifPortActionPolicy.ActionId) - (strLen(aifActionId)-1));
                                        regExMatch = System.Text.RegularExpressions.Regex::Match(s, strFmt(@'(?i)classnum\(%1', scn));
                                        isValid = regExMatch.get_Success();
                                        if (isValid)
                                        {
                                            // Create a portaction exm. serviceclassname.action
                                            sActionAddedToPort = scn+subStr(aifActionId, 2, strLen(aifActionId));
                                            break;
                                        }
                                    }
                                }
                            }
                            // Output Port info
                            if (sEnabled && sActionAddedToPort)
                            {
                                info(#PortInfo(aifPort.Name, sDirection, sEnabled, sMethod, sActionAddedToPort, sFolderName, sdm.path()));
                            }
                            else
                            {
                                error(#PortInfo(aifPort.Name, sDirection, sEnabled, sMethod, sActionAddedToPort, sFolderName, sdm.path()));
                            }

                            ioData.write(
                                [
                                        sLable
                                    , sMenuItem
                                    , sClass
                                    , aifPort.Name
                                    , sDirection
                                    , sEnabled
                                    , sMethod
                                    , sActionAddedToPort, sFolderName
                                ]);

                        }

                        // Find port from AifSendService::submitDefault
                        recId = 0;
                        sDirection = '';
                        sEnabled = '';
                        sFolderName = '';
                        sActionAddedToPort = '';

                        regExMatch = System.Text.RegularExpressions.Regex::Match(s, @'(?i)AifSendService::submitDefault\(');
                        isValid = regExMatch.get_Success();
                        regExMatch = System.Text.RegularExpressions.Regex::Match(s, @'(?i)classnum\(');
                        isValid = isValid && regExMatch.get_Success();

                        if (isValid)
                        {
                            // Calculate position of the portClass
                            position    = regExMatch.get_Index();
                            posStart    = position+1+strLen('classnum\(');
                            posEnd      = strScan(s, '),', position, strLen(s));

                            // Convet actiontype to actionId-searchstring
                            scn = subStr(s, posStart, posEnd-posStart);

                            // Find Port
                            if (scn)
                            {
                                select firstOnly AifPortActionPolicy
                                    where AifPortActionPolicy.ActionId == scn + #MethodNameSeparator + #DefaultSendByKeyAction
                                        join aifPort
                                            where aifPort.RecId == AifPortActionPolicy.Port
                                            join aifChannel
                                                where aifChannel.ChannelId == aifPort.ChannelId;
                                sDirection = enum2Value(aifChannel.Direction);
                                sEnabled = enum2Value(aifChannel.Enabled);
                                sFolderName = aifChannel.TransportAddress;

                                recId = AifPortActionPolicy.Port;
                                aifFound = true;
                            }

                            if (recId)
                            {
                                aifActionId = "*.read";

                                // Find portaction
                                while select AifPortActionPolicy
                                        where AifPortActionPolicy.ActionId like aifActionId
                                            && AifPortActionPolicy.Port == recId
                                {
                                    // Get the serviceclassname
                                    scn = subStr(AifPortActionPolicy.ActionId, 1, strLen(AifPortActionPolicy.ActionId) - (strLen(aifActionId)-1));
                                    regExMatch = System.Text.RegularExpressions.Regex::Match(s, strFmt(@'(?i)classnum\(%1', scn));
                                    isValid = regExMatch.get_Success();
                                    if (isValid)
                                    {
                                        // Create a portaction exm. serviceclassname.action
                                        sActionAddedToPort = scn+subStr(aifActionId, 2, strLen(aifActionId));
                                        break;
                                    }
                                }
                            }

                            // Output Port info
                            if (sEnabled && sActionAddedToPort)
                            {
                                info(#PortInfo(aifPort.Name, sDirection, sEnabled, sMethod, sActionAddedToPort, sFolderName, sdm.path()));
                            }
                            else
                            {
                                error(#PortInfo(aifPort.Name, sDirection, sEnabled, sMethod, sActionAddedToPort, sFolderName, sdm.path()));
                            }

                            ioData.write(
                                [
                                        sLable
                                    , sMenuItem
                                    , sClass
                                    , aifPort.Name
                                    , sDirection
                                    , sEnabled
                                    , sMethod
                                    , sActionAddedToPort, sFolderName
                                ]);

                        }
                    }
                    if (!aifFound)
                    {
                        info(strFmt('%1, %2, %3, %4, %5, %6, %7, %8'
                              , sLable
                              , sMenuItem
                              , sClass
                              , "Not AIF"
                              , "No"
                              , "No"
                              , "No"
                              , "No"));
                        ioData.write(
                            [
                                sLable
                              , sMenuItem
                              , sClass
                              , "Not AIF"
                              , "No"
                              , "No"
                              , "No"
                              , "No"
                            ]);
                    }
                }
            }
        }

        CodeAccessPermission::revertAssert();
    }
}