You pass remainingCreates
as the batchSize
parameter but your code never references batchSize
so you are just going to reenter that while
loop every time.
Also, I'm not sure how you are doing all your error handling but you need to update your catch
block so that it doesn't just let FaultExceptions pass-through if they don't contain a MaxBatchSize
value. Right now, if you take a FaultException
regarding something other than batch size it will be ignored.
{
if (fault.Detail.ErrorDetails.Contains("MaxBatchSize"))
{
var allowedBatchSize = Convert.ToInt32(fault.Detail.ErrorDetails["MaxBatchSize"]);
int remainingCreates = batchSize;
while (remainingCreates > 0)
{
var recordsToCreate = Math.Min(remainingCreates, allowedBatchSize);
UpdateMultipleProducts(service, recordsToCreate, UpdateProductsCollection, PriceListGuid);
remainingCreates -= recordsToCreate;
}
}
else throw;
}