Whatever this is
This commit is contained in:
@@ -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<string, FileInfo> 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 });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user