Compare commits
4 Commits
InventoryT
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| dcd1a9ccec | |||
| aee37eb8f7 | |||
| 0ce0dc35e1 | |||
| 1ddf18a400 |
@@ -1,8 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using PartSource.Data.Models;
|
using PartSource.Data.Models;
|
||||||
using PartSource.Services;
|
using PartSource.Services;
|
||||||
using System.Net;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace PartSource.Api.Controllers
|
namespace PartSource.Api.Controllers
|
||||||
{
|
{
|
||||||
@@ -37,7 +36,7 @@ namespace PartSource.Api.Controllers
|
|||||||
StoreNumber = inventory.Store,
|
StoreNumber = inventory.Store,
|
||||||
Sku = sku,
|
Sku = sku,
|
||||||
Quantity = inventory.QTY,
|
Quantity = inventory.QTY,
|
||||||
Updated = inventory.Updated ?? System.DateTime.MinValue
|
Updated = inventory.Updated
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"PartSourceDatabase": "Server=tcp:ps-whi.database.windows.net,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=ps-whi;Password=9-^*N5dw!6:|.5Q;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
|
"PartSourceDatabase": "Server=tcp:ps-whi.database.windows.net,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=ps-whi;Password=9-^*N5dw!6:|.5Q;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
|
||||||
"FitmentDatabase": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=automation;Password=)6L)XP%m(x-UU#M;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300"
|
|
||||||
//"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true"
|
//"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true"
|
||||||
"FitmentDatabase": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=sa;Password=GZ0`-ekd~[2u;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300"
|
"FitmentDatabase": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=sa;Password=GZ0`-ekd~[2u;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
dataTable.Columns.Add("Store", typeof(int));
|
dataTable.Columns.Add("Store", typeof(int));
|
||||||
dataTable.Columns.Add("SKU", typeof(string));
|
dataTable.Columns.Add("SKU", typeof(string));
|
||||||
dataTable.Columns.Add("QTY", typeof(int));
|
dataTable.Columns.Add("QTY", typeof(int));
|
||||||
dataTable.Columns.Add("Updated", typeof(DateTime));
|
dataTable.Columns.Add("Updated", typeof(string));
|
||||||
|
|
||||||
using StreamReader reader = new StreamReader(filename);
|
using StreamReader reader = new StreamReader(filename);
|
||||||
string line = reader.ReadLine(); // Burn the header row
|
string line = reader.ReadLine(); // Burn the header row
|
||||||
@@ -90,10 +90,12 @@ namespace PartSource.Automation.Jobs
|
|||||||
}
|
}
|
||||||
|
|
||||||
string sku = columns[1].Trim();
|
string sku = columns[1].Trim();
|
||||||
|
string updated = columns[3].Trim();
|
||||||
|
|
||||||
if (int.TryParse(columns[0], out int store)
|
if (int.TryParse(columns[0], out int store)
|
||||||
&& !string.IsNullOrEmpty(sku)
|
&& !string.IsNullOrEmpty(sku)
|
||||||
&& int.TryParse(columns[2], out int quantity)
|
&& int.TryParse(columns[2], out int quantity)
|
||||||
&& DateTime.TryParse(columns[3], out DateTime updated))
|
&& !string.IsNullOrEmpty(updated))
|
||||||
{
|
{
|
||||||
dataTable.Rows.Add(new object[] { store, sku, quantity, updated });
|
dataTable.Rows.Add(new object[] { store, sku, quantity, updated });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,11 +69,13 @@ namespace PartSource.Automation.Jobs
|
|||||||
{
|
{
|
||||||
columns[j] = columns[j].Replace("\"", string.Empty);
|
columns[j] = columns[j].Replace("\"", string.Empty);
|
||||||
}
|
}
|
||||||
|
string sku = columns[1].Trim();
|
||||||
|
string updated = columns[3].Trim();
|
||||||
|
|
||||||
if (int.TryParse(columns[0], out int store)
|
if (int.TryParse(columns[0], out int store)
|
||||||
&& int.TryParse(columns[1], out int sku)
|
&& !string.IsNullOrEmpty(sku)
|
||||||
&& int.TryParse(columns[2], out int quantity)
|
&& int.TryParse(columns[2], out int quantity)
|
||||||
&& DateTime.TryParse(columns[3], out DateTime updated))
|
&& !string.IsNullOrEmpty(updated))
|
||||||
{
|
{
|
||||||
command += $"UPDATE PartAvailability SET QTY = @qty_{i}, Updated = @updated_{i} WHERE SKU = @sku_{i} AND Store = @store_{i};";
|
command += $"UPDATE PartAvailability SET QTY = @qty_{i}, Updated = @updated_{i} WHERE SKU = @sku_{i} AND Store = @store_{i};";
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
#pragma warning disable CS1998, CA1303
|
#pragma warning disable CS1998, CA1303
|
||||||
public async Task Run(CancellationToken token, params string[] arguments)
|
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.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.");
|
_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.");
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ namespace PartSource.Automation.Jobs
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_shopifyClient.BulkActions.Add(new Metafield
|
|
||||||
|
await _shopifyClient.Metafields.Add(new Metafield
|
||||||
{
|
{
|
||||||
Namespace = "Pricing",
|
Namespace = "Pricing",
|
||||||
Key = "CorePrice",
|
Key = "CorePrice",
|
||||||
@@ -85,24 +86,16 @@ namespace PartSource.Automation.Jobs
|
|||||||
OwnerResource = "product",
|
OwnerResource = "product",
|
||||||
OwnerId = product.Id
|
OwnerId = product.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await _shopifyClient.Products.Update(product);
|
||||||
|
|
||||||
|
_logger.LogInformation("Updated product id {productId}", product.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception ex)
|
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");
|
_logger.LogWarning(ex, "Failed to get the next set of products. Retrying");
|
||||||
products = await _shopifyClient.Products.GetPrevious();
|
products = await _shopifyClient.Products.GetPrevious();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
while (_shopifyClient.BulkActions.PendingCount() > 0)
|
_emailService.Send("Pricing Update Completed", $"The pricing update has completed.");
|
||||||
{
|
}
|
||||||
await Task.Delay(15 * 1000, token);
|
|
||||||
_logger.LogInformation(_shopifyClient.BulkActions.PendingCount().ToString());
|
|
||||||
}
|
|
||||||
// _emailService.Send("Pricing Update Completed", $"The pricing update has completed.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ namespace PartSource.Automation
|
|||||||
{
|
{
|
||||||
options.ApiKey = builder.Configuration["Shopify:ApiKey"];
|
options.ApiKey = builder.Configuration["Shopify:ApiKey"];
|
||||||
options.ApiSecret = builder.Configuration["Shopify:ApiSecret"];
|
options.ApiSecret = builder.Configuration["Shopify:ApiSecret"];
|
||||||
options.ApiVersion = "2022-10";
|
options.ApiVersion = "2024-10";
|
||||||
options.ShopDomain = builder.Configuration["Shopify:ShopDomain"];
|
options.ShopDomain = builder.Configuration["Shopify:ShopDomain"];
|
||||||
|
|
||||||
//options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed";
|
//options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed";
|
||||||
@@ -92,23 +92,23 @@ namespace PartSource.Automation
|
|||||||
//.HasJob<StatusCheck>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
//.HasJob<StatusCheck>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
// .StartsAt(DateTime.Parse("2021-04-01 08:00:00"))
|
// .StartsAt(DateTime.Parse("2021-04-01 08:00:00"))
|
||||||
//)
|
//)
|
||||||
.HasJob<ExecuteSsisPackages>(options =>
|
//.HasJob<ExecuteSsisPackages>(options =>
|
||||||
options.HasInterval(new TimeSpan(24, 0, 0))
|
// options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
.StartsAt(DateTime.Today.AddHours(-24))
|
// .StartsAt(DateTime.Today.AddHours(-24))
|
||||||
)
|
// )
|
||||||
.HasJob<UpdatePricing>(options =>
|
.HasJob<UpdatePricing>(options =>
|
||||||
options.HasInterval(new TimeSpan(24, 0, 0))
|
options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
.StartsAt(DateTime.Today.AddHours(-22))
|
.StartsAt(DateTime.Today.AddHours(-22))
|
||||||
.HasDependency<ExecuteSsisPackages>()
|
//.HasDependency<ExecuteSsisPackages>()
|
||||||
)
|
|
||||||
.HasJob<BulkUpdateInventory>(options =>
|
|
||||||
options.HasInterval(new TimeSpan(1, 0, 0))
|
|
||||||
.StartsAt(DateTime.Today.AddHours(-27))
|
|
||||||
)
|
|
||||||
.HasJob<PartialInventoryUpdate>(options =>
|
|
||||||
options.HasInterval(new TimeSpan(1, 0, 0))
|
|
||||||
.StartsAt(DateTime.Today.AddHours(-27).AddMinutes(30))
|
|
||||||
);
|
);
|
||||||
|
//.HasJob<BulkUpdateInventory>(options =>
|
||||||
|
// options.HasInterval(new TimeSpan(1, 0, 0))
|
||||||
|
// .StartsAt(DateTime.Today.AddHours(-27))
|
||||||
|
// );
|
||||||
|
//.HasJob<TestJob>(options =>
|
||||||
|
// options.HasInterval(new TimeSpan(1, 0, 0))
|
||||||
|
// .StartsAt(DateTime.Today.AddHours(-27).AddMinutes(30))
|
||||||
|
//);
|
||||||
|
|
||||||
//.HasJob<PartialInventoryUpdate>(options => options.HasInterval(new TimeSpan(1, 0, 0))
|
//.HasJob<PartialInventoryUpdate>(options => options.HasInterval(new TimeSpan(1, 0, 0))
|
||||||
//.HasDependency<ExecuteSsisPackages>()
|
//.HasDependency<ExecuteSsisPackages>()
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
},
|
},
|
||||||
"emailConfiguration": {
|
"emailConfiguration": {
|
||||||
"From": "alerts@ps-automation.eastus2.cloudapp.azure.com",
|
"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@soundpress.com,josh@soundpress.com,alex.au@partsource.ca,michael.massara@partsource.ca",
|
||||||
//"To": "tom@tomraterman.com",
|
//"To": "tom@tomraterman.com,josh@soundpress.com",
|
||||||
"SmtpHost": "localhost"
|
"SmtpHost": "localhost"
|
||||||
},
|
},
|
||||||
"FtpServers": {
|
"FtpServers": {
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ namespace PartSource.Data.Models
|
|||||||
|
|
||||||
public int? QTY { get; set; }
|
public int? QTY { get; set; }
|
||||||
|
|
||||||
public DateTime? Updated { get; set; }
|
public string Updated { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user