Hi

The simplest way to create an export containing changes in USR layer is :
1. Create an empty project and open it
2. Click "filter" button
3. Click "Choose"
4. Type "USR" in the row with "utilLevel"
5. OK, OK
6. Project containing objects changed in USR level will be created for
you, now you can export it

However if you'd like to automate this process - the better way is to
use UtilIdElements pseudo-table instead of drilling down the AOT tree
using TreeNode objects. Look at the xUtilIdElements class to get the
idea of how they work (actually TreeNodes work on top of UtilIdElements).

--
Wojciech Lewicki

>
> Hi guys,
>
> could anyone help optimize this code? I'm new in X++, so don't expect
> much from this...
> What this does it exports all objects in the "usr" layer to files in
> the C:\TEMP dir. The main idea is to collect this from different
> servers and check for diferences, so I know what needs to be updated
> at each server.
>
> Tanks
>
>
> static void Job1(Args _args)
> {
>       ProjectNode         MainProjectNode;
>       ProjectNode         ProjectNode;
>       ProjectNode         SubProjectNode;
>       ProjectNode         MainFather;
>       ProjectNode         Father;
>       ProjectNode         SubFather;
>       ProjectNode         MainChild;
>       ProjectNode         Child;
>       ProjectNode         SubChild;
>       TreeNode            usrLayer;
>       TreeNodeIterator    MainIterator;
>       TreeNodeIterator    Iterator;
>       TreeNodeIterator    SubIterator;
>       str ObjectProperties;
>       str ObjectType;
>       ;
>
>       MainProjectNode = infolog.rootNode();
>       MainFather = MainProjectNode;
>
>       MainProjectNode = MainProjectNode.AOTfirstChild();
>
>       MainIterator = MainFather.AOTiterator();
>
>       MainChild = MainIterator.next();
>       while(MainChild)
>       {
>             if(MainChild.AOTchildNodeCount() > 0)
>             {
>                   Father = MainChild;
>                   Iterator = Father.AOTiterator();
>                   Child = Iterator.next();
>                   While(Child)
>                   {
>                         if(Child.AOTchildNodeCount() > 0)
>                         {
>                               ObjectProperties = Child.AOTgetProperties();
>                               if(ObjectProperties != "")
>                               {
>                                     usrLayer = Child.getNodeInLayer( UtilEntryLevel::usr);
>                                     if(usrLayer)
>                                     {
>                                           ObjectType = usrLayer.AOTtypeStr();
>                                           usrLayer.treeNodeExport('C:\\temp\\' + Mainchild.AOTname() +
> '-' + child.AOTname() + '_' + ObjectType + '.xpo',1); // Subbu, pls
> appened the content
>                                     }
>                               }
>                               else
>                               {
>                                     SubFather = Child;
>                                     SubIterator = SubFather.AOTiterator();
>                                     SubChild = SubIterator.next();
>                                     While(SubChild)
>                                     {
>                                           if(SubChild.AOTchildNodeCount() > 0)
>                                           {
>                                                 ObjectProperties = SubChild.AOTgetProperties();
>                                                 if(ObjectProperties != "")
>                                                 {
>                                                       usrLayer = SubChild.getNodeInLayer( UtilEntryLevel::usr);
>                                                       if(usrLayer)
>                                                       {
>                                                             ObjectType = usrLayer.AOTtypeStr();
>                                                             usrLayer.treeNodeExport('C:\\temp\\' + Mainchild.AOTname() +
> '-' + child.AOTname() + '-' + SubChild.AOTname() + '_' + ObjectType +
> '.xpo',1); // Subbu, pls appened the content
>                                                       }
>                                                 }
>                                           }
>                                           else
>                                           {
>                                                 usrLayer = Child.getNodeInLayer( UtilEntryLevel::usr);
>                                                 if(usrLayer)
>                                                 {
>                                                       ObjectType = usrLayer.AOTtypeStr();
>                                                       usrLayer.treeNodeExport('C:\\temp\\' + Mainchild.AOTname() +
> '-' + child.AOTname() + '-' + SubChild.AOTname() + '_' + ObjectType +
> '.xpo',1); // Subbu, pls appened the content
>                                                 }
>                                           }
>                                           SubChild = SubIterator.next();
>                                     }
>                               }
>                         }
>                         else
>                         {
>                               usrLayer = Child.getNodeInLayer( UtilEntryLevel::usr);
>                               if(usrLayer)
>                               {
>                                     ObjectType = usrLayer.AOTtypeStr();
>                                     usrLayer.treeNodeExport('C:\\temp\\' + Mainchild.AOTname() + '-'
> + child.AOTname() + '_' + ObjectType + '.xpo',1); // Subbu, pls
> appened the content
>                               }
>                         }
>                         Child = Iterator.next();
>                   }
>             }
>             else
>             {
>                   usrLayer = MainChild.getNodeInLayer( UtilEntryLevel::usr);
>                   if(usrLayer)
>                   {
>                         ObjectType = usrLayer.AOTtypeStr();
>                         usrLayer.treeNodeExport('C:\\temp\\' + child.treeNodePath() + '-'
> + child.AOTname() + '_' + ObjectType + '.xpo',1); // Subbu, pls
> appened the content
>                   }
>             }
>             MainChild = MainIterator.next();
>       }
>
> }
>








SPONSORED LINKS
Computer part Programming languages Microsoft axapta
Support exchange


YAHOO! GROUPS LINKS




Reply via email to