From 547c5c935c53828eaba34c1b61237e6a9bf05fd2 Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Wed, 13 Sep 2023 09:33:14 -0400 Subject: [PATCH 1/8] WIP --- PartSource.Data/Contexts/FitmentContext.cs | 4 ++- PartSource.Data/Models/VehicleFitment.cs | 27 +++++++++++++++++ PartSource.Services/FitmentService.cs | 35 +++++++++++++++++++++- 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 PartSource.Data/Models/VehicleFitment.cs diff --git a/PartSource.Data/Contexts/FitmentContext.cs b/PartSource.Data/Contexts/FitmentContext.cs index ef1c9a4..af33cc3 100644 --- a/PartSource.Data/Contexts/FitmentContext.cs +++ b/PartSource.Data/Contexts/FitmentContext.cs @@ -19,7 +19,9 @@ namespace PartSource.Data.Contexts public DbSet Vehicles { get; set; } - public DbSet Wipers { get; set; } + public DbSet VehicleFitments { get; set; } + + public DbSet Wipers { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { 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..945cc30 100644 --- a/PartSource.Services/FitmentService.cs +++ b/PartSource.Services/FitmentService.cs @@ -19,7 +19,40 @@ namespace PartSource.Services _fitmentContext = fitmentContext; } - public IList GetYmmFitment(IList vehicles) + 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(); + + if (vehicleFitment == null) + { + return null; + } + + vehicleFitment.SubmodelNames = await _fitmentContext.VehicleFitments + .Where(vf => vf.BaseVehicleId == vehicleFitment.BaseVehicleId && vf.Sku == sku) + .Select(vf => vf.SubmodelName) + .Distinct() + .ToListAsync(); + + return vehicleFitment; + } + + public IList GetYmmFitment(IList vehicles) { if (vehicles.Count == 0) { From 6a81fe4f87259564f80e67540efe39d30efac31a Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Wed, 13 Sep 2023 09:41:33 -0400 Subject: [PATCH 2/8] WIP --- PartSource.Api/Controllers/PartsController.cs | 33 +++++++++++++----- PartSource.Api/PartSource.Api.csproj | 1 + PartSource.Api/Startup.cs | 5 +-- .../PartSource.Automation.csproj | 2 +- .../Services/VehicleFitmentService.cs | 33 ------------------ PartSource.Data/Dtos/VehicleFitmentDto.cs | 12 +++---- PartSource.Services/FitmentService.cs | 34 +------------------ .../PartSource.Services.csproj | 2 +- PartSource.sln | 20 ----------- 9 files changed, 37 insertions(+), 105 deletions(-) diff --git a/PartSource.Api/Controllers/PartsController.cs b/PartSource.Api/Controllers/PartsController.cs index a007504..6d719cc 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] @@ -54,10 +71,10 @@ namespace PartSource.Api.Controllers IList mappings = await _partService.GetDcfMapping(part.LineCode); Item[] items = mappings.Select(m => new Item - { - PartNumber = part.PartNumber, - MfrCode = m.WhiCode - }) + { + PartNumber = part.PartNumber, + MfrCode = m.WhiCode + }) .ToArray(); SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch @@ -76,9 +93,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..572789a 100644 --- a/PartSource.Api/PartSource.Api.csproj +++ b/PartSource.Api/PartSource.Api.csproj @@ -35,6 +35,7 @@ + diff --git a/PartSource.Api/Startup.cs b/PartSource.Api/Startup.cs index ec84a24..6d068f2 100644 --- a/PartSource.Api/Startup.cs +++ b/PartSource.Api/Startup.cs @@ -50,8 +50,9 @@ namespace PartSource.Api }); services.AddAutoMapper(typeof(PartSourceProfile)); - - services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); 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/Services/VehicleFitmentService.cs b/PartSource.Automation/Services/VehicleFitmentService.cs index d8d5a3d..b082315 100644 --- a/PartSource.Automation/Services/VehicleFitmentService.cs +++ b/PartSource.Automation/Services/VehicleFitmentService.cs @@ -122,38 +122,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.Data/Dtos/VehicleFitmentDto.cs b/PartSource.Data/Dtos/VehicleFitmentDto.cs index 56bf211..d1b29ed 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; } + } +} \ No newline at end of file diff --git a/PartSource.Services/FitmentService.cs b/PartSource.Services/FitmentService.cs index 945cc30..a32a80a 100644 --- a/PartSource.Services/FitmentService.cs +++ b/PartSource.Services/FitmentService.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; @@ -155,38 +156,5 @@ namespace PartSource.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.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 9a2d57f97597071d154be76a7b84c4007c21ebc2 Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Wed, 13 Sep 2023 09:44:04 -0400 Subject: [PATCH 3/8] WIP --- PartSource.Api/PartSource.Api.csproj | 1 - PartSource.Api/Startup.cs | 6 +++--- PartSource.Api/appsettings.json | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PartSource.Api/PartSource.Api.csproj b/PartSource.Api/PartSource.Api.csproj index 572789a..55bc2ca 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 6d068f2..af62368 100644 --- a/PartSource.Api/Startup.cs +++ b/PartSource.Api/Startup.cs @@ -70,9 +70,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..b609459 100644 --- a/PartSource.Api/appsettings.json +++ b/PartSource.Api/appsettings.json @@ -2,6 +2,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": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true" + "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" }, "Logging": { "LogLevel": { From 469fb0ff5f0ed0e206a65581357ba49943503607 Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Wed, 11 Oct 2023 13:52:53 -0400 Subject: [PATCH 4/8] DBContext changes --- PartSource.Automation/Jobs/UpdateFitment.cs | 439 +++++++++++--------- PartSource.Data/Contexts/FitmentContext.cs | 3 +- 2 files changed, 245 insertions(+), 197 deletions(-) diff --git a/PartSource.Automation/Jobs/UpdateFitment.cs b/PartSource.Automation/Jobs/UpdateFitment.cs index 3b74881..8b1f9de 100644 --- a/PartSource.Automation/Jobs/UpdateFitment.cs +++ b/PartSource.Automation/Jobs/UpdateFitment.cs @@ -38,212 +38,259 @@ namespace PartSource.Automation.Jobs IEnumerable products = null; - try + IList partTypes = new List { - products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 }, { "product_type", "CA111-SC250-FL25049_Entry Ball Joints" } }); - //products = new List - //{ - // await _shopifyClient.Products.GetById(4388919574575) - //}; - } + "CA115-SC118-FL11803_Custom Lighting Accessories", + "CA117-SC141-FL14106_Jeep Accessories", + "CA117-SC141-FL14134_Truck Running Board and Steps", + "CA117-SC141-FL14199_Bumpers, Bull Bars & Brush Guards", + "CA117-SC157-FL15704_Headache Rack Frames", + "CA117-SC158-FL15802_Salters and Plow Accessories", + "CA117-SC699-FL69902_Crossover Boxes", + "CA117-SC699-FL69903_Specialty Boxes", + "CA117-SC699-FL69904_Transfer Tanks", + "CA135-SC176-FL17601_Trailer Lighting, Stop, Turn, Tail", + "CA135-SC186-FL18607_Roof Racks", + "CA135-SC186-FL18608_Bike Carriers", + "CA135-SC186-FL18609_Cargo Accessories", + "CA135-SC186-FL18610_Cargo Carriers", + "CA135-SC186-FL18611_Watersport Carriers", + "CA135-SC192-FL19201_Class 1 Hitches", + "CA135-SC192-FL19202_Class 2 Hitches", + "CA135-SC192-FL19203_Class 3 Hitches", + "CA135-SC192-FL19204_Towing, Heavy Duty", + "CA135-SC192-FL19205_Towing Electrical, Vehicle Specific", + "CA135-SC192-FL19206_Trailer Parts & Accessories", + "CA135-SC192-FL19207_Trailer Winches, Jacks & Couplers", + "CA135-SC192-FL19208_Class 5 Hitches", + "CA135-SC192-FL19221_Towing Electrical, Connectors & Adapters", + "CA135-SC192-FL19230_Towing Electrical, Controls & Converters", + "CA135-SC192-FL19235_Towing Electrical, Harnesses", + "CA135-SC192-FL19240_Towing Security, Non-Locking", + "CA135-SC192-FL19245_Towing Class V", + "CA135-SC192-FL19280_Towing Balls", + "CA135-SC192-FL19281_Towing Ball Mounts", + "CA135-SC192-FL19282_Towing Security, Locking", + "CA135-SC192-FL19283_Towing Kits & Acc" + }; - catch (Exception ex) + foreach (string partType in partTypes) { - _logger.LogError("Failed to get products from Shopify", ex); - throw; - } - - int i = 1; - - while (products != null && products.Any()) - { - foreach (Product product in products) - { - ImportData importData = null; - - try - { - IEnumerable metafields = await _shopifyClient.Metafields.Get(new Dictionary { { "metafield[owner_id]", product.Id }, { "metafield[owner_resource]", "product" } }); - importData = new ImportData - { - LineCode = metafields.FirstOrDefault(m => m.Key == "custom_label_0")?.Value ?? string.Empty, - PartNumber = metafields.FirstOrDefault(m => m.Key == "custom_label_1")?.Value ?? string.Empty, - VariantSku = product.Variants[0].Sku // They know we can't do fitment for variants - }; - - bool isFitment = false; - string bodyHtml = product.BodyHtml.Substring(0, product.BodyHtml.IndexOf("") + "".Length); - - IList vehicles = _vehicleFitmentService.GetVehiclesForPart(importData.PartNumber, importData.LineCode); - IList vehicleIdFitment = _vehicleFitmentService.GetVehicleIdFitment(vehicles); - - if (vehicleIdFitment.Count > 0) - { - string vehicleIdString = string.Join(',', vehicleIdFitment.Select(j => $"v{j}")); - - bodyHtml += $"
{vehicleIdString}
"; - - isFitment = true; - - string json = JsonConvert.SerializeObject(vehicleIdFitment); - if (json.Length < 100000) - { - Metafield vehicleMetafield = new Metafield - { - Namespace = "fitment", - Key = "ids", - Value = json, - Type = "json_string", - OwnerResource = "product", - OwnerId = product.Id - }; - - 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; - } - } - - IList ymmFitment = _vehicleFitmentService.GetYmmFitment(vehicles); - if (ymmFitment.Count > 0) - { - isFitment = true; - - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.AppendLine(""); - - foreach (string fitment in ymmFitment) - { - try - { - string[] parts = fitment.Split(' ', 2); - - stringBuilder.AppendLine($""); - } - - catch - { - // This is still a POC at this point. Oh well... - } - } - - stringBuilder.AppendLine("
This Part Fits
{parts[1]}{parts[0].Replace("-", ", ")}
"); - - bodyHtml += $"
{stringBuilder.ToString()}
"; - - string json = JsonConvert.SerializeObject(ymmFitment); - if (json.Length < 100000) - { - Metafield ymmMetafield = new Metafield - { - Namespace = "fitment", - Key = "seo", - Value = json, - Type = "json_string", - OwnerResource = "product", - OwnerId = product.Id - }; - - await _shopifyClient.Metafields.Add(ymmMetafield); - } - - else - { - _logger.LogWarning($"Year/make/model fitment data for SKU {importData.VariantSku} is too large for Shopify and cannot be added."); - continue; - } - } - - Metafield isFitmentMetafield = new Metafield - { - Namespace = "Flags", - Key = "IsFitment", - Value = isFitment.ToString(), - Type = "string", - OwnerResource = "product", - OwnerId = product.Id - }; - - await _shopifyClient.Metafields.Add(isFitmentMetafield); - - //Metafield lineCodeMetafield = new Metafield - //{ - // Namespace = "google", - // Key = "custom_label_0", - // Value = importData.LineCode, - // Type = "string", - // OwnerResource = "product", - // OwnerId = product.Id - //}; - - //await _shopifyClient.Metafields.Add(lineCodeMetafield); - - //Metafield partNumberMetafield = new Metafield - //{ - // Namespace = "google", - // Key = "custom_label_1", - // Value = importData.PartNumber, - // Type = "string", - // OwnerResource = "product", - // OwnerId = product.Id - //}; - - //await _shopifyClient.Metafields.Add(partNumberMetafield); - - List tags = new List(); - - for (int j = 0; j < vehicleIdFitment.Count; j += 25) - { - tags.Add(string.Join('-', vehicleIdFitment.Skip(j).Take(25).Select(j => $"v{j}"))); - } - - tags.AddRange(ymmFitment); - - if (tags.Count > 249) - { - tags = tags.Take(249).ToList(); - } - - string zzzIsFitment = isFitment - ? "zzzIsFitment=true" - : "zzzIsFitment=false"; - - tags.Add(zzzIsFitment); - - product.Tags = string.Join(',', tags); - product.BodyHtml = bodyHtml; - await _shopifyClient.Products.Update(product); - - importData.IsFitment = isFitment; - importData.UpdatedAt = DateTime.Now; - importData.UpdateType = "Fitment"; - } - - catch (Exception ex) - { - _logger.LogError($"Failed to updated fitment data for SKU {importData?.VariantSku} - {ex.Message}", ex); - } - - } try { - Console.WriteLine(i); - - _partSourceContext.SaveChanges(); - products = await _shopifyClient.Products.GetNext(); - - i++; + products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 }, { "product_type", partType } }); + //products = new List + //{ + // await _shopifyClient.Products.GetById(4388919574575) + //}; } catch (Exception ex) { - _logger.LogWarning(ex, "Failed to get the next set of products. Retrying"); - products = await _shopifyClient.Products.GetPrevious(); + _logger.LogError("Failed to get products from Shopify", ex); + throw; } + + int i = 1; + + while (products != null && products.Any()) + { + foreach (Product product in products) + { + ImportData importData = null; + + try + { + IEnumerable metafields = await _shopifyClient.Metafields.Get(new Dictionary { { "metafield[owner_id]", product.Id }, { "metafield[owner_resource]", "product" } }); + importData = new ImportData + { + LineCode = metafields.FirstOrDefault(m => m.Key == "custom_label_0")?.Value ?? string.Empty, + PartNumber = metafields.FirstOrDefault(m => m.Key == "custom_label_1")?.Value ?? string.Empty, + VariantSku = product.Variants[0].Sku // They know we can't do fitment for variants + }; + + bool isFitment = false; + string bodyHtml = product.BodyHtml.Substring(0, product.BodyHtml.IndexOf("") + "".Length); + + IList vehicles = _vehicleFitmentService.GetVehiclesForPart(importData.PartNumber, importData.LineCode); + IList vehicleIdFitment = _vehicleFitmentService.GetVehicleIdFitment(vehicles); + + if (!vehicleIdFitment.Any()) + { + Console.WriteLine($"No fitment data for SKU {importData.VariantSku}"); + continue; + } + + if (vehicleIdFitment.Count > 0) + { + string vehicleIdString = string.Join(',', vehicleIdFitment.Select(j => $"v{j}")); + + bodyHtml += $"
{vehicleIdString}
"; + + isFitment = true; + + string json = JsonConvert.SerializeObject(vehicleIdFitment); + if (json.Length < 100000) + { + Metafield vehicleMetafield = new Metafield + { + Namespace = "fitment", + Key = "ids", + Value = json, + Type = "json_string", + OwnerResource = "product", + OwnerId = product.Id + }; + + 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; + } + } + + IList ymmFitment = _vehicleFitmentService.GetYmmFitment(vehicles); + if (ymmFitment.Count > 0) + { + isFitment = true; + + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.AppendLine(""); + + foreach (string fitment in ymmFitment) + { + try + { + string[] parts = fitment.Split(' ', 2); + + stringBuilder.AppendLine($""); + } + + catch + { + // This is still a POC at this point. Oh well... + } + } + + stringBuilder.AppendLine("
This Part Fits
{parts[1]}{parts[0].Replace("-", ", ")}
"); + + bodyHtml += $"
{stringBuilder.ToString()}
"; + + string json = JsonConvert.SerializeObject(ymmFitment); + if (json.Length < 100000) + { + Metafield ymmMetafield = new Metafield + { + Namespace = "fitment", + Key = "seo", + Value = json, + Type = "json_string", + OwnerResource = "product", + OwnerId = product.Id + }; + + await _shopifyClient.Metafields.Add(ymmMetafield); + } + + else + { + _logger.LogWarning($"Year/make/model fitment data for SKU {importData.VariantSku} is too large for Shopify and cannot be added."); + continue; + } + } + + Metafield isFitmentMetafield = new Metafield + { + Namespace = "Flags", + Key = "IsFitment", + Value = isFitment.ToString(), + Type = "string", + OwnerResource = "product", + OwnerId = product.Id + }; + + await _shopifyClient.Metafields.Add(isFitmentMetafield); + + //Metafield lineCodeMetafield = new Metafield + //{ + // Namespace = "google", + // Key = "custom_label_0", + // Value = importData.LineCode, + // Type = "string", + // OwnerResource = "product", + // OwnerId = product.Id + //}; + + //await _shopifyClient.Metafields.Add(lineCodeMetafield); + + //Metafield partNumberMetafield = new Metafield + //{ + // Namespace = "google", + // Key = "custom_label_1", + // Value = importData.PartNumber, + // Type = "string", + // OwnerResource = "product", + // OwnerId = product.Id + //}; + + //await _shopifyClient.Metafields.Add(partNumberMetafield); + + List tags = new List(); + + for (int j = 0; j < vehicleIdFitment.Count; j += 25) + { + tags.Add(string.Join('-', vehicleIdFitment.Skip(j).Take(25).Select(j => $"v{j}"))); + } + + tags.AddRange(ymmFitment); + + if (tags.Count > 249) + { + tags = tags.Take(249).ToList(); + } + + string zzzIsFitment = isFitment + ? "zzzIsFitment=true" + : "zzzIsFitment=false"; + + tags.Add(zzzIsFitment); + + product.Tags = string.Join(',', tags); + product.BodyHtml = bodyHtml; + await _shopifyClient.Products.Update(product); + + importData.IsFitment = isFitment; + importData.UpdatedAt = DateTime.Now; + importData.UpdateType = "Fitment"; + } + + catch (Exception ex) + { + _logger.LogError($"Failed to updated fitment data for SKU {importData?.VariantSku} - {ex.Message}", ex); + } + + } + try + { + Console.WriteLine(i); + + _partSourceContext.SaveChanges(); + products = await _shopifyClient.Products.GetNext(); + + i++; + } + + catch (Exception ex) + { + _logger.LogWarning(ex, "Failed to get the next set of products. Retrying"); + products = await _shopifyClient.Products.GetPrevious(); + } + } + + Console.WriteLine($"Finished {partType}"); } } } diff --git a/PartSource.Data/Contexts/FitmentContext.cs b/PartSource.Data/Contexts/FitmentContext.cs index af33cc3..d55c722 100644 --- a/PartSource.Data/Contexts/FitmentContext.cs +++ b/PartSource.Data/Contexts/FitmentContext.cs @@ -30,8 +30,9 @@ 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()) + foreach (IMutableEntityType entityType in modelBuilder.Model.GetEntityTypes()) { entityType.SetTableName(entityType.ClrType.Name); } From b8406a7f7135244e77f095c86d7979c000edbdd0 Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Tue, 14 Nov 2023 11:58:54 -0500 Subject: [PATCH 5/8] WIP --- PartSource.Api/PartSource.Api.csproj | 1 + .../Jobs/ExecuteSsisPackages.cs | 2 +- PartSource.Automation/Program.cs | 2 +- PartSource.Automation/Services/SsisService.cs | 2 +- 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 | 8 +-- 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 +- 72 files changed, 142 insertions(+), 141 deletions(-) diff --git a/PartSource.Api/PartSource.Api.csproj b/PartSource.Api/PartSource.Api.csproj index 55bc2ca..09e7782 100644 --- a/PartSource.Api/PartSource.Api.csproj +++ b/PartSource.Api/PartSource.Api.csproj @@ -4,6 +4,7 @@ net6.0 f9e2fd37-0f2d-4e3a-955a-8e49a16fce1c Debug;Release;Also Debug + en-us;en diff --git a/PartSource.Automation/Jobs/ExecuteSsisPackages.cs b/PartSource.Automation/Jobs/ExecuteSsisPackages.cs index b078563..c287910 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 Price" }; public ExecuteSsisPackages(EmailService emailService, IConfiguration configuration, SsisService ssisService, ILogger logger) { diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index 90a8d1d..4ef6835 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/SsisService.cs b/PartSource.Automation/Services/SsisService.cs index 6fccf2a..246227b 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 (x86)\\Microsoft SQL Server\\130\\DTS\\Binn\\dtexec", Arguments = $"/file \"{_ssisConfiguration.Directory}\\{packageName}\"", UseShellExecute = false, CreateNoWindow = false, 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..7f3a7ae 100644 --- a/PartSource.Data/Nexpart/PSRequestHeader.cs +++ b/PartSource.Data/Nexpart/PSRequestHeader.cs @@ -8,19 +8,19 @@ 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() { - this.SvcVersion = "1.0"; + this.SvcVersion = "2.0"; 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..8e5641c 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("https://acespssprod.nexpart.com:4085/partselect/2.0/services/PartSelectService.PartSelectHttpSoap11Endpoint", new StringContent(textWriter.ToString(), Encoding.UTF8, "text/xml")); Stream result = await response.Content.ReadAsStreamAsync(); string str = await response.Content.ReadAsStringAsync(); From aed30707be256298629713aef185eba6efc0a164 Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Tue, 19 Dec 2023 14:49:30 -0500 Subject: [PATCH 6/8] WIP --- PartSource.Api/Controllers/PartsController.cs | 66 ++++++++++++++++++- .../Controllers/WipersController.cs | 2 +- PartSource.Api/Properties/launchSettings.json | 19 +++--- .../Jobs/ExecuteSsisPackages.cs | 4 +- .../Jobs/POC/UpdateBulbFitment.cs | 2 +- .../Jobs/POC/UpdateWiperFitment.cs | 2 +- .../Jobs/ProcessWhiFitment.cs | 7 +- PartSource.Automation/Program.cs | 50 +++++++------- .../Services/WhiSeoService.cs | 2 +- PartSource.Automation/appsettings.json | 2 +- PartSource.Data/Dtos/VehicleFitmentDto.cs | 2 + PartSource.Data/Nexpart/Answer.cs | 22 +++++++ PartSource.Data/Nexpart/ApplicationSearch.cs | 3 + .../Nexpart/ApplicationSearchResponse.cs | 8 +-- PartSource.Data/Nexpart/Question.cs | 25 +++++++ PartSource.Data/Nexpart/Questions.cs | 19 ++++++ PartSource.Services/FitmentService.cs | 9 +-- 17 files changed, 184 insertions(+), 60 deletions(-) create mode 100644 PartSource.Data/Nexpart/Answer.cs create mode 100644 PartSource.Data/Nexpart/Question.cs create mode 100644 PartSource.Data/Nexpart/Questions.cs diff --git a/PartSource.Api/Controllers/PartsController.cs b/PartSource.Api/Controllers/PartsController.cs index 6d719cc..24d2942 100644 --- a/PartSource.Api/Controllers/PartsController.cs +++ b/PartSource.Api/Controllers/PartsController.cs @@ -41,6 +41,66 @@ namespace PartSource.Api.Controllers return NotFound(); } + Item[] items = new[] + { + new Item { PartNumber = vehicleFitment.PartNumber, MfrCode = vehicleFitment.LineCode } + }; + + SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch + { + Items = items + }; + + SmartPageDataSearchResponse smartPageResponse = await _nexpartService.SendRequest(smartPageDataSearch); + if (smartPageResponse.ResponseBody?.Item != null) + { + PartType[] partTypes = smartPageResponse.ResponseBody.Item.Select(i => new PartType + { + Id = i.Part.PartType.Id + }) + .ToArray(); + + ApplicationSearch applicationSearch = new ApplicationSearch + { + VehicleIdentifier = new VehicleIdentifier + { + BaseVehicleId = vehicleFitment.BaseVehicleId, + EngineConfigId = vehicleFitment.EngineConfigId + }, + MfrCode = new[] { vehicleFitment.LineCode }, + PartType = partTypes, + GroupBy = "MFR", + QuestionOption = "QUESTION_OTHERWISE_APP" + }; + + ApplicationSearchResponse response = await _nexpartService.SendRequest(applicationSearch); + if (response.ResponseBody != null) + { + vehicleFitment.DriveTypes = new List(); + + Question driveTypeQuestion = ((Questions)response.ResponseBody).Question + .Where(q => q.Attribute == "DRIVE_TYPE") + .FirstOrDefault(); + + if (driveTypeQuestion != null) + { + foreach (Answer answer in driveTypeQuestion.Answer) + { + applicationSearch.Criterion = new[] + { + new Criterion { Attribute = "DRIVE_TYPE", Id = answer.Id} + }; + + ApplicationSearchResponse driveTypeResponse = await _nexpartService.SendRequest(applicationSearch); + if (driveTypeResponse.ResponseBody != null && ((Apps)driveTypeResponse.ResponseBody).App.Where(a => a.Part == vehicleFitment.PartNumber).Any()) + { + vehicleFitment.DriveTypes.Add(answer.Value); + } + } + } + } + } + return Ok(vehicleFitment); } @@ -75,7 +135,7 @@ namespace PartSource.Api.Controllers PartNumber = part.PartNumber, MfrCode = m.WhiCode }) - .ToArray(); + .ToArray(); SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch { @@ -96,7 +156,7 @@ namespace PartSource.Api.Controllers { Id = i.Part.PartType.Id }) - .ToArray(); + .ToArray(); ApplicationSearch applicationSearch = new ApplicationSearch { @@ -129,7 +189,7 @@ namespace PartSource.Api.Controllers } IList positions = new List(); - foreach (App app in response.ResponseBody?.App) + foreach (App app in ((Apps)response.ResponseBody)?.App) { if (!string.IsNullOrEmpty(app.Position) && app.Part == part.PartNumber) { diff --git a/PartSource.Api/Controllers/WipersController.cs b/PartSource.Api/Controllers/WipersController.cs index 5245389..4ae77aa 100644 --- a/PartSource.Api/Controllers/WipersController.cs +++ b/PartSource.Api/Controllers/WipersController.cs @@ -51,7 +51,7 @@ namespace PartSource.Api.Controllers if (response.ResponseBody != null) { - return NexpartResponse(response); + return NexpartResponse(response); } else diff --git a/PartSource.Api/Properties/launchSettings.json b/PartSource.Api/Properties/launchSettings.json index 319f4c1..468c578 100644 --- a/PartSource.Api/Properties/launchSettings.json +++ b/PartSource.Api/Properties/launchSettings.json @@ -1,13 +1,4 @@ { - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:31337", - "sslPort": 0 - } - }, - "$schema": "http://json.schemastore.org/launchsettings.json", "profiles": { "IIS Express": { "commandName": "IISExpress", @@ -18,12 +9,20 @@ }, "PartSource.Api": { "commandName": "Project", - "launchBrowser": true, "launchUrl": "api/values", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "https://localhost:5001;http://localhost:5000" } + }, + "$schema": "http://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:31337", + "sslPort": 0 + } } } \ No newline at end of file diff --git a/PartSource.Automation/Jobs/ExecuteSsisPackages.cs b/PartSource.Automation/Jobs/ExecuteSsisPackages.cs index c287910..c6f30cc 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" }; + private readonly string[] _ssisPackages = {"Parts Availability" }; public ExecuteSsisPackages(EmailService emailService, IConfiguration configuration, SsisService ssisService, ILogger logger) { @@ -36,7 +36,7 @@ namespace PartSource.Automation.Jobs { try { - _ftpService.Download($"{package}.txt"); + // _ftpService.Download($"{package}.txt"); _ssisService.Execute($"{package}.dtsx"); _logger.LogInformation($"Execution of SSIS package {package} completed successfully."); diff --git a/PartSource.Automation/Jobs/POC/UpdateBulbFitment.cs b/PartSource.Automation/Jobs/POC/UpdateBulbFitment.cs index 6c0fddf..b2275b4 100644 --- a/PartSource.Automation/Jobs/POC/UpdateBulbFitment.cs +++ b/PartSource.Automation/Jobs/POC/UpdateBulbFitment.cs @@ -68,7 +68,7 @@ namespace PartSource.Automation.Jobs.POC ApplicationSearchResponse response = await _nexpartService.SendRequest(applicationSearch); if (response.ResponseBody != null) { - foreach (App app in response.ResponseBody.App) + foreach (App app in ((Apps)response.ResponseBody).App) { try { diff --git a/PartSource.Automation/Jobs/POC/UpdateWiperFitment.cs b/PartSource.Automation/Jobs/POC/UpdateWiperFitment.cs index 68d58d4..e1c582b 100644 --- a/PartSource.Automation/Jobs/POC/UpdateWiperFitment.cs +++ b/PartSource.Automation/Jobs/POC/UpdateWiperFitment.cs @@ -68,7 +68,7 @@ namespace PartSource.Automation.Jobs.POC ApplicationSearchResponse response = await _nexpartService.SendRequest(applicationSearch); if (response.ResponseBody != null) { - foreach (App app in response.ResponseBody.App) + foreach (App app in ((Apps)response.ResponseBody).App) { try { diff --git a/PartSource.Automation/Jobs/ProcessWhiFitment.cs b/PartSource.Automation/Jobs/ProcessWhiFitment.cs index b625e65..ea34942 100644 --- a/PartSource.Automation/Jobs/ProcessWhiFitment.cs +++ b/PartSource.Automation/Jobs/ProcessWhiFitment.cs @@ -56,7 +56,7 @@ namespace PartSource.Automation.Jobs fileGroups.Enqueue(fileGroup); } - Task[] taskArray = new Task[8]; + Task[] taskArray = new Task[12]; for (int i = 0; i < taskArray.Length; i++) { @@ -95,10 +95,9 @@ namespace PartSource.Automation.Jobs } Task.WaitAll(taskArray); + _whiSeoService.SaveNotes(_noteDictionary); - // _whiSeoService.CreateFitmentView(); - - //_whiSeoService.SaveNotes(_noteDictionary); + _whiSeoService.CreateFitmentView(); } public string Decompress(FileInfo fileInfo) diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index 4ef6835..01cc20a 100644 --- a/PartSource.Automation/Program.cs +++ b/PartSource.Automation/Program.cs @@ -77,32 +77,32 @@ namespace PartSource.Automation .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)) - // ) + options.HasBaseInterval(new TimeSpan(0, 1, 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(24, 0, 0)) - //.HasDependency() - // .StartsAt(DateTime.Today.AddHours(28)) + //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) + // .HasDependency() + // // .StartsAt(DateTime.Today.AddHours(28)) ); //); //.AddApiServer(); diff --git a/PartSource.Automation/Services/WhiSeoService.cs b/PartSource.Automation/Services/WhiSeoService.cs index 78cf932..a086b13 100644 --- a/PartSource.Automation/Services/WhiSeoService.cs +++ b/PartSource.Automation/Services/WhiSeoService.cs @@ -153,7 +153,7 @@ namespace PartSource.Automation.Services command.ExecuteNonQuery(); using SqlCommand command2 = new SqlCommand($"exec CreateFitmentIndexes", connection); - command.CommandTimeout = 1800; + command.CommandTimeout = 3600; command2.ExecuteNonQuery(); } diff --git a/PartSource.Automation/appsettings.json b/PartSource.Automation/appsettings.json index cb63be3..ec663d7 100644 --- a/PartSource.Automation/appsettings.json +++ b/PartSource.Automation/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true;TrustServerCertificate=True", + "FitmentDatabase": "Data Source=omg-optiplex;Initial Catalog=WhiFitment;User ID=sa;Password=TNG497us?4TW!;TrustServerCertificate=True", "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": { diff --git a/PartSource.Data/Dtos/VehicleFitmentDto.cs b/PartSource.Data/Dtos/VehicleFitmentDto.cs index d1b29ed..66819ed 100644 --- a/PartSource.Data/Dtos/VehicleFitmentDto.cs +++ b/PartSource.Data/Dtos/VehicleFitmentDto.cs @@ -8,5 +8,7 @@ namespace PartSource.Data.Dtos public class VehicleFitmentDto : VehicleFitment { public IList SubmodelNames { get; set; } + + public IList DriveTypes { get; set; } } } \ No newline at end of file diff --git a/PartSource.Data/Nexpart/Answer.cs b/PartSource.Data/Nexpart/Answer.cs new file mode 100644 index 0000000..f0b2166 --- /dev/null +++ b/PartSource.Data/Nexpart/Answer.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace PartSource.Data.Nexpart +{ + [XmlType(Namespace = "http://whisolutions.com/pss/common/helper/parts")] + public class Answer + { + [XmlAttribute] + public int Id { get; set; } + + [XmlAttribute] + public int Count { get; set; } + + [XmlText] + public string Value { get; set; } + } +} diff --git a/PartSource.Data/Nexpart/ApplicationSearch.cs b/PartSource.Data/Nexpart/ApplicationSearch.cs index b4a3a29..db4111c 100644 --- a/PartSource.Data/Nexpart/ApplicationSearch.cs +++ b/PartSource.Data/Nexpart/ApplicationSearch.cs @@ -35,5 +35,8 @@ namespace PartSource.Data.Nexpart [XmlElement(Order = 7)] public string GroupBy { get; set; } + + [XmlElement(Order = 8)] + public string QuestionOption { get; set; } } } diff --git a/PartSource.Data/Nexpart/ApplicationSearchResponse.cs b/PartSource.Data/Nexpart/ApplicationSearchResponse.cs index 1b20c86..f5a4a6f 100644 --- a/PartSource.Data/Nexpart/ApplicationSearchResponse.cs +++ b/PartSource.Data/Nexpart/ApplicationSearchResponse.cs @@ -9,13 +9,13 @@ using PartSource.Data.Nexpart.Interfaces; namespace PartSource.Data.Nexpart { [XmlType(AnonymousType = true, Namespace = "http://whisolutions.com/pss/common/model/parts")] - public class ApplicationSearchResponse : IResponseElement + public class ApplicationSearchResponse : IResponseElement { - [XmlElement] public PSResponseHeader PSResponseHeader { get; set; } - [XmlElement(ElementName = nameof(Apps))] - public Apps ResponseBody { get; set; } + [XmlElement(ElementName = nameof(Apps), Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(Apps))] + [XmlElement(ElementName = nameof(Questions), Namespace = "http://whisolutions.com/pss/common/model/parts", Type = typeof(Questions))] + public object ResponseBody { get; set; } } } diff --git a/PartSource.Data/Nexpart/Question.cs b/PartSource.Data/Nexpart/Question.cs new file mode 100644 index 0000000..45ca2fc --- /dev/null +++ b/PartSource.Data/Nexpart/Question.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace PartSource.Data.Nexpart +{ + [XmlType(Namespace = "http://whisolutions.com/pss/common/helper/parts")] + public class Question + { + [XmlAttribute(AttributeName = "Attrib")] + public string Attribute { get; set; } + + [XmlAttribute] + public int Count { get; set; } + + [XmlAttribute] + public string Text { get; set; } + + [XmlElement] + public Answer[] Answer { get; set; } + } +} diff --git a/PartSource.Data/Nexpart/Questions.cs b/PartSource.Data/Nexpart/Questions.cs new file mode 100644 index 0000000..a6d1914 --- /dev/null +++ b/PartSource.Data/Nexpart/Questions.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace PartSource.Data.Nexpart +{ + [XmlType(Namespace = "http://whisolutions.com/pss/common/model/parts")] + public class Questions + { + [XmlElement(Namespace = "http://whisolutions.com/pss/common/helper/parts")] + public Question[] Question { get; set; } + + [XmlAttribute] + public int NumApps { get; set; } + } +} diff --git a/PartSource.Services/FitmentService.cs b/PartSource.Services/FitmentService.cs index a32a80a..f0903bb 100644 --- a/PartSource.Services/FitmentService.cs +++ b/PartSource.Services/FitmentService.cs @@ -35,7 +35,8 @@ namespace PartSource.Services ModelName = vf.ModelName, BaseVehicleId = vf.BaseVehicleId, EngineConfigId = vf.EngineConfigId, - VehicleToEngineConfigId = vf.VehicleToEngineConfigId + VehicleToEngineConfigId = vf.VehicleToEngineConfigId, + SubmodelName = vf.SubmodelName }) .FirstOrDefaultAsync(); @@ -44,12 +45,6 @@ namespace PartSource.Services return null; } - vehicleFitment.SubmodelNames = await _fitmentContext.VehicleFitments - .Where(vf => vf.BaseVehicleId == vehicleFitment.BaseVehicleId && vf.Sku == sku) - .Select(vf => vf.SubmodelName) - .Distinct() - .ToListAsync(); - return vehicleFitment; } From cc2cbd09e1a5e52d672c4b06a9cf90c31da1e2ac Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Wed, 12 Feb 2025 18:12:19 -0500 Subject: [PATCH 7/8] Whatever this is --- PartSource.Api/Controllers/PartsController.cs | 68 +++-- PartSource.Api/appsettings.json | 2 +- PartSource.Automation/Jobs/POC/ImageList.cs | 69 ++--- PartSource.Automation/Jobs/PartsSync.cs | 89 +++++++ .../Jobs/ProcessWhiFitment.cs | 28 ++- PartSource.Automation/Jobs/UpdateFitment.cs | 172 +++---------- .../Models/Configuration/FtpConfiguration.cs | 2 + PartSource.Automation/Program.cs | 13 +- .../Services/VehicleFitmentService.cs | 6 +- .../Services/WhiSeoService.cs | 235 +++++++++--------- PartSource.Automation/appsettings.json | 11 +- PartSource.Data/Contexts/FitmentContext.cs | 4 + PartSource.Data/Contexts/PartSourceContext.cs | 2 +- PartSource.Data/Dtos/VehicleFitmentDto.cs | 5 + PartSource.Data/Models/ProductType.cs | 17 ++ PartSource.Data/Models/VehicleFitment.cs | 5 +- PartSource.Data/Nexpart/ApplicationSearch.cs | 7 +- PartSource.Services/FitmentService.cs | 169 ++++++------- PartSource.Services/NexpartService.cs | 12 +- PartSource.Services/PartService.cs | 14 +- 20 files changed, 496 insertions(+), 434 deletions(-) create mode 100644 PartSource.Automation/Jobs/PartsSync.cs create mode 100644 PartSource.Data/Models/ProductType.cs diff --git a/PartSource.Api/Controllers/PartsController.cs b/PartSource.Api/Controllers/PartsController.cs index 24d2942..cc9f5ad 100644 --- a/PartSource.Api/Controllers/PartsController.cs +++ b/PartSource.Api/Controllers/PartsController.cs @@ -4,6 +4,7 @@ using PartSource.Data.Dtos; using PartSource.Data.Models; using PartSource.Data.Nexpart; using PartSource.Services; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -41,14 +42,27 @@ namespace PartSource.Api.Controllers return NotFound(); } - Item[] items = new[] + try { - new Item { PartNumber = vehicleFitment.PartNumber, MfrCode = vehicleFitment.LineCode } - }; + string[] segments = vehicleFitment.NoteText.Split(']'); + vehicleFitment.PartDescription = segments[0].TrimStart('['); + vehicleFitment.DriveTypes = GetDriveTypesFromNote(vehicleFitment.NoteText); + vehicleFitment.Notes = segments[1].Split(';') + .Select(n => n.Trim()) + .ToList(); + } + + catch + { + throw new InvalidOperationException($"The note_text field provided by WHI for {vehicleFitment.LineCode} {vehicleFitment.PartNumber} was in an invalid format."); + } SmartPageDataSearch smartPageDataSearch = new SmartPageDataSearch { - Items = items + Items = new[] + { + new Item { PartNumber = vehicleFitment.PartNumber, MfrCode = vehicleFitment.LineCode } + } }; SmartPageDataSearchResponse smartPageResponse = await _nexpartService.SendRequest(smartPageDataSearch); @@ -74,10 +88,8 @@ namespace PartSource.Api.Controllers }; ApplicationSearchResponse response = await _nexpartService.SendRequest(applicationSearch); - if (response.ResponseBody != null) + if (response.ResponseBody != null && response.ResponseBody is Questions) { - vehicleFitment.DriveTypes = new List(); - Question driveTypeQuestion = ((Questions)response.ResponseBody).Question .Where(q => q.Attribute == "DRIVE_TYPE") .FirstOrDefault(); @@ -124,7 +136,7 @@ namespace PartSource.Api.Controllers { return BadRequest(new { - Message = $"No vehicle data is available for SKU {sku}. Confirm it is available in the database maintained by Sound Press.", + Message = $"No vehicle data is available for vehicle ID {vehicleId}. Confirm it is available in the database maintained by Sound Press.", Reason = $"{nameof(_vehicleService.GetVehicleById)} returned null" }); } @@ -167,13 +179,13 @@ namespace PartSource.Api.Controllers MfrCode = mappings.Select(m => m.WhiCode).ToArray(), PartType = new[] { new PartType { Id = smartPageResponse.ResponseBody.Item[0].Part.PartType.Id } }, Criterion = new[] + { + new Criterion { - new Criterion - { - Attribute = "REGION", - Id = 2 - } - }, + Attribute = "REGION", + Id = 2 + } + }, GroupBy = "PARTTYPE" }; @@ -205,5 +217,33 @@ namespace PartSource.Api.Controllers }); } + private IList GetDriveTypesFromNote(string fitmentNote) + { + fitmentNote = fitmentNote.ToUpperInvariant(); + IList driveTypes = new List(); + + if (fitmentNote.Contains("FWD")) + { + driveTypes.Add("FWD"); + } + + if (fitmentNote.Contains("RWD")) + { + driveTypes.Add("RWD"); + } + + if (fitmentNote.Contains("AWD")) + { + driveTypes.Add("AWD"); + } + + if (fitmentNote.Contains("4WD")) + { + driveTypes.Add("4WD"); + } + + return driveTypes; + } + } } diff --git a/PartSource.Api/appsettings.json b/PartSource.Api/appsettings.json index b609459..fe5b261 100644 --- a/PartSource.Api/appsettings.json +++ b/PartSource.Api/appsettings.json @@ -2,7 +2,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": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true" - "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": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=sa;Password=GZ0`-ekd~[2u;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300" }, "Logging": { "LogLevel": { diff --git a/PartSource.Automation/Jobs/POC/ImageList.cs b/PartSource.Automation/Jobs/POC/ImageList.cs index 77ec44e..556dc3a 100644 --- a/PartSource.Automation/Jobs/POC/ImageList.cs +++ b/PartSource.Automation/Jobs/POC/ImageList.cs @@ -22,11 +22,13 @@ namespace PartSource.Automation.Jobs.POC { private readonly NexpartService _nexpartService; private readonly PartSourceContext _partSourceContext; + private readonly FitmentContext _fitmentContext; - public GetImageUrls(NexpartService nexpartService, PartSourceContext partSourceContext) + public GetImageUrls(NexpartService nexpartService, PartSourceContext partSourceContext, FitmentContext fitmentContext) { _nexpartService = nexpartService; _partSourceContext = partSourceContext; + _fitmentContext = fitmentContext; } public async Task Run(CancellationToken token, params string[] arguments) @@ -34,45 +36,54 @@ namespace PartSource.Automation.Jobs.POC IList rows = new List { "\"Line Code\", \"Part Number\", \"Image URL(s)\"" }; - - IList importData = await _partSourceContext.ImportData - //.Take(5000) - .ToListAsync(); - foreach (ImportData item in importData) + IList parts = await _fitmentContext.Parts.ToListAsync(); + string oldLineCode = string.Empty; + IList mappings = new List(); + + foreach (Data.Models.Part part in parts) { - SmartPageDataSearch dataSearch = new SmartPageDataSearch + if (part.LineCode != oldLineCode) { - Items = new Item[] + mappings = await _fitmentContext.DcfMappings.Where(d => d.LineCode == part.LineCode).ToListAsync(); + } + ; + + foreach (DcfMapping mapping in mappings) + { + SmartPageDataSearch dataSearch = new SmartPageDataSearch { + Items = new Item[] + { new Item { - MfrCode = item.LineCode, - PartNumber = item.PartNumber + MfrCode = mapping.WhiCode, + PartNumber = part.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); + }, + DataOption = new[] { "ALL" } }; - if (response.ResponseBody.Item[0].AddImgs?.AddImg?.Length > 0) - { - urls.AddRange(response.ResponseBody.Item[0].AddImgs.AddImg.Select(i => i.AddImgUrl)); - } + SmartPageDataSearchResponse response = await _nexpartService.SendRequest(dataSearch); - if (urls.Count > 0) + if (response.ResponseBody.Item?.Length > 0) { - rows.Add($"\"{item.LineCode}\", \"{item.PartNumber}\", \"{string.Join(";", urls)}\""); + 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($"\"{part.LineCode}\", \"{part.PartNumber}\", \"{string.Join(";", urls)}\""); + } } } diff --git a/PartSource.Automation/Jobs/PartsSync.cs b/PartSource.Automation/Jobs/PartsSync.cs new file mode 100644 index 0000000..34e1cee --- /dev/null +++ b/PartSource.Automation/Jobs/PartsSync.cs @@ -0,0 +1,89 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using PartSource.Automation.Models.Jobs; +using PartSource.Automation.Services; +using PartSource.Data.Contexts; +using PartSource.Data.Models; +using Ratermania.Automation.Interfaces; +using Ratermania.Shopify; +using Ratermania.Shopify.Resources; +using Ratermania.Shopify.Resources.Enums; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Mail; +using System.Threading; +using System.Threading.Tasks; + +namespace PartSource.Automation.Jobs +{ + public class PartsSync : IAutomationJob + { + private readonly ILogger _logger; + private readonly FitmentContext _fitmentContext; + private readonly ShopifyClient _shopifyClient; + + public PartsSync(ILogger logger, FitmentContext fitmentContext, ShopifyClient shopifyClient) + { + _logger = logger; + _fitmentContext = fitmentContext; + _shopifyClient = shopifyClient; + } + + public async Task Run(CancellationToken token, params string[] arguments) + { + IEnumerable products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 } }); + + while (products != null && products.Any()) + { + + foreach (Product product in products) + { + try + { + IEnumerable metafields = await _shopifyClient.Metafields.Get(new Dictionary { { "metafield[owner_id]", product.Id }, { "metafield[owner_resource]", "product" } }); + Part part = new Part + { + LineCode = metafields.FirstOrDefault(m => m.Key == "custom_label_0")?.Value ?? string.Empty, + PartNumber = metafields.FirstOrDefault(m => m.Key == "custom_label_1")?.Value ?? string.Empty, + Sku = product.Variants[0].Sku // They know we can't do fitment for variants + }; + + // part.PartNumber = part.PartNumber.Replace("-", string.Empty); + + if ( + string.IsNullOrEmpty(part.LineCode) + || string.IsNullOrEmpty(part.PartNumber) + || int.TryParse(part.LineCode, out _)) //If the line code is numeric, it cannot have fitment data associated with it. + { + continue; + } + + Part? existing = await _fitmentContext.Parts.FirstOrDefaultAsync(p => p.Sku == part.Sku); + if (existing == null) + { + await _fitmentContext.Parts.AddAsync(part); + await _fitmentContext.SaveChangesAsync(); + } + } + + catch (Exception ex) + { + _logger.LogInformation(ex.Message); + } + } + + try + { + products = await _shopifyClient.Products.GetNext(); + } + + catch (Exception ex) + { + _logger.LogInformation(ex.Message); + } + } + } + } +} \ No newline at end of file diff --git a/PartSource.Automation/Jobs/ProcessWhiFitment.cs b/PartSource.Automation/Jobs/ProcessWhiFitment.cs index ea34942..44e601c 100644 --- a/PartSource.Automation/Jobs/ProcessWhiFitment.cs +++ b/PartSource.Automation/Jobs/ProcessWhiFitment.cs @@ -56,24 +56,25 @@ namespace PartSource.Automation.Jobs fileGroups.Enqueue(fileGroup); } - Task[] taskArray = new Task[12]; - + Task[] taskArray = new Task[18]; for (int i = 0; i < taskArray.Length; i++) { taskArray[i] = Task.Factory.StartNew(() => { while (fileGroups.TryDequeue(out IGrouping fileGroup)) { + string tableName = string.Empty; + foreach (FileInfo fileInfo in fileGroup) { try { string filename = Decompress(fileInfo); - string tableName = fileInfo.Name.Substring(0, fileInfo.Name.IndexOf('.')); + DataTable dataTable = GetDataTable(filename, out tableName); - DataTable dataTable = GetDataTable(filename); + string tempTable = $"Fitment_{Guid.NewGuid():N}_{tableName}"; - _whiSeoService.BulkCopyFitment(dataTable, tableName); + _whiSeoService.BulkCopyFitment(dataTable, tempTable); _logger.LogInformation($"Copied {fileInfo.Name} to the database."); File.Delete(filename); @@ -85,10 +86,9 @@ namespace PartSource.Automation.Jobs } } - string fitmentTable = fileGroup.Key.Substring(0, fileGroup.Key.IndexOf('.')); - _whiSeoService.CreateFitmentTable(fitmentTable); + _whiSeoService.CreateFitmentTable(tableName); - _logger.LogInformation($"Created fitment table for part group {fitmentTable}."); + _logger.LogInformation($"Created fitment table for part group {tableName}."); } }); @@ -112,8 +112,10 @@ namespace PartSource.Automation.Jobs return decompressedFile; } - private DataTable GetDataTable(string filename) + private DataTable GetDataTable(string filename, out string lineCode) { + lineCode = string.Empty; + using DataTable dataTable = new DataTable(); dataTable.Columns.Add("LineCode", typeof(string)); dataTable.Columns.Add("PartNumber", typeof(string)); @@ -121,8 +123,9 @@ namespace PartSource.Automation.Jobs dataTable.Columns.Add("EngineConfigId", typeof(int)); dataTable.Columns.Add("Position", typeof(string)); dataTable.Columns.Add("FitmentNoteHash", typeof(string)); + dataTable.Columns.Add("PartTerminologyId", typeof(int)); - using StreamReader reader = new StreamReader(filename); + using StreamReader reader = new StreamReader(filename); string line = reader.ReadLine(); // Burn the header row while (reader.Peek() > 0) @@ -135,7 +138,7 @@ namespace PartSource.Automation.Jobs columns[i] = columns[i].Replace("\"", string.Empty); } - string lineCode = Regex.Replace(columns[0], "[^a-zA-Z0-9]", string.Empty).Trim(); + lineCode = Regex.Replace(columns[0], "[^a-zA-Z0-9]", string.Empty).Trim(); string partNumber = Regex.Replace(columns[1], "[^a-zA-Z0-9]", string.Empty).Trim(); string position = columns[7].Trim(); @@ -149,10 +152,11 @@ namespace PartSource.Automation.Jobs if (!string.IsNullOrEmpty(lineCode) && !string.IsNullOrEmpty(partNumber) + && int.TryParse(columns[2], out int partTerminologyId) && int.TryParse(columns[5], out int baseVehicleId) && int.TryParse(columns[6], out int engineConfigId)) { - dataTable.Rows.Add(new object[] { lineCode, partNumber, baseVehicleId, engineConfigId, position, noteTextHash }); + dataTable.Rows.Add(new object[] { lineCode, partNumber, baseVehicleId, engineConfigId, position, noteTextHash, partTerminologyId }); } } diff --git a/PartSource.Automation/Jobs/UpdateFitment.cs b/PartSource.Automation/Jobs/UpdateFitment.cs index 8b1f9de..b08ae3b 100644 --- a/PartSource.Automation/Jobs/UpdateFitment.cs +++ b/PartSource.Automation/Jobs/UpdateFitment.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using PartSource.Automation.Services; @@ -13,6 +14,7 @@ using PartSource.Data.Models; using Ratermania.Automation.Interfaces; using Ratermania.Shopify; using Ratermania.Shopify.Resources; +using System.Web; namespace PartSource.Automation.Jobs { @@ -36,52 +38,22 @@ namespace PartSource.Automation.Jobs public async Task Run(CancellationToken token, params string[] arguments) { - IEnumerable products = null; + IList productTypes = await _fitmentContext.ProductTypes + .Where(p => p.Active) + .Select(p => HttpUtility.UrlEncode(p.Name)) + .ToListAsync(); - IList partTypes = new List + foreach (string productType in productTypes) { - "CA115-SC118-FL11803_Custom Lighting Accessories", - "CA117-SC141-FL14106_Jeep Accessories", - "CA117-SC141-FL14134_Truck Running Board and Steps", - "CA117-SC141-FL14199_Bumpers, Bull Bars & Brush Guards", - "CA117-SC157-FL15704_Headache Rack Frames", - "CA117-SC158-FL15802_Salters and Plow Accessories", - "CA117-SC699-FL69902_Crossover Boxes", - "CA117-SC699-FL69903_Specialty Boxes", - "CA117-SC699-FL69904_Transfer Tanks", - "CA135-SC176-FL17601_Trailer Lighting, Stop, Turn, Tail", - "CA135-SC186-FL18607_Roof Racks", - "CA135-SC186-FL18608_Bike Carriers", - "CA135-SC186-FL18609_Cargo Accessories", - "CA135-SC186-FL18610_Cargo Carriers", - "CA135-SC186-FL18611_Watersport Carriers", - "CA135-SC192-FL19201_Class 1 Hitches", - "CA135-SC192-FL19202_Class 2 Hitches", - "CA135-SC192-FL19203_Class 3 Hitches", - "CA135-SC192-FL19204_Towing, Heavy Duty", - "CA135-SC192-FL19205_Towing Electrical, Vehicle Specific", - "CA135-SC192-FL19206_Trailer Parts & Accessories", - "CA135-SC192-FL19207_Trailer Winches, Jacks & Couplers", - "CA135-SC192-FL19208_Class 5 Hitches", - "CA135-SC192-FL19221_Towing Electrical, Connectors & Adapters", - "CA135-SC192-FL19230_Towing Electrical, Controls & Converters", - "CA135-SC192-FL19235_Towing Electrical, Harnesses", - "CA135-SC192-FL19240_Towing Security, Non-Locking", - "CA135-SC192-FL19245_Towing Class V", - "CA135-SC192-FL19280_Towing Balls", - "CA135-SC192-FL19281_Towing Ball Mounts", - "CA135-SC192-FL19282_Towing Security, Locking", - "CA135-SC192-FL19283_Towing Kits & Acc" - }; + _logger.LogInformation("Processing {productType}", HttpUtility.UrlDecode(productType)); - foreach (string partType in partTypes) - { + IEnumerable products = null; try { - products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 }, { "product_type", partType } }); + products = await _shopifyClient.Products.Get(new Dictionary { { "limit", 250 }, { "product_type", productType } }); //products = new List //{ - // await _shopifyClient.Products.GetById(4388919574575) + // await _shopifyClient.Products.GetById(7458071052335) //}; } @@ -91,13 +63,12 @@ namespace PartSource.Automation.Jobs throw; } - int i = 1; - while (products != null && products.Any()) { foreach (Product product in products) { ImportData importData = null; + bool isFitment = false; try { @@ -109,48 +80,32 @@ namespace PartSource.Automation.Jobs VariantSku = product.Variants[0].Sku // They know we can't do fitment for variants }; - bool isFitment = false; - string bodyHtml = product.BodyHtml.Substring(0, product.BodyHtml.IndexOf("") + "".Length); + importData.PartNumber = importData.PartNumber.Replace("-", string.Empty); + + //If the line code is numeric, it cannot have fitment data associated with it. + if (int.TryParse(importData.LineCode, out _)) + { + continue; + } + + // Extract Partsource bullet points if present. + string bodyHtml = string.IsNullOrEmpty(product.BodyHtml) + ? string.Empty + : product.BodyHtml.Substring(0, product.BodyHtml.IndexOf("") + "".Length); IList vehicles = _vehicleFitmentService.GetVehiclesForPart(importData.PartNumber, importData.LineCode); IList vehicleIdFitment = _vehicleFitmentService.GetVehicleIdFitment(vehicles); if (!vehicleIdFitment.Any()) { - Console.WriteLine($"No fitment data for SKU {importData.VariantSku}"); + Console.WriteLine($"No fitment data for {importData.LineCode} {importData.PartNumber}"); continue; } - if (vehicleIdFitment.Count > 0) - { - string vehicleIdString = string.Join(',', vehicleIdFitment.Select(j => $"v{j}")); + string vehicleIdString = string.Join(',', vehicleIdFitment.Select(j => $"v{j}")); - bodyHtml += $"
{vehicleIdString}
"; - - isFitment = true; - - string json = JsonConvert.SerializeObject(vehicleIdFitment); - if (json.Length < 100000) - { - Metafield vehicleMetafield = new Metafield - { - Namespace = "fitment", - Key = "ids", - Value = json, - Type = "json_string", - OwnerResource = "product", - OwnerId = product.Id - }; - - 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; - } - } + bodyHtml += $"
{vehicleIdString}
"; + isFitment = true; IList ymmFitment = _vehicleFitmentService.GetYmmFitment(vehicles); if (ymmFitment.Count > 0) @@ -165,79 +120,20 @@ namespace PartSource.Automation.Jobs try { string[] parts = fitment.Split(' ', 2); - stringBuilder.AppendLine($"{parts[1]}{parts[0].Replace("-", ", ")}"); } - catch + catch (Exception ex) { - // This is still a POC at this point. Oh well... + _logger.LogWarning(ex, "YMM fitment for {fitment} was in an invalid format", fitment); } } stringBuilder.AppendLine(""); - bodyHtml += $"
{stringBuilder.ToString()}
"; - - string json = JsonConvert.SerializeObject(ymmFitment); - if (json.Length < 100000) - { - Metafield ymmMetafield = new Metafield - { - Namespace = "fitment", - Key = "seo", - Value = json, - Type = "json_string", - OwnerResource = "product", - OwnerId = product.Id - }; - - await _shopifyClient.Metafields.Add(ymmMetafield); - } - - else - { - _logger.LogWarning($"Year/make/model fitment data for SKU {importData.VariantSku} is too large for Shopify and cannot be added."); - continue; - } + bodyHtml += $"
{stringBuilder}
"; } - Metafield isFitmentMetafield = new Metafield - { - Namespace = "Flags", - Key = "IsFitment", - Value = isFitment.ToString(), - Type = "string", - OwnerResource = "product", - OwnerId = product.Id - }; - - await _shopifyClient.Metafields.Add(isFitmentMetafield); - - //Metafield lineCodeMetafield = new Metafield - //{ - // Namespace = "google", - // Key = "custom_label_0", - // Value = importData.LineCode, - // Type = "string", - // OwnerResource = "product", - // OwnerId = product.Id - //}; - - //await _shopifyClient.Metafields.Add(lineCodeMetafield); - - //Metafield partNumberMetafield = new Metafield - //{ - // Namespace = "google", - // Key = "custom_label_1", - // Value = importData.PartNumber, - // Type = "string", - // OwnerResource = "product", - // OwnerId = product.Id - //}; - - //await _shopifyClient.Metafields.Add(partNumberMetafield); - List tags = new List(); for (int j = 0; j < vehicleIdFitment.Count; j += 25) @@ -275,12 +171,8 @@ namespace PartSource.Automation.Jobs } try { - Console.WriteLine(i); - - _partSourceContext.SaveChanges(); products = await _shopifyClient.Products.GetNext(); - i++; } catch (Exception ex) @@ -289,8 +181,6 @@ namespace PartSource.Automation.Jobs products = await _shopifyClient.Products.GetPrevious(); } } - - Console.WriteLine($"Finished {partType}"); } } } diff --git a/PartSource.Automation/Models/Configuration/FtpConfiguration.cs b/PartSource.Automation/Models/Configuration/FtpConfiguration.cs index 7feee23..cceef98 100644 --- a/PartSource.Automation/Models/Configuration/FtpConfiguration.cs +++ b/PartSource.Automation/Models/Configuration/FtpConfiguration.cs @@ -16,5 +16,7 @@ namespace PartSource.Automation.Models.Configuration public string Username { get; set; } public string Password { get; set; } + + public int Port { get; set; } } } diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index 01cc20a..3020c37 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, 1, 0)) + options.HasBaseInterval(new TimeSpan(0, 15, 0)) .HasMaxFailures(1) //.HasJob(options => options.HasInterval(new TimeSpan(7, 0, 0, 0))); // @@ -95,15 +95,16 @@ namespace PartSource.Automation //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) // .StartsAt(DateTime.Parse("2021-04-01 08:00:00")) //) - .HasJob(options => + + .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) - //.StartsAt(DateTime.Today.AddHours(25)) + // .StartsAt(DateTime.Today.AddMinutes(15)) // ) //.HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) - // .HasDependency() - // // .StartsAt(DateTime.Today.AddHours(28)) - ); + // .HasDependency() + // // .StartsAt(DateTime.Today.AddHours(28)) + ); //); //.AddApiServer(); }) diff --git a/PartSource.Automation/Services/VehicleFitmentService.cs b/PartSource.Automation/Services/VehicleFitmentService.cs index b082315..7e7c59e 100644 --- a/PartSource.Automation/Services/VehicleFitmentService.cs +++ b/PartSource.Automation/Services/VehicleFitmentService.cs @@ -90,7 +90,9 @@ namespace PartSource.Automation.Services public IList GetVehicleIdFitment(IList vehicles) { - return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToArray(); + return vehicles != null + ? vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToArray() + : new List(); } public IList GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0) @@ -100,7 +102,7 @@ namespace PartSource.Automation.Services 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) diff --git a/PartSource.Automation/Services/WhiSeoService.cs b/PartSource.Automation/Services/WhiSeoService.cs index a086b13..0f35c91 100644 --- a/PartSource.Automation/Services/WhiSeoService.cs +++ b/PartSource.Automation/Services/WhiSeoService.cs @@ -5,167 +5,154 @@ using Microsoft.Extensions.Logging; using PartSource.Automation.Models.Configuration; using PartSource.Automation.Models.Enums; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Text; +using System.Threading.Tasks; namespace PartSource.Automation.Services { - public class WhiSeoService - { - private readonly FtpService _ftpService; - private readonly string _connectionString; - private readonly ILogger _logger; + public class WhiSeoService + { + private readonly FtpService _ftpService; + private readonly string _connectionString; + private readonly ILogger _logger; - public WhiSeoService(IConfiguration configuration, ILogger logger) - { - FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:WhiConfiguration").Get(); - _ftpService = new FtpService(ftpConfiguration); + public WhiSeoService(IConfiguration configuration, ILogger logger) + { + FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:WhiConfiguration").Get(); + _ftpService = new FtpService(ftpConfiguration); - _connectionString = configuration.GetConnectionString("FitmentDatabase"); + _connectionString = configuration.GetConnectionString("FitmentDatabase"); - _logger = logger; - } + _logger = logger; + } - public void GetFiles(SeoDataType seoDataType) - { - string seoDataTypeString = seoDataType.ToString().ToLowerInvariant(); - string[] files = _ftpService.ListFiles(seoDataTypeString); + public void GetFiles(SeoDataType seoDataType) + { + string seoDataTypeString = seoDataType.ToString().ToLowerInvariant(); + + // WHI changed the transfer protocol to SFTP and then messed with the directory structure. + // Since fitment isn't really all that automated anyway, just download the files manually with an SFTP client. + Console.WriteLine($"Remember to manually download the {seoDataTypeString} files with an SFTP client. Press any key to continue."); + Console.ReadLine(); + } - foreach (string file in files) - { - if (file.Contains(".csv")) - { - try - { - _ftpService.Download($"{seoDataTypeString}/{file}"); - _logger.LogInformation($"Finished downloading {file}."); - } + public void TruncateVehicleTable() + { + using SqlConnection connection = new SqlConnection(_connectionString); + connection.Open(); + using SqlCommand command = new SqlCommand($"truncate table dbo.Vehicle", connection); + command.ExecuteNonQuery(); + } - catch (Exception ex) - { - _logger.LogWarning($"Failed to download {file}, quitting", ex); - throw; - } - } - } - } + public void TruncateFitmentTables() + { + using SqlConnection connection = new SqlConnection(_connectionString); + connection.Open(); - public void TruncateVehicleTable() - { - using SqlConnection connection = new SqlConnection(_connectionString); - connection.Open(); + using SqlCommand command = new SqlCommand($"exec DropFitmentTables", connection); + command.ExecuteNonQuery(); + } - using SqlCommand command = new SqlCommand($"truncate table dbo.Vehicle", connection); - command.ExecuteNonQuery(); - } + public void SaveNotes(IDictionary notes) + { + using DataTable dataTable = new DataTable(); + dataTable.Columns.Add("NoteText", typeof(string)); + dataTable.Columns.Add("Hash", typeof(string)); - public void TruncateFitmentTables() - { - using SqlConnection connection = new SqlConnection(_connectionString); - connection.Open(); + foreach (KeyValuePair note in notes) + { - using SqlCommand command = new SqlCommand($"exec DropFitmentTables", connection); - command.ExecuteNonQuery(); - } + dataTable.Rows.Add(new string[] { note.Value, note.Key }); + } - public void SaveNotes(IDictionary notes) - { - using DataTable dataTable = new DataTable(); - dataTable.Columns.Add("NoteText", typeof(string)); - dataTable.Columns.Add("Hash", typeof(string)); + using SqlConnection connection = new SqlConnection(_connectionString); + connection.Open(); - foreach (KeyValuePair note in notes) - { + using SqlBulkCopy bulk = new SqlBulkCopy(connection) + { + DestinationTableName = $"FitmentNote", + BulkCopyTimeout = 14400 + }; - dataTable.Rows.Add(new string[] { note.Value, note.Key }); - } + bulk.WriteToServer(dataTable); + } - using SqlConnection connection = new SqlConnection(_connectionString); - connection.Open(); + public void BulkCopyFitment(DataTable dataTable, string tableName) + { + using SqlConnection connection = new SqlConnection(_connectionString); + connection.Open(); - using SqlBulkCopy bulk = new SqlBulkCopy(connection) - { - DestinationTableName = $"FitmentNote", - BulkCopyTimeout = 14400 - }; + string sql = string.Empty; - bulk.WriteToServer(dataTable); - } + using SqlCommand command = new SqlCommand($"EXEC CreateFitmentTempTable @tableName = '{tableName}'", connection); + command.ExecuteNonQuery(); - public void BulkCopyFitment(DataTable dataTable, string tableName) - { - using SqlConnection connection = new SqlConnection(_connectionString); - connection.Open(); + using SqlBulkCopy bulk = new SqlBulkCopy(connection) + { + DestinationTableName = $"FitmentTemp.{tableName}", + BulkCopyTimeout = 14400 + }; - string sql = string.Empty; + bulk.WriteToServer(dataTable); + } - using SqlCommand command = new SqlCommand($"EXEC CreateFitmentTempTable @tableName = '{tableName}'", connection); - command.ExecuteNonQuery(); + public void BulkCopyVehicle(DataTable dataTable, string tableName) + { + using SqlConnection connection = new SqlConnection(_connectionString); + connection.Open(); - using SqlBulkCopy bulk = new SqlBulkCopy(connection) - { - DestinationTableName = $"FitmentTemp.{tableName}", - BulkCopyTimeout = 14400 - }; + string sql = string.Empty; - bulk.WriteToServer(dataTable); - } + using SqlCommand command = new SqlCommand($"EXEC CreateVehicleTempTable @tableName = '{tableName}'", connection); + command.ExecuteNonQuery(); - public void BulkCopyVehicle(DataTable dataTable, string tableName) - { - using SqlConnection connection = new SqlConnection(_connectionString); - connection.Open(); + using SqlBulkCopy bulk = new SqlBulkCopy(connection) + { + DestinationTableName = $"VehicleTemp.{tableName}", + BulkCopyTimeout = 14400 + }; - string sql = string.Empty; + bulk.WriteToServer(dataTable); + } - using SqlCommand command = new SqlCommand($"EXEC CreateVehicleTempTable @tableName = '{tableName}'", connection); - command.ExecuteNonQuery(); + public void CreateFitmentTable(string tableName) + { + using SqlConnection connection = new SqlConnection(_connectionString); + connection.Open(); - using SqlBulkCopy bulk = new SqlBulkCopy(connection) - { - DestinationTableName = $"VehicleTemp.{tableName}", - BulkCopyTimeout = 14400 - }; + using SqlCommand command = new SqlCommand($"exec CreateFitmentTable @tableName = '{tableName}'", connection); + command.CommandTimeout = 1800; + command.ExecuteNonQuery(); + } - bulk.WriteToServer(dataTable); - } + public void CreateFitmentView() + { + using SqlConnection connection = new SqlConnection(_connectionString); + connection.Open(); - public void CreateFitmentTable(string tableName) - { - using SqlConnection connection = new SqlConnection(_connectionString); - connection.Open(); + using SqlCommand command = new SqlCommand($"exec CreateFitmentView", connection); + command.CommandTimeout = 1800; + command.ExecuteNonQuery(); - using SqlCommand command = new SqlCommand($"exec CreateFitmentTable @tableName = '{tableName}'", connection); - command.CommandTimeout = 1800; - command.ExecuteNonQuery(); - } + using SqlCommand command2 = new SqlCommand($"exec CreateFitmentIndexes", connection); + command.CommandTimeout = 3600; + command2.ExecuteNonQuery(); + } - public void CreateFitmentView() - { - using SqlConnection connection = new SqlConnection(_connectionString); - connection.Open(); + public void CreateVehicleTable() + { + using SqlConnection connection = new SqlConnection(_connectionString); + connection.Open(); - using SqlCommand command = new SqlCommand($"exec CreateFitmentView", connection); - command.CommandTimeout = 1800; - command.ExecuteNonQuery(); - - using SqlCommand command2 = new SqlCommand($"exec CreateFitmentIndexes", connection); - command.CommandTimeout = 3600; - command2.ExecuteNonQuery(); - } - - public void CreateVehicleTable() - { - using SqlConnection connection = new SqlConnection(_connectionString); - connection.Open(); - - using SqlCommand command = new SqlCommand($"exec CreateVehicleTable", connection); - command.CommandTimeout = 1800; - command.ExecuteNonQuery(); - } - } + using SqlCommand command = new SqlCommand($"exec CreateVehicleTable", connection); + command.CommandTimeout = 1800; + command.ExecuteNonQuery(); + } + } } #pragma warning restore CA2100 // Review SQL queries for security vulnerabilities \ No newline at end of file diff --git a/PartSource.Automation/appsettings.json b/PartSource.Automation/appsettings.json index ec663d7..4fe295c 100644 --- a/PartSource.Automation/appsettings.json +++ b/PartSource.Automation/appsettings.json @@ -1,6 +1,7 @@ { "ConnectionStrings": { - "FitmentDatabase": "Data Source=omg-optiplex;Initial Catalog=WhiFitment;User ID=sa;Password=TNG497us?4TW!;TrustServerCertificate=True", + //"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true;TrustServerCertificate=true", + "FitmentDatabase": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=sa;Password=GZ0`-ekd~[2u;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300", "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": { @@ -14,13 +15,15 @@ "Username": "ps-ftp\\$ps-ftp", "Password": "ycvXptffBxqkBXW4vuRYqn4Zi1soCvnvMMolTe5HNSeAlcl3bAyJYtNhG579", "Url": "ftp://waws-prod-yq1-007.ftp.azurewebsites.windows.net/site/wwwroot", - "Destination": "C:\\Partsource.Automation\\Downloads" + "Destination": "C:\\Partsource.Automation\\Downloads", + "Port": 21 }, "WhiConfiguration": { "Username": "ctc_seo", - "Password": "be34hz64e4", + "Password": "YD3gtaQ5kPdtNKs", "Url": "ftp://ftp.whisolutions.com", - "Destination": "C:\\Partsource.Automation\\Downloads\\WHI" + "Destination": "C:\\Partsource.Automation\\Downloads\\WHI", + "Port": 3001 } }, "ssisConfiguration": { diff --git a/PartSource.Data/Contexts/FitmentContext.cs b/PartSource.Data/Contexts/FitmentContext.cs index d55c722..a46169c 100644 --- a/PartSource.Data/Contexts/FitmentContext.cs +++ b/PartSource.Data/Contexts/FitmentContext.cs @@ -13,10 +13,14 @@ namespace PartSource.Data.Contexts public DbSet DcfMappings { get; set; } + public DbSet Parts { get; set; } + public DbSet Fitments { get; set; } public DbSet FitmentNotes { get; set; } + public DbSet ProductTypes { get; set; } + public DbSet Vehicles { get; set; } public DbSet VehicleFitments { get; set; } diff --git a/PartSource.Data/Contexts/PartSourceContext.cs b/PartSource.Data/Contexts/PartSourceContext.cs index 6fc0e76..1ec414e 100644 --- a/PartSource.Data/Contexts/PartSourceContext.cs +++ b/PartSource.Data/Contexts/PartSourceContext.cs @@ -26,7 +26,7 @@ namespace PartSource.Data.Contexts public DbSet PartPrices { get; set; } - public DbSet Parts { get; set; } + // public DbSet Parts { get; set; } public DbSet ShopifyChangelogs { get; set; } diff --git a/PartSource.Data/Dtos/VehicleFitmentDto.cs b/PartSource.Data/Dtos/VehicleFitmentDto.cs index 66819ed..de558db 100644 --- a/PartSource.Data/Dtos/VehicleFitmentDto.cs +++ b/PartSource.Data/Dtos/VehicleFitmentDto.cs @@ -7,8 +7,13 @@ namespace PartSource.Data.Dtos { public class VehicleFitmentDto : VehicleFitment { + public string PartDescription { get; set; } + + // May not be needed, but don't remove just yet public IList SubmodelNames { get; set; } public IList DriveTypes { get; set; } + + public IList Notes { get; set; } } } \ No newline at end of file diff --git a/PartSource.Data/Models/ProductType.cs b/PartSource.Data/Models/ProductType.cs new file mode 100644 index 0000000..844b618 --- /dev/null +++ b/PartSource.Data/Models/ProductType.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace PartSource.Data.Models +{ + public class ProductType + { + [Key] + public string Name { get; set; } + + public bool Active { get; set; } + } +} diff --git a/PartSource.Data/Models/VehicleFitment.cs b/PartSource.Data/Models/VehicleFitment.cs index ed55446..7e39a58 100644 --- a/PartSource.Data/Models/VehicleFitment.cs +++ b/PartSource.Data/Models/VehicleFitment.cs @@ -1,4 +1,6 @@ -namespace PartSource.Data.Models +using Newtonsoft.Json; + +namespace PartSource.Data.Models { public class VehicleFitment { @@ -8,6 +10,7 @@ public string PartNumber { get; set; } + [JsonIgnore] public string NoteText { get; set; } public int Year { get; set; } diff --git a/PartSource.Data/Nexpart/ApplicationSearch.cs b/PartSource.Data/Nexpart/ApplicationSearch.cs index db4111c..174031c 100644 --- a/PartSource.Data/Nexpart/ApplicationSearch.cs +++ b/PartSource.Data/Nexpart/ApplicationSearch.cs @@ -31,12 +31,15 @@ namespace PartSource.Data.Nexpart public bool SecondaryDCF => true; [XmlElement(Order = 6)] - public Criterion[] Criterion { get; set; } + public string[] AppOption { get; set; } [XmlElement(Order = 7)] - public string GroupBy { get; set; } + public Criterion[] Criterion { get; set; } [XmlElement(Order = 8)] + public string GroupBy { get; set; } + + [XmlElement(Order = 9)] public string QuestionOption { get; set; } } } diff --git a/PartSource.Services/FitmentService.cs b/PartSource.Services/FitmentService.cs index f0903bb..264d6d0 100644 --- a/PartSource.Services/FitmentService.cs +++ b/PartSource.Services/FitmentService.cs @@ -13,11 +13,11 @@ 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 async Task GetFitmentNotes(string sku, int vehicleId) @@ -36,120 +36,115 @@ namespace PartSource.Services BaseVehicleId = vf.BaseVehicleId, EngineConfigId = vf.EngineConfigId, VehicleToEngineConfigId = vf.VehicleToEngineConfigId, - SubmodelName = vf.SubmodelName + SubmodelName = vf.SubmodelName }) .FirstOrDefaultAsync(); - if (vehicleFitment == null) - { - return null; - } - return vehicleFitment; } public IList GetYmmFitment(IList vehicles) - { - if (vehicles.Count == 0) - { - return new string[0]; - } + { + if (vehicles.Count == 0) + { + return new string[0]; + } - IList fitmentTags = new List(); + IList fitmentTags = new List(); - IList makeModels = vehicles.OrderBy(v => v.MakeName).ThenBy(v => v.ModelName).Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList(); + IList makeModels = vehicles.OrderBy(v => v.MakeName).ThenBy(v => v.ModelName).Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList(); - foreach (string makeModel in makeModels) - { - string make = makeModel.Split(',')[0]; - string model = makeModel.Split(',')[1]; + foreach (string makeModel in makeModels) + { + string make = makeModel.Split(',')[0]; + string model = makeModel.Split(',')[1]; - List years = vehicles - .Where(v => v.MakeName == make && v.ModelName == model) - .OrderBy(v => v.Year) - .Select(v => v.Year.ToString().Trim()) - .Distinct() - .ToList(); + List years = vehicles + .Where(v => v.MakeName == make && v.ModelName == model) + .OrderBy(v => v.Year) + .Select(v => v.Year.ToString().Trim()) + .Distinct() + .ToList(); - string tag = $"{string.Join('-', years)} {make.Trim()} {model.Trim()}"; + string tag = $"{string.Join('-', years)} {make.Trim()} {model.Trim()}"; - System.Diagnostics.Debug.WriteLine(tag); + System.Diagnostics.Debug.WriteLine(tag); - fitmentTags.Add(tag); - } + fitmentTags.Add(tag); + } - return fitmentTags; - } + return fitmentTags; + } - public IList GetYmmFitmentRange(IList vehicles) - { - if (vehicles.Count == 0) - { - return new string[0]; - } + public IList GetYmmFitmentRange(IList vehicles) + { + if (vehicles.Count == 0) + { + return new string[0]; + } - IList fitmentTags = new List(); + IList fitmentTags = new List(); - IList makeModels = vehicles.Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList(); + IList makeModels = vehicles.Select(v => $"{v.MakeName},{v.ModelName}").Distinct().ToList(); - foreach (string makeModel in makeModels) - { - string make = makeModel.Split(',')[0]; - string model = makeModel.Split(',')[1]; + foreach (string makeModel in makeModels) + { + string make = makeModel.Split(',')[0]; + string model = makeModel.Split(',')[1]; - int minYear = vehicles - .Where(v => v.MakeName == make && v.ModelName == model) - .Min(v => v.Year); + int minYear = vehicles + .Where(v => v.MakeName == make && v.ModelName == model) + .Min(v => v.Year); - int maxYear = vehicles - .Where(v => v.MakeName == make && v.ModelName == model) - .Max(v => v.Year); + int maxYear = vehicles + .Where(v => v.MakeName == make && v.ModelName == model) + .Max(v => v.Year); - string tag = minYear == maxYear - ? $"{minYear} {make.Trim()} {model.Trim()}" - : $"{minYear}-{maxYear} {make.Trim()} {model.Trim()}"; + string tag = minYear == maxYear + ? $"{minYear} {make.Trim()} {model.Trim()}" + : $"{minYear}-{maxYear} {make.Trim()} {model.Trim()}"; - System.Diagnostics.Debug.WriteLine(tag); + System.Diagnostics.Debug.WriteLine(tag); - fitmentTags.Add(tag); - } + fitmentTags.Add(tag); + } - return fitmentTags; - } + return fitmentTags; + } - public IList GetVehicleIdFitment(IList vehicles) - { - return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToList(); - } + public IList GetVehicleIdFitment(IList vehicles) + { + return vehicles.Select(v => v.VehicleToEngineConfigId).Distinct().ToList(); + } - public IList GetVehiclesForPart(string partNumber, string lineCode, int maxVehicles = 0) - { - if (string.IsNullOrEmpty(partNumber) || string.IsNullOrEmpty(lineCode)) - { - return null; - } + public IList 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); + 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) => v) - .Distinct() - .OrderByDescending(x => x.Year); + 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); - if (maxVehicles > 0) - { - vehicles = vehicles.Take(maxVehicles); - } + if (maxVehicles > 0) + { + vehicles = vehicles.Take(maxVehicles); + } - return vehicles.ToList(); - } - } + return vehicles.ToList(); + } + } } diff --git a/PartSource.Services/NexpartService.cs b/PartSource.Services/NexpartService.cs index 8e5641c..0bf411b 100644 --- a/PartSource.Services/NexpartService.cs +++ b/PartSource.Services/NexpartService.cs @@ -25,17 +25,20 @@ namespace PartSource.Services U content; string x = textWriter.ToString(); - - using (HttpClient client = new HttpClient()) + System.Diagnostics.Debug.WriteLine(x); + + using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "QjM4ODAyMzM3QjQxNEM2QTk4M0RFMjM0Mjk4Rjk4M0UtOUIzNUUxNzNBQUYxNEE2QjhCQjI2RjZDOUY2ODk1NDU6MkMzOUVCOTYtRDBBRS00QkVBLTlCMzItMUYyNTA5MDJGQTE0"); try { //HttpResponseMessage response = await client.PostAsync(ConfigurationManager.AppSettings["NexpartUrl"], (HttpContent)new StringContent(sb.ToString(), Encoding.UTF8, "text/xml")); - HttpResponseMessage response = await client.PostAsync("https://acespssprod.nexpart.com:4085/partselect/2.0/services/PartSelectService.PartSelectHttpSoap11Endpoint", new StringContent(textWriter.ToString(), Encoding.UTF8, "text/xml")); + HttpResponseMessage response = await client.PostAsync("http://acespssprod.nexpart.com:8085/partselect/2.0/services/PartSelectService.PartSelectHttpSoap11Endpoint", new StringContent(textWriter.ToString(), Encoding.UTF8, "text/xml")); Stream result = await response.Content.ReadAsStreamAsync(); + string str = await response.Content.ReadAsStringAsync(); - + System.Diagnostics.Debug.WriteLine(str); + content = (U)((Envelope)serializer.Deserialize(result)).Body.Content; ; } @@ -44,6 +47,7 @@ namespace PartSource.Services throw; } } + return content; } } diff --git a/PartSource.Services/PartService.cs b/PartSource.Services/PartService.cs index 4162a3d..fda4ffb 100644 --- a/PartSource.Services/PartService.cs +++ b/PartSource.Services/PartService.cs @@ -12,26 +12,28 @@ namespace PartSource.Services { public class PartService { - private readonly PartSourceContext _context; + private readonly PartSourceContext _partSourceContext; + private readonly FitmentContext _fitmentContext; - public PartService(PartSourceContext context) + public PartService(PartSourceContext partSourceContext, FitmentContext fitmentContext) { - _context = context; + _partSourceContext = partSourceContext; + _fitmentContext = fitmentContext; } public async Task GetInventory(int sku, int storeNumber) { - return await _context.PartAvailabilities.FirstOrDefaultAsync(s => s.Store == storeNumber && s.SKU == sku); + return await _partSourceContext.PartAvailabilities.FirstOrDefaultAsync(s => s.Store == storeNumber && s.SKU == sku); } public async Task GetPartBySku(string sku) { - return await _context.Parts.SingleOrDefaultAsync(p => p.Sku == sku); + return await _fitmentContext.Parts.SingleOrDefaultAsync(p => p.Sku == sku); } public async Task> GetDcfMapping(string partsourceLineCode) { - return await _context.DcfMappings + return await _fitmentContext.DcfMappings .Where(dcf => dcf.LineCode == partsourceLineCode) .ToListAsync(); } From a3a08d9cff26524df6d06fc15b01b07b3e52ddd2 Mon Sep 17 00:00:00 2001 From: Tom Raterman Date: Thu, 3 Apr 2025 20:28:46 -0400 Subject: [PATCH 8/8] WIP --- .../Jobs/ProcessWhiVehicles.cs | 23 ++++++++----------- PartSource.Automation/Program.cs | 2 +- PartSource.Automation/appsettings.json | 4 ++-- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/PartSource.Automation/Jobs/ProcessWhiVehicles.cs b/PartSource.Automation/Jobs/ProcessWhiVehicles.cs index 6ff9f06..e6558f7 100644 --- a/PartSource.Automation/Jobs/ProcessWhiVehicles.cs +++ b/PartSource.Automation/Jobs/ProcessWhiVehicles.cs @@ -1,25 +1,20 @@ -using Microsoft.Extensions.Configuration; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using PartSource.Automation.Models.Configuration; using PartSource.Automation.Models.Enums; using PartSource.Automation.Services; using Ratermania.Automation.Interfaces; -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Data; -using System.IO; -using System.IO.Compression; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; namespace PartSource.Automation.Jobs { - public class ProcessWhiVehicles : IAutomationJob + public class ProcessWhiVehicles : IAutomationJob { private readonly ILogger _logger; private readonly WhiSeoService _whiSeoService; diff --git a/PartSource.Automation/Program.cs b/PartSource.Automation/Program.cs index 3020c37..ac3d679 100644 --- a/PartSource.Automation/Program.cs +++ b/PartSource.Automation/Program.cs @@ -96,7 +96,7 @@ namespace PartSource.Automation // .StartsAt(DateTime.Parse("2021-04-01 08:00:00")) //) - .HasJob(options => + .HasJob(options => options.HasInterval(new TimeSpan(24, 0, 0)) // .StartsAt(DateTime.Today.AddMinutes(15)) // ) diff --git a/PartSource.Automation/appsettings.json b/PartSource.Automation/appsettings.json index 4fe295c..005fb59 100644 --- a/PartSource.Automation/appsettings.json +++ b/PartSource.Automation/appsettings.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { - //"FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true;TrustServerCertificate=true", - "FitmentDatabase": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=sa;Password=GZ0`-ekd~[2u;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300", + "FitmentDatabase": "Data Source=localhost;Initial Catalog=WhiFitment;Integrated Security=true;TrustServerCertificate=true", + //"FitmentDatabase": "Server=tcp:ps-automation.eastus2.cloudapp.azure.com,1433;Initial Catalog=WhiFitment;User ID=sa;Password=GZ0`-ekd~[2u;Encrypt=True;TrustServerCertificate=True;Connection Timeout=300", "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": {