Threaded ProcessWhiFitment
This commit is contained in:
@@ -39,6 +39,7 @@ namespace PartSource.Automation.Jobs
|
|||||||
_noteDictionary = new ConcurrentDictionary<string, string>();
|
_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()
|
public async Task Run()
|
||||||
{
|
{
|
||||||
_whiSeoService.TruncateFitmentTables();
|
_whiSeoService.TruncateFitmentTables();
|
||||||
@@ -54,18 +55,14 @@ namespace PartSource.Automation.Jobs
|
|||||||
fileGroups.Enqueue(fileGroup);
|
fileGroups.Enqueue(fileGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fileGroups.Count > 0)
|
Task[] taskArray = new Task[8];
|
||||||
{
|
|
||||||
Parallel.For(0, 2, i =>
|
|
||||||
{
|
|
||||||
bool result = fileGroups.TryDequeue(out IGrouping<string, FileInfo> fileGroup);
|
|
||||||
|
|
||||||
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)
|
foreach (FileInfo fileInfo in fileGroup)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -91,9 +88,13 @@ namespace PartSource.Automation.Jobs
|
|||||||
_whiSeoService.CreateFitmentTable(fitmentTable);
|
_whiSeoService.CreateFitmentTable(fitmentTable);
|
||||||
|
|
||||||
_logger.LogInformation($"Created fitment table for part group {fitmentTable}.");
|
_logger.LogInformation($"Created fitment table for part group {fitmentTable}.");
|
||||||
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Task.WaitAll(taskArray);
|
||||||
|
|
||||||
_whiSeoService.CreateFitmentView();
|
_whiSeoService.CreateFitmentView();
|
||||||
|
|
||||||
_whiSeoService.SaveNotes(_noteDictionary);
|
_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 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 position = columns[7].Trim();
|
||||||
|
|
||||||
string noteText = columns[4].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<TestJob>(options => options.HasInterval(new TimeSpan(7, 0, 0, 0)));
|
||||||
//
|
//
|
||||||
//.HasJob<SyncronizeProducts>(options => options.HasInterval(new TimeSpan(24, 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))
|
//.HasJob<ProcessWhiVehicles>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
//.HasDependency<SyncronizeProducts>()
|
//.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))
|
//.HasJob<UpdatePositioning>(options => options.HasInterval(new TimeSpan(24, 0, 0))
|
||||||
// .HasDependency<UpdateFitment>()
|
// .HasDependency<UpdateFitment>()
|
||||||
// .HasDependency<ProcessWhiFitment>()
|
// .HasDependency<ProcessWhiFitment>()
|
||||||
@@ -96,7 +96,7 @@ namespace PartSource.Automation
|
|||||||
// .StartsAt(DateTime.Parse("2021-04-01 08:00:00"))
|
// .StartsAt(DateTime.Parse("2021-04-01 08:00:00"))
|
||||||
//)
|
//)
|
||||||
//.HasJob<ExecuteSsisPackages>(options =>
|
//.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(5))
|
||||||
// );
|
// );
|
||||||
//.StartsAt(DateTime.Today.AddHours(26))
|
//.StartsAt(DateTime.Today.AddHours(26))
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ namespace PartSource.Automation.Services
|
|||||||
using SqlBulkCopy bulk = new SqlBulkCopy(connection)
|
using SqlBulkCopy bulk = new SqlBulkCopy(connection)
|
||||||
{
|
{
|
||||||
DestinationTableName = $"FitmentTemp.{tableName}",
|
DestinationTableName = $"FitmentTemp.{tableName}",
|
||||||
BulkCopyTimeout = 1
|
BulkCopyTimeout = 14400
|
||||||
};
|
};
|
||||||
|
|
||||||
bulk.WriteToServer(dataTable);
|
bulk.WriteToServer(dataTable);
|
||||||
@@ -149,9 +149,11 @@ namespace PartSource.Automation.Services
|
|||||||
connection.Open();
|
connection.Open();
|
||||||
|
|
||||||
using SqlCommand command = new SqlCommand($"exec CreateFitmentView", connection);
|
using SqlCommand command = new SqlCommand($"exec CreateFitmentView", connection);
|
||||||
|
command.CommandTimeout = 1800;
|
||||||
command.ExecuteNonQuery();
|
command.ExecuteNonQuery();
|
||||||
|
|
||||||
using SqlCommand command2 = new SqlCommand($"exec CreateFitmentIndexes", connection);
|
using SqlCommand command2 = new SqlCommand($"exec CreateFitmentIndexes", connection);
|
||||||
|
command.CommandTimeout = 1800;
|
||||||
command2.ExecuteNonQuery();
|
command2.ExecuteNonQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user