通过基于SOAP契约的API从Acumatica导出大量数据的推荐方法是什么?
答案 0 :(得分:0)
Stock Items 屏幕(IN.20.25.00)是Acumatica ERP中用于导出数据的最常用数据输入形式之一。 广告资源ID 是 Stock Items 屏幕上唯一的主键:
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实例中的所有记录,很快就会发现超时错误。增加超时可能是一次性的,但不是非常好的长期解决方案。解决这一挑战的最佳选择是分批导出库存物品。
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 属性
批量导出记录时,批量大小是通过传递给GetList
方法的实体的 RowNumber 属性配置的,以请求下一个结果集
销售订单屏幕(SO.30.10.00)是具有复合主键的数据输入表单的完美示例。 销售订单屏幕上的主键由 订单类型 和 订单号 <组成/强>:
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();
}
}
上面的示例演示了如何从100个记录的批次中导出Acumatica ERP的所有销售订单。我们首先要求从Acumatica获得前100个销售订单。之后,我们独立地导出每种类型的销售订单:您的SOAP请求获得相同的先前收到的类型的下一个100个订单或下一个订单类型的前100个销售订单。