首页 > 其他分享 >Export AX model from code in a specific AOT layer

Export AX model from code in a specific AOT layer

时间:2023-05-05 09:34:09浏览次数:37  
标签:layer code modelElement modelElementData specific export modelManifest model whe

Recently we have decided to merge two AX models sitting in different layers with overlapping objects as part of our code cleanup exercise, thus the requirement came to export AX model from code in a specific AOT layer only.

The following 3 object types has to be exported:

  • X++ metadata and code
  • Project definitions
  • Label files

By providing the name of the model and the export path for the XPOs and labels, the following job can be executed to export AX model from code if you log on to the layer where the model is sitting:

 

static void WIK_ExportLayer(Args _args)
{
    #define.ModelToExport1("ISV Model")
    #define.ModelToExport2("USR Model")
    #define.ExportDestination(@"C:\Temp\")
    #AOTExport
    boolean     currentLayerOnly = true;

    void exportModel(ModelName _modelName)
    {
        ProjectNode             project;
        SysModelCreateProject   createProject   = SysModelCreateProject::construct();
        ProjectName             projectName     = strReplace(_modelName, ' ', '_') + '_All';
        SysModel                model;
        SysModelManifest        modelManifest;
        SysModelElement         modelElement;
        SysModelElementData     modelElementData;
        SysLabelFileExport      label           = SysLabelFileExport::construct();

        select firstOnly Model, RecId from modelManifest
            where modelManifest.Name == _modelName
            join Layer from model
                where modelManifest.Model   == model.RecId
                    && model.Layer          == currentAOLayer();

        createProject.parmModelId(modelManifest.RecId);
        createProject.parmProjectName(projectName);

        if (createProject.parmModelId())
        {
            // Export model metadata and source
            createProject.run();
            project = SysTreeNode::getPrivateProject().AOTfindChild(projectName);
            project.treeNodeExport(#ExportDestination + projectName + '.xpo', currentLayerOnly ? #export | #expLayer : #export);

            // Export label files and languages
            while select modelElement
                where modelElement.ElementType  == UtilElementType::LabelFileLanguage
                exists join modelElementData
                    where modelElementData.ModelId  == modelManifest.Model
                        && modelElement.RecId       == modelElementData.ModelElement
            {
                label.parmTreenode(TreeNode::findNode(SysTreeNode::modelElement2Path(modelElement)));
                label.parmPath(#ExportDestination);
                label.run();
            }

            // Export project definitions
            while select modelElement
                where modelElement.ElementType  == UtilElementType::SharedProject
                exists join modelElementData
                    where modelElementData.ModelId  == modelManifest.Model
                        && modelElement.RecId       == modelElementData.ModelElement
            {
                project = TreeNode::findNode(SysTreeNode::modelElement2Path(modelElement));
                if (!WinAPI::folderExists(#ExportDestination + 'Projects'))
                {
                    WinAPI::createDirectory(#ExportDestination + 'Projects');
                }
                project.treeNodeExport(#ExportDestination + @'Projects\' + enum2str(currentAOLayer()) + modelElement.Name + '.xpo', currentLayerOnly ? #export | #expProjectOnly | #expLayer : #export | #expProjectOnly);
            }
        }
        else
        {
            error(strFmt('Layer %1 does not have model %2', strUpr(enum2str(currentAOLayer())), _modelName));
        }
    }

    exportModel(#ModelToExport1);
    exportModel(#ModelToExport2);
}

The results will contain the three components we have identified – 1 XPO for the model, ALD files per label and language, and all shared project definitions in a subfolder.

标签:layer,code,modelElement,modelElementData,specific,export,modelManifest,model,whe
From: https://www.cnblogs.com/lingdanglfw/p/17373155.html

相关文章

  • [vscode] 代码提示不能默认选中第一项问题
    [vscode]代码提示不能默认选中第一项问题码代码时发现一个问题,有些代码提示无法选中第一项。如果是所有代码提示都无法选中第一项,直接百度。这里说的是另一种,部分代码无法默认选中。在输入类似class=“”这类代码的代码自动补全回车后,输入代码触发代码提示后不会默认选中第......
  • Codeforces Round 867 (Div. 3)
    A.TubeTubeFeed分析:从所有a[i]+i-1<=t的选择种取个max即可code:#include<bits/stdc++.h>usingnamespacestd;constintN=55;inta[N],b[N];intmain(){std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0); intt; cin>>t;......
  • Codeforces 908H - New Year and Boolean Bridges(FWT)
    一道挺有意思的题,并且感觉有点诈骗的成分在内(首先考虑分析三种字符的性质:显然任意两点\(i,j\)之间要么\(i\)可以到达\(j\),要么\(j\)可以到达\(i\),否则AOX三个一个都不能满足。如果两点间的状态是A,那么这两点必须在同一强连通分量内。如果两点间的状态是X,那么这......
  • 三步 让你的 vscode 自动编译ts文件
    1:环境安装tsc 作用:负责将ts 代码 转为 浏览器和nodejs识别的 js代码。/全局安装npminstall-gtypescript//检查是否安装成功tsc-v 2:自动编译运行tsc--init,创建tsconfig.json文件;修改tsconfig.json文件,设置编译后的js文件夹。快速查找outDir,输出......
  • LeetCode/简化路径
    简化unix文件路径1.分割提取+栈classSolution{public:stringsimplifyPath(stringpath){vector<string>names=split(path,'/');//消除/并得到待处理的多段文件名vector<string>stack;//这里需要使用栈来判断..的回跳for(string&na......
  • vscode使用git推送代码
    下载vscodehttps://code.visualstudio.com/点击应用管理搜素Chinese(Simplified)LanguagePackforVisualStudioCode点击安装后记得全屏安装,好了后会有提示点击蓝色的按钮vscode会自动重新启动命令如下桌面新建一个文件夹-随便起一个名字把你需要的代码......
  • [Leetcode] 0657. 机器人能否返回原点
    657.机器人能否返回原点题目描述在二维平面上,有一个机器人从原点(0,0)开始。给出它的移动顺序,判断这个机器人在完成移动后是否在 (0,0)处结束。移动顺序由字符串 moves 表示。字符move[i]表示其第i次移动。机器人的有效动作有 R(右),L(左),U(上)和D(下)。如果机器人在完......
  • [Leetcode] 0001. 两数之和
    1.两数之和题目描述给定一个整数数组nums 和一个整数目标值target,请你在该数组中找出和为目标值target 的那 两个 整数,并返回它们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。你可以按任意顺序返回答案。 示例1......
  • LeetCode 双周赛 103(2023/04/29)区间求和的树状数组经典应用
    本文已收录到AndroidFamily,技术和职场问题,请关注公众号[彭旭锐]提问。大家好,我是小彭。这场周赛是LeetCode双周赛第103场,难得在五一假期第一天打周赛的人数也没有少太多。这场比赛前3题比较简单,我们把篇幅留给最后一题。往期周赛回顾:LeetCode单周赛第342场·容......
  • django-channel 配置 channel layer 添加redis的账号和密码
    最近公司要使用django-channel搭建socket, 文档:https://channels.readthedocs.io/en/stable/introduction.html文档里面并没有写如果redis有账号和密码的话,怎么配置。配置方法:https://github.com/django/channels/issues/164#issuecomment-220513297如下:CHANNEL_LAYERS......