Compare commits
5 Commits
HourlyInve
...
ca45a77a0f
| Author | SHA1 | Date | |
|---|---|---|---|
| ca45a77a0f | |||
| 8b6892df60 | |||
| f1ca48c1d0 | |||
| 57f42a0e47 | |||
| eb928a7c56 |
@@ -14,18 +14,21 @@ using PartSource.Automation.Models.Ftp;
|
|||||||
using PartSource.Automation.Services;
|
using PartSource.Automation.Services;
|
||||||
using Ratermania.Automation.Interfaces;
|
using Ratermania.Automation.Interfaces;
|
||||||
|
|
||||||
namespace PartSource.Automation.Jobs.POC
|
namespace PartSource.Automation.Jobs
|
||||||
{
|
{
|
||||||
public class BulkUpdateInventory : IAutomationJob
|
public class BulkUpdateInventory : IAutomationJob
|
||||||
{
|
{
|
||||||
private readonly FtpService _ftpService;
|
private readonly FtpService _ftpService;
|
||||||
private readonly ILogger<BulkUpdateInventory> _logger;
|
private readonly ILogger<BulkUpdateInventory> _logger;
|
||||||
|
private readonly string _connectionString;
|
||||||
|
|
||||||
public BulkUpdateInventory(IConfiguration configuration, ILogger<BulkUpdateInventory> logger)
|
public BulkUpdateInventory(IConfiguration configuration, ILogger<BulkUpdateInventory> logger)
|
||||||
{
|
{
|
||||||
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AutomationConfiguration").Get<FtpConfiguration>();
|
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AutomationConfiguration").Get<FtpConfiguration>();
|
||||||
_ftpService = new FtpService(ftpConfiguration);
|
_ftpService = new FtpService(ftpConfiguration);
|
||||||
|
|
||||||
|
_connectionString = configuration.GetConnectionString("PartSourceDatabase");
|
||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +49,7 @@ namespace PartSource.Automation.Jobs.POC
|
|||||||
|
|
||||||
DataTable dataTable = GetDataTable(file);
|
DataTable dataTable = GetDataTable(file);
|
||||||
|
|
||||||
using SqlConnection connection = new SqlConnection("Server=tcp:ps-whi.database.windows.net,1433;Initial Catalog=ps-whi-test;Persist Security Info=False;User ID=ps-whi;Password=9-^*N5dw!6:|.5Q;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;");
|
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
using SqlCommand command = new SqlCommand("TRUNCATE TABLE PartAvailability", connection);
|
using SqlCommand command = new SqlCommand("TRUNCATE TABLE PartAvailability", connection);
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PartSource.Automation.Models.Configuration;
|
using PartSource.Automation.Models.Configuration;
|
||||||
|
using PartSource.Automation.Models.Ftp;
|
||||||
using PartSource.Automation.Services;
|
using PartSource.Automation.Services;
|
||||||
using Ratermania.Automation.Interfaces;
|
using Ratermania.Automation.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@@ -17,11 +19,11 @@ namespace PartSource.Automation.Jobs
|
|||||||
private readonly ILogger<ExecuteSsisPackages> _logger;
|
private readonly ILogger<ExecuteSsisPackages> _logger;
|
||||||
|
|
||||||
// TODO: set from config
|
// TODO: set from config
|
||||||
private readonly string[] _ssisPackages = {"Parts Availability" };
|
private readonly string[] _ssisPackages = {"Parts Price" };
|
||||||
|
|
||||||
public ExecuteSsisPackages(EmailService emailService, IConfiguration configuration, SsisService ssisService, ILogger<ExecuteSsisPackages> logger)
|
public ExecuteSsisPackages(EmailService emailService, IConfiguration configuration, SsisService ssisService, ILogger<ExecuteSsisPackages> logger)
|
||||||
{
|
{
|
||||||
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AzureConfiguration").Get<FtpConfiguration>();
|
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AutomationConfiguration").Get<FtpConfiguration>();
|
||||||
|
|
||||||
_emailService = emailService;
|
_emailService = emailService;
|
||||||
_ftpService = new FtpService(ftpConfiguration);
|
_ftpService = new FtpService(ftpConfiguration);
|
||||||
@@ -36,7 +38,18 @@ namespace PartSource.Automation.Jobs
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// _ftpService.Download($"{package}.txt");
|
FtpFileInfo lastUploadedFile = _ftpService.ListFilesExtended()
|
||||||
|
.Where(f => f.FileType == FtpFileType.File && f.Filename.IndexOf(package) > -1)
|
||||||
|
.OrderByDescending(f => f.Modified)
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
|
if (lastUploadedFile == null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation($"No {package} file available.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_ftpService.Download($"{package}.txt");
|
||||||
_ssisService.Execute($"{package}.dtsx");
|
_ssisService.Execute($"{package}.dtsx");
|
||||||
|
|
||||||
_logger.LogInformation($"Execution of SSIS package {package} completed successfully.");
|
_logger.LogInformation($"Execution of SSIS package {package} completed successfully.");
|
||||||
@@ -45,7 +58,6 @@ namespace PartSource.Automation.Jobs
|
|||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError($"Execution of SSIS package {package} failed.", ex);
|
_logger.LogError($"Execution of SSIS package {package} failed.", ex);
|
||||||
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ using Ratermania.Shopify.Resources;
|
|||||||
|
|
||||||
namespace PartSource.Automation.Jobs.POC
|
namespace PartSource.Automation.Jobs.POC
|
||||||
{
|
{
|
||||||
public class GetImageUrls : IAutomationJob
|
public class ImageList : IAutomationJob
|
||||||
{
|
{
|
||||||
private readonly NexpartService _nexpartService;
|
private readonly NexpartService _nexpartService;
|
||||||
private readonly PartSourceContext _partSourceContext;
|
private readonly PartSourceContext _partSourceContext;
|
||||||
private readonly FitmentContext _fitmentContext;
|
private readonly FitmentContext _fitmentContext;
|
||||||
|
|
||||||
public GetImageUrls(NexpartService nexpartService, PartSourceContext partSourceContext, FitmentContext fitmentContext)
|
public ImageList(NexpartService nexpartService, PartSourceContext partSourceContext, FitmentContext fitmentContext)
|
||||||
{
|
{
|
||||||
_nexpartService = nexpartService;
|
_nexpartService = nexpartService;
|
||||||
_partSourceContext = partSourceContext;
|
_partSourceContext = partSourceContext;
|
||||||
|
|||||||
@@ -14,18 +14,21 @@ using PartSource.Automation.Models.Ftp;
|
|||||||
using PartSource.Automation.Services;
|
using PartSource.Automation.Services;
|
||||||
using Ratermania.Automation.Interfaces;
|
using Ratermania.Automation.Interfaces;
|
||||||
|
|
||||||
namespace PartSource.Automation.Jobs.POC
|
namespace PartSource.Automation.Jobs
|
||||||
{
|
{
|
||||||
public class PartialInventoryUpdate : IAutomationJob
|
public class PartialInventoryUpdate : IAutomationJob
|
||||||
{
|
{
|
||||||
private readonly FtpService _ftpService;
|
private readonly FtpService _ftpService;
|
||||||
private readonly ILogger<PartialInventoryUpdate> _logger;
|
private readonly ILogger<PartialInventoryUpdate> _logger;
|
||||||
|
private readonly string _connectionString;
|
||||||
|
|
||||||
public PartialInventoryUpdate(IConfiguration configuration, ILogger<PartialInventoryUpdate> logger)
|
public PartialInventoryUpdate(IConfiguration configuration, ILogger<PartialInventoryUpdate> logger)
|
||||||
{
|
{
|
||||||
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AutomationConfiguration").Get<FtpConfiguration>();
|
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AutomationConfiguration").Get<FtpConfiguration>();
|
||||||
_ftpService = new FtpService(ftpConfiguration);
|
_ftpService = new FtpService(ftpConfiguration);
|
||||||
|
|
||||||
|
_connectionString = _connectionString = configuration.GetConnectionString("PartSourceDatabase");
|
||||||
|
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,7 +49,7 @@ namespace PartSource.Automation.Jobs.POC
|
|||||||
|
|
||||||
string file = _ftpService.Download($"{lastUploadedFile.Filename}");
|
string file = _ftpService.Download($"{lastUploadedFile.Filename}");
|
||||||
|
|
||||||
using SqlConnection connection = new SqlConnection("Server=tcp:ps-whi.database.windows.net,1433;Initial Catalog=ps-whi-test;Persist Security Info=False;User ID=ps-whi;Password=9-^*N5dw!6:|.5Q;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;");
|
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
using StreamReader reader = new StreamReader(file);
|
using StreamReader reader = new StreamReader(file);
|
||||||
@@ -93,7 +93,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
? string.Empty
|
? string.Empty
|
||||||
: product.BodyHtml.Substring(0, product.BodyHtml.IndexOf("</ul>") + "</ul>".Length);
|
: product.BodyHtml.Substring(0, product.BodyHtml.IndexOf("</ul>") + "</ul>".Length);
|
||||||
|
|
||||||
IList<Vehicle> vehicles = _vehicleFitmentService.GetVehiclesForPart(importData.PartNumber, importData.LineCode);
|
IList<Vehicle> vehicles = await _vehicleFitmentService.GetVehiclesForPart(importData.PartNumber, importData.LineCode);
|
||||||
IList<int> vehicleIdFitment = _vehicleFitmentService.GetVehicleIdFitment(vehicles);
|
IList<int> vehicleIdFitment = _vehicleFitmentService.GetVehicleIdFitment(vehicles);
|
||||||
|
|
||||||
if (!vehicleIdFitment.Any())
|
if (!vehicleIdFitment.Any())
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using PartSource.Automation.Jobs;
|
using PartSource.Automation.Jobs;
|
||||||
using PartSource.Automation.Jobs.POC;
|
|
||||||
using PartSource.Automation.Services;
|
using PartSource.Automation.Services;
|
||||||
using PartSource.Data.AutoMapper;
|
using PartSource.Data.AutoMapper;
|
||||||
using PartSource.Data.Contexts;
|
using PartSource.Data.Contexts;
|
||||||
@@ -93,6 +92,15 @@ 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 =>
|
||||||
|
options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
|
.StartsAt(DateTime.Today.AddHours(-24))
|
||||||
|
)
|
||||||
|
.HasJob<UpdatePricing>(options =>
|
||||||
|
options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
|
.StartsAt(DateTime.Today.AddHours(-22))
|
||||||
|
.HasDependency<ExecuteSsisPackages>()
|
||||||
|
)
|
||||||
.HasJob<BulkUpdateInventory>(options =>
|
.HasJob<BulkUpdateInventory>(options =>
|
||||||
options.HasInterval(new TimeSpan(1, 0, 0))
|
options.HasInterval(new TimeSpan(1, 0, 0))
|
||||||
.StartsAt(DateTime.Today.AddHours(-27))
|
.StartsAt(DateTime.Today.AddHours(-27))
|
||||||
|
|||||||
@@ -11,19 +11,18 @@
|
|||||||
"SmtpHost": "localhost"
|
"SmtpHost": "localhost"
|
||||||
},
|
},
|
||||||
"FtpServers": {
|
"FtpServers": {
|
||||||
"AzureConfiguration": {
|
|
||||||
"Username": "ps-ftp\\$ps-ftp",
|
|
||||||
"Password": "ycvXptffBxqkBXW4vuRYqn4Zi1soCvnvMMolTe5HNSeAlcl3bAyJYtNhG579",
|
|
||||||
"Url": "ftp://waws-prod-yq1-007.ftp.azurewebsites.windows.net/site/wwwroot",
|
|
||||||
"Destination": "C:\\Partsource.Automation\\Downloads",
|
|
||||||
"Port": 21
|
|
||||||
},
|
|
||||||
"WhiConfiguration": {
|
"WhiConfiguration": {
|
||||||
"Username": "ctc_seo",
|
"Username": "ctc_seo",
|
||||||
"Password": "YD3gtaQ5kPdtNKs",
|
"Password": "YD3gtaQ5kPdtNKs",
|
||||||
"Url": "ftp://ftp.whisolutions.com",
|
"Url": "ftp://ftp.whisolutions.com",
|
||||||
"Destination": "C:\\Partsource.Automation\\Downloads\\WHI",
|
"Destination": "C:\\Partsource.Automation\\Downloads\\WHI",
|
||||||
"Port": 3001
|
"Port": 3001
|
||||||
|
},
|
||||||
|
"AutomationConfiguration": {
|
||||||
|
"Username": "stageuser",
|
||||||
|
"Password": "FXepK^cFYS|[H<",
|
||||||
|
"Url": "ftp://localhost",
|
||||||
|
"Destination": "C:\\Partsource.Automation\\Downloads"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ssisConfiguration": {
|
"ssisConfiguration": {
|
||||||
|
|||||||
Reference in New Issue
Block a user