public void RunStockItems(DateTime?lastModifiedMinUtc = null) { var startOfRun = DateTime.UtcNow; var page = 1; var lastModifiedAcuTime = lastModifiedMinUtc.HasValue ? _instanceTimeZoneService.ToAcumaticaTimeZone(lastModifiedMinUtc.Value) : (DateTime?)null; while (true) { var json = _inventoryClient.RetrieveStockItems( page: page, pageSize: _config.PageSize, lastModifiedAcuTz: lastModifiedAcuTime); var stockItems = json.DeserializeFromJson <List <StockItem> >(); UpsertStockItemToPersist(stockItems); if (stockItems.Count == 0) { break; } page++; } var batchStateEnd = startOfRun.AddAcumaticaBatchFudge(); _batchStateRepository.UpdateStockItemGetEnd(batchStateEnd); }