Current state, whatever that means
This commit is contained in:
@@ -35,7 +35,7 @@ namespace PartSource.Automation.Services
|
||||
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (file.EndsWith("csv.gz"))
|
||||
if (file.Contains(".csv"))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -53,7 +53,16 @@ namespace PartSource.Automation.Services
|
||||
}
|
||||
}
|
||||
|
||||
public void Truncate()
|
||||
public void TruncateVehicleTable()
|
||||
{
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
|
||||
using SqlCommand command = new SqlCommand($"truncate table dbo.Vehicle", connection);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public void TruncateFitmentTables()
|
||||
{
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
@@ -62,11 +71,36 @@ namespace PartSource.Automation.Services
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public void BulkCopy(SeoDataType seoDataType, DataTable dataTable, string tableName)
|
||||
public void SaveNotes(IDictionary<string, string> notes)
|
||||
{
|
||||
using DataTable dataTable = new DataTable();
|
||||
dataTable.Columns.Add("NoteText", typeof(string));
|
||||
dataTable.Columns.Add("Hash", typeof(string));
|
||||
|
||||
foreach (KeyValuePair<string, string> note in notes)
|
||||
{
|
||||
|
||||
dataTable.Rows.Add(new string[] { note.Value, note.Key });
|
||||
}
|
||||
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
|
||||
using SqlBulkCopy bulk = new SqlBulkCopy(connection)
|
||||
{
|
||||
DestinationTableName = $"FitmentNote",
|
||||
BulkCopyTimeout = 14400
|
||||
};
|
||||
|
||||
bulk.WriteToServer(dataTable);
|
||||
}
|
||||
|
||||
public void BulkCopyFitment(DataTable dataTable, string tableName)
|
||||
{
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
|
||||
string sql = string.Empty;
|
||||
|
||||
using SqlCommand command = new SqlCommand($"EXEC CreateFitmentTempTable @tableName = '{tableName}'", connection);
|
||||
command.ExecuteNonQuery();
|
||||
@@ -74,6 +108,25 @@ namespace PartSource.Automation.Services
|
||||
using SqlBulkCopy bulk = new SqlBulkCopy(connection)
|
||||
{
|
||||
DestinationTableName = $"FitmentTemp.{tableName}",
|
||||
BulkCopyTimeout = 1
|
||||
};
|
||||
|
||||
bulk.WriteToServer(dataTable);
|
||||
}
|
||||
|
||||
public void BulkCopyVehicle(DataTable dataTable, string tableName)
|
||||
{
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
|
||||
string sql = string.Empty;
|
||||
|
||||
using SqlCommand command = new SqlCommand($"EXEC CreateVehicleTempTable @tableName = '{tableName}'", connection);
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
using SqlBulkCopy bulk = new SqlBulkCopy(connection)
|
||||
{
|
||||
DestinationTableName = $"VehicleTemp.{tableName}",
|
||||
BulkCopyTimeout = 14400
|
||||
};
|
||||
|
||||
@@ -97,6 +150,21 @@ namespace PartSource.Automation.Services
|
||||
|
||||
using SqlCommand command = new SqlCommand($"exec CreateFitmentView", connection);
|
||||
command.ExecuteNonQuery();
|
||||
|
||||
using SqlCommand command2 = new SqlCommand($"exec CreateFitmentIndexes", connection);
|
||||
command2.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public void CreateVehicleTable()
|
||||
{
|
||||
return;
|
||||
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
|
||||
using SqlCommand command = new SqlCommand($"exec CreateVehicleTable", connection);
|
||||
command.CommandTimeout = 1800;
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user