0

テーブル名を取得するために、X++ で次のコードを使用しています。

client server public static container tableNames()
{
tableId         tableId;
int             tablecounter;
Dictionary      dict = new Dictionary();
container       tableNamesList;

for (tablecounter=1; tablecounter<=dict.tableCnt(); tablecounter++)
{
    tableId = dict.tableCnt2Id(tablecounter);
    tableNamesList = conIns(tableNamesList,1,dict.tableName(tableId));
}

return tableNamesList;
}

ビジネス コネクタ コード:

tablesList = (AxaptaContainer)Global.ax.
                CallStaticClassMethod("Code_Generator", "tableNames");

for (int i = 1; i <= tablesList.Count; i++)
{
    tableName = tablesList.get_Item(i).ToString();
    tables.Add(tableName);
}

データのフェッチ中に、アプリケーションが 2 ~ 3 分間ハングします。原因は何ですか?最適化はありますか?

4

4 に答える 4

0

前に述べたように、コンテナの新しいコピーを作成するため、コンテナに要素を追加するときはconIns()を避けてください。代わりに+=を使用して、その場で追加します。

また、権限を確認し、一時テーブル、テーブルマップ、およびその他の特殊なケースを除外することもできます。Standard Axeには、これらのことを考慮したテーブル名ルックアップフォームを作成する方法があります。詳細については、メソッドGlobal :: pickTable()を確認してください。

ビジネスコネクタを介した一部の呼び出しも回避し、同様の方法でAxでリスト全体を作成し、それを1回の関数呼び出しで返すことができます。

于 2013-02-01T14:55:06.697 に答える
0

Dynamics Ax 2012 を使用している場合は、treeNode をスキップし、SysModelElement テーブルを使用してデータを取得し、すぐに .Net 配列として返すことで、反対側の作業を簡単にすることができます。

public static System.Collections.ArrayList FetchTableNames_ModelElementTables()
{
    SysModelElement                 element;
    SysModelElementType             elementType;
    System.Collections.ArrayList    tableNames = new System.Collections.ArrayList();
    ;  

    // The SysModelElementType table contains the element types 
    // and we need the recId for the next selection
    select firstonly RecId
    from  elementType
    where elementType.Name == 'Table';

    // With the recId of the table element type, 
    // select all of the elements with that type (hence, select all of the tables)
    while select Name
        from element
        where element.ElementType == elementType.RecId
    {
        tableNames.Add(element.Name);
    }

    return tableNames;
    }
}
于 2013-02-03T21:24:27.330 に答える
0

さて、私は多くのことを試しましたが、最終的に、すべてのテーブル名で構成されるテーブルを作成することにしました。このテーブルには、ジョブが入力されます。このテーブルからレコードを取得しています。

于 2013-02-05T10:24:18.997 に答える