private void Run(DateTime?shopifyProductsGetEnd) { if (_jobMonitoringService.DetectCurrentJobInterrupt()) { return; } var filter = new SearchFilter(); filter.UpdatedAtMinUtc = shopifyProductsGetEnd; // We've hanging on to this to compute the end of the Batch State // var startOfRun = DateTime.UtcNow; var results = _productApi.RetrieveProducts(filter); while (true) { var products = results.Body.DeserializeFromJson <ProductList>().products; UpsertProductsAndInventory(products); if (_jobMonitoringService.DetectCurrentJobInterrupt()) { return; } if (results.LinkHeader.NoMo()) { break; } //if (currentProducts.Count == 0) //{ // break; //} results = _productApi.RetrieveProducts(results.LinkHeader.NextLink); } // Process Delete Events // if (shopifyProductsGetEnd.HasValue) { PullDeletedEventsAndUpsert(shopifyProductsGetEnd.Value); } // Compute the Batch State end marker // var batchEnd = startOfRun.SubtractFudgeFactor(); _batchRepository.UpdateProductsGetEnd(batchEnd); }
private void HydrateExternalJson(int shopifyJsonType, long shopifyId) { if (shopifyJsonType == ShopifyJsonType.Location) { var json = _inventoryApi.RetrieveLocation(shopifyId); UpdateRecord(shopifyJsonType, shopifyId, json); } if (shopifyJsonType == ShopifyJsonType.Customer) { var json = _customerApi.Retrieve(shopifyId); UpdateRecord(shopifyJsonType, shopifyId, json); } if (shopifyJsonType == ShopifyJsonType.Product) { var json = _productApi.RetrieveProducts(shopifyId); UpdateRecord(shopifyJsonType, shopifyId, json); } if (shopifyJsonType == ShopifyJsonType.Variant) { var json = _productApi.RetrieveVariant(shopifyId); UpdateRecord(shopifyJsonType, shopifyId, json); } if (shopifyJsonType == ShopifyJsonType.Order) { var json = _orderApi.Retrieve(shopifyId); UpdateRecord(shopifyJsonType, shopifyId, json); } if (shopifyJsonType == ShopifyJsonType.Transaction) { var transactions = _orderApi.RetrieveTransactions(shopifyId) .DeserializeFromJson <List <Push.Shopify.Api.Transactions.Transaction> >(); foreach (var transaction in transactions) { UpdateRecord(shopifyJsonType, transaction.id, transaction.SerializeToJson()); } } throw new NotImplementedException(); }