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; }