从具有单个主键的输入表单导出数据

库存产品屏幕(IN.20.25.00)是最常用的数据输入表单 Acumatica ERP 的导出数据之一。库存 ID库存项目屏幕上唯一的主键 : StackOverflow 文档

要从数据输入表单导出记录,你的 SOAP 请求必须始终以 ServiceCommands.Every[Key] 命令开头,其中 [Key] 将替换为主键名称。

要在单个 Web 服务调用中导出所有库存项目:

Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaERP/Soap/IN202500.asmx";
context.Login(username, password);
try
{
    Content stockItemsSchema = PX.Soap.Helper.GetSchema<Content>(context);
    Field lastModifiedField = new Field
    {
        ObjectName = stockItemsSchema.StockItemSummary.InventoryID.ObjectName,
        FieldName = "LastModifiedDateTime"
    };
    var commands = new Command[]
    {
        stockItemsSchema.StockItemSummary.ServiceCommands.EveryInventoryID,
        stockItemsSchema.StockItemSummary.InventoryID,
        stockItemsSchema.StockItemSummary.Description,
        stockItemsSchema.GeneralSettingsItemDefaults.ItemClass,
        stockItemsSchema.GeneralSettingsUnitOfMeasureBaseUnit.BaseUnit,
        lastModifiedField
    };
    var items = context.Export(commands, null, 0, false, false);
}
finally
{
    context.Logout();
}

随着时间的推移,任何 ERP 应用程序中的数据量都会增加。如果你要在单个 Web 服务调用中导出 Acumatica ERP 实例中的所有记录,很快就会发现超时错误。增加超时可能是一次性但不是很好的长期解决方案。解决此挑战的最佳选择是分批导出多个记录的库存项目。

要分批导出 10 个记录的库存项目:

Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaERP/Soap/IN202500.asmx";
context.Login(username, password);
try
{
    Content stockItemsSchema = PX.Soap.Helper.GetSchema<Content>(context);
    Field lastModifiedField = new Field
    {
        ObjectName = stockItemsSchema.StockItemSummary.InventoryID.ObjectName,
        FieldName = "LastModifiedDateTime"
    };
    var commands = new Command[]
    {
        stockItemsSchema.StockItemSummary.ServiceCommands.EveryInventoryID,
        stockItemsSchema.StockItemSummary.InventoryID,
        stockItemsSchema.StockItemSummary.Description,
        stockItemsSchema.GeneralSettingsItemDefaults.ItemClass,
        stockItemsSchema.GeneralSettingsUnitOfMeasureBaseUnit.BaseUnit,
        lastModifiedField
    };
    var items = context.Export(commands, null, 10, false, false);

    while (items.Length == 10)
    {
        var filters = new Filter[]
        {
            new Filter
            {
                Field = stockItemsSchema.StockItemSummary.InventoryID,
                Condition = FilterCondition.Greater,
                Value = items[items.Length - 1][0]
            }
        };
        items = context.Export(commands, filters, 10, false, false);
    }
}
finally
{
    context.Logout();
}

单一呼叫方法与批量导出之间存在两个主要差异:

  • **** 在单次调用方法中, Export 命令的 topCount 参数始终设置为 0

  • 批量导出记录时,通过由 Filter 数组补充的 topCount 参数配置批量大小以请求下一个结果集 ****