【问题标题】:AX 2012 - Get Instance Name not Server Name in X++AX 2012 - 在 X++ 中获取实例名称而不是服务器名称
【发布时间】:2015-11-16 21:01:24
【问题描述】:

是否可以在 X++ 中获取 Instance Name 而不是 Server Name?

附图显示了我正在寻找的字段:

当我使用xSession.AOSName(); 时,它返回服务器名称,当我使用sysServerSessions..Instance_Name; 时,返回一个空字符串。 Instance_Name 字段在数据库中只有“01”,所以如果它确实返回一个值,它仍然是不正确的。

【问题讨论】:

    标签: axapta microsoft-dynamics x++


    【解决方案1】:

    Instance name (optional),我相信只是文件夹名称和服务显示名称。因此,当您创建多个实例时,它会创建一个文件夹 C:\Program Files\Microsoft Dynamics AX\60\Server\[InstanceName]\,然后创建一个具有该实例显示名称的 AOS 服务。

    如果您真的想要它,您可以枚举文件夹并使用正则表达式或任何数量的其他方法对其进行解析。要枚举文件夹,请在某处创建此 server 静态方法并调用它:

    static server FilenameOpen pathServer()
    {
        return xInfo::directory(DirectoryType::Bin);
    }
    

    还有一个ServerId,我觉得和Instance Name不一样,但是在SysServerConfig表里:

    while select sysServerConfig
    {
        info(strFmt("%1", sysServerConfig.ServerId));
    }
    

    而ServerId 是从 AOSId 和名称等派生的值。您可以在此方法中查看它是如何派生的: \Data Dictionary\Tables\SysServerConfig\Methods\delete

    【讨论】:

    • 谢谢亚历克斯。创建服务器静态方法有效。我添加了一些额外的逻辑来检索实例名称。
    【解决方案2】:

    下面是 Alex 获取实例名称的答案的附加逻辑。

    static server str getAOSInstanceName()
    {
        str serverPath;
        str instanceName;
    
        int fullPathLen;
        int serverNameEnd;
        int instanceNameStart;
    
        //Get the full path of the AOS Server install.
        serverPath = xInfo::directory(DirectoryType::Bin);
    
        fullPathLen = strLen(serverPath);
    
        //Get the location of where the Instance Names Ends. "-5" represents "\bin\" in the full path.
        serverNameEnd = fullPathLen - 5;
    
        //Get the location where the Instance Name Starts - 1.
        instanceNameStart = strFind(serverPath, @"\", serverNameEnd, - fullPathLen);
    
        //Get the Instance Name.
        instanceName = subStr(serverPath, instanceNameStart + 1, serverNameEnd - serverNameStart);
    
        return instanceName;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-12
      • 2012-05-24
      • 1970-01-01
      • 2017-03-02
      • 1970-01-01
      相关资源
      最近更新 更多