Various changes
This commit is contained in:
@@ -51,12 +51,11 @@ namespace PartSource.Automation.Jobs
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
string filename = Decompress(fileInfo);
|
string filename = Decompress(fileInfo);
|
||||||
DataTable dataTable = GetDataTable(filename);
|
|
||||||
|
|
||||||
string tableName = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.'));
|
string tableName = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.'));
|
||||||
|
|
||||||
_whiSeoService.BulkCopy(_seoDataType, dataTable, tableName);
|
DataTable dataTable = GetDataTable(filename);
|
||||||
|
|
||||||
|
_whiSeoService.BulkCopy(_seoDataType, dataTable, tableName);
|
||||||
_logger.LogInformation($"Copied {fileInfo.Name} to the database.");
|
_logger.LogInformation($"Copied {fileInfo.Name} to the database.");
|
||||||
|
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
@@ -96,8 +95,8 @@ namespace PartSource.Automation.Jobs
|
|||||||
dataTable.Columns.Add("PartNumber", typeof(string));
|
dataTable.Columns.Add("PartNumber", typeof(string));
|
||||||
dataTable.Columns.Add("BaseVehicleId", typeof(int));
|
dataTable.Columns.Add("BaseVehicleId", typeof(int));
|
||||||
dataTable.Columns.Add("EngineConfigId", typeof(int));
|
dataTable.Columns.Add("EngineConfigId", typeof(int));
|
||||||
//dataTable.Columns.Add("Position", typeof(string));
|
dataTable.Columns.Add("Position", typeof(string));
|
||||||
//dataTable.Columns.Add("NoteText", typeof(string));
|
dataTable.Columns.Add("NoteText", 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
|
||||||
@@ -122,7 +121,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
&& int.TryParse(columns[5], out int baseVehicleId)
|
&& int.TryParse(columns[5], out int baseVehicleId)
|
||||||
&& int.TryParse(columns[6], out int engineConfigId))
|
&& int.TryParse(columns[6], out int engineConfigId))
|
||||||
{
|
{
|
||||||
dataTable.Rows.Add(new object[] { lineCode, partNumber, baseVehicleId, engineConfigId }); //, position, noteText });
|
dataTable.Rows.Add(new object[] { lineCode, partNumber, baseVehicleId, engineConfigId, position, noteText });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,22 +5,25 @@ using System.Collections.Generic;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PartSource.Automation.Services;
|
||||||
|
|
||||||
namespace PartSource.Automation.Jobs
|
namespace PartSource.Automation.Jobs
|
||||||
{
|
{
|
||||||
public class TestJob : IAutomationJob
|
public class TestJob : IAutomationJob
|
||||||
{
|
{
|
||||||
private readonly ILogger<TestJob> _logger;
|
private readonly ILogger<TestJob> _logger;
|
||||||
|
private readonly EmailService _emailService;
|
||||||
|
|
||||||
public TestJob(ILogger<TestJob> logger)
|
public TestJob(ILogger<TestJob> logger, EmailService emailService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
|
_emailService = emailService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma warning disable CS1998, CA1303
|
#pragma warning disable CS1998, CA1303
|
||||||
public async Task Run()
|
public async Task Run()
|
||||||
{
|
{
|
||||||
await Task.Delay(5000);
|
// _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.");
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
products = await _shopifyClient.Products.Get(new Dictionary<string, object> { { "limit", 250 } });
|
products = await _shopifyClient.Products.Get(new Dictionary<string, object> { { "limit", 250 } });//, {"product_type", "CA142-SC130-FL13029_Certified Brake Pads" } });
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -51,10 +51,6 @@ namespace PartSource.Automation.Jobs
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
IList<ImportData> parts = await _partSourceContext.ImportData
|
|
||||||
.Where(i => i.UpdatedAt <= DateTime.Now.AddDays(-7))
|
|
||||||
.ToListAsync();
|
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
while (products != null && products.Any())
|
while (products != null && products.Any())
|
||||||
@@ -65,7 +61,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
importData = parts.FirstOrDefault(parts => parts.ShopifyId == product.Id);
|
importData = await _partSourceContext.ImportData.FirstOrDefaultAsync(parts => parts.ShopifyId == product.Id);
|
||||||
|
|
||||||
if (importData == null)
|
if (importData == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
products = await _shopifyClient.Products.Get(new Dictionary<string, object> { { "limit", 250 } });
|
products = await _shopifyClient.Products.Get(new Dictionary<string, object> { { "limit", 250 } });
|
||||||
|
|
||||||
prices = await _partSourceContext.PartPrices.ToListAsync();
|
prices = await _partSourceContext.PartPrices.ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_emailService.Send("Update Pricing Completed", $"{updateCount} prices were updated");
|
_emailService.Send("Pricing Update Completed", $"The pricing update has completed. Total updated: {updateCount}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,25 +70,28 @@ namespace PartSource.Automation
|
|||||||
{
|
{
|
||||||
options.HasBaseInterval(new TimeSpan(0, 15, 0))
|
options.HasBaseInterval(new TimeSpan(0, 15, 0))
|
||||||
.HasMaxFailures(5)
|
.HasMaxFailures(5)
|
||||||
|
//.HasJob<TestJob>(options => options.HasInterval(new TimeSpan(7, 0, 0, 0)));
|
||||||
//
|
//
|
||||||
//.HasJob<SyncronizeProducts>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
//.HasJob<SyncronizeProducts>(options => options.HasInterval(new TimeSpan(24, 0, 0)))
|
||||||
// .HasJob<ProcessWhiFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
.HasJob<ProcessWhiFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
//.HasJob<UpdateFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
// .HasDependency<SyncronizeProducts>()
|
||||||
|
// .HasJob<UpdateFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
// .HasDependency<ProcessWhiFitment>()
|
// .HasDependency<ProcessWhiFitment>()
|
||||||
|
//.HasDependency<SyncronizeProducts>()
|
||||||
// .StartsAt(DateTime.Today.AddHours(8))
|
// .StartsAt(DateTime.Today.AddHours(8))
|
||||||
//)
|
//) ;
|
||||||
//.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 => options.HasInterval(new TimeSpan(24, 0, 0))
|
// .HasJob<ExecuteSsisPackages>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
.StartsAt(DateTime.Today.AddHours(26))
|
// .StartsAt(DateTime.Today.AddHours(26))
|
||||||
)
|
// )
|
||||||
.HasJob<UpdatePricing>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
// .HasJob<UpdatePricing>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
.HasDependency<ExecuteSsisPackages>()
|
// .HasDependency<ExecuteSsisPackages>()
|
||||||
.StartsAt(DateTime.Today.AddHours(27)
|
// .StartsAt(DateTime.Today.AddHours(27)
|
||||||
)
|
// )
|
||||||
);
|
);
|
||||||
//.AddApiServer();
|
//.AddApiServer();
|
||||||
})
|
})
|
||||||
|
|
||||||
.AddSingleton<EmailService>()
|
.AddSingleton<EmailService>()
|
||||||
@@ -101,10 +104,10 @@ namespace PartSource.Automation
|
|||||||
})
|
})
|
||||||
.ConfigureLogging((builder, logging) =>
|
.ConfigureLogging((builder, logging) =>
|
||||||
{
|
{
|
||||||
//logging.AddEventLog();
|
logging.AddEventLog();
|
||||||
logging.AddConsole();
|
logging.AddConsole();
|
||||||
|
|
||||||
// logging.AddProvider(new AutomationLoggerProvider());
|
// logging.AddProvider(new AutomationLoggerProvider());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace PartSource.Automation.Services
|
|||||||
mailMessage.To.Add(address);
|
mailMessage.To.Add(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
smtpClient.Send(mailMessage);
|
// smtpClient.Send(mailMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Send(string to, string subject, string body)
|
public void Send(string to, string subject, string body)
|
||||||
@@ -62,7 +62,7 @@ namespace PartSource.Automation.Services
|
|||||||
mailMessage.To.Add(to);
|
mailMessage.To.Add(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
smtpClient.Send(mailMessage);
|
// smtpClient.Send(mailMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ namespace PartSource.Automation.Services
|
|||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
using SqlCommand command = new SqlCommand($"exec CreateFitmentTable @tableName = '{tableName}'", connection);
|
using SqlCommand command = new SqlCommand($"exec CreateFitmentTable @tableName = '{tableName}'", connection);
|
||||||
|
command.CommandTimeout = 1800;
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,8 @@
|
|||||||
"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=True;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=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
|
||||||
},
|
},
|
||||||
"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",
|
"To": "tom@soundpress.com,Anas.Bajwa@Partsource.ca,josh@soundpress.com,alex.au@partsource.ca,michael.massara@partsource.ca",
|
||||||
"To": "tom@tomraterman.com",
|
|
||||||
"SmtpHost": "localhost"
|
"SmtpHost": "localhost"
|
||||||
},
|
},
|
||||||
"FtpServers": {
|
"FtpServers": {
|
||||||
@@ -37,6 +35,11 @@
|
|||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
"Microsoft": "Warning",
|
"Microsoft": "Warning",
|
||||||
"Microsoft.Hosting.Lifetime": "Information"
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
},
|
||||||
|
"EventLog": {
|
||||||
|
"LogLevel": {
|
||||||
|
"default": "Information"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user