diff --git a/PartSource.Automation/Jobs/TestJob.cs b/PartSource.Automation/Jobs/TestJob.cs index 891f20e..b3c8f71 100644 --- a/PartSource.Automation/Jobs/TestJob.cs +++ b/PartSource.Automation/Jobs/TestJob.cs @@ -24,7 +24,7 @@ namespace PartSource.Automation.Jobs #pragma warning disable CS1998, CA1303 public async Task Run(CancellationToken token, params string[] arguments) { - // _emailService.Send("Automation Test Message", "This is a test email from the automation server. If this message was in your spam folder, whitelist the address that sent this email."); + _emailService.Send("Automation Test Message", "This is a test email from the automation server. If this message was in your spam folder, whitelist the address that sent this email."); _logger.LogInformation("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc scelerisque congue euismod. Curabitur enim eros, sollicitudin ac purus eget, dignissim mattis augue. In quam sapien, tincidunt et elementum vitae, interdum vitae sem."); _logger.LogWarning("Praesent feugiat sapien non suscipit faucibus. Mauris fermentum ut augue a feugiat. Integer felis sem, laoreet et augue at, finibus maximus ex. Fusce sit amet erat non tortor porta condimentum condimentum quis ipsum."); diff --git a/PartSource.Automation/Jobs/UpdatePricing.cs b/PartSource.Automation/Jobs/UpdatePricing.cs index b22ef4f..c6112b6 100644 --- a/PartSource.Automation/Jobs/UpdatePricing.cs +++ b/PartSource.Automation/Jobs/UpdatePricing.cs @@ -76,7 +76,8 @@ namespace PartSource.Automation.Jobs try { - _shopifyClient.BulkActions.Add(new Metafield + + await _shopifyClient.Metafields.Add(new Metafield { Namespace = "Pricing", Key = "CorePrice", @@ -85,24 +86,16 @@ namespace PartSource.Automation.Jobs OwnerResource = "product", OwnerId = product.Id }); + + await _shopifyClient.Products.Update(product); + + _logger.LogInformation("Updated product id {productId}", product.Id); } catch (Exception ex) { - _logger.LogWarning(ex, $"Failed to update pricing for product ID {product.Id}"); + _logger.LogWarning(ex, "Failed to update pricing for product ID {productId}", product.Id); } - - - } - - try - { - _shopifyClient.BulkActions.Update(product); - } - - catch (Exception ex) - { - _logger.LogWarning(ex, $"Failed to update pricing for product ID {product.Id}"); } } } @@ -119,14 +112,9 @@ namespace PartSource.Automation.Jobs _logger.LogWarning(ex, "Failed to get the next set of products. Retrying"); products = await _shopifyClient.Products.GetPrevious(); } - } - while (_shopifyClient.BulkActions.PendingCount() > 0) - { - await Task.Delay(15 * 1000, token); - _logger.LogInformation(_shopifyClient.BulkActions.PendingCount().ToString()); + _emailService.Send("Pricing Update Completed", $"The pricing update has completed."); } - // _emailService.Send("Pricing Update Completed", $"The pricing update has completed."); } } } \ No newline at end of file diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index a6ead01..75027f0 100644 --- a/PartSource.Automation/Program.cs +++ b/PartSource.Automation/Program.cs @@ -63,7 +63,7 @@ namespace PartSource.Automation { options.ApiKey = builder.Configuration["Shopify:ApiKey"]; options.ApiSecret = builder.Configuration["Shopify:ApiSecret"]; - options.ApiVersion = "2022-10"; + options.ApiVersion = "2024-10"; options.ShopDomain = builder.Configuration["Shopify:ShopDomain"]; //options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed"; @@ -92,23 +92,23 @@ namespace PartSource.Automation //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) // .StartsAt(DateTime.Parse("2021-04-01 08:00:00")) //) - .HasJob(options => - options.HasInterval(new TimeSpan(24, 0, 0)) - .StartsAt(DateTime.Today.AddHours(-24)) - ) + //.HasJob(options => + // options.HasInterval(new TimeSpan(24, 0, 0)) + // .StartsAt(DateTime.Today.AddHours(-24)) + // ) .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) .StartsAt(DateTime.Today.AddHours(-22)) - .HasDependency() - ) - .HasJob(options => - options.HasInterval(new TimeSpan(1, 0, 0)) - .StartsAt(DateTime.Today.AddHours(-27)) - ) - .HasJob(options => - options.HasInterval(new TimeSpan(1, 0, 0)) - .StartsAt(DateTime.Today.AddHours(-27).AddMinutes(30)) - ); + //.HasDependency() + ); + //.HasJob(options => + // options.HasInterval(new TimeSpan(1, 0, 0)) + // .StartsAt(DateTime.Today.AddHours(-27)) + // ); + //.HasJob(options => + // options.HasInterval(new TimeSpan(1, 0, 0)) + // .StartsAt(DateTime.Today.AddHours(-27).AddMinutes(30)) + //); //.HasJob(options => options.HasInterval(new TimeSpan(1, 0, 0)) //.HasDependency() diff --git a/PartSource.Automation/appsettings.json b/PartSource.Automation/appsettings.json index 03017bf..84e9124 100644 --- a/PartSource.Automation/appsettings.json +++ b/PartSource.Automation/appsettings.json @@ -6,8 +6,8 @@ }, "emailConfiguration": { "From": "alerts@ps-automation.eastus2.cloudapp.azure.com", - "To": "tom@soundpress.com,Anas.Bajwa@Partsource.ca,josh@soundpress.com,alex.au@partsource.ca,michael.massara@partsource.ca", - //"To": "tom@tomraterman.com", + "To": "tom@soundpress.com,josh@soundpress.com,alex.au@partsource.ca,michael.massara@partsource.ca", + //"To": "tom@tomraterman.com,josh@soundpress.com", "SmtpHost": "localhost" }, "FtpServers": {