From d95d947bc2318a06215c6a68a175f8ec96b903bd Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Sat, 25 Mar 2023 17:50:25 -0400 Subject: [PATCH 1/4] WIP --- .../Jobs/POC/PartialInventoryUpdate.cs | 84 ++++++++++++ PartSource.Automation/Jobs/UpdateFitment.cs | 2 +- .../Models/Ftp/FtpFileInfo.cs | 19 +++ .../Models/Ftp/FtpFileType.cs | 14 ++ PartSource.Automation/Program.cs | 2 +- PartSource.Automation/Services/FtpService.cs | 129 +++++++++++++----- 6 files changed, 215 insertions(+), 35 deletions(-) create mode 100644 PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs create mode 100644 PartSource.Automation/Models/Ftp/FtpFileInfo.cs create mode 100644 PartSource.Automation/Models/Ftp/FtpFileType.cs diff --git a/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs b/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs new file mode 100644 index 0000000..754cc30 --- /dev/null +++ b/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Data.SqlClient; +using Microsoft.Extensions.Configuration; +using PartSource.Automation.Models.Configuration; +using PartSource.Automation.Models.Ftp; +using PartSource.Automation.Services; +using Ratermania.Automation.Interfaces; + +namespace PartSource.Automation.Jobs.POC +{ + public class PartialInventoryUpdate : IAutomationJob + { + private readonly FtpService _ftpService; + + public PartialInventoryUpdate(IConfiguration configuration) + { + FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AzureConfiguration").Get(); + _ftpService = new FtpService(ftpConfiguration); + } + + public async Task Run(CancellationToken token, params string[] arguments) + { + FtpFileInfo lastUploadedFile = _ftpService.ListFilesExtended("") + .Where(f => f.FileType == FtpFileType.File && f.Filename.IndexOf("Availability") > -1) + .OrderByDescending(f => f.Modified) + .First(); + + string file = _ftpService.Download(lastUploadedFile.Filename, Path.GetTempPath()); + + DataTable dataTable = GetDataTable(file); + + using SqlConnection connection = new SqlConnection("Server=tcp:ps-automation-stage.eastus2.cloudapp.azure.com,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=stageuser;Password=]FXepK^cFYS|[H<;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;"); + connection.Open(); + + using SqlBulkCopy bulk = new SqlBulkCopy(connection) + { + DestinationTableName = $"PartAvailability", + BulkCopyTimeout = 14400 + }; + + bulk.WriteToServer(dataTable); + + return; + } + + private DataTable GetDataTable(string filename) + { + using DataTable dataTable = new DataTable(); + dataTable.Columns.Add("Store", typeof(int)); + dataTable.Columns.Add("SKU", typeof(int)); + dataTable.Columns.Add("QTY", typeof(int)); + + using StreamReader reader = new StreamReader(filename); + string line = reader.ReadLine(); // Burn the header row + + while (reader.Peek() > 0) + { + line = reader.ReadLine(); + + string[] columns = line.Split("|"); + for (int i = 0; i < columns.Length; i++) + { + columns[i] = columns[i].Replace("\"", string.Empty); + } + + if (int.TryParse(columns[0], out int store) + && int.TryParse(columns[1], out int sku) + && int.TryParse(columns[2], out int quantity)) + { + dataTable.Rows.Add(new object[] { store, sku, quantity }); + } + } + + return dataTable; + } + } +} diff --git a/PartSource.Automation/Jobs/UpdateFitment.cs b/PartSource.Automation/Jobs/UpdateFitment.cs index 3b74881..5eb9c25 100644 --- a/PartSource.Automation/Jobs/UpdateFitment.cs +++ b/PartSource.Automation/Jobs/UpdateFitment.cs @@ -40,7 +40,7 @@ namespace PartSource.Automation.Jobs try { - products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 }, { "product_type", "CA111-SC250-FL25049_Entry Ball Joints" } }); + products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 } }); //products = new List //{ // await _shopifyClient.Products.GetById(4388919574575) diff --git a/PartSource.Automation/Models/Ftp/FtpFileInfo.cs b/PartSource.Automation/Models/Ftp/FtpFileInfo.cs new file mode 100644 index 0000000..7c76489 --- /dev/null +++ b/PartSource.Automation/Models/Ftp/FtpFileInfo.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PartSource.Automation.Models.Ftp +{ + public class FtpFileInfo + { + public string Filename { get; set; } + + public DateTime Modified { get; set; } + + public long Size { get; set; } + + public FtpFileType FileType { get; set; } + } +} diff --git a/PartSource.Automation/Models/Ftp/FtpFileType.cs b/PartSource.Automation/Models/Ftp/FtpFileType.cs new file mode 100644 index 0000000..2c9dcf7 --- /dev/null +++ b/PartSource.Automation/Models/Ftp/FtpFileType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PartSource.Automation.Models.Ftp +{ + public enum FtpFileType + { + File, + Directory + } +} diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index 90a8d1d..8790f7e 100644 --- a/PartSource.Automation/Program.cs +++ b/PartSource.Automation/Program.cs @@ -100,7 +100,7 @@ namespace PartSource.Automation // //.StartsAt(DateTime.Today.AddHours(25)) // ) - .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) + .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) //.HasDependency() // .StartsAt(DateTime.Today.AddHours(28)) ); diff --git a/PartSource.Automation/Services/FtpService.cs b/PartSource.Automation/Services/FtpService.cs index 25ed55a..84d5a80 100644 --- a/PartSource.Automation/Services/FtpService.cs +++ b/PartSource.Automation/Services/FtpService.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Configuration; using PartSource.Automation.Models.Configuration; +using PartSource.Automation.Models.Ftp; using System; using System.Collections.Generic; using System.Configuration; @@ -9,44 +10,106 @@ using System.Threading.Tasks; namespace PartSource.Automation.Services { - public class FtpService - { - private readonly FtpConfiguration _ftpConfiguration; + public class FtpService + { + private readonly FtpConfiguration _ftpConfiguration; - public FtpService(FtpConfiguration ftpConfiguration) - { - _ftpConfiguration = ftpConfiguration; - } + public FtpService(FtpConfiguration ftpConfiguration) + { + _ftpConfiguration = ftpConfiguration; + } - public string[] ListFiles(string directory) - { - FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{directory}")); - request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); - request.Method = WebRequestMethods.Ftp.ListDirectory; + public IList ListFilesExtended(string directory) + { + FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{directory}")); + request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); + request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; - using FtpWebResponse response = (FtpWebResponse)request.GetResponse(); - using StreamReader reader = new StreamReader(response.GetResponseStream()); + using FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + using StreamReader reader = new StreamReader(response.GetResponseStream()); - string files = reader.ReadToEnd(); + IList files = new List(); + string[] fileStrings = reader.ReadToEnd().Split("\r\n"); - return files.Length > 0 - ? files.Split("\r\n") - : Array.Empty(); - } + foreach (string fileString in fileStrings) + { + if (string.IsNullOrEmpty(fileString)) + { + continue; + } - public void Download(string filename) - { - string file = $"{_ftpConfiguration.Destination}\\{filename.Replace("/", "\\")}"; + string dateString = fileString[..17]; + string[] sizeAndName = fileString[18..].TrimStart().Split(" ", 2); - FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{filename}")); - request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); - request.Method = WebRequestMethods.Ftp.DownloadFile; - - using FtpWebResponse response = (FtpWebResponse)request.GetResponse(); - using Stream responseStream = response.GetResponseStream(); - using FileStream fileStream = new FileStream($"{_ftpConfiguration.Destination}\\{filename.Replace("/", "\\")}", FileMode.Create); - - responseStream.CopyTo(fileStream); - } - } + if (sizeAndName[0].ToUpperInvariant().IndexOf("DIR") > -1) + { + files.Add(new FtpFileInfo + { + Modified = DateTime.Parse(fileString[..17]), + Size = 0, + Filename = sizeAndName[1].Trim(), + FileType = FtpFileType.Directory + }); + } + + else + { + files.Add(new FtpFileInfo + { + Modified = DateTime.Parse(fileString[..17]), + Size = long.Parse(sizeAndName[0]), + Filename = sizeAndName[1].Trim(), + FileType = FtpFileType.File + }); + } + } + + return files; + } + + public string[] ListFiles(string directory) + { + FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{directory}")); + request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); + request.Method = WebRequestMethods.Ftp.ListDirectory; + + using FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + using StreamReader reader = new StreamReader(response.GetResponseStream()); + + string files = reader.ReadToEnd(); + + return files.Length > 0 + ? files.Split("\r\n") + : Array.Empty(); + } + + public string Download(string filename, string destination = null) + { + + + FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{filename}")); + request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); + request.Method = WebRequestMethods.Ftp.DownloadFile; + + if (string.IsNullOrEmpty(destination)) + { + destination = _ftpConfiguration.Destination; + } + + if (Path.DirectorySeparatorChar == '\\') + { + filename = filename.Replace("/", "\\"); + } + + destination = Path.Combine(destination, filename); + + using FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + using Stream responseStream = response.GetResponseStream(); + using FileStream fileStream = new FileStream(destination, FileMode.Create); + + responseStream.CopyTo(fileStream); + + return destination; + } + } } From 68c9e01ef1f6e73e43e2eceb5ee19c62cea29b6c Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Wed, 23 Aug 2023 15:04:54 -0400 Subject: [PATCH 2/4] . --- PartSource.Api/Controllers/PartsController.cs | 48 ++-- PartSource.Api/PartSource.Api.csproj | 1 - PartSource.Api/Startup.cs | 9 +- PartSource.Api/appsettings.json | 1 + .../Extensions/FileInfoExtensions.cs | 23 ++ .../Jobs/ExecuteSsisPackages.cs | 2 +- .../Jobs/POC/BulkUpdateInventory.cs | 85 +++++++ .../Jobs/POC/GetImageUrls.cs | 119 +++++++++ .../Jobs/POC/GetImageUrlsTemp.cs | 106 +++++++++ PartSource.Automation/Jobs/POC/ImageList.cs | 84 ------- .../Jobs/POC/PartialInventoryUpdate.cs | 86 ++++--- .../Jobs/ProcessWhiFitment.cs | 5 +- .../Jobs/ProcessWhiVehicles.cs | 5 +- PartSource.Automation/Jobs/UpdateFitment.cs | 63 ++--- .../Jobs/UpdatePositioning.cs | 2 +- PartSource.Automation/Program.cs | 73 +++--- PartSource.Automation/Services/FtpService.cs | 11 +- PartSource.Automation/Services/SsisService.cs | 2 +- .../Services/VehicleFitmentService.cs | 45 +--- PartSource.Automation/appsettings.json | 8 +- PartSource.Data/Contexts/FitmentContext.cs | 3 + PartSource.Data/Dtos/VehicleFitmentDto.cs | 10 +- PartSource.Data/Models/VehicleFitment.cs | 27 +++ PartSource.Services/FitmentService.cs | 225 +++++++++--------- 24 files changed, 655 insertions(+), 388 deletions(-) create mode 100644 PartSource.Automation/Extensions/FileInfoExtensions.cs create mode 100644 PartSource.Automation/Jobs/POC/BulkUpdateInventory.cs create mode 100644 PartSource.Automation/Jobs/POC/GetImageUrls.cs create mode 100644 PartSource.Automation/Jobs/POC/GetImageUrlsTemp.cs delete mode 100644 PartSource.Automation/Jobs/POC/ImageList.cs create mode 100644 PartSource.Data/Models/VehicleFitment.cs diff --git a/PartSource.Api/Controllers/PartsController.cs b/PartSource.Api/Controllers/PartsController.cs index a007504..fb9ccb0 100644 --- a/PartSource.Api/Controllers/PartsController.cs +++ b/PartSource.Api/Controllers/PartsController.cs @@ -19,12 +19,29 @@ namespace PartSource.Api.Controllers private readonly NexpartService _nexpartService; private readonly PartService _partService; private readonly VehicleService _vehicleService; + private readonly FitmentService _fitmentService; - public PartsController(NexpartService nexpartService, PartService partService, VehicleService vehicleService) + public PartsController(NexpartService nexpartService, PartService partService, VehicleService vehicleService, FitmentService fitmentService) { _nexpartService = nexpartService; _partService = partService; _vehicleService = vehicleService; + _fitmentService = fitmentService; + } + + [HttpGet] + [Route("fitment")] + [Route("fitmentnote")] + public async Task GetFitment([FromQuery] string sku, [FromQuery] int vehicleId) + { + VehicleFitmentDto vehicleFitment = await _fitmentService.GetFitmentNotes(sku, vehicleId); + + if (vehicleFitment == null) + { + return NotFound(); + } + + return Ok(vehicleFitment); } [HttpGet] @@ -34,31 +51,22 @@ namespace PartSource.Api.Controllers Part part = await _partService.GetPartBySku(sku); Vehicle vehicle = await _vehicleService.GetVehicleById(vehicleId); - if (part == null) + if (part == null || vehicle == null) { return BadRequest(new { - Message = $"No part data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.", + Message = $"No data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.", Reason = $"{nameof(_partService.GetPartBySku)} returned null" }); } - if (vehicle == null) - { - return BadRequest(new - { - Message = $"No vehicle data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.", - Reason = $"{nameof(_vehicleService.GetVehicleById)} returned null" - }); - } - IList mappings = await _partService.GetDcfMapping(part.LineCode); Item[] items = mappings.Select(m => new Item - { - PartNumber = part.PartNumber, - MfrCode = m.WhiCode - }) - .ToArray(); + { + PartNumber = part.PartNumber, + MfrCode = m.WhiCode + }) + .ToArray(); SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch { @@ -76,9 +84,9 @@ namespace PartSource.Api.Controllers } PartType[] partTypes = smartPageResponse.ResponseBody.Item.Select(i => new PartType - { - Id = i.Part.PartType.Id - }) + { + Id = i.Part.PartType.Id + }) .ToArray(); ApplicationSearch applicationSearch = new ApplicationSearch diff --git a/PartSource.Api/PartSource.Api.csproj b/PartSource.Api/PartSource.Api.csproj index b04d8fa..9557f13 100644 --- a/PartSource.Api/PartSource.Api.csproj +++ b/PartSource.Api/PartSource.Api.csproj @@ -23,7 +23,6 @@ - Always diff --git a/PartSource.Api/Startup.cs b/PartSource.Api/Startup.cs index ec84a24..b555ea1 100644 --- a/PartSource.Api/Startup.cs +++ b/PartSource.Api/Startup.cs @@ -52,13 +52,12 @@ namespace PartSource.Api services.AddAutoMapper(typeof(PartSourceProfile)); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddCors(o => o.AddPolicy("Default", builder => { builder.AllowAnyOrigin() @@ -69,9 +68,9 @@ namespace PartSource.Api services.AddDbContext(options => options.UseSqlServer(Configuration.GetConnectionString("PartSourceDatabase")) ); - //services.AddDbContext(options => - // options.UseSqlServer(Configuration.GetConnectionString("FitmentDatabase")) - //); + services.AddDbContext(options => + options.UseSqlServer(Configuration.GetConnectionString("FitmentDatabase")) + ); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/PartSource.Api/appsettings.json b/PartSource.Api/appsettings.json index b3e4a45..b7c90dd 100644 --- a/PartSource.Api/appsettings.json +++ b/PartSource.Api/appsettings.json @@ -1,6 +1,7 @@ { "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;", + "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" }, "Logging": { diff --git a/PartSource.Automation/Extensions/FileInfoExtensions.cs b/PartSource.Automation/Extensions/FileInfoExtensions.cs new file mode 100644 index 0000000..538602c --- /dev/null +++ b/PartSource.Automation/Extensions/FileInfoExtensions.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace PartSource.Automation.Extensions +{ + public static class FileInfoExtensions + { + public static DateTime GetWhiTimestamp(this FileInfo fileInfo) + { + Match match = Regex.Match(fileInfo.Name, "[0-9]{8}"); + + return match.Success && DateTime.TryParseExact(match.Value, "MMddyyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime timestamp) + ? timestamp + : DateTime.MinValue; + } + } +} diff --git a/PartSource.Automation/Jobs/ExecuteSsisPackages.cs b/PartSource.Automation/Jobs/ExecuteSsisPackages.cs index b078563..305a12e 100644 --- a/PartSource.Automation/Jobs/ExecuteSsisPackages.cs +++ b/PartSource.Automation/Jobs/ExecuteSsisPackages.cs @@ -17,7 +17,7 @@ namespace PartSource.Automation.Jobs private readonly ILogger _logger; // TODO: set from config - private readonly string[] _ssisPackages = {"Parts Price", "Parts Availability" }; + private readonly string[] _ssisPackages = { "Parts Availability" }; public ExecuteSsisPackages(EmailService emailService, IConfiguration configuration, SsisService ssisService, ILogger logger) { diff --git a/PartSource.Automation/Jobs/POC/BulkUpdateInventory.cs b/PartSource.Automation/Jobs/POC/BulkUpdateInventory.cs new file mode 100644 index 0000000..067d963 --- /dev/null +++ b/PartSource.Automation/Jobs/POC/BulkUpdateInventory.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Data.SqlClient; +using Microsoft.Extensions.Configuration; +using PartSource.Automation.Models.Configuration; +using PartSource.Automation.Models.Ftp; +using PartSource.Automation.Services; +using Ratermania.Automation.Interfaces; + +namespace PartSource.Automation.Jobs.POC +{ + public class BulkUpdateInventory : IAutomationJob + { + private readonly FtpService _ftpService; + + public BulkUpdateInventory(IConfiguration configuration) + { + FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AzureConfiguration").Get(); + _ftpService = new FtpService(ftpConfiguration); + } + + public async Task Run(CancellationToken token, params string[] arguments) + { + FtpFileInfo lastUploadedFile = _ftpService.ListFilesExtended() + .Where(f => f.FileType == FtpFileType.File && f.Filename.IndexOf("Availability") > -1) + .OrderByDescending(f => f.Modified) + .First(); + + string file = _ftpService.Download(lastUploadedFile.Filename, Path.GetTempPath()); + + DataTable dataTable = GetDataTable(file); + + using SqlConnection connection = new SqlConnection("Server=tcp:ps-automation-stage.eastus2.cloudapp.azure.com,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=stageuser;Password=]FXepK^cFYS|[H<;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;"); + connection.Open(); + + using SqlBulkCopy bulk = new SqlBulkCopy(connection) + { + DestinationTableName = $"PartAvailability", + BulkCopyTimeout = 14400 + }; + + bulk.WriteToServer(dataTable); + + return; + } + + private DataTable GetDataTable(string filename) + { + using DataTable dataTable = new DataTable(); + dataTable.Columns.Add("Store", typeof(int)); + dataTable.Columns.Add("SKU", typeof(string)); + dataTable.Columns.Add("QTY", typeof(int)); + + using StreamReader reader = new StreamReader(filename); + string line = reader.ReadLine(); // Burn the header row + + while (reader.Peek() > 0) + { + line = reader.ReadLine(); + + string[] columns = line.Split("|"); + for (int i = 0; i < columns.Length; i++) + { + columns[i] = columns[i].Replace("\"", string.Empty); + } + + string sku = columns[1].Trim(); + if (int.TryParse(columns[0], out int store) + && !string.IsNullOrEmpty(sku) + && int.TryParse(columns[2], out int quantity)) + { + dataTable.Rows.Add(new object[] { store, sku, quantity }); + } + } + + return dataTable; + } + } +} diff --git a/PartSource.Automation/Jobs/POC/GetImageUrls.cs b/PartSource.Automation/Jobs/POC/GetImageUrls.cs new file mode 100644 index 0000000..05a5beb --- /dev/null +++ b/PartSource.Automation/Jobs/POC/GetImageUrls.cs @@ -0,0 +1,119 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Newtonsoft.Json; +using PartSource.Data.Contexts; +using PartSource.Data.Models; +using PartSource.Data.Nexpart; +using PartSource.Services; +using Ratermania.Automation.Interfaces; +using Ratermania.Shopify; +using Ratermania.Shopify.Resources; + +namespace PartSource.Automation.Jobs.POC +{ + public class GetImageUrls : IAutomationJob + { + private readonly NexpartService _nexpartService; + private readonly FitmentContext _fitmentContext; + private readonly PartService _partService; + private readonly ShopifyClient _shopifyClient; + + public GetImageUrls(NexpartService nexpartService, PartService partService, FitmentContext fitmentContext, ShopifyClient shopifyClient) + { + _nexpartService = nexpartService; + _fitmentContext = fitmentContext; + _partService = partService; + _shopifyClient = shopifyClient; + } + + public async Task Run(CancellationToken token, params string[] arguments) + { + IList rows = new List { + "\"Line Code\", \"Part Number\", \"Image URL(s)\"" + }; + + using StreamReader reader = new StreamReader("C:\\Users\\Tom\\Desktop\\image parts.csv"); + string line = reader.ReadLine(); // Burn the header row + + while (reader.Peek() > 0) + { + line = reader.ReadLine(); + + string[] columns = line.Split(","); + for (int i = 0; i < columns.Length; i++) + { + columns[i] = columns[i].Replace("\"", string.Empty); + } + + string partsourceCode = columns[0].Trim(); + string partNumber = columns[1].Trim(); + + + IList dcfMappings = await _partService.GetDcfMapping(partsourceCode); + if (dcfMappings.Count == 0) + { + Console.WriteLine($"No images for {partsourceCode} {partNumber}"); + } + + bool hasImage = false; + foreach (DcfMapping mapping in dcfMappings) + { + if (hasImage) + { + continue; + } + + SmartPageDataSearch dataSearch = new SmartPageDataSearch + { + Items = new Item[] + { + new Item + { + MfrCode = mapping.WhiCode, + PartNumber = partNumber + } + }, + DataOption = new[] { "ALL" } + }; + + SmartPageDataSearchResponse response = await _nexpartService.SendRequest(dataSearch); + + if (response.ResponseBody.Item?.Length > 0) + { + List urls = new List(); + + if (!string.IsNullOrEmpty(response.ResponseBody.Item[0].PrimaryImg?.ImgUrl)) + { + urls.Add(response.ResponseBody.Item[0].PrimaryImg?.ImgUrl); + }; + + if (response.ResponseBody.Item[0].AddImgs?.AddImg?.Length > 0) + { + urls.AddRange(response.ResponseBody.Item[0].AddImgs.AddImg.Select(i => i.AddImgUrl)); + } + + if (urls.Count > 0) + { + rows.Add($"\"{partsourceCode}\", \"{partNumber}\", \"{string.Join(";", urls)}\""); + hasImage = true; + } + } + } + + if (!hasImage) + { + Console.WriteLine($"No images for {partsourceCode} {partNumber}"); + } + } + + await File.WriteAllLinesAsync($"C:\\users\\Tom\\desktop\\WHI Images {DateTime.Now:yyyyMMdd}.csv", rows); + } + } +} diff --git a/PartSource.Automation/Jobs/POC/GetImageUrlsTemp.cs b/PartSource.Automation/Jobs/POC/GetImageUrlsTemp.cs new file mode 100644 index 0000000..2c951ea --- /dev/null +++ b/PartSource.Automation/Jobs/POC/GetImageUrlsTemp.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using Newtonsoft.Json; +using PartSource.Data.Contexts; +using PartSource.Data.Models; +using PartSource.Data.Nexpart; +using PartSource.Services; +using Ratermania.Automation.Interfaces; +using Ratermania.Shopify; +using Ratermania.Shopify.Resources; + +namespace PartSource.Automation.Jobs.POC +{ + public class GetImageUrlsTemp : IAutomationJob + { + private readonly NexpartService _nexpartService; + private readonly FitmentContext _fitmentContext; + private readonly PartService _partService; + private readonly ShopifyClient _shopifyClient; + + private readonly string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + public GetImageUrlsTemp(NexpartService nexpartService, PartService partService, FitmentContext fitmentContext, ShopifyClient shopifyClient) + { + _nexpartService = nexpartService; + _fitmentContext = fitmentContext; + _partService = partService; + _shopifyClient = shopifyClient; + } + + public async Task Run(CancellationToken token, params string[] arguments) + { + IList> parts = new List>(); + parts.Add(new KeyValuePair("DAY", "89310")); + parts.Add(new KeyValuePair("CNI", "141.40113")); + parts.Add(new KeyValuePair("PRF", "MU19631")); + parts.Add(new KeyValuePair("TRK", "SB8100")); + parts.Add(new KeyValuePair("MON", "906970")); + parts.Add(new KeyValuePair("FEL", "70804")); + parts.Add(new KeyValuePair("FEL", "SS71198")); + parts.Add(new KeyValuePair("CFP", "STS314")); + parts.Add(new KeyValuePair("NGK", "21517")); + parts.Add(new KeyValuePair("NGK", "RC-XX89")); + parts.Add(new KeyValuePair("FRA", "CA176")); + + for (int i = 0; i < chars.Length; i++) + { + for (int j = 0; j < chars.Length; j++) + { + for (int k = 0; k < chars.Length; k++) + { + string actualLineCode = $"{chars[i]}{chars[j]}{chars[k]}"; + System.Diagnostics.Debug.WriteLine(actualLineCode); + + foreach (KeyValuePair part in parts) + { + + + SmartPageDataSearch dataSearch = new SmartPageDataSearch + { + Items = new Item[] + { + new Item + { + MfrCode = actualLineCode, + PartNumber = part.Value + } + }, + DataOption = new[] { "DIST_LINE", "ALL" } + }; + + SmartPageDataSearchResponse response = await _nexpartService.SendRequest(dataSearch); + + if (response.ResponseBody.Item?.Length > 0) + { + List urls = new List(); + + if (!string.IsNullOrEmpty(response.ResponseBody.Item[0].PrimaryImg?.ImgUrl)) + { + urls.Add(response.ResponseBody.Item[0].PrimaryImg?.ImgUrl); + }; + + if (response.ResponseBody.Item[0].AddImgs?.AddImg?.Length > 0) + { + urls.AddRange(response.ResponseBody.Item[0].AddImgs.AddImg.Select(i => i.AddImgUrl)); + } + + if (urls.Count > 0) + { + Console.WriteLine($"Image {urls[0]} found for {part.Value}. Expected: {part.Key}, Actual: {actualLineCode}"); + } + } + } + } + } + } + } + } +} diff --git a/PartSource.Automation/Jobs/POC/ImageList.cs b/PartSource.Automation/Jobs/POC/ImageList.cs deleted file mode 100644 index 77ec44e..0000000 --- a/PartSource.Automation/Jobs/POC/ImageList.cs +++ /dev/null @@ -1,84 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Newtonsoft.Json; -using PartSource.Data.Contexts; -using PartSource.Data.Models; -using PartSource.Data.Nexpart; -using PartSource.Services; -using Ratermania.Automation.Interfaces; -using Ratermania.Shopify; -using Ratermania.Shopify.Resources; - -namespace PartSource.Automation.Jobs.POC -{ - public class GetImageUrls : IAutomationJob - { - private readonly NexpartService _nexpartService; - private readonly PartSourceContext _partSourceContext; - - public GetImageUrls(NexpartService nexpartService, PartSourceContext partSourceContext) - { - _nexpartService = nexpartService; - _partSourceContext = partSourceContext; - } - - public async Task Run(CancellationToken token, params string[] arguments) - { - IList rows = new List { - "\"Line Code\", \"Part Number\", \"Image URL(s)\"" - }; - - IList importData = await _partSourceContext.ImportData - //.Take(5000) - .ToListAsync(); - - foreach (ImportData item in importData) - { - SmartPageDataSearch dataSearch = new SmartPageDataSearch - { - Items = new Item[] - { - new Item - { - MfrCode = item.LineCode, - PartNumber = item.PartNumber - } - }, - DataOption = new[] { "DIST_LINE", "ALL" } - }; - - SmartPageDataSearchResponse response = await _nexpartService.SendRequest(dataSearch); - - if (response.ResponseBody.Item?.Length > 0) - { - List urls = new List(); - - if (!string.IsNullOrEmpty(response.ResponseBody.Item[0].PrimaryImg?.ImgUrl)) - { - urls.Add(response.ResponseBody.Item[0].PrimaryImg?.ImgUrl); - }; - - if (response.ResponseBody.Item[0].AddImgs?.AddImg?.Length > 0) - { - urls.AddRange(response.ResponseBody.Item[0].AddImgs.AddImg.Select(i => i.AddImgUrl)); - } - - if (urls.Count > 0) - { - rows.Add($"\"{item.LineCode}\", \"{item.PartNumber}\", \"{string.Join(";", urls)}\""); - } - } - - } - - await File.WriteAllLinesAsync("C:\\users\\Tommy\\desktop\\WHI Images.csv", rows); - } - } -} \ No newline at end of file diff --git a/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs b/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs index 754cc30..fddc010 100644 --- a/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs +++ b/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using PartSource.Automation.Models.Configuration; using PartSource.Automation.Models.Ftp; using PartSource.Automation.Services; @@ -18,67 +19,62 @@ namespace PartSource.Automation.Jobs.POC public class PartialInventoryUpdate : IAutomationJob { private readonly FtpService _ftpService; + private readonly ILogger _logger; - public PartialInventoryUpdate(IConfiguration configuration) + public PartialInventoryUpdate(IConfiguration configuration, ILogger logger) { - FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AzureConfiguration").Get(); + FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AutomationConfiguration").Get(); _ftpService = new FtpService(ftpConfiguration); + + _logger = logger; } public async Task Run(CancellationToken token, params string[] arguments) { - FtpFileInfo lastUploadedFile = _ftpService.ListFilesExtended("") - .Where(f => f.FileType == FtpFileType.File && f.Filename.IndexOf("Availability") > -1) + FtpFileInfo lastUploadedFile = _ftpService.ListFilesExtended() + .Where(f => f.FileType == FtpFileType.File && f.Modified >= DateTime.Now.AddHours(-24) && f.Filename.IndexOf("Availability Partial") > -1) .OrderByDescending(f => f.Modified) - .First(); + .FirstOrDefault(); - string file = _ftpService.Download(lastUploadedFile.Filename, Path.GetTempPath()); + if (lastUploadedFile == null) + { + _logger.LogInformation($"No partial inventory file available for the time period {DateTime.Now.AddHours(-24)} - {DateTime.Now}"); + return; + } - DataTable dataTable = GetDataTable(file); + string file = _ftpService.Download($"{lastUploadedFile.Filename}", "C:\\Users\\Tom\\Desktop"); - using SqlConnection connection = new SqlConnection("Server=tcp:ps-automation-stage.eastus2.cloudapp.azure.com,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=stageuser;Password=]FXepK^cFYS|[H<;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;"); + + using SqlConnection connection = new SqlConnection("Server=tcp:ps-automation-stage.eastus2.cloudapp.azure.com,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=stageuser;Password=]FXepK^cFYS|[H<;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;"); connection.Open(); - using SqlBulkCopy bulk = new SqlBulkCopy(connection) - { - DestinationTableName = $"PartAvailability", - BulkCopyTimeout = 14400 - }; + using StreamReader reader = new StreamReader(file); + string line = reader.ReadLine(); // Burn the header row - bulk.WriteToServer(dataTable); + while (reader.Peek() > 0) + { + line = reader.ReadLine(); + + string[] columns = line.Split(","); + for (int i = 0; i < columns.Length; i++) + { + columns[i] = columns[i].Replace("\"", string.Empty); + } + + if (int.TryParse(columns[0], out int store) + && int.TryParse(columns[1], out int quantity) + && int.TryParse(columns[2], out int sku)) + { + using SqlCommand sqlCommand = new SqlCommand("UPDATE Inventory SET QTY = @qty WHERE SKU = @sku AND Store = @store", connection); + sqlCommand.Parameters.Add(new SqlParameter("qty", quantity)); + sqlCommand.Parameters.Add(new SqlParameter("sku", sku)); + sqlCommand.Parameters.Add(new SqlParameter("store", store)); + + await sqlCommand.ExecuteNonQueryAsync(); + } + } return; } - - private DataTable GetDataTable(string filename) - { - using DataTable dataTable = new DataTable(); - dataTable.Columns.Add("Store", typeof(int)); - dataTable.Columns.Add("SKU", typeof(int)); - dataTable.Columns.Add("QTY", typeof(int)); - - using StreamReader reader = new StreamReader(filename); - string line = reader.ReadLine(); // Burn the header row - - while (reader.Peek() > 0) - { - line = reader.ReadLine(); - - string[] columns = line.Split("|"); - for (int i = 0; i < columns.Length; i++) - { - columns[i] = columns[i].Replace("\"", string.Empty); - } - - if (int.TryParse(columns[0], out int store) - && int.TryParse(columns[1], out int sku) - && int.TryParse(columns[2], out int quantity)) - { - dataTable.Rows.Add(new object[] { store, sku, quantity }); - } - } - - return dataTable; - } } } diff --git a/PartSource.Automation/Jobs/ProcessWhiFitment.cs b/PartSource.Automation/Jobs/ProcessWhiFitment.cs index b625e65..5a6f482 100644 --- a/PartSource.Automation/Jobs/ProcessWhiFitment.cs +++ b/PartSource.Automation/Jobs/ProcessWhiFitment.cs @@ -96,9 +96,8 @@ namespace PartSource.Automation.Jobs Task.WaitAll(taskArray); - // _whiSeoService.CreateFitmentView(); - - //_whiSeoService.SaveNotes(_noteDictionary); + _whiSeoService.SaveNotes(_noteDictionary); + //_whiSeoService.CreateFitmentView(); } public string Decompress(FileInfo fileInfo) diff --git a/PartSource.Automation/Jobs/ProcessWhiVehicles.cs b/PartSource.Automation/Jobs/ProcessWhiVehicles.cs index 6ff9f06..2c0352d 100644 --- a/PartSource.Automation/Jobs/ProcessWhiVehicles.cs +++ b/PartSource.Automation/Jobs/ProcessWhiVehicles.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; +using PartSource.Automation.Extensions; using PartSource.Automation.Models.Configuration; using PartSource.Automation.Models.Enums; using PartSource.Automation.Services; @@ -45,7 +46,9 @@ namespace PartSource.Automation.Jobs string directory = Path.Combine(_ftpConfiguration.Destination, _seoDataType.ToString().ToLowerInvariant()); DirectoryInfo directoryInfo = new DirectoryInfo(directory); - IEnumerable files = directoryInfo.GetFiles().Where(f => f.Name.StartsWith("seo_aces_vehicle_feed")); + IEnumerable files = directoryInfo.GetFiles() + .Where(f => f.Name.StartsWith("seo_aces_vehicle_feed")) + .OrderByDescending(f => f.GetWhiTimestamp()); foreach (FileInfo fileInfo in files) { diff --git a/PartSource.Automation/Jobs/UpdateFitment.cs b/PartSource.Automation/Jobs/UpdateFitment.cs index 5eb9c25..2de202a 100644 --- a/PartSource.Automation/Jobs/UpdateFitment.cs +++ b/PartSource.Automation/Jobs/UpdateFitment.cs @@ -40,11 +40,11 @@ namespace PartSource.Automation.Jobs try { - products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 } }); - //products = new List - //{ - // await _shopifyClient.Products.GetById(4388919574575) - //}; + //products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 } }); + products = new List + { + await _shopifyClient.Products.GetById(7285013446703) + }; } catch (Exception ex) @@ -72,40 +72,43 @@ namespace PartSource.Automation.Jobs }; bool isFitment = false; - string bodyHtml = product.BodyHtml.Substring(0, product.BodyHtml.IndexOf("") + "".Length); + string bodyHtml = string.IsNullOrEmpty(product.BodyHtml) + ? "
    " + : product.BodyHtml.Substring(0, product.BodyHtml.IndexOf("") + "".Length); - IList vehicles = _vehicleFitmentService.GetVehiclesForPart(importData.PartNumber, importData.LineCode); + IList vehicles = await _vehicleFitmentService.GetVehiclesForPart(importData.PartNumber, importData.LineCode); IList vehicleIdFitment = _vehicleFitmentService.GetVehicleIdFitment(vehicles); - if (vehicleIdFitment.Count > 0) + if (vehicleIdFitment.Count == 0) { - string vehicleIdString = string.Join(',', vehicleIdFitment.Select(j => $"v{j}")); + continue; + } + string vehicleIdString = string.Join(',', vehicleIdFitment.Select(j => $"v{j}")); - bodyHtml += $"
    {vehicleIdString}
    "; + bodyHtml += $"
    {vehicleIdString}
    "; - isFitment = true; + isFitment = true; - string json = JsonConvert.SerializeObject(vehicleIdFitment); - if (json.Length < 100000) + string json = JsonConvert.SerializeObject(vehicleIdFitment); + if (json.Length < 100000) + { + Metafield vehicleMetafield = new Metafield { - Metafield vehicleMetafield = new Metafield - { - Namespace = "fitment", - Key = "ids", - Value = json, - Type = "json_string", - OwnerResource = "product", - OwnerId = product.Id - }; + Namespace = "fitment", + Key = "ids", + Value = json, + Type = "json_string", + OwnerResource = "product", + OwnerId = product.Id + }; - await _shopifyClient.Metafields.Add(vehicleMetafield); - } + await _shopifyClient.Metafields.Add(vehicleMetafield); + } - else - { - _logger.LogWarning($"Vehicle ID fitment data for SKU {importData.VariantSku} is too large for Shopify and cannot be added."); - continue; - } + else + { + _logger.LogWarning($"Vehicle ID fitment data for SKU {importData.VariantSku} is too large for Shopify and cannot be added."); + continue; } IList ymmFitment = _vehicleFitmentService.GetYmmFitment(vehicles); @@ -135,7 +138,7 @@ namespace PartSource.Automation.Jobs bodyHtml += $"
    {stringBuilder.ToString()}
    "; - string json = JsonConvert.SerializeObject(ymmFitment); + json = JsonConvert.SerializeObject(ymmFitment); if (json.Length < 100000) { Metafield ymmMetafield = new Metafield diff --git a/PartSource.Automation/Jobs/UpdatePositioning.cs b/PartSource.Automation/Jobs/UpdatePositioning.cs index e4cbcf6..9359cba 100644 --- a/PartSource.Automation/Jobs/UpdatePositioning.cs +++ b/PartSource.Automation/Jobs/UpdatePositioning.cs @@ -64,7 +64,7 @@ namespace PartSource.Automation.Jobs } IList fitments = GetPositionOrderedFitments(importData?.PartNumber, importData?.LineCode); - IList vehicles = _vehicleFitmentService.GetVehiclesForPart(importData?.PartNumber, importData?.LineCode); + IList vehicles = await _vehicleFitmentService.GetVehiclesForPart(importData?.PartNumber, importData?.LineCode); if (fitments.Count == 0 || vehicles.Count == 0) { diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index 8790f7e..259ba2f 100644 --- a/PartSource.Automation/Program.cs +++ b/PartSource.Automation/Program.cs @@ -64,49 +64,49 @@ namespace PartSource.Automation .AddShopify(options => { - options.ApiKey = builder.Configuration["Shopify:ApiKey"]; - options.ApiSecret = builder.Configuration["Shopify:ApiSecret"]; - options.ApiVersion = "2022-10"; - options.ShopDomain = builder.Configuration["Shopify:ShopDomain"]; + options.ApiKey = builder.Configuration["Shopify:ApiKey"]; + options.ApiSecret = builder.Configuration["Shopify:ApiSecret"]; + options.ApiVersion = "2022-10"; + options.ShopDomain = builder.Configuration["Shopify:ShopDomain"]; - //options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed"; - //options.ApiSecret = "dc9e28365d9858e544d57ac7af43fee7"; - //options.ApiVersion = "2022-10"; - //options.ShopDomain = "dev-partsource.myshopify.com"; - }) + //options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed"; + //options.ApiSecret = "dc9e28365d9858e544d57ac7af43fee7"; + //options.ApiVersion = "2022-10"; + //options.ShopDomain = "dev-partsource.myshopify.com"; + }) .AddAutomation(options => { options.HasBaseInterval(new TimeSpan(0, 15, 0)) .HasMaxFailures(1) - //.HasJob(options => options.HasInterval(new TimeSpan(7, 0, 0, 0))); - // - //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))) - // .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))); - //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) - //.HasDependency() - //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))); - //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) - // .HasDependency() - // .HasDependency() - // .HasDependency() - // .StartsAt(DateTime.Today.AddHours(8)) - //) ; - //.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(25)) - // ) + //.HasJob(options => options.HasInterval(new TimeSpan(7, 0, 0, 0))); + // + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))) + // .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))); + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) + //.HasDependency() + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))); + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) + // .HasDependency() + // .HasDependency() + // .HasDependency() + // .StartsAt(DateTime.Today.AddHours(8)) + //) ; + //.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(25)) + // ) - .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) - //.HasDependency() - // .StartsAt(DateTime.Today.AddHours(28)) - ); - //); - //.AddApiServer(); - }) + .HasJob(options => options.HasInterval(new TimeSpan(1, 0, 0)) + //.HasDependency() + .StartsAt(new DateTime(2023, 01, 01, 01, 0, 0)) + ); + //); + //.AddApiServer(); + }) .AddSingleton() .AddSingleton() @@ -114,6 +114,7 @@ namespace PartSource.Automation .AddSingleton() .AddSingleton() .AddSingleton() + .AddSingleton() .AddAutoMapper(typeof(PartSourceProfile)); }) diff --git a/PartSource.Automation/Services/FtpService.cs b/PartSource.Automation/Services/FtpService.cs index 84d5a80..c2598a3 100644 --- a/PartSource.Automation/Services/FtpService.cs +++ b/PartSource.Automation/Services/FtpService.cs @@ -19,7 +19,7 @@ namespace PartSource.Automation.Services _ftpConfiguration = ftpConfiguration; } - public IList ListFilesExtended(string directory) + public IList ListFilesExtended(string directory = "") { FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{directory}")); request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); @@ -67,7 +67,7 @@ namespace PartSource.Automation.Services return files; } - public string[] ListFiles(string directory) + public string[] ListFiles(string directory = "") { FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{directory}")); request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); @@ -102,7 +102,12 @@ namespace PartSource.Automation.Services } destination = Path.Combine(destination, filename); - + string destinationDirectory = Path.GetDirectoryName(destination); + if (!Directory.Exists(destinationDirectory)) + { + Directory.CreateDirectory(destinationDirectory); + } + using FtpWebResponse response = (FtpWebResponse)request.GetResponse(); using Stream responseStream = response.GetResponseStream(); using FileStream fileStream = new FileStream(destination, FileMode.Create); diff --git a/PartSource.Automation/Services/SsisService.cs b/PartSource.Automation/Services/SsisService.cs index 6fccf2a..4c15b17 100644 --- a/PartSource.Automation/Services/SsisService.cs +++ b/PartSource.Automation/Services/SsisService.cs @@ -28,7 +28,7 @@ namespace PartSource.Automation.Services { StartInfo = new ProcessStartInfo { - FileName = "dtexec", + FileName = "C:\\Program Files\\Microsoft SQL Server\\150\\DTS\\Binn\\dtexec.exe", Arguments = $"/file \"{_ssisConfiguration.Directory}\\{packageName}\"", UseShellExecute = false, CreateNoWindow = false, diff --git a/PartSource.Automation/Services/VehicleFitmentService.cs b/PartSource.Automation/Services/VehicleFitmentService.cs index d8d5a3d..a4355ba 100644 --- a/PartSource.Automation/Services/VehicleFitmentService.cs +++ b/PartSource.Automation/Services/VehicleFitmentService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using PartSource.Data.Contexts; using PartSource.Data.Dtos; using PartSource.Data.Models; @@ -93,18 +94,19 @@ namespace PartSource.Automation.Services return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToArray(); } - public IList GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0) + public async Task> GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0) { if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode)) { return null; } - partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9\\-]", string.Empty); + partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9]", string.Empty); - IQueryable whiCodes = _fitmentContext.DcfMappings - .Where(d => d.LineCode == lineCode) - .Select(d => d.WhiCode); + IList whiCodes = await _fitmentContext.DcfMappings + .Where(dcf => dcf.LineCode == lineCode) + .Select(dcf => dcf.WhiCode) + .ToListAsync(); IQueryable vehicles = _fitmentContext.Fitments .Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode)) @@ -122,38 +124,5 @@ namespace PartSource.Automation.Services return vehicles.ToList(); } - - public IList GetVehicleFitmentForPart(string partNumber, string lineCode, int maxVehicles = 0) - { - if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode)) - { - return null; - } - - partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9\\-]", string.Empty); - - IQueryable whiCodes = _fitmentContext.DcfMappings - .Where(d => d.LineCode == lineCode) - .Select(d => d.WhiCode); - - IQueryable vehicles = _fitmentContext.Fitments - .Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode)) - .Join(_fitmentContext.Vehicles, - f => new { f.BaseVehicleId, f.EngineConfigId }, - v => new { v.BaseVehicleId, v.EngineConfigId }, - (f, v) => new VehicleFitmentDto - { - Fitment = f, - Vehicle = v - }) - .Distinct(); - - if (maxVehicles > 0) - { - vehicles = vehicles.Take(maxVehicles); - } - - return vehicles.ToList(); - } } } diff --git a/PartSource.Automation/appsettings.json b/PartSource.Automation/appsettings.json index cb63be3..4377f40 100644 --- a/PartSource.Automation/appsettings.json +++ b/PartSource.Automation/appsettings.json @@ -16,6 +16,12 @@ "Url": "ftp://waws-prod-yq1-007.ftp.azurewebsites.windows.net/site/wwwroot", "Destination": "C:\\Partsource.Automation\\Downloads" }, + "AutomationConfiguration": { + "Username": "stageuser", + "Password": "FXepK^cFYS|[H<", + "Url": "ftp://ps-automation-stage.eastus2.cloudapp.azure.com", + "Destination": "C:\\Partsource.Automation\\Downloads\\Stage" + }, "WhiConfiguration": { "Username": "ctc_seo", "Password": "be34hz64e4", @@ -35,7 +41,7 @@ "LogLevel": { "Default": "Information", "Microsoft": "Warning", - "Microsoft.Hosting.Lifetime": "Information", + "Microsoft.Hosting.Lifetime": "Information" // "Microsoft.EntityFrameworkCore.Database.Command": "Information" }, "EventLog": { diff --git a/PartSource.Data/Contexts/FitmentContext.cs b/PartSource.Data/Contexts/FitmentContext.cs index ef1c9a4..ffd356b 100644 --- a/PartSource.Data/Contexts/FitmentContext.cs +++ b/PartSource.Data/Contexts/FitmentContext.cs @@ -19,6 +19,8 @@ namespace PartSource.Data.Contexts public DbSet Vehicles { get; set; } + public DbSet VehicleFitments { get; set; } + public DbSet Wipers { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) @@ -28,6 +30,7 @@ namespace PartSource.Data.Contexts modelBuilder.Entity().HasKey(d => new { d.LineCode, d.WhiCode }); modelBuilder.Entity().HasKey(f => new { f.BaseVehicleId, f.EngineConfigId, f.LineCode, f.PartNumber }); modelBuilder.Entity().HasKey(f => new { f.BaseVehicleId, f.PartNumber, f.LineCode, f.Position}); + modelBuilder.Entity().HasNoKey(); foreach (IMutableEntityType entityType in modelBuilder.Model.GetEntityTypes()) { diff --git a/PartSource.Data/Dtos/VehicleFitmentDto.cs b/PartSource.Data/Dtos/VehicleFitmentDto.cs index 56bf211..682137d 100644 --- a/PartSource.Data/Dtos/VehicleFitmentDto.cs +++ b/PartSource.Data/Dtos/VehicleFitmentDto.cs @@ -5,10 +5,8 @@ using System.Text; namespace PartSource.Data.Dtos { - public class VehicleFitmentDto - { - public Fitment Fitment { get; set; } - - public Vehicle Vehicle { get; set; } - } + public class VehicleFitmentDto : VehicleFitment + { + public IList SubmodelNames { get; set; } + } } diff --git a/PartSource.Data/Models/VehicleFitment.cs b/PartSource.Data/Models/VehicleFitment.cs new file mode 100644 index 0000000..ed55446 --- /dev/null +++ b/PartSource.Data/Models/VehicleFitment.cs @@ -0,0 +1,27 @@ +namespace PartSource.Data.Models +{ + public class VehicleFitment + { + public string Sku { get; set; } + + public string LineCode { get; set; } + + public string PartNumber { get; set; } + + public string NoteText { get; set; } + + public int Year { get; set; } + + public string MakeName { get; set; } + + public string ModelName { get; set; } + + public string SubmodelName { get; set; } + + public int BaseVehicleId { get; set; } + + public int EngineConfigId { get; set; } + + public int VehicleToEngineConfigId { get; set; } + } +} diff --git a/PartSource.Services/FitmentService.cs b/PartSource.Services/FitmentService.cs index 38a2354..6353f3d 100644 --- a/PartSource.Services/FitmentService.cs +++ b/PartSource.Services/FitmentService.cs @@ -1,159 +1,160 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using PartSource.Data.Contexts; using PartSource.Data.Dtos; using PartSource.Data.Models; +using PartSource.Data.Nexpart; namespace PartSource.Services { public class FitmentService { - private readonly FitmentContext _fitmentContext; + private readonly FitmentContext _fitmentContext; - public FitmentService(FitmentContext fitmentContext) + public FitmentService(FitmentContext fitmentContext) { - _fitmentContext = fitmentContext; + _fitmentContext = fitmentContext; } - public IList GetYmmFitment(IList vehicles) - { - if (vehicles.Count == 0) - { - return new string[0]; - } + public async Task GetFitmentNotes(string sku, int vehicleId) + { + VehicleFitmentDto vehicleFitment = await _fitmentContext.VehicleFitments + .Where(vf => vf.VehicleToEngineConfigId == vehicleId && vf.Sku == sku) + .Select(vf => new VehicleFitmentDto + { + Sku = vf.Sku, + LineCode = vf.LineCode, + PartNumber = vf.PartNumber, + NoteText = vf.NoteText, + Year = vf.Year, + MakeName = vf.MakeName, + ModelName = vf.ModelName, + BaseVehicleId = vf.BaseVehicleId, + EngineConfigId = vf.EngineConfigId, + VehicleToEngineConfigId = vf.VehicleToEngineConfigId + }) + .FirstOrDefaultAsync(); - IList fitmentTags = new List(); + if (vehicleFitment == null) + { + return null; + } - IList makeModels = vehicles.OrderBy(v => v.MakeName).ThenBy(v => v.ModelName).Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList(); + vehicleFitment.SubmodelNames = await _fitmentContext.VehicleFitments + .Where(vf => vf.BaseVehicleId == vehicleFitment.BaseVehicleId && vf.Sku == sku) + .Select(vf => vf.SubmodelName) + .Distinct() + .ToListAsync(); - foreach (string makeModel in makeModels) - { - string make = makeModel.Split(',')[0]; - string model = makeModel.Split(',')[1]; + return vehicleFitment; + } - List years = vehicles - .Where(v => v.MakeName == make && v.ModelName == model) - .OrderBy(v => v.Year) - .Select(v => v.Year.ToString().Trim()) - .Distinct() - .ToList(); + public IList GetYmmFitment(IList vehicles) + { + if (vehicles.Count == 0) + { + return new string[0]; + } - string tag = $"{string.Join('-', years)} {make.Trim()} {model.Trim()}"; + IList fitmentTags = new List(); - System.Diagnostics.Debug.WriteLine(tag); + IList makeModels = vehicles.OrderBy(v => v.MakeName).ThenBy(v => v.ModelName).Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList(); - fitmentTags.Add(tag); - } + foreach (string makeModel in makeModels) + { + string make = makeModel.Split(',')[0]; + string model = makeModel.Split(',')[1]; - return fitmentTags; - } + List years = vehicles + .Where(v => v.MakeName == make && v.ModelName == model) + .OrderBy(v => v.Year) + .Select(v => v.Year.ToString().Trim()) + .Distinct() + .ToList(); - public IList GetYmmFitmentRange(IList vehicles) - { - if (vehicles.Count == 0) - { - return new string[0]; - } + string tag = $"{string.Join('-', years)} {make.Trim()} {model.Trim()}"; - IList fitmentTags = new List(); + System.Diagnostics.Debug.WriteLine(tag); - IList makeModels = vehicles.Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList(); + fitmentTags.Add(tag); + } - foreach (string makeModel in makeModels) - { - string make = makeModel.Split(',')[0]; - string model = makeModel.Split(',')[1]; + return fitmentTags; + } - int minYear = vehicles - .Where(v => v.MakeName == make && v.ModelName == model) - .Min(v => v.Year); + public IList GetYmmFitmentRange(IList vehicles) + { + if (vehicles.Count == 0) + { + return new string[0]; + } - int maxYear = vehicles - .Where(v => v.MakeName == make && v.ModelName == model) - .Max(v => v.Year); + IList fitmentTags = new List(); - string tag = minYear == maxYear - ? $"{minYear} {make.Trim()} {model.Trim()}" - : $"{minYear}-{maxYear} {make.Trim()} {model.Trim()}"; + IList makeModels = vehicles.Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList(); - System.Diagnostics.Debug.WriteLine(tag); + foreach (string makeModel in makeModels) + { + string make = makeModel.Split(',')[0]; + string model = makeModel.Split(',')[1]; - fitmentTags.Add(tag); - } + int minYear = vehicles + .Where(v => v.MakeName == make && v.ModelName == model) + .Min(v => v.Year); - return fitmentTags; - } + int maxYear = vehicles + .Where(v => v.MakeName == make && v.ModelName == model) + .Max(v => v.Year); - public IList GetVehicleIdFitment(IList vehicles) - { - return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToList(); - } + string tag = minYear == maxYear + ? $"{minYear} {make.Trim()} {model.Trim()}" + : $"{minYear}-{maxYear} {make.Trim()} {model.Trim()}"; - public IList GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0) - { - if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode)) - { - return null; - } + System.Diagnostics.Debug.WriteLine(tag); - partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9]", string.Empty); + fitmentTags.Add(tag); + } - IQueryable whiCodes = _fitmentContext.DcfMappings - .Where(d => d.LineCode == lineCode) - .Select(d => d.WhiCode); + return fitmentTags; + } - IQueryable vehicles = _fitmentContext.Fitments - .Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode)) - .Join(_fitmentContext.Vehicles, - f => new { f.BaseVehicleId, f.EngineConfigId }, - v => new { v.BaseVehicleId, v.EngineConfigId }, - (f, v) => v) - .Distinct() - .OrderByDescending(x => x.Year); + public IList GetVehicleIdFitment(IList vehicles) + { + return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToList(); + } - if (maxVehicles > 0) - { - vehicles = vehicles.Take(maxVehicles); - } + public IList GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0) + { + if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode)) + { + return null; + } - return vehicles.ToList(); - } + partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9]", string.Empty); - public IList GetVehicleFitmentForPart(string partNumber, string lineCode, int maxVehicles = 0) - { - if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode)) - { - return null; - } + IQueryable whiCodes = _fitmentContext.DcfMappings + .Where(d => d.LineCode == lineCode) + .Select(d => d.WhiCode); - partNumber = Regex.Replace(partNumber, "[^a-zA-Z0-9\\-]", string.Empty); + IQueryable vehicles = _fitmentContext.Fitments + .Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode)) + .Join(_fitmentContext.Vehicles, + f => new { f.BaseVehicleId, f.EngineConfigId }, + v => new { v.BaseVehicleId, v.EngineConfigId }, + (f, v) => v) + .Distinct() + .OrderByDescending(x => x.Year); - IQueryable whiCodes = _fitmentContext.DcfMappings - .Where(d => d.LineCode == lineCode) - .Select(d => d.WhiCode); + if (maxVehicles > 0) + { + vehicles = vehicles.Take(maxVehicles); + } - IQueryable vehicles = _fitmentContext.Fitments - .Where(f => f.PartNumber == partNumber && whiCodes.Contains(f.LineCode)) - .Join(_fitmentContext.Vehicles, - f => new { f.BaseVehicleId, f.EngineConfigId }, - v => new { v.BaseVehicleId, v.EngineConfigId }, - (f, v) => new VehicleFitmentDto - { - Fitment = f, - Vehicle = v - }) - .Distinct(); - - if (maxVehicles > 0) - { - vehicles = vehicles.Take(maxVehicles); - } - - return vehicles.ToList(); - } - } + return vehicles.ToList(); + } + } } From cbf7bb8de6c22878b474eb8668a20e76ec6440c2 Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Wed, 13 Sep 2023 06:34:53 -0400 Subject: [PATCH 3/4] Namespace migration --- .../PartSource.Automation.csproj | 2 +- PartSource.Automation/Program.cs | 16 ++--- PartSource.Data/Nexpart/AddImg.cs | 2 +- PartSource.Data/Nexpart/AddImgs.cs | 2 +- PartSource.Data/Nexpart/App.cs | 2 +- PartSource.Data/Nexpart/ApplicationSearch.cs | 2 +- .../Nexpart/ApplicationSearchResponse.cs | 2 +- PartSource.Data/Nexpart/Apps.cs | 4 +- PartSource.Data/Nexpart/BaseVehicle.cs | 2 +- PartSource.Data/Nexpart/BaseVehicleDetail.cs | 10 ++-- .../Nexpart/BaseVehicleDetailLookup.cs | 2 +- .../BaseVehicleDetailLookupResponse.cs | 2 +- PartSource.Data/Nexpart/BaseVehicleSearch.cs | 2 +- .../Nexpart/BaseVehicleSearchResponse.cs | 2 +- PartSource.Data/Nexpart/BaseVehicles.cs | 4 +- PartSource.Data/Nexpart/Body.cs | 58 +++++++++---------- PartSource.Data/Nexpart/Criterion.cs | 2 +- PartSource.Data/Nexpart/Engine.cs | 2 +- PartSource.Data/Nexpart/EngineSearch.cs | 2 +- .../Nexpart/EngineSearchResponse.cs | 2 +- PartSource.Data/Nexpart/Engines.cs | 4 +- PartSource.Data/Nexpart/Exceptions.cs | 2 +- PartSource.Data/Nexpart/Item.cs | 2 +- PartSource.Data/Nexpart/Items.cs | 4 +- PartSource.Data/Nexpart/Make.cs | 2 +- PartSource.Data/Nexpart/MakeSearch.cs | 10 ++-- PartSource.Data/Nexpart/MakeSearchResponse.cs | 2 +- PartSource.Data/Nexpart/Makes.cs | 4 +- PartSource.Data/Nexpart/MenuNode.cs | 2 +- PartSource.Data/Nexpart/MenuNodes.cs | 4 +- PartSource.Data/Nexpart/MenuNodesLookup.cs | 2 +- .../Nexpart/MenuNodesLookupResponse.cs | 2 +- PartSource.Data/Nexpart/Model.cs | 2 +- PartSource.Data/Nexpart/ModelSearch.cs | 12 ++-- .../Nexpart/ModelSearchResponse.cs | 4 +- PartSource.Data/Nexpart/Models.cs | 4 +- PartSource.Data/Nexpart/PSRequestHeader.cs | 6 +- PartSource.Data/Nexpart/PSResponseHeader.cs | 14 ++--- PartSource.Data/Nexpart/Part.cs | 4 +- PartSource.Data/Nexpart/PartNumber.cs | 2 +- PartSource.Data/Nexpart/PartType.cs | 2 +- PartSource.Data/Nexpart/PartTypeSearch.cs | 2 +- .../Nexpart/PartTypeSearchResponse.cs | 2 +- PartSource.Data/Nexpart/PartTypes.cs | 4 +- .../Nexpart/PartTypesValidateLookup.cs | 2 +- .../PartTypesValidateLookupResponse.cs | 2 +- PartSource.Data/Nexpart/PrimaryImg.cs | 2 +- PartSource.Data/Nexpart/Region.cs | 2 +- PartSource.Data/Nexpart/RegionId.cs | 2 +- PartSource.Data/Nexpart/ResultOption.cs | 2 +- .../Nexpart/SmartPageDataSearch.cs | 8 +-- .../Nexpart/SmartPageDataSearchResponse.cs | 2 +- PartSource.Data/Nexpart/SubModel.cs | 2 +- .../Nexpart/SubModelSearchResponse.cs | 2 +- PartSource.Data/Nexpart/SubModels.cs | 4 +- PartSource.Data/Nexpart/SubModelsSearch.cs | 2 +- PartSource.Data/Nexpart/VehicleDetail.cs | 4 +- PartSource.Data/Nexpart/VehicleIdSearch.cs | 2 +- .../Nexpart/VehicleIdSearchResponse.cs | 2 +- PartSource.Data/Nexpart/VehicleIdentifier.cs | 6 +- PartSource.Data/Nexpart/VehicleType.cs | 2 +- PartSource.Data/Nexpart/VehicleTypes.cs | 4 +- PartSource.Data/Nexpart/VehicleTypesGet.cs | 4 +- .../Nexpart/VehicleTypesGetResponse.cs | 2 +- PartSource.Data/Nexpart/WHIEngine.cs | 2 +- PartSource.Data/Nexpart/WHIEngineSearch.cs | 2 +- .../Nexpart/WHIEngineSearchResponse.cs | 2 +- PartSource.Data/Nexpart/WHIEngines.cs | 4 +- PartSource.Data/Nexpart/Years.cs | 2 +- PartSource.Services/NexpartService.cs | 2 +- .../PartSource.Services.csproj | 2 +- PartSource.sln | 20 ------- 72 files changed, 147 insertions(+), 167 deletions(-) diff --git a/PartSource.Automation/PartSource.Automation.csproj b/PartSource.Automation/PartSource.Automation.csproj index 8609737..68b6933 100644 --- a/PartSource.Automation/PartSource.Automation.csproj +++ b/PartSource.Automation/PartSource.Automation.csproj @@ -21,11 +21,11 @@ +
    - diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index 259ba2f..63a5c38 100644 --- a/PartSource.Automation/Program.cs +++ b/PartSource.Automation/Program.cs @@ -77,7 +77,7 @@ namespace PartSource.Automation .AddAutomation(options => { - options.HasBaseInterval(new TimeSpan(0, 15, 0)) + options.HasBaseInterval(new TimeSpan(0, 5, 0)) .HasMaxFailures(1) //.HasJob(options => options.HasInterval(new TimeSpan(7, 0, 0, 0))); // @@ -95,15 +95,15 @@ 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(25)) - // ) + .HasJob(options => + options.HasInterval(new TimeSpan(24, 0, 0)) + .StartsAt(DateTime.Today) + ); - .HasJob(options => options.HasInterval(new TimeSpan(1, 0, 0)) + //.HasJob(options => options.HasInterval(new TimeSpan(1, 0, 0)) //.HasDependency() - .StartsAt(new DateTime(2023, 01, 01, 01, 0, 0)) - ); + // .StartsAt(DateTime.Today) + //); //); //.AddApiServer(); }) diff --git a/PartSource.Data/Nexpart/AddImg.cs b/PartSource.Data/Nexpart/AddImg.cs index d653707..2f140e6 100644 --- a/PartSource.Data/Nexpart/AddImg.cs +++ b/PartSource.Data/Nexpart/AddImg.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class AddImg { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/AddImgs.cs b/PartSource.Data/Nexpart/AddImgs.cs index 245b816..bd62473 100644 --- a/PartSource.Data/Nexpart/AddImgs.cs +++ b/PartSource.Data/Nexpart/AddImgs.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class AddImgs { [XmlElement] diff --git a/PartSource.Data/Nexpart/App.cs b/PartSource.Data/Nexpart/App.cs index 81308cf..9e429f8 100644 --- a/PartSource.Data/Nexpart/App.cs +++ b/PartSource.Data/Nexpart/App.cs @@ -8,7 +8,7 @@ using Newtonsoft.Json; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class App { [XmlElement] diff --git a/PartSource.Data/Nexpart/ApplicationSearch.cs b/PartSource.Data/Nexpart/ApplicationSearch.cs index d343f32..b4a3a29 100644 --- a/PartSource.Data/Nexpart/ApplicationSearch.cs +++ b/PartSource.Data/Nexpart/ApplicationSearch.cs @@ -7,7 +7,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class ApplicationSearch { public ApplicationSearch() diff --git a/PartSource.Data/Nexpart/ApplicationSearchResponse.cs b/PartSource.Data/Nexpart/ApplicationSearchResponse.cs index b9b4bbf..1b20c86 100644 --- a/PartSource.Data/Nexpart/ApplicationSearchResponse.cs +++ b/PartSource.Data/Nexpart/ApplicationSearchResponse.cs @@ -8,7 +8,7 @@ using PartSource.Data.Nexpart.Interfaces; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class ApplicationSearchResponse : IResponseElement { diff --git a/PartSource.Data/Nexpart/Apps.cs b/PartSource.Data/Nexpart/Apps.cs index c10214d..de49601 100644 --- a/PartSource.Data/Nexpart/Apps.cs +++ b/PartSource.Data/Nexpart/Apps.cs @@ -3,10 +3,10 @@ using Newtonsoft.Json; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class Apps { - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] [JsonProperty("wipers")] public App[] App { get; set; } } diff --git a/PartSource.Data/Nexpart/BaseVehicle.cs b/PartSource.Data/Nexpart/BaseVehicle.cs index 6f10dd4..632ef67 100644 --- a/PartSource.Data/Nexpart/BaseVehicle.cs +++ b/PartSource.Data/Nexpart/BaseVehicle.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class BaseVehicle { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/BaseVehicleDetail.cs b/PartSource.Data/Nexpart/BaseVehicleDetail.cs index 667ef30..b819b19 100644 --- a/PartSource.Data/Nexpart/BaseVehicleDetail.cs +++ b/PartSource.Data/Nexpart/BaseVehicleDetail.cs @@ -8,22 +8,22 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class BaseVehicleDetail { [XmlAttribute] public int WHIMakeId { get; set; } - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public int BaseVehicleId { get; set; } - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public string MakeName { get; set; } - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public string ModelName { get; set; } - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public int Year { get; set; } } } diff --git a/PartSource.Data/Nexpart/BaseVehicleDetailLookup.cs b/PartSource.Data/Nexpart/BaseVehicleDetailLookup.cs index b7e90f3..e5534d8 100644 --- a/PartSource.Data/Nexpart/BaseVehicleDetailLookup.cs +++ b/PartSource.Data/Nexpart/BaseVehicleDetailLookup.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class BaseVehicleDetailLookup { public BaseVehicleDetailLookup() diff --git a/PartSource.Data/Nexpart/BaseVehicleDetailLookupResponse.cs b/PartSource.Data/Nexpart/BaseVehicleDetailLookupResponse.cs index b4d8b28..2514726 100644 --- a/PartSource.Data/Nexpart/BaseVehicleDetailLookupResponse.cs +++ b/PartSource.Data/Nexpart/BaseVehicleDetailLookupResponse.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class BaseVehicleDetailLookupResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/BaseVehicleSearch.cs b/PartSource.Data/Nexpart/BaseVehicleSearch.cs index fda2c9e..fb7b6cf 100644 --- a/PartSource.Data/Nexpart/BaseVehicleSearch.cs +++ b/PartSource.Data/Nexpart/BaseVehicleSearch.cs @@ -2,7 +2,7 @@ namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class BaseVehicleSearch { public BaseVehicleSearch() diff --git a/PartSource.Data/Nexpart/BaseVehicleSearchResponse.cs b/PartSource.Data/Nexpart/BaseVehicleSearchResponse.cs index 1dcd8b2..f9bc7e6 100644 --- a/PartSource.Data/Nexpart/BaseVehicleSearchResponse.cs +++ b/PartSource.Data/Nexpart/BaseVehicleSearchResponse.cs @@ -3,7 +3,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class BaseVehicleSearchResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/BaseVehicles.cs b/PartSource.Data/Nexpart/BaseVehicles.cs index 3367fd3..52343ae 100644 --- a/PartSource.Data/Nexpart/BaseVehicles.cs +++ b/PartSource.Data/Nexpart/BaseVehicles.cs @@ -5,10 +5,10 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class BaseVehicles { - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public BaseVehicle[] BaseVehicle { get; set; } diff --git a/PartSource.Data/Nexpart/Body.cs b/PartSource.Data/Nexpart/Body.cs index c38881f..0780391 100644 --- a/PartSource.Data/Nexpart/Body.cs +++ b/PartSource.Data/Nexpart/Body.cs @@ -8,37 +8,37 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class Body { - [XmlElement(ElementName = "ApplicationSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(ApplicationSearch))] - [XmlElement(ElementName = "ApplicationSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(ApplicationSearchResponse))] - [XmlElement(ElementName = "BaseVehicleDetailLookup", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(BaseVehicleDetailLookup))] - [XmlElement(ElementName = "BaseVehicleDetailLookupResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(BaseVehicleDetailLookupResponse))] - [XmlElement(ElementName = "BaseVehicleSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(BaseVehicleSearch))] - [XmlElement(ElementName = "BaseVehicleSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(BaseVehicleSearchResponse))] - [XmlElement(ElementName = "EngineSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(EngineSearch))] - [XmlElement(ElementName = "EngineSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(EngineSearchResponse))] - [XmlElement(ElementName = "MakeSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(MakeSearch))] - [XmlElement(ElementName = "MakeSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(MakeSearchResponse))] - [XmlElement(ElementName = "ModelSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(ModelSearch))] - [XmlElement(ElementName = "ModelSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(ModelSearchResponse))] - [XmlElement(ElementName = "MenuNodesLookup", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(MenuNodesLookup))] - [XmlElement(ElementName = "MenuNodesLookupResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(MenuNodesLookupResponse))] - [XmlElement(ElementName = "PartTypeSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(PartTypeSearch))] - [XmlElement(ElementName = "PartTypeSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(PartTypeSearchResponse))] - [XmlElement(ElementName = "PartTypesValidateLookup", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(PartTypesValidateLookup))] - [XmlElement(ElementName = "PartTypesValidateLookupResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(PartTypesValidateLookupResponse))] - [XmlElement(ElementName = "SmartPageDataSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(SmartPageDataSearch))] - [XmlElement(ElementName = "SmartPageDataSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(SmartPageDataSearchResponse))] - [XmlElement(ElementName = "SubModelSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(SubModelSearch))] - [XmlElement(ElementName = "SubModelSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(SubModelSearchResponse))] - [XmlElement(ElementName = "VehicleIdSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(VehicleIdSearch))] - [XmlElement(ElementName = "VehicleIdSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(VehicleIdSearchResponse))] - [XmlElement(ElementName = "VehicleTypesGet", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(VehicleTypesGet))] - [XmlElement(ElementName = "VehicleTypesGetResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(VehicleTypesGetResponse))] - [XmlElement(ElementName = "WHIEngineSearch", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(WHIEngineSearch))] - [XmlElement(ElementName = "WHIEngineSearchResponse", Namespace = "http://whisolutions.com/PartSelectService-v1", Type = typeof(WHIEngineSearchResponse))] + [XmlElement(ElementName = "ApplicationSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(ApplicationSearch))] + [XmlElement(ElementName = "ApplicationSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(ApplicationSearchResponse))] + [XmlElement(ElementName = "BaseVehicleDetailLookup", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(BaseVehicleDetailLookup))] + [XmlElement(ElementName = "BaseVehicleDetailLookupResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(BaseVehicleDetailLookupResponse))] + [XmlElement(ElementName = "BaseVehicleSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(BaseVehicleSearch))] + [XmlElement(ElementName = "BaseVehicleSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(BaseVehicleSearchResponse))] + [XmlElement(ElementName = "EngineSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(EngineSearch))] + [XmlElement(ElementName = "EngineSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(EngineSearchResponse))] + [XmlElement(ElementName = "MakeSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(MakeSearch))] + [XmlElement(ElementName = "MakeSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(MakeSearchResponse))] + [XmlElement(ElementName = "ModelSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(ModelSearch))] + [XmlElement(ElementName = "ModelSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(ModelSearchResponse))] + [XmlElement(ElementName = "MenuNodesLookup", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(MenuNodesLookup))] + [XmlElement(ElementName = "MenuNodesLookupResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(MenuNodesLookupResponse))] + [XmlElement(ElementName = "PartTypeSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(PartTypeSearch))] + [XmlElement(ElementName = "PartTypeSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(PartTypeSearchResponse))] + [XmlElement(ElementName = "PartTypesValidateLookup", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(PartTypesValidateLookup))] + [XmlElement(ElementName = "PartTypesValidateLookupResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(PartTypesValidateLookupResponse))] + [XmlElement(ElementName = "SmartPageDataSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(SmartPageDataSearch))] + [XmlElement(ElementName = "SmartPageDataSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(SmartPageDataSearchResponse))] + [XmlElement(ElementName = "SubModelSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(SubModelSearch))] + [XmlElement(ElementName = "SubModelSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(SubModelSearchResponse))] + [XmlElement(ElementName = "VehicleIdSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(VehicleIdSearch))] + [XmlElement(ElementName = "VehicleIdSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(VehicleIdSearchResponse))] + [XmlElement(ElementName = "VehicleTypesGet", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(VehicleTypesGet))] + [XmlElement(ElementName = "VehicleTypesGetResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(VehicleTypesGetResponse))] + [XmlElement(ElementName = "WHIEngineSearch", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(WHIEngineSearch))] + [XmlElement(ElementName = "WHIEngineSearchResponse", Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(WHIEngineSearchResponse))] public object Content { get; set; } } } diff --git a/PartSource.Data/Nexpart/Criterion.cs b/PartSource.Data/Nexpart/Criterion.cs index 73ae819..15386cf 100644 --- a/PartSource.Data/Nexpart/Criterion.cs +++ b/PartSource.Data/Nexpart/Criterion.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class Criterion { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/Engine.cs b/PartSource.Data/Nexpart/Engine.cs index 1ccffc9..395260a 100644 --- a/PartSource.Data/Nexpart/Engine.cs +++ b/PartSource.Data/Nexpart/Engine.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class Engine { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/EngineSearch.cs b/PartSource.Data/Nexpart/EngineSearch.cs index 587b0e5..c9e7812 100644 --- a/PartSource.Data/Nexpart/EngineSearch.cs +++ b/PartSource.Data/Nexpart/EngineSearch.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class EngineSearch { public EngineSearch() diff --git a/PartSource.Data/Nexpart/EngineSearchResponse.cs b/PartSource.Data/Nexpart/EngineSearchResponse.cs index 9be5b2f..d0d5ee1 100644 --- a/PartSource.Data/Nexpart/EngineSearchResponse.cs +++ b/PartSource.Data/Nexpart/EngineSearchResponse.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class EngineSearchResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/Engines.cs b/PartSource.Data/Nexpart/Engines.cs index 63674cd..0049192 100644 --- a/PartSource.Data/Nexpart/Engines.cs +++ b/PartSource.Data/Nexpart/Engines.cs @@ -8,10 +8,10 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class Engines { - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public Engine[] Engine; } } diff --git a/PartSource.Data/Nexpart/Exceptions.cs b/PartSource.Data/Nexpart/Exceptions.cs index 2594481..e081fdf 100644 --- a/PartSource.Data/Nexpart/Exceptions.cs +++ b/PartSource.Data/Nexpart/Exceptions.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/header/parts")] public class Exceptions { [XmlAttribute(AttributeName = "code")] diff --git a/PartSource.Data/Nexpart/Item.cs b/PartSource.Data/Nexpart/Item.cs index e9a4b00..14406db 100644 --- a/PartSource.Data/Nexpart/Item.cs +++ b/PartSource.Data/Nexpart/Item.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class Item { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/Items.cs b/PartSource.Data/Nexpart/Items.cs index ee3d888..bd93d8d 100644 --- a/PartSource.Data/Nexpart/Items.cs +++ b/PartSource.Data/Nexpart/Items.cs @@ -8,10 +8,10 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class Items { - [XmlElement(ElementName = "Item", Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21", Order = 1)] + [XmlElement(ElementName = "Item", Namespace = "http://whisolutions.com/pss/common/helper/parts", Order = 1)] public PartSource.Data.Nexpart.Item[] Item { get; set; } } } diff --git a/PartSource.Data/Nexpart/Make.cs b/PartSource.Data/Nexpart/Make.cs index fd48574..5b1a4ba 100644 --- a/PartSource.Data/Nexpart/Make.cs +++ b/PartSource.Data/Nexpart/Make.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class Make { [XmlText] diff --git a/PartSource.Data/Nexpart/MakeSearch.cs b/PartSource.Data/Nexpart/MakeSearch.cs index 6dec0ce..4bd441a 100644 --- a/PartSource.Data/Nexpart/MakeSearch.cs +++ b/PartSource.Data/Nexpart/MakeSearch.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class MakeSearch { public MakeSearch() @@ -18,16 +18,16 @@ namespace PartSource.Data.Nexpart this.RegionId = new int[]{ 2 }; } - [XmlElement(ElementName = "PSRequestHeader", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 1)] + [XmlElement(ElementName = "PSRequestHeader", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 1)] public PSRequestHeader PSRequestHeader { get; set; } - [XmlElement(ElementName = "Years", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 2)] + [XmlElement(ElementName = "Years", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 2)] public Years Years { get; set; } - [XmlElement(ElementName = "RegionId", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 3)] + [XmlElement(ElementName = "RegionId", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 3)] public int[] RegionId { get; set; } - [XmlElement(ElementName = "VehicleTypeId", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 4)] + [XmlElement(ElementName = "VehicleTypeId", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 4)] public int[] VehicleTypeId { get; set; } } } diff --git a/PartSource.Data/Nexpart/MakeSearchResponse.cs b/PartSource.Data/Nexpart/MakeSearchResponse.cs index 9337679..b362e73 100644 --- a/PartSource.Data/Nexpart/MakeSearchResponse.cs +++ b/PartSource.Data/Nexpart/MakeSearchResponse.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class MakeSearchResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/Makes.cs b/PartSource.Data/Nexpart/Makes.cs index 18d87a3..1d53157 100644 --- a/PartSource.Data/Nexpart/Makes.cs +++ b/PartSource.Data/Nexpart/Makes.cs @@ -8,10 +8,10 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class Makes { - [XmlElement(ElementName = "Make", Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21", Order = 1)] + [XmlElement(ElementName = "Make", Namespace = "http://whisolutions.com/pss/common/helper/parts", Order = 1)] public PartSource.Data.Nexpart.Make[] Make { get; set; } } } diff --git a/PartSource.Data/Nexpart/MenuNode.cs b/PartSource.Data/Nexpart/MenuNode.cs index 794921a..ef39a3e 100644 --- a/PartSource.Data/Nexpart/MenuNode.cs +++ b/PartSource.Data/Nexpart/MenuNode.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class MenuNode { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/MenuNodes.cs b/PartSource.Data/Nexpart/MenuNodes.cs index f6c8c63..f2166f8 100644 --- a/PartSource.Data/Nexpart/MenuNodes.cs +++ b/PartSource.Data/Nexpart/MenuNodes.cs @@ -8,10 +8,10 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class MenuNodes { - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public MenuNode[] MenuNode{ get; set; } } } diff --git a/PartSource.Data/Nexpart/MenuNodesLookup.cs b/PartSource.Data/Nexpart/MenuNodesLookup.cs index 5e03f10..b990541 100644 --- a/PartSource.Data/Nexpart/MenuNodesLookup.cs +++ b/PartSource.Data/Nexpart/MenuNodesLookup.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class MenuNodesLookup { public MenuNodesLookup() diff --git a/PartSource.Data/Nexpart/MenuNodesLookupResponse.cs b/PartSource.Data/Nexpart/MenuNodesLookupResponse.cs index 16c74ae..46f0e8b 100644 --- a/PartSource.Data/Nexpart/MenuNodesLookupResponse.cs +++ b/PartSource.Data/Nexpart/MenuNodesLookupResponse.cs @@ -3,7 +3,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class MenuNodesLookupResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/Model.cs b/PartSource.Data/Nexpart/Model.cs index af901c3..c5d33cc 100644 --- a/PartSource.Data/Nexpart/Model.cs +++ b/PartSource.Data/Nexpart/Model.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class Model { [XmlText] diff --git a/PartSource.Data/Nexpart/ModelSearch.cs b/PartSource.Data/Nexpart/ModelSearch.cs index 9c13a71..2c5596c 100644 --- a/PartSource.Data/Nexpart/ModelSearch.cs +++ b/PartSource.Data/Nexpart/ModelSearch.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class ModelSearch { public ModelSearch() @@ -17,19 +17,19 @@ namespace PartSource.Data.Nexpart this.RegionId = new int[] { 2 }; } - [XmlElement(ElementName = "PSRequestHeader", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 1)] + [XmlElement(ElementName = "PSRequestHeader", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 1)] public PSRequestHeader PSRequestHeader { get; set; } - [XmlElement(ElementName = "Year", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 2)] + [XmlElement(ElementName = "Year", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 2)] public int Year { get; set; } - [XmlElement(ElementName = "MakeId", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 3)] + [XmlElement(ElementName = "MakeId", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 3)] public int MakeId { get; set; } - [XmlElement(ElementName = "RegionId", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 4)] + [XmlElement(ElementName = "RegionId", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 4)] public int[] RegionId { get; set; } - [XmlElement(ElementName = "VehicleTypeId", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 5)] + [XmlElement(ElementName = "VehicleTypeId", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 5)] public int[] VehicleTypeId { get; set; } } } diff --git a/PartSource.Data/Nexpart/ModelSearchResponse.cs b/PartSource.Data/Nexpart/ModelSearchResponse.cs index af77cee..37c57f7 100644 --- a/PartSource.Data/Nexpart/ModelSearchResponse.cs +++ b/PartSource.Data/Nexpart/ModelSearchResponse.cs @@ -9,13 +9,13 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class ModelSearchResponse : IResponseElement { [XmlElement] public PSResponseHeader PSResponseHeader { get; set; } - [XmlElement(ElementName = "Models", Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlElement(ElementName = "Models", Namespace = "http://whisolutions.com/pss/common/model/parts")] public Models[] ResponseBody { get; set; } } } diff --git a/PartSource.Data/Nexpart/Models.cs b/PartSource.Data/Nexpart/Models.cs index 9c01ea2..222e82a 100644 --- a/PartSource.Data/Nexpart/Models.cs +++ b/PartSource.Data/Nexpart/Models.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class Models { public Models() @@ -19,7 +19,7 @@ namespace PartSource.Data.Nexpart [XmlAttribute] public int Region { get; set; } - [XmlElement(ElementName = "Model", Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(ElementName = "Model", Namespace = "http://whisolutions.com/pss/common/helper/parts")] public PartSource.Data.Nexpart.Model[] Model { get; set; } } } diff --git a/PartSource.Data/Nexpart/PSRequestHeader.cs b/PartSource.Data/Nexpart/PSRequestHeader.cs index f5497e5..c42f82c 100644 --- a/PartSource.Data/Nexpart/PSRequestHeader.cs +++ b/PartSource.Data/Nexpart/PSRequestHeader.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class PSRequestHeader { public PSRequestHeader() @@ -17,10 +17,10 @@ namespace PartSource.Data.Nexpart this.ReturnWarnings = "true"; } - [XmlElement(ElementName = "SvcVersion", Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlElement(ElementName = "SvcVersion", Namespace = "http://whisolutions.com/pss/common/header/parts")] public string SvcVersion { get; set; } - [XmlElement(ElementName = "ReturnWarnings", Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlElement(ElementName = "ReturnWarnings", Namespace = "http://whisolutions.com/pss/common/header/parts")] public string ReturnWarnings { get; set; } } } diff --git a/PartSource.Data/Nexpart/PSResponseHeader.cs b/PartSource.Data/Nexpart/PSResponseHeader.cs index 9967d02..481f4c0 100644 --- a/PartSource.Data/Nexpart/PSResponseHeader.cs +++ b/PartSource.Data/Nexpart/PSResponseHeader.cs @@ -8,25 +8,25 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class PSResponseHeader { - [XmlElement(ElementName = "RequestId", Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlElement(ElementName = "RequestId", Namespace = "http://whisolutions.com/pss/common/header/parts")] public string RequestId { get; set; } - [XmlElement(ElementName = "RequestProcessingTime", Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlElement(ElementName = "RequestProcessingTime", Namespace = "http://whisolutions.com/pss/common/header/parts")] public string RequestProcessingTime { get; set; } - [XmlElement(ElementName = "Build", Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlElement(ElementName = "Build", Namespace = "http://whisolutions.com/pss/common/header/parts")] public string Build { get; set; } - [XmlElement(ElementName = "TimeStamp", Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlElement(ElementName = "TimeStamp", Namespace = "http://whisolutions.com/pss/common/header/parts")] public string TimeStamp { get; set; } - [XmlElement(ElementName = "StatusCode", Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlElement(ElementName = "StatusCode", Namespace = "http://whisolutions.com/pss/common/header/parts")] public string StatusCode { get; set; } - [XmlElement(ElementName = "Exceptions", Namespace = "http://whisolutions.com/PartSelectCommon/2011-07-21")] + [XmlElement(ElementName = "Exceptions", Namespace = "http://whisolutions.com/pss/common/header/parts")] public PartSource.Data.Nexpart.Exceptions[] Exceptions { get; set; } } } diff --git a/PartSource.Data/Nexpart/Part.cs b/PartSource.Data/Nexpart/Part.cs index f6cfc75..b1bd4e2 100644 --- a/PartSource.Data/Nexpart/Part.cs +++ b/PartSource.Data/Nexpart/Part.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class Part { [XmlElement] @@ -15,7 +15,7 @@ namespace PartSource.Data.Nexpart public PartPartType PartType { get; set; } // There are two different kinds of PartType because of course there are... - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class PartPartType { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/PartNumber.cs b/PartSource.Data/Nexpart/PartNumber.cs index 42ceeea..05cdcea 100644 --- a/PartSource.Data/Nexpart/PartNumber.cs +++ b/PartSource.Data/Nexpart/PartNumber.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class PartNumber { [XmlText] diff --git a/PartSource.Data/Nexpart/PartType.cs b/PartSource.Data/Nexpart/PartType.cs index ad179e8..f5acb7f 100644 --- a/PartSource.Data/Nexpart/PartType.cs +++ b/PartSource.Data/Nexpart/PartType.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class PartType { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/PartTypeSearch.cs b/PartSource.Data/Nexpart/PartTypeSearch.cs index 707b06f..4489511 100644 --- a/PartSource.Data/Nexpart/PartTypeSearch.cs +++ b/PartSource.Data/Nexpart/PartTypeSearch.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class PartTypeSearch { public PartTypeSearch() diff --git a/PartSource.Data/Nexpart/PartTypeSearchResponse.cs b/PartSource.Data/Nexpart/PartTypeSearchResponse.cs index 0316603..81ac907 100644 --- a/PartSource.Data/Nexpart/PartTypeSearchResponse.cs +++ b/PartSource.Data/Nexpart/PartTypeSearchResponse.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class PartTypeSearchResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/PartTypes.cs b/PartSource.Data/Nexpart/PartTypes.cs index ba5345e..1240b3f 100644 --- a/PartSource.Data/Nexpart/PartTypes.cs +++ b/PartSource.Data/Nexpart/PartTypes.cs @@ -8,10 +8,10 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class PartTypes { - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public PartSource.Data.Nexpart.PartType[] PartType { get; set; } } } diff --git a/PartSource.Data/Nexpart/PartTypesValidateLookup.cs b/PartSource.Data/Nexpart/PartTypesValidateLookup.cs index 0cde0d3..ab73f4b 100644 --- a/PartSource.Data/Nexpart/PartTypesValidateLookup.cs +++ b/PartSource.Data/Nexpart/PartTypesValidateLookup.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class PartTypesValidateLookup { public PartTypesValidateLookup() diff --git a/PartSource.Data/Nexpart/PartTypesValidateLookupResponse.cs b/PartSource.Data/Nexpart/PartTypesValidateLookupResponse.cs index 116169a..0433467 100644 --- a/PartSource.Data/Nexpart/PartTypesValidateLookupResponse.cs +++ b/PartSource.Data/Nexpart/PartTypesValidateLookupResponse.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class PartTypesValidateLookupResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/PrimaryImg.cs b/PartSource.Data/Nexpart/PrimaryImg.cs index fb0dfdc..9e15b5f 100644 --- a/PartSource.Data/Nexpart/PrimaryImg.cs +++ b/PartSource.Data/Nexpart/PrimaryImg.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class PrimaryImg { [XmlElement] diff --git a/PartSource.Data/Nexpart/Region.cs b/PartSource.Data/Nexpart/Region.cs index bb5513a..f023b51 100644 --- a/PartSource.Data/Nexpart/Region.cs +++ b/PartSource.Data/Nexpart/Region.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class Region { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/RegionId.cs b/PartSource.Data/Nexpart/RegionId.cs index de0f944..e19ebc2 100644 --- a/PartSource.Data/Nexpart/RegionId.cs +++ b/PartSource.Data/Nexpart/RegionId.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class RegionId { [XmlText] diff --git a/PartSource.Data/Nexpart/ResultOption.cs b/PartSource.Data/Nexpart/ResultOption.cs index c26ccbd..9d71f27 100644 --- a/PartSource.Data/Nexpart/ResultOption.cs +++ b/PartSource.Data/Nexpart/ResultOption.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class ResultOption { [XmlText] diff --git a/PartSource.Data/Nexpart/SmartPageDataSearch.cs b/PartSource.Data/Nexpart/SmartPageDataSearch.cs index f85f0b0..5831ff8 100644 --- a/PartSource.Data/Nexpart/SmartPageDataSearch.cs +++ b/PartSource.Data/Nexpart/SmartPageDataSearch.cs @@ -2,7 +2,7 @@ namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class SmartPageDataSearch { public SmartPageDataSearch() @@ -10,15 +10,15 @@ namespace PartSource.Data.Nexpart PSRequestHeader = new PSRequestHeader(); } - [XmlElement(ElementName = "PSRequestHeader", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 1)] + [XmlElement(ElementName = "PSRequestHeader", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 1)] public PSRequestHeader PSRequestHeader { get; set; } - [XmlElement(ElementName = "Item", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 2)] + [XmlElement(ElementName = "Item", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 2)] public Item[] Items { get; set; } - [XmlElement(ElementName = "DataOption", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 3)] + [XmlElement(ElementName = "DataOption", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 3)] public string[] DataOption { get; set; } } } diff --git a/PartSource.Data/Nexpart/SmartPageDataSearchResponse.cs b/PartSource.Data/Nexpart/SmartPageDataSearchResponse.cs index 28b3f44..28f2550 100644 --- a/PartSource.Data/Nexpart/SmartPageDataSearchResponse.cs +++ b/PartSource.Data/Nexpart/SmartPageDataSearchResponse.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class SmartPageDataSearchResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/SubModel.cs b/PartSource.Data/Nexpart/SubModel.cs index 366ee88..a9c4496 100644 --- a/PartSource.Data/Nexpart/SubModel.cs +++ b/PartSource.Data/Nexpart/SubModel.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class SubModel { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/SubModelSearchResponse.cs b/PartSource.Data/Nexpart/SubModelSearchResponse.cs index 5b2f7e1..ca17cb3 100644 --- a/PartSource.Data/Nexpart/SubModelSearchResponse.cs +++ b/PartSource.Data/Nexpart/SubModelSearchResponse.cs @@ -6,7 +6,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class SubModelSearchResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/SubModels.cs b/PartSource.Data/Nexpart/SubModels.cs index a2ba80b..7b64ea0 100644 --- a/PartSource.Data/Nexpart/SubModels.cs +++ b/PartSource.Data/Nexpart/SubModels.cs @@ -5,10 +5,10 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class SubModels { - [XmlElement(ElementName = "SubModel", Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21", Order = 1)] + [XmlElement(ElementName = "SubModel", Namespace = "http://whisolutions.com/pss/common/helper/parts", Order = 1)] public SubModel[] SubModel { get; set; } } } diff --git a/PartSource.Data/Nexpart/SubModelsSearch.cs b/PartSource.Data/Nexpart/SubModelsSearch.cs index 6e7813a..091b16a 100644 --- a/PartSource.Data/Nexpart/SubModelsSearch.cs +++ b/PartSource.Data/Nexpart/SubModelsSearch.cs @@ -2,7 +2,7 @@ namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class SubModelSearch { public SubModelSearch() diff --git a/PartSource.Data/Nexpart/VehicleDetail.cs b/PartSource.Data/Nexpart/VehicleDetail.cs index 315d311..6718eb9 100644 --- a/PartSource.Data/Nexpart/VehicleDetail.cs +++ b/PartSource.Data/Nexpart/VehicleDetail.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class VehicleDetail { [XmlAttribute] @@ -32,7 +32,7 @@ namespace PartSource.Data.Nexpart [XmlAttribute] public int VehicleToEngineConfigId { get; set; } - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public BaseVehicle BaseVehicle { get; set; } } } diff --git a/PartSource.Data/Nexpart/VehicleIdSearch.cs b/PartSource.Data/Nexpart/VehicleIdSearch.cs index 46ebad0..29b2ec1 100644 --- a/PartSource.Data/Nexpart/VehicleIdSearch.cs +++ b/PartSource.Data/Nexpart/VehicleIdSearch.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class VehicleIdSearch { public VehicleIdSearch() diff --git a/PartSource.Data/Nexpart/VehicleIdSearchResponse.cs b/PartSource.Data/Nexpart/VehicleIdSearchResponse.cs index b96ade7..7548250 100644 --- a/PartSource.Data/Nexpart/VehicleIdSearchResponse.cs +++ b/PartSource.Data/Nexpart/VehicleIdSearchResponse.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class VehicleIdSearchResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/VehicleIdentifier.cs b/PartSource.Data/Nexpart/VehicleIdentifier.cs index b292248..c1ec837 100644 --- a/PartSource.Data/Nexpart/VehicleIdentifier.cs +++ b/PartSource.Data/Nexpart/VehicleIdentifier.cs @@ -8,13 +8,13 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class VehicleIdentifier { - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public int BaseVehicleId { get; set; } - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public int EngineConfigId { get; set; } public bool ShouldSerializeBaseVehicleId() diff --git a/PartSource.Data/Nexpart/VehicleType.cs b/PartSource.Data/Nexpart/VehicleType.cs index ac7fa9a..309816c 100644 --- a/PartSource.Data/Nexpart/VehicleType.cs +++ b/PartSource.Data/Nexpart/VehicleType.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class VehicleType { [XmlText] diff --git a/PartSource.Data/Nexpart/VehicleTypes.cs b/PartSource.Data/Nexpart/VehicleTypes.cs index 004d989..bf6e59d 100644 --- a/PartSource.Data/Nexpart/VehicleTypes.cs +++ b/PartSource.Data/Nexpart/VehicleTypes.cs @@ -8,10 +8,10 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class VehicleTypes { - [XmlElement(ElementName = "VehicleType", Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21", Order = 1)] + [XmlElement(ElementName = "VehicleType", Namespace = "http://whisolutions.com/pss/common/helper/parts", Order = 1)] public PartSource.Data.Nexpart.VehicleType[] VehicleType { get; set; } } } diff --git a/PartSource.Data/Nexpart/VehicleTypesGet.cs b/PartSource.Data/Nexpart/VehicleTypesGet.cs index 82e8b0e..c582be6 100644 --- a/PartSource.Data/Nexpart/VehicleTypesGet.cs +++ b/PartSource.Data/Nexpart/VehicleTypesGet.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class VehicleTypesGet { public VehicleTypesGet() @@ -16,7 +16,7 @@ namespace PartSource.Data.Nexpart this.PSRequestHeader = new PSRequestHeader(); } - [XmlElement(ElementName = "PSRequestHeader", Namespace = "http://whisolutions.com/PartSelectService-v1", Order = 1)] + [XmlElement(ElementName = "PSRequestHeader", Namespace = "http://whisolutions.com/pss/common/model/parts", Order = 1)] public PSRequestHeader PSRequestHeader { get; set; } } } diff --git a/PartSource.Data/Nexpart/VehicleTypesGetResponse.cs b/PartSource.Data/Nexpart/VehicleTypesGetResponse.cs index a550513..46484b4 100644 --- a/PartSource.Data/Nexpart/VehicleTypesGetResponse.cs +++ b/PartSource.Data/Nexpart/VehicleTypesGetResponse.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class VehicleTypesGetResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/WHIEngine.cs b/PartSource.Data/Nexpart/WHIEngine.cs index ddad15c..43547ad 100644 --- a/PartSource.Data/Nexpart/WHIEngine.cs +++ b/PartSource.Data/Nexpart/WHIEngine.cs @@ -2,7 +2,7 @@ namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/helper/parts")] public class WHIEngine { [XmlAttribute] diff --git a/PartSource.Data/Nexpart/WHIEngineSearch.cs b/PartSource.Data/Nexpart/WHIEngineSearch.cs index 06bab14..0884144 100644 --- a/PartSource.Data/Nexpart/WHIEngineSearch.cs +++ b/PartSource.Data/Nexpart/WHIEngineSearch.cs @@ -5,7 +5,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class WHIEngineSearch { public WHIEngineSearch() diff --git a/PartSource.Data/Nexpart/WHIEngineSearchResponse.cs b/PartSource.Data/Nexpart/WHIEngineSearchResponse.cs index ff6d027..2df44c8 100644 --- a/PartSource.Data/Nexpart/WHIEngineSearchResponse.cs +++ b/PartSource.Data/Nexpart/WHIEngineSearchResponse.cs @@ -6,7 +6,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class WHIEngineSearchResponse : IResponseElement { [XmlElement] diff --git a/PartSource.Data/Nexpart/WHIEngines.cs b/PartSource.Data/Nexpart/WHIEngines.cs index 6b7e2d6..94adfeb 100644 --- a/PartSource.Data/Nexpart/WHIEngines.cs +++ b/PartSource.Data/Nexpart/WHIEngines.cs @@ -2,10 +2,10 @@ namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class WHIEngines { - [XmlElement(Namespace = "http://whisolutions.com/PartSelectServ/2011-07-21")] + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] public WHIEngine[] WHIEngine; } } diff --git a/PartSource.Data/Nexpart/Years.cs b/PartSource.Data/Nexpart/Years.cs index 2202041..2aba94c 100644 --- a/PartSource.Data/Nexpart/Years.cs +++ b/PartSource.Data/Nexpart/Years.cs @@ -8,7 +8,7 @@ using System.Xml.Serialization; namespace PartSource.Data.Nexpart { - [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/PartSelectService-v1")] + [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] public class Years { [XmlAttribute(AttributeName = "to")] diff --git a/PartSource.Services/NexpartService.cs b/PartSource.Services/NexpartService.cs index c0c24d3..c09dc82 100644 --- a/PartSource.Services/NexpartService.cs +++ b/PartSource.Services/NexpartService.cs @@ -32,7 +32,7 @@ namespace PartSource.Services try { //HttpResponseMessage response = await client.PostAsync(ConfigurationManager.AppSettings["NexpartUrl"], (HttpContent)new StringContent(sb.ToString(), Encoding.UTF8, "text/xml")); - HttpResponseMessage response = await client.PostAsync("http://acespssprod.nexpart.com:8081/partselect/1.0/services/PartSelectService.PartSelectHttpSoap11Endpoint/", new StringContent(textWriter.ToString(), Encoding.UTF8)); + HttpResponseMessage response = await client.PostAsync("http://acespssprod.nexpart.com:8085/partselect/2.0/services/PartSelectService.PartSelectHttpSoap11Endpoint", new StringContent(textWriter.ToString(), Encoding.UTF8)); Stream result = await response.Content.ReadAsStreamAsync(); string str = await response.Content.ReadAsStringAsync(); diff --git a/PartSource.Services/PartSource.Services.csproj b/PartSource.Services/PartSource.Services.csproj index 38a3ec3..6d967c3 100644 --- a/PartSource.Services/PartSource.Services.csproj +++ b/PartSource.Services/PartSource.Services.csproj @@ -14,10 +14,10 @@ + - diff --git a/PartSource.sln b/PartSource.sln index f439b13..198692f 100644 --- a/PartSource.sln +++ b/PartSource.sln @@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PartSource.Services", "Part EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PartSource.Automation", "PartSource.Automation\PartSource.Automation.csproj", "{C85D675B-A76C-4F9C-9C57-1E063211C946}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shopify", "..\ratermania\Packages\Shopify\Shopify.csproj", "{1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Also Debug|Any CPU = Also Debug|Any CPU @@ -98,24 +96,6 @@ Global {C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x64.Build.0 = Release|Any CPU {C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x86.ActiveCfg = Release|Any CPU {C85D675B-A76C-4F9C-9C57-1E063211C946}.Release|x86.Build.0 = Release|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|Any CPU.Build.0 = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|x64.ActiveCfg = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|x64.Build.0 = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|x86.ActiveCfg = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Also Debug|x86.Build.0 = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|x64.ActiveCfg = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|x64.Build.0 = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|x86.ActiveCfg = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Debug|x86.Build.0 = Debug|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|Any CPU.Build.0 = Release|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|x64.ActiveCfg = Release|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|x64.Build.0 = Release|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|x86.ActiveCfg = Release|Any CPU - {1A9096CE-AF40-4DBA-A754-93F8CFC1EBDA}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 857f94c59a168022a4b960a832345ab729e33cf2 Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Fri, 4 Apr 2025 00:18:03 +0000 Subject: [PATCH 4/4] Hourly inventory updates --- .../Jobs/POC/BulkUpdateInventory.cs | 31 ++- .../Jobs/POC/PartialInventoryUpdate.cs | 21 +- PartSource.Automation/Program.cs | 200 +++++++++--------- PartSource.Automation/Services/FtpService.cs | 12 +- PartSource.Automation/appsettings.json | 4 +- 5 files changed, 149 insertions(+), 119 deletions(-) diff --git a/PartSource.Automation/Jobs/POC/BulkUpdateInventory.cs b/PartSource.Automation/Jobs/POC/BulkUpdateInventory.cs index 067d963..5b60373 100644 --- a/PartSource.Automation/Jobs/POC/BulkUpdateInventory.cs +++ b/PartSource.Automation/Jobs/POC/BulkUpdateInventory.cs @@ -8,6 +8,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; using PartSource.Automation.Models.Configuration; using PartSource.Automation.Models.Ftp; using PartSource.Automation.Services; @@ -18,36 +19,50 @@ namespace PartSource.Automation.Jobs.POC public class BulkUpdateInventory : IAutomationJob { private readonly FtpService _ftpService; + private readonly ILogger _logger; - public BulkUpdateInventory(IConfiguration configuration) + public BulkUpdateInventory(IConfiguration configuration, ILogger logger) { - FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AzureConfiguration").Get(); + FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:AutomationConfiguration").Get(); _ftpService = new FtpService(ftpConfiguration); + + _logger = logger; } public async Task Run(CancellationToken token, params string[] arguments) { FtpFileInfo lastUploadedFile = _ftpService.ListFilesExtended() - .Where(f => f.FileType == FtpFileType.File && f.Filename.IndexOf("Availability") > -1) + .Where(f => f.FileType == FtpFileType.File && f.Filename.IndexOf("Availability Full") > -1) .OrderByDescending(f => f.Modified) - .First(); + .FirstOrDefault(); - string file = _ftpService.Download(lastUploadedFile.Filename, Path.GetTempPath()); + if (lastUploadedFile == null) + { + _logger.LogInformation($"No full inventory file available."); + return; + } + + string file = _ftpService.Download(lastUploadedFile.Filename); DataTable dataTable = GetDataTable(file); - using SqlConnection connection = new SqlConnection("Server=tcp:ps-automation-stage.eastus2.cloudapp.azure.com,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=stageuser;Password=]FXepK^cFYS|[H<;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;"); + 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;"); connection.Open(); + using SqlCommand command = new SqlCommand("TRUNCATE TABLE PartAvailability", connection); + await command.ExecuteNonQueryAsync(); + using SqlBulkCopy bulk = new SqlBulkCopy(connection) { - DestinationTableName = $"PartAvailability", + DestinationTableName = "PartAvailability", BulkCopyTimeout = 14400 }; bulk.WriteToServer(dataTable); - return; + _ftpService.Delete(lastUploadedFile.Filename); + + return; } private DataTable GetDataTable(string filename) diff --git a/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs b/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs index fddc010..ff6286e 100644 --- a/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs +++ b/PartSource.Automation/Jobs/POC/PartialInventoryUpdate.cs @@ -32,20 +32,21 @@ namespace PartSource.Automation.Jobs.POC public async Task Run(CancellationToken token, params string[] arguments) { FtpFileInfo lastUploadedFile = _ftpService.ListFilesExtended() - .Where(f => f.FileType == FtpFileType.File && f.Modified >= DateTime.Now.AddHours(-24) && f.Filename.IndexOf("Availability Partial") > -1) + .Where(f => f.FileType == FtpFileType.File && f.Filename.IndexOf("Availability Partial") > -1) .OrderByDescending(f => f.Modified) .FirstOrDefault(); if (lastUploadedFile == null) { - _logger.LogInformation($"No partial inventory file available for the time period {DateTime.Now.AddHours(-24)} - {DateTime.Now}"); + _logger.LogInformation($"No partial inventory file available."); return; } - string file = _ftpService.Download($"{lastUploadedFile.Filename}", "C:\\Users\\Tom\\Desktop"); + _logger.LogInformation("Processing {filename}", lastUploadedFile.Filename); + string file = _ftpService.Download($"{lastUploadedFile.Filename}"); - using SqlConnection connection = new SqlConnection("Server=tcp:ps-automation-stage.eastus2.cloudapp.azure.com,1433;Initial Catalog=ps-whi-stage;Persist Security Info=False;User ID=stageuser;Password=]FXepK^cFYS|[H<;MultipleActiveResultSets=True;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;"); + 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;"); connection.Open(); using StreamReader reader = new StreamReader(file); @@ -55,17 +56,17 @@ namespace PartSource.Automation.Jobs.POC { line = reader.ReadLine(); - string[] columns = line.Split(","); + string[] columns = line.Split("|"); for (int i = 0; i < columns.Length; i++) { columns[i] = columns[i].Replace("\"", string.Empty); } if (int.TryParse(columns[0], out int store) - && int.TryParse(columns[1], out int quantity) - && int.TryParse(columns[2], out int sku)) + && int.TryParse(columns[1], out int sku) + && int.TryParse(columns[2], out int quantity)) { - using SqlCommand sqlCommand = new SqlCommand("UPDATE Inventory SET QTY = @qty WHERE SKU = @sku AND Store = @store", connection); + using SqlCommand sqlCommand = new SqlCommand("UPDATE PartAvailability SET QTY = @qty WHERE SKU = @sku AND Store = @store", connection); sqlCommand.Parameters.Add(new SqlParameter("qty", quantity)); sqlCommand.Parameters.Add(new SqlParameter("sku", sku)); sqlCommand.Parameters.Add(new SqlParameter("store", store)); @@ -74,7 +75,9 @@ namespace PartSource.Automation.Jobs.POC } } - return; + _ftpService.Delete(lastUploadedFile.Filename); + + return; } } } diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index 63a5c38..9b3b2a3 100644 --- a/PartSource.Automation/Program.cs +++ b/PartSource.Automation/Program.cs @@ -1,5 +1,4 @@ -using AutoMapper; -using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -7,12 +6,10 @@ using Microsoft.Extensions.Logging; using PartSource.Automation.Jobs; using PartSource.Automation.Jobs.POC; using PartSource.Automation.Services; -using PartSource.Data; using PartSource.Data.AutoMapper; using PartSource.Data.Contexts; using PartSource.Services; using Ratermania.Automation.DependencyInjection; -using Ratermania.Automation.Logging; using Ratermania.Shopify.DependencyInjection; using System; using System.IO; @@ -20,111 +17,116 @@ using System.Threading.Tasks; namespace PartSource.Automation { - class Program - { - static async Task Main(string[] args){ - try - { - using IHost host = CreateHostBuilder().Build(); + class Program + { + static async Task Main(string[] args) + { + try + { + using IHost host = CreateHostBuilder().Build(); - await host.StartAsync(); - } + await host.StartAsync(); + } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - throw; - } - } + catch (Exception ex) + { + Console.WriteLine(ex.ToString()); + throw; + } + } - private static IHostBuilder CreateHostBuilder() - { - return Host.CreateDefaultBuilder() - .ConfigureAppConfiguration(builder => - { - string environment = Environment.GetEnvironmentVariable("AUTOMATION_ENVIRONMENT"); + private static IHostBuilder CreateHostBuilder() + { + return Host.CreateDefaultBuilder() + .ConfigureAppConfiguration(builder => + { + string environment = Environment.GetEnvironmentVariable("AUTOMATION_ENVIRONMENT"); - builder.SetBasePath(Directory.GetCurrentDirectory()) - .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true); - }) - .ConfigureServices((builder, services) => - { - services.AddDbContext(options => - options.UseSqlServer(builder.Configuration.GetConnectionString("PartSourceDatabase"), opts => opts.EnableRetryOnFailure()) - ) + builder.SetBasePath(Directory.GetCurrentDirectory()) + .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) + .AddJsonFile($"appsettings.{environment}.json", optional: true, reloadOnChange: true); + }) + .ConfigureServices((builder, services) => + { + services.AddDbContext(options => + options.UseSqlServer(builder.Configuration.GetConnectionString("PartSourceDatabase"), opts => opts.EnableRetryOnFailure()) + ) - .AddDbContext(options => - options.UseSqlServer(builder.Configuration.GetConnectionString("FitmentDatabase"), opts => - { - opts.EnableRetryOnFailure(); - opts.CommandTimeout(600); - }) - ) + .AddDbContext(options => + options.UseSqlServer(builder.Configuration.GetConnectionString("FitmentDatabase"), opts => + { + opts.EnableRetryOnFailure(); + opts.CommandTimeout(600); + }) + ) - .AddShopify(options => - { - options.ApiKey = builder.Configuration["Shopify:ApiKey"]; - options.ApiSecret = builder.Configuration["Shopify:ApiSecret"]; - options.ApiVersion = "2022-10"; - options.ShopDomain = builder.Configuration["Shopify:ShopDomain"]; + .AddShopify(options => + { + options.ApiKey = builder.Configuration["Shopify:ApiKey"]; + options.ApiSecret = builder.Configuration["Shopify:ApiSecret"]; + options.ApiVersion = "2022-10"; + options.ShopDomain = builder.Configuration["Shopify:ShopDomain"]; - //options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed"; - //options.ApiSecret = "dc9e28365d9858e544d57ac7af43fee7"; - //options.ApiVersion = "2022-10"; - //options.ShopDomain = "dev-partsource.myshopify.com"; - }) + //options.ApiKey = "9a533dad460321c6ce8f30bf5b8691ed"; + //options.ApiSecret = "dc9e28365d9858e544d57ac7af43fee7"; + //options.ApiVersion = "2022-10"; + //options.ShopDomain = "dev-partsource.myshopify.com"; + }) - .AddAutomation(options => - { - options.HasBaseInterval(new TimeSpan(0, 5, 0)) - .HasMaxFailures(1) - //.HasJob(options => options.HasInterval(new TimeSpan(7, 0, 0, 0))); - // - //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))) - // .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))); - //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) - //.HasDependency() - //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))); - //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) - // .HasDependency() - // .HasDependency() - // .HasDependency() - // .StartsAt(DateTime.Today.AddHours(8)) - //) ; - //.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) - ); + .AddAutomation(options => + { + options.HasBaseInterval(new TimeSpan(0, 5, 0)) + .HasMaxFailures(1) + //.HasJob(options => options.HasInterval(new TimeSpan(7, 0, 0, 0))); + // + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))) + // .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))); + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) + //.HasDependency() + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0))); + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) + // .HasDependency() + // .HasDependency() + // .HasDependency() + // .StartsAt(DateTime.Today.AddHours(8)) + //) ; + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) + // .StartsAt(DateTime.Parse("2021-04-01 08:00:00")) + //) + .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() - // .StartsAt(DateTime.Today) - //); - //); - //.AddApiServer(); - }) + //.HasJob(options => options.HasInterval(new TimeSpan(1, 0, 0)) + //.HasDependency() + // .StartsAt(DateTime.Today) + //); + //); + //.AddApiServer(); + }) - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() - .AddAutoMapper(typeof(PartSourceProfile)); - }) - .ConfigureLogging((builder, logging) => - { - logging.AddEventLog(); - logging.AddConsole(); + .AddAutoMapper(typeof(PartSourceProfile)); + }) + .ConfigureLogging((builder, logging) => + { + logging.AddEventLog(); + logging.AddConsole(); - // logging.AddProvider(new AutomationLoggerProvider()); - }); - } - } + // logging.AddProvider(new AutomationLoggerProvider()); + }); + } + } } diff --git a/PartSource.Automation/Services/FtpService.cs b/PartSource.Automation/Services/FtpService.cs index c2598a3..3609296 100644 --- a/PartSource.Automation/Services/FtpService.cs +++ b/PartSource.Automation/Services/FtpService.cs @@ -85,8 +85,6 @@ namespace PartSource.Automation.Services public string Download(string filename, string destination = null) { - - FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{filename}")); request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); request.Method = WebRequestMethods.Ftp.DownloadFile; @@ -116,5 +114,15 @@ namespace PartSource.Automation.Services return destination; } + + public void Delete(string filename) + { + FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri($"{_ftpConfiguration.Url}/{filename}")); + request.Credentials = new NetworkCredential(_ftpConfiguration.Username, _ftpConfiguration.Password); + request.Method = WebRequestMethods.Ftp.DeleteFile; + + + using FtpWebResponse response = (FtpWebResponse)request.GetResponse(); + } } } diff --git a/PartSource.Automation/appsettings.json b/PartSource.Automation/appsettings.json index 4377f40..2fc2d0a 100644 --- a/PartSource.Automation/appsettings.json +++ b/PartSource.Automation/appsettings.json @@ -1,6 +1,8 @@ { "ConnectionStrings": { - "FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true;TrustServerCertificate=True", + //"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true;TrustServerCertificate=True", + //"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;User ID=stageuser;Password=FXepK^cFYS|[H<;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300", + "FitmentDatabase": "Data Source=localhost;User ID=stageuser;Password=FXepK^cFYS|[H<;Connect Timeout=30;Encrypt=True;Trust Server Certificate=True;Application Intent=ReadWrite;Multi Subnet Failover=False", "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": {