Whatever this is
This commit is contained in:
@@ -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<string> rows = new List<string> {
|
||||
"\"Line Code\", \"Part Number\", \"Image URL(s)\""
|
||||
};
|
||||
|
||||
IList<ImportData> importData = await _partSourceContext.ImportData
|
||||
//.Take(5000)
|
||||
.ToListAsync();
|
||||
|
||||
foreach (ImportData item in importData)
|
||||
IList<Data.Models.Part> parts = await _fitmentContext.Parts.ToListAsync();
|
||||
string oldLineCode = string.Empty;
|
||||
IList<DcfMapping> mappings = new List<DcfMapping>();
|
||||
|
||||
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<SmartPageDataSearch, SmartPageDataSearchResponse>(dataSearch);
|
||||
|
||||
if (response.ResponseBody.Item?.Length > 0)
|
||||
{
|
||||
List<string> urls = new List<string>();
|
||||
|
||||
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<SmartPageDataSearch, SmartPageDataSearchResponse>(dataSearch);
|
||||
|
||||
if (urls.Count > 0)
|
||||
if (response.ResponseBody.Item?.Length > 0)
|
||||
{
|
||||
rows.Add($"\"{item.LineCode}\", \"{item.PartNumber}\", \"{string.Join(";", urls)}\"");
|
||||
List<string> urls = new List<string>();
|
||||
|
||||
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)}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user