Search This Blog

Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

Monday, May 23, 2022

 Create the User into ActiveDirectory

static void CreateADUSER(Args _args)

{

    System.DirectoryServices DirectoryServices;

    System.DirectoryServices.AccountManagement AccountManagement;

    System.DirectoryServices.AccountManagement.UserPrincipal up;

 

    System.DirectoryServices.AccountManagement.PrincipalContext pricipalContext;

    str networkDomain="KrishhDAX";

    InteropPermission                                               permission;

 

try

{

     permission = new InteropPermission(InteropKind::CLRInterop);

     permission.assert();

    pricipalContext = new System.DirectoryServices.AccountManagement.PrincipalContext(System.DirectoryServices.AccountManagement.ContextType::Domain, "KRISHHDAX", "OU=mDK,OU=Users,OU=TestOU,DC=KrishhDAX,DC=com");

    //Sometimes we need to connect to AD using service/admin account credentials, in that case the above line of code will be as below

    //pricipalContext = new PrincipalContext(ContextType.Domain, "yourdomain.com", "OU=TestOU,DC=yourdomain,DC=com","YourAdminUser","YourAdminPassword");

    up = new System.DirectoryServices.AccountManagement.UserPrincipal(pricipalContext);

    up.set_SamAccountName("krishh");

    up.set_DisplayName("krishh Reddy");

    up.set_EmailAddress(krishh.009@KRISHHDAX.com);

    up.set_GivenName("krishh Reddy");

    up.set_UserPrincipalName(krishh.009@KRISHHDAX.com);

    up.set_Name("Krishh");

    up.set_Surname("Reddy");

    up.set_Description("User Created for testing");

    up.set_Enabled(True);

   

    up.SetPassword("KRISHHDAX#");

    up.Save();

   // info(strFmt("User Created %1",up.get_DisplayName()));

     CodeAccessPermission::revertAssert();

}

catch(Exception::CLRError)

{

       CodeAccessPermission::revertAssert();

        info(CLRInterop::getLastException().ToString());

}

}

Friday, August 24, 2018

Useful X++ functions



//Return the value from the xmlNode
static str getXmlNodeValue(XmlNode _node)
{
    System.Text.RegularExpressions.Regex re =
    // BP deviation documented
    new System.Text.RegularExpressions.Regex('^[ \r\n\t]*((.|\n)*?)[ \r\n\t]*$');
    System.Text.RegularExpressions.Match m = re.Match(_node.text());
    str result;
    ;

    result = m.Result('$1');
    return result;
}

/// <summary>
/// Provides a lookup of dimension values.
/// </summary>
/// <param name="_ctrl">The control to provide a lookup for.</param>
/// <param name="_dimensionName">The dimension attribute to filter by.</param>
public static client void lookupDimension(FormStringControl _ctrl, Name _dimensionName)
{
    SysTableLookup          sysTableLookup = SysTableLookup::newParameters(tablenum(DimensionAttribute),_ctrl);
    Query                   query = new Query();
    QueryBuildDataSource    queryBuildDataSource = query.addDataSource(tablenum(DimensionAttribute));

    sysTableLookup.addLookupfield(fieldnum(DimensionAttribute, Name));

    queryBuildDataSource.addRange(fieldnum(DimensionAttribute, Type)).value(queryNotValue(DimensionAttributeType::MainAccount));

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

}


/// <summary>
/// This method has the complete source file as input and will concatenate the target path with the filename
/// </summary>
/// <param name="_sourceFilename">
///  This is the full filename including the path
/// </param>
/// <param name="_targetPath">
///  the target folder
/// </param>
/// <returns>
///  It will return the target filename.
/// </returns>

static filename getTargetFilename(Filename _sourceFilename, Filepath _targetPath)
{
    Filename    targetFilename;
    ;
    new InteropPermission(InteropKind::ClrInterop).assert();

    targetFilename = System.IO.Path::Combine(_targetPath, System.IO.Path::GetFileName(_sourceFilename));

    return targetFilename;
}


// Generate nodes into container.
static container containerFromXMLNode(XmlNode n)
{
    container retval, containerToInsert;
    Common recordToInsert;
    XmlNamedNodeMap attrs;
    XmlNode typeAttr, element, recordNode, containerNode;
    int elemNo = 1;
    ;
    //validate arguments before using them
    if (n == null)
        return retval;

    // Collect all the elements ...
    element = n.firstChild();
    if (element.name() == 'container')
    {
        element = element.firstChild();
    }
    while (element)
    {
        attrs = element.attributes();
        if (attrs)
        {
            typeAttr = attrs.getNamedItem('type');

            switch (typeAttr.nodeValue())
            {
                case 'int'      :
                    retval = conins(retval, elemNo, str2int(BisTools::getXmlNodeValue(element)));
                    break;

                case 'str'      :
                    retval = conins(retval, elemNo, BisTools::getXmlNodeValue(element));
                    break;

                case 'real'     :
                    retval = conins(retval, elemNo, str2num(BisTools::getXmlNodeValue(element)));
                    break;

                case 'enum':
                    retval = conins(retval, elemNo, str2int(BisTools::getXmlNodeValue(element)));
                    break;

                case 'date'     :
                    retval = conins(retval, elemNo, str2date(BisTools::getXmlNodeValue(element), 321));
                    break;

                case 'record'   :
                    recordNode = element.firstChild();
                    recordToInsert = Global::recordFromXMLNode(recordNode);
                    retval = conins(retval, elemNo, recordToInsert);
                    break;

                case 'container':
                    containerNode = element.firstChild();
                    containerToInsert = BisTools::containerFromXMLNode(containerNode);
                    retval = conins(retval, elemNo, containerToInsert);
                    break;

                case 'blob':
                    containerToInsert = BinData::stringToData(BisTools::getXmlNodeValue(element));
                    retval = conins(retval, elemNo, containerToInsert);
                    break;
            }
        }

        element = element.nextSibling();
        elemNo += 1;
    }

    return retval;
}




//Generate html from Record
static str record2html(Common record)
{
    str html;
    DictTable   dictTable = new dictTable(record.TableId);
    DictField   dictField;
    fieldId     fieldId;


    void addField2html(str fieldName, anyType fieldValue, str htmlCode, str fieldLabel)
    {
        str newValue = strFmt('%1',fieldValue);
        if (newValue == '')
        {
            newValue = '-';
        }
        html += strFmt('<tr><td width=30%>%3%4</td><td width=50%>%3%2</td><td width=20%>%3%1</td></tr>',fieldName, newValue , htmlCode, fieldLabel);
    }
    ;
    html = '<html><b>Record values<table border width=100%>';
    addField2html('Field name','Value','<b>','Label');

    fieldId = dictTable.fieldNext(0);
    while (fieldId)
    {
        dictField = dictTable.fieldObject(fieldId);
        if (dictField.arraySize() == 1 && dictField.baseType() != Types::Container && dictField.baseType() != Types::BLOB)
        {
            addField2html(dictField.name(), record.(fieldId),"", dictField.label());
        }
        fieldId = dictTable.fieldNext(fieldId);
    }


    html+='</table></html>';
    return html;
}




//Generate record to Text
static str record2text(Common record)
{
    str         text;
    DictTable   dictTable = new dictTable(record.TableId);
    DictField   dictField;
    fieldId     fieldId;


    void addField2text(str fieldName, anyType fieldValue, str fieldLabel)
    {
        str newValue = strFmt('%1',fieldValue);
        if (newValue == '')
        {
            newValue = '-';
        }
        text += strFmt('Field \'%1\' = \'%2\', Label: \'%3\'\n',fieldName, newValue, fieldLabel);
    }
    ;
    text = strFmt("@BIS635", tableid2name(record.tableId));
    addField2text('Field name','Value', 'Label');

    fieldId = dictTable.fieldNext(0);
    while (fieldId)
    {
        dictField = dictTable.fieldObject(fieldId);
        if (dictField.arraySize() == 1)
        {
            addField2text(dictField.name(), record.(fieldId), dictField.label());
        }
        fieldId = dictTable.fieldNext(fieldId);
    }


    return text;
}


//Create the table record from xmlnode
// Input is <Record table="name"> <Field:field1> value </Field:field1> ... </Record>
// it's the opposite from record.xml() method
static Common xml2record(XmlNode n, Common c = null)
{
    tableId table;
    fieldId field;
    DictTable dt;
    DictField df;
    XmlNode fieldNode;
    str fieldName;
    Struct content;
    str tableName;
    Types t;

    //validate arguments before using them
    if (n == null)
        return null;
    // If we don't have an incoming buffer, one is created
    if (prmisdefault(c))
    {
        // Create a buffer of the correct type
        tableName = n.name();
       // tableName = n.attributes().getNamedItem('name');

        // Check if table node can be accessed
        if (tableName != '')
        {
            table = tablename2id(tableName);
            dt = new DictTable(table);
            c = dt.makeRecord();
        }
    }
    else
    {
        table = c.TableId;
        dt = new DictTable(table);
    }

    fieldNode = n.firstChild();
    while (fieldNode)
    {
        fieldName = fieldNode.attributes().getNamedItem('name').text();
        field = dt.fieldName2Id(fieldName);
        df = new DictField(table, field);

        t = df.baseType();
        if (t == Types::Enum) //Enums need to be treated as Integers. By defult, Enums are getting treated as a boolean and hence loosing its value.
            t = Types::Integer;

        content = BisTools::valueFromXMLNode (t, fieldNode);

        c.(field) = content.value('value');

        fieldNode = fieldNode.nextSibling();
    }
    return c;
}

//Get next working date from the date .
public static date GetNextWorkDay(date _fromDate)
{
    WorkCalendarDate    workCalendar;
    ;

    select firstOnly TransDate from workCalendar
    order by TransDate ASC
        where workCalendar.TransDate > _fromDate
           && workCalendar.WorkTimeControl == WorkTimeControl::Open;

    return workCalendar.TransDate;
}


/// <summary>
///     Attempts to find executatble for file type specified, and open file with it.
/// </summary>
/// <param name="_filename">
///     File name to show
/// </param>
public static client void showFile(Filename _filename)
{
    str filePath, fileName, fileExt, executable;
    if (System.IO.File::Exists(_filename))
    {
        [filePath, filename, fileExt] = fileNameSplit(_filename);
        executable = WinAPI::findExecutable(_filename);
        if (!executable)
        {
            error(strFmt("Windows were not able to find executable for file %1", _filename));
            return;
        }
        if (fileExt == '.msg')
            WinAPI::shellExecute(strFmt('"%1"', executable),strFmt('/f "%1"', _filename),strFmt('"%1"', filePath)); // outlook requires extra parameter  /f
        else
            WinAPI::shellExecute(strFmt('"%1"', executable),strFmt('"%1"', _filename),strFmt('"%1"', filePath));
    }
    else
    {
        error("File not found");
    }
}





/// <summary>
///     Converts enum value to enum label in language specified
/// </summary>
/// <param name="enumId">
///     Enum Id
/// </param>
/// <param name="value">
///     Enum value
/// </param>
/// <param name="languageId">
///     Language for label
/// </param>
/// <returns>
///     Label of enum value in language specified
/// </returns>
public static str enum2Label(EnumId enumId, int value, LanguageId languageId = SrsReportRunUtil::getCurrentUserLangId())
{
    DictEnum dictEnum;
    int      valueIndex, valueBuf;
    ;
    dictEnum = new DictEnum(enumId);
    if (dictEnum)
    {

        for (valueIndex = 0 ; valueIndex < dictEnum.values(); valueIndex++)
        {
            valueBuf = dictEnum.index2Value(valueIndex);
            if (valueBuf == value)
                return SysLabel::labelId2String(dictEnum.index2LabelId(valueIndex), languageId);
        }
    }
    return '';
}


/// <summary>
///     Converts time value into string with hours and minutes. Mostly used when generating file names
/// </summary>
/// <param name="time">
///     Time as integer
/// </param>
/// <returns>
///     Time converted to string in format HHMM
/// </returns>
public static TempStr time2StrHM(int time)
{
    return num2str( time div 3600       ,2,0,0,0) + num2Str0(time mod 3600 div 60,2,0,0,0);
}

/// <summary>
///     Converts any value to string. This is hardcoded conversion without using culture context
/// </summary>
/// <param name="_value">
///     The value to convert
/// </param>
/// <returns>
///     Converted value as string
/// </returns>
public static str any2String(anytype _value)
{
    switch(typeOf(_value))
    {
        // BP deviation documented
        case Types::Date: return date2str(_value, -1,-1,-1,-1,-1,-1,DateFlags::None);
        case Types::Time: return KrishhUtils::time2StrHM(_value);
        case Types::Int64, Types::Integer: return int2str(_value);
        case Types::Real: return strFmt('%1', _value);
        case Types::Enum: return strFmt('%1', _value);
        case Types::UtcDateTime: return DateTimeUtil::toStr(DateTimeUtil::applyTimeZoneOffset(_value, DateTimeUtil::getUserPreferredTimeZone())); // Hotfix 52
        default: return strFmt('%1', _value);
    }
    return "";
}


/// <summary>
///     Checks full path, and if \ is missing at the end - adds it
/// </summary>
/// <param name="path">
///     Full path to analyse
/// </param>
/// <returns>
///     Full path with \ at the end
/// </returns>
public static str fixPath(str path)
{
    str buf = strLRTrim(path);
    if (!path)
        return "";
    if (subStr(buf, strLen(buf),1) != '\\')
        buf = buf + '\\';
    return buf;
}

/// <summary>
///     Generates temporrary file with extension. Also creates file and saves it.
/// </summary>
/// <param name="filePrefix">
///     File prefix to use
/// </param>
/// <param name="extension">
///     Extension to use
/// </param>
/// <param name="filePath">
///     File path to use
/// </param>
/// <returns>
///     Created temporrary file name
/// </returns>
/// <remarks>
///     Creates empty file with unique name. Safe to use with multiple threads
/// </remarks>
/// <exception cref="Exception::Error">
///     When 10 attempts to create file failed
/// </exception>
/// <exception cref="Exception::Error">
///     When 10 attempts to create file failed
/// </exception>
public static str getTempFile(str filePrefix, str extension, str filePath = '')
{
    #File
    str                  tmpPath;
    str                  fileName;
    System.IO.FileStream fileStream;
    boolean              ok;
    int                  i;

    if (filePath)
        tmpPath = KrishhUtils::fixPath(filePath);
    else
    {
        new InteropPermission(InteropKind::ClrInterop).assert();
        tmpPath = System.IO.Path::GetTempPath();
        CodeAccessPermission::revertAssert();
    }
    while(!ok)
    {
        fileName = tmpPath + (filePrefix?filePrefix:filePrefix + guid2str(newGuid())) + extension; // First attempt direct
        new InteropPermission(InteropKind::ClrInterop).assert();
        while(System.IO.File::Exists(fileName))
        {
            fileName = tmpPath + filePrefix + guid2str(newGuid()) + extension;
        }
        CodeAccessPermission::revertAssert();
        try
        {
            i++;
            if (i>10)
                throw Exception::Error;
            new FileIOPermission(fileName, #IO_WRITE).assert();
            fileStream = System.IO.File::Create(fileName);
            fileStream.Dispose();
            CodeAccessPermission::revertAssert();
            ok = true;
        }
        catch (Exception::Error)
        {
            throw error("@SYS326095");
        }
        catch
        {
            exceptionTextFallThrough();
            CodeAccessPermission::revertAssert();
        }
    }

    return fileName;
}



/// <summary>
///     Returns the number associated with the specified month name.
/// </summary>
/// <param name="_monthName">
/// The name of the month.
/// </param>
/// <returns>
/// The number associated with the month name.
/// </returns>
public static int monthUSName2Num(str _monthName)
{
    int ret;
    str monthName = _monthName;
    #Define.month1('january')
    #Define.jan('jan')
    #Define.month2('february')
    #Define.feb('feb')
    #Define.month3('march')
    #Define.mar('mar')
    #Define.month4('april')
    #Define.apr('apr')
    #Define.month5('may')
    #Define.month6('june')
    #Define.jun('jun')
    #Define.month7('july')
    #Define.jul('jul')
    #Define.month8('august')
    #Define.aug('aug')
    #Define.month9('september')
    #Define.sep('sep')
    #Define.month10('october')
    #Define.oct('oct')
    #Define.month11('november')
    #Define.nov('nov')
    #Define.month12('december')
    #Define.dec('dec');

    monthName = strLwr(_monthName);

    switch(monthName)
    {
        case #month1:
        case #jan:
            ret = 1;
            break;
        case #month2:
        case #feb:
            ret = 2;
            break;
        case  #month3:
        case #mar:
            ret = 3;
            break;
        case #month4:
        case #apr:
            ret = 4;
            break;
        case #month5:
            ret = 5;
            break;
        case #month6:
        case #jun:
            ret = 6;
            break;
        case #month7:
        case #jul:
            ret = 7;
            break;
        case #month8:
        case #aug:
            ret = 8;
            break;
        case #month9:
        case #sep:
            ret = 9;
            break;
        case #month10:
        case #oct:
            ret = 10;
            break;
        case #month11:
        case #nov:
            ret = 11;
            break;
        case #month12:
        case #dec:
            ret = 12;
            break;
        default:
            ret = 0;
            break;
    }
    return ret;
}


Get DimensionAttribute by providing the dimensionnumber



public static dimensionAttribute getDimensionByNumber(int _dimensionNumber)
{
    RecId companyLedger =  Ledger::findByLegalEntity(CompanyInfo::findDataArea(curext()).RecId).RecId;
    DimensionAttribute dimensionAttribute;
    Query query = new Query();
    QueryBuildDataSource qbd;
    QueryRun qr;
    ;
    if (! _dimensionNumber)
    {
        return dimensionAttribute;
    }
    qbd = query.addDataSource(tableNum(dimensionAttribute));
    qbd.fields().dynamic(false);
    qbd.fields().addField(fieldNum(dimensionAttribute, Name));
    qbd.addOrderByField(fieldNum(dimensionAttribute, Name));
    qbd.addGroupByField(fieldNum(dimensionAttribute, Name));
    qbd.addRange(fieldNum(dimensionAttribute, RecId)).value(queryNotValue(DimensionAttribute::getMainAccountDimensionAttribute()));
    qbd = qbd.addDataSource(tableNum(dimensionHierarchyLevel));
    qbd.fields().dynamic(true);
    qbd.relations(true);

    qbd = qbd.addDataSource(tableNum(ledgerStructure));
    qbd.relations(false);
    qbd.addLink(fieldNum(dimensionHierarchyLevel, DimensionHierarchy), fieldNum(ledgerStructure, DimensionHierarchy));
    qbd.addRange(fieldNum(ledgerStructure, Ledger)).value(queryvalue(companyLedger));

    qr = new QueryRun(query);
    qr.enablePositionPaging(true);
    qr.addPageRange(_dimensionNumber,1);
    if (qr.next())
    {
        dimensionAttribute = qr.getNo(1);
    }
    return dimensionAttribute;
}

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 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();
    }
}