通过基于 SOAP 合同的 Acumatica 导出记录 API
Exporting Records from Acumatica via SOAP Contract-Based API
通过基于 SOAP 合同的 Acumatica 导出大量数据的推荐方法是什么API?
使用单个主键从条目表单导出数据
库存项目 屏幕 (IN.20.25.00) 是 Acumatica ERP 导出数据最常用的数据输入形式之一。 库存 ID 是 库存物品 屏幕上唯一的主键:
要在单个 Web 服务调用中导出所有库存项目:
using (DefaultSoapClient client = new DefaultSoapClient())
{
client.Login(username, password, null, null, null);
try
{
var items = client.GetList(new StockItem());
}
finally
{
client.Logout();
}
}
随着时间的推移,任何 ERP 应用程序中的数据量都趋于增长。如果您将在单个 Web 服务调用中从 Acumatica ERP 实例中导出所有记录,很快您可能会注意到超时错误。增加超时是一种可能的一次性解决方案,但不是很好的长期解决方案。应对这一挑战的最佳选择是以多条记录为单位批量导出库存项目。
要以 10 条记录为一组导出库存项目:
using (DefaultSoapClient client = new DefaultSoapClient())
{
client.Login(username, password, null, null, null);
try
{
var items = client.GetList(
new StockItem
{
RowNumber = new LongSearch
{
Condition = LongCondition.IsLessThan,
Value = 10
}
});
while (items.Length == 10)
{
StockItem filter = new StockItem
{
RowNumber = new LongSearch
{
Condition = LongCondition.IsLessThan,
Value = 10
},
InventoryID = new StringSearch
{
Condition = StringCondition.IsGreaterThan,
Value = (items[items.Length - 1] as StockItem).InventoryID.Value
}
};
}
}
finally
{
client.Logout();
}
}
单次调用方式和批量导出方式有两个主要区别:
RowNumber 属性 的 StockItem 实体未在单一调用方法中使用
批量导出记录时,批量的大小通过RowNumber 属性配置,实体传入GetList
方法请求下一个结果集
从具有复合主键的条目表单中导出数据
销售订单 屏幕 (SO.30.10.00) 是具有复合主键的数据输入表单的完美示例。 销售订单屏幕上的主键由订单类型和订单号:
批量导出销售订单,每条记录100条:
using (DefaultSoapClient client = new DefaultSoapClient())
{
client.Login(username, password, null, null, null);
try
{
var orders = client.GetList(
new SalesOrder
{
OrderType = new StringReturn(),
OrderNbr = new StringReturn(),
RowNumber = new LongSearch
{
Condition = LongCondition.IsLessThan,
Value = 100
},
ReturnBehavior = ReturnBehavior.OnlySpecified
});
bool sameOrderType = true;
while (orders.Length > 0 && (orders.Length == 100 || !sameOrderType))
{
SalesOrder filter = new SalesOrder
{
RowNumber = new LongSearch
{
Condition = LongCondition.IsLessThan,
Value = 100
},
OrderType = new StringSearch
{
Condition = sameOrderType ? StringCondition.Equal : StringCondition.IsGreaterThan,
Value = (orders[orders.Length - 1] as SalesOrder).OrderType.Value
},
OrderNbr = new StringSearch
{
Condition = StringCondition.IsGreaterThan,
Value = sameOrderType ? (orders[orders.Length - 1] as SalesOrder).OrderNbr.Value : string.Empty
},
ReturnBehavior = ReturnBehavior.OnlySpecified
};
orders = client.GetList(filter);
sameOrderType = orders.Length == 100;
}
}
finally
{
client.Logout();
}
}
上面的示例演示了如何从 Acumatica ERP 中以 100 条记录为一组导出所有销售订单。我们从请求从 Acumatica 获得前 100 个销售订单开始。之后,我们独立导出每种类型的销售订单:您的 SOAP 请求获取之前收到的相同类型的下 100 个订单或下一个订单类型的前 100 个销售订单。
通过基于 SOAP 合同的 Acumatica 导出大量数据的推荐方法是什么API?
使用单个主键从条目表单导出数据
库存项目 屏幕 (IN.20.25.00) 是 Acumatica ERP 导出数据最常用的数据输入形式之一。 库存 ID 是 库存物品 屏幕上唯一的主键:
要在单个 Web 服务调用中导出所有库存项目:
using (DefaultSoapClient client = new DefaultSoapClient())
{
client.Login(username, password, null, null, null);
try
{
var items = client.GetList(new StockItem());
}
finally
{
client.Logout();
}
}
随着时间的推移,任何 ERP 应用程序中的数据量都趋于增长。如果您将在单个 Web 服务调用中从 Acumatica ERP 实例中导出所有记录,很快您可能会注意到超时错误。增加超时是一种可能的一次性解决方案,但不是很好的长期解决方案。应对这一挑战的最佳选择是以多条记录为单位批量导出库存项目。
要以 10 条记录为一组导出库存项目:
using (DefaultSoapClient client = new DefaultSoapClient())
{
client.Login(username, password, null, null, null);
try
{
var items = client.GetList(
new StockItem
{
RowNumber = new LongSearch
{
Condition = LongCondition.IsLessThan,
Value = 10
}
});
while (items.Length == 10)
{
StockItem filter = new StockItem
{
RowNumber = new LongSearch
{
Condition = LongCondition.IsLessThan,
Value = 10
},
InventoryID = new StringSearch
{
Condition = StringCondition.IsGreaterThan,
Value = (items[items.Length - 1] as StockItem).InventoryID.Value
}
};
}
}
finally
{
client.Logout();
}
}
单次调用方式和批量导出方式有两个主要区别:
RowNumber 属性 的 StockItem 实体未在单一调用方法中使用
批量导出记录时,批量的大小通过RowNumber 属性配置,实体传入
GetList
方法请求下一个结果集
从具有复合主键的条目表单中导出数据
销售订单 屏幕 (SO.30.10.00) 是具有复合主键的数据输入表单的完美示例。 销售订单屏幕上的主键由订单类型和订单号:
批量导出销售订单,每条记录100条:
using (DefaultSoapClient client = new DefaultSoapClient())
{
client.Login(username, password, null, null, null);
try
{
var orders = client.GetList(
new SalesOrder
{
OrderType = new StringReturn(),
OrderNbr = new StringReturn(),
RowNumber = new LongSearch
{
Condition = LongCondition.IsLessThan,
Value = 100
},
ReturnBehavior = ReturnBehavior.OnlySpecified
});
bool sameOrderType = true;
while (orders.Length > 0 && (orders.Length == 100 || !sameOrderType))
{
SalesOrder filter = new SalesOrder
{
RowNumber = new LongSearch
{
Condition = LongCondition.IsLessThan,
Value = 100
},
OrderType = new StringSearch
{
Condition = sameOrderType ? StringCondition.Equal : StringCondition.IsGreaterThan,
Value = (orders[orders.Length - 1] as SalesOrder).OrderType.Value
},
OrderNbr = new StringSearch
{
Condition = StringCondition.IsGreaterThan,
Value = sameOrderType ? (orders[orders.Length - 1] as SalesOrder).OrderNbr.Value : string.Empty
},
ReturnBehavior = ReturnBehavior.OnlySpecified
};
orders = client.GetList(filter);
sameOrderType = orders.Length == 100;
}
}
finally
{
client.Logout();
}
}
上面的示例演示了如何从 Acumatica ERP 中以 100 条记录为一组导出所有销售订单。我们从请求从 Acumatica 获得前 100 个销售订单开始。之后,我们独立导出每种类型的销售订单:您的 SOAP 请求获取之前收到的相同类型的下 100 个订单或下一个订单类型的前 100 个销售订单。