Threaded ProcessWhiFitment
This commit is contained in:
@@ -39,6 +39,7 @@ namespace PartSource.Automation.Jobs
|
||||
_noteDictionary = new ConcurrentDictionary<string, string>();
|
||||
}
|
||||
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2008:Do not create tasks without passing a TaskScheduler", Justification = "<Pending>")]
|
||||
public async Task Run()
|
||||
{
|
||||
_whiSeoService.TruncateFitmentTables();
|
||||
@@ -54,18 +55,14 @@ namespace PartSource.Automation.Jobs
|
||||
fileGroups.Enqueue(fileGroup);
|
||||
}
|
||||
|
||||
while (fileGroups.Count > 0)
|
||||
{
|
||||
Parallel.For(0, 2, i =>
|
||||
{
|
||||
bool result = fileGroups.TryDequeue(out IGrouping<string, FileInfo> fileGroup);
|
||||
Task[] taskArray = new Task[8];
|
||||
|
||||
if (!result)
|
||||
for (int i = 0; i < taskArray.Length; i++)
|
||||
{
|
||||
taskArray[i] = Task.Factory.StartNew(() =>
|
||||
{
|
||||
while (fileGroups.TryDequeue(out IGrouping<string, FileInfo> fileGroup))
|
||||
{
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
foreach (FileInfo fileInfo in fileGroup)
|
||||
{
|
||||
try
|
||||
@@ -91,9 +88,13 @@ namespace PartSource.Automation.Jobs
|
||||
_whiSeoService.CreateFitmentTable(fitmentTable);
|
||||
|
||||
_logger.LogInformation($"Created fitment table for part group {fitmentTable}.");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Task.WaitAll(taskArray);
|
||||
|
||||
_whiSeoService.CreateFitmentView();
|
||||
|
||||
_whiSeoService.SaveNotes(_noteDictionary);
|
||||
@@ -135,7 +136,7 @@ namespace PartSource.Automation.Jobs
|
||||
}
|
||||
|
||||
string 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 partNumber = Regex.Replace(columns[1], "[^a-zA-Z0-9]", string.Empty).Trim();
|
||||
string position = columns[7].Trim();
|
||||
|
||||
string noteText = columns[4].Trim();
|
||||
|
||||
@@ -82,10 +82,10 @@ namespace PartSource.Automation
|
||||
//.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<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<UpdateFitment>(options => options.HasInterval(new TimeSpan(24, 0, 0)));
|
||||
//.HasJob<UpdatePositioning>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
||||
// .HasDependency<UpdateFitment>()
|
||||
// .HasDependency<ProcessWhiFitment>()
|
||||
@@ -96,7 +96,7 @@ namespace PartSource.Automation
|
||||
// .StartsAt(DateTime.Parse("2021-04-01 08:00:00"))
|
||||
//)
|
||||
//.HasJob<ExecuteSsisPackages>(options =>
|
||||
// options.HasInterval(new TimeSpan(24, 0, 0))
|
||||
//options.HasInterval(new TimeSpan(24, 0, 0))
|
||||
// .StartsAt(DateTime.Today.AddHours(5))
|
||||
// );
|
||||
//.StartsAt(DateTime.Today.AddHours(26))
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace PartSource.Automation.Services
|
||||
using SqlBulkCopy bulk = new SqlBulkCopy(connection)
|
||||
{
|
||||
DestinationTableName = $"FitmentTemp.{tableName}",
|
||||
BulkCopyTimeout = 1
|
||||
BulkCopyTimeout = 14400
|
||||
};
|
||||
|
||||
bulk.WriteToServer(dataTable);
|
||||
@@ -149,9 +149,11 @@ namespace PartSource.Automation.Services
|
||||
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 = 1800;
|
||||
command2.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user