Migration to DevOps
This commit is contained in:
@@ -21,7 +21,7 @@ namespace PartSource.Automation.Services
|
||||
FtpConfiguration ftpConfiguration = configuration.GetSection("FtpServers:WhiConfiguration").Get<FtpConfiguration>();
|
||||
_ftpService = new FtpService(ftpConfiguration);
|
||||
|
||||
_connectionString = configuration.GetConnectionString("PartSourceDatabase");
|
||||
_connectionString = configuration.GetConnectionString("FitmentDatabase");
|
||||
|
||||
_logger = logger;
|
||||
}
|
||||
@@ -51,29 +51,41 @@ namespace PartSource.Automation.Services
|
||||
}
|
||||
}
|
||||
|
||||
public void Truncate(SeoDataType seoDataType)
|
||||
public void Truncate()
|
||||
{
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
|
||||
using SqlCommand command = new SqlCommand($"exec DropFitmentTables", connection);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
public void BulkCopy(SeoDataType seoDataType, DataTable dataTable, string tableName)
|
||||
{
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
|
||||
#pragma warning disable CA2100 // Review SQL queries for security vulnerabilities
|
||||
using SqlCommand command = new SqlCommand($"TRUNCATE TABLE [{seoDataType}]", connection);
|
||||
using SqlCommand command = new SqlCommand($"EXEC AddFitmentTable @tableName = '{tableName}'", connection);
|
||||
command.ExecuteNonQuery();
|
||||
#pragma warning restore CA2100 // Review SQL queries for security vulnerabilities
|
||||
}
|
||||
|
||||
public void BulkCopy(SeoDataType seoDataType, DataTable dataTable)
|
||||
{
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
#pragma warning restore CA2100 // Review SQL queries for security vulnerabilities
|
||||
|
||||
using SqlBulkCopy bulk = new SqlBulkCopy(connection)
|
||||
{
|
||||
DestinationTableName = seoDataType.ToString(),
|
||||
DestinationTableName = $"{seoDataType}.{tableName}",
|
||||
BulkCopyTimeout = 14400
|
||||
};
|
||||
|
||||
bulk.WriteToServer(dataTable);
|
||||
}
|
||||
|
||||
public void CreateFitmentView()
|
||||
{
|
||||
using SqlConnection connection = new SqlConnection(_connectionString);
|
||||
connection.Open();
|
||||
|
||||
using SqlCommand command = new SqlCommand($"exec CreateFitmentView", connection);
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user