This commit is contained in:
2023-12-19 14:49:30 -05:00
parent b8406a7f71
commit aed30707be
17 changed files with 184 additions and 60 deletions

View File

@@ -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, SmartPageDataSearchResponse>(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, ApplicationSearchResponse>(applicationSearch);
if (response.ResponseBody != null)
{
vehicleFitment.DriveTypes = new List<string>();
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, ApplicationSearchResponse>(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<string> positions = new List<string>();
foreach (App app in response.ResponseBody?.App)
foreach (App app in ((Apps)response.ResponseBody)?.App)
{
if (!string.IsNullOrEmpty(app.Position) && app.Part == part.PartNumber)
{

View File

@@ -51,7 +51,7 @@ namespace PartSource.Api.Controllers
if (response.ResponseBody != null)
{
return NexpartResponse<ApplicationSearchResponse, Apps>(response);
return NexpartResponse<ApplicationSearchResponse, object>(response);
}
else

View File

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

View File

@@ -17,7 +17,7 @@ namespace PartSource.Automation.Jobs
private readonly ILogger<ExecuteSsisPackages> _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<ExecuteSsisPackages> 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.");

View File

@@ -68,7 +68,7 @@ namespace PartSource.Automation.Jobs.POC
ApplicationSearchResponse response = await _nexpartService.SendRequest<ApplicationSearch, ApplicationSearchResponse>(applicationSearch);
if (response.ResponseBody != null)
{
foreach (App app in response.ResponseBody.App)
foreach (App app in ((Apps)response.ResponseBody).App)
{
try
{

View File

@@ -68,7 +68,7 @@ namespace PartSource.Automation.Jobs.POC
ApplicationSearchResponse response = await _nexpartService.SendRequest<ApplicationSearch, ApplicationSearchResponse>(applicationSearch);
if (response.ResponseBody != null)
{
foreach (App app in response.ResponseBody.App)
foreach (App app in ((Apps)response.ResponseBody).App)
{
try
{

View File

@@ -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)

View File

@@ -77,32 +77,32 @@ namespace PartSource.Automation
.AddAutomation(options =>
{
options.HasBaseInterval(new TimeSpan(0, 15, 0))
.HasMaxFailures(1)
//.HasJob<TestJob>(options => options.HasInterval(new TimeSpan(7, 0, 0, 0)));
//
//.HasJob<SyncronizeProducts>(options => options.HasInterval(new TimeSpan(24, 0, 0)))
// .HasJob<ProcessWhiFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0)));
//.HasJob<ProcessWhiVehicles>(options => options.HasInterval(new TimeSpan(24, 0, 0))
//.HasDependency<SyncronizeProducts>()
//.HasJob<UpdateFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0)));
//.HasJob<UpdatePositioning>(options => options.HasInterval(new TimeSpan(24, 0, 0))
// .HasDependency<UpdateFitment>()
// .HasDependency<ProcessWhiFitment>()
// .HasDependency<SyncronizeProducts>()
// .StartsAt(DateTime.Today.AddHours(8))
//) ;
//.HasJob<StatusCheck>(options => options.HasInterval(new TimeSpan(24, 0, 0))
// .StartsAt(DateTime.Parse("2021-04-01 08:00:00"))
//)
//.HasJob<ExecuteSsisPackages>(options =>
// options.HasInterval(new TimeSpan(24, 0, 0))
// //.StartsAt(DateTime.Today.AddHours(25))
// )
options.HasBaseInterval(new TimeSpan(0, 1, 0))
.HasMaxFailures(1)
//.HasJob<TestJob>(options => options.HasInterval(new TimeSpan(7, 0, 0, 0)));
//
//.HasJob<SyncronizeProducts>(options => options.HasInterval(new TimeSpan(24, 0, 0)))
// .HasJob<ProcessWhiFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0)));
//.HasJob<ProcessWhiVehicles>(options => options.HasInterval(new TimeSpan(24, 0, 0))
//.HasDependency<SyncronizeProducts>()
//.HasJob<UpdateFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0)));
//.HasJob<UpdatePositioning>(options => options.HasInterval(new TimeSpan(24, 0, 0))
// .HasDependency<UpdateFitment>()
// .HasDependency<ProcessWhiFitment>()
// .HasDependency<SyncronizeProducts>()
// .StartsAt(DateTime.Today.AddHours(8))
//) ;
//.HasJob<StatusCheck>(options => options.HasInterval(new TimeSpan(24, 0, 0))
// .StartsAt(DateTime.Parse("2021-04-01 08:00:00"))
//)
.HasJob<ProcessWhiFitment>(options =>
options.HasInterval(new TimeSpan(24, 0, 0))
//.StartsAt(DateTime.Today.AddHours(25))
// )
.HasJob<UpdatePricing>(options => options.HasInterval(new TimeSpan(24, 0, 0))
//.HasDependency<ExecuteSsisPackages>()
// .StartsAt(DateTime.Today.AddHours(28))
//.HasJob<UpdatePricing>(options => options.HasInterval(new TimeSpan(24, 0, 0))
// .HasDependency<ExecuteSsisPackages>()
// // .StartsAt(DateTime.Today.AddHours(28))
);
//);
//.AddApiServer();

View File

@@ -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();
}

View File

@@ -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": {

View File

@@ -8,5 +8,7 @@ namespace PartSource.Data.Dtos
public class VehicleFitmentDto : VehicleFitment
{
public IList<string> SubmodelNames { get; set; }
public IList<string> DriveTypes { get; set; }
}
}

View File

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

View File

@@ -35,5 +35,8 @@ namespace PartSource.Data.Nexpart
[XmlElement(Order = 7)]
public string GroupBy { get; set; }
[XmlElement(Order = 8)]
public string QuestionOption { get; set; }
}
}

View File

@@ -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<Apps>
public class ApplicationSearchResponse : IResponseElement<object>
{
[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; }
}
}

View File

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

View File

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

View File

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