public static void DBProcedure(string processName, byte[] beginTimeStamp, byte[] endTimeStamp, string destination, params string[] tradingArea)
{
Logger.LogMessage(Constants.Information, "Begin DB Processing : " + Thread.CurrentThread.Name + " : " + DateTime.Now.ToLocalTime());
SqlConnection connection = new SqlConnection(connectionString);
try
{
SqlCommand command = new SqlCommand(GetProcName(destination), connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Clear();
command.Parameters.Add("@ProcessName", SqlDbType.VarChar, 200).Value = processName;
command.Parameters.Add("@BeginTimeStamp", SqlDbType.Binary).Value = beginTimeStamp;
command.Parameters.Add("@EndTimeStamp", SqlDbType.Binary).Value = endTimeStamp;
if (destination.ToUpper() != Constants.MAIN && destination.ToUpper() != Constants.SEPARATE_DB)
command.Parameters.Add("@DestinationTables", SqlDbType.VarChar).Value = destination;
if ((tradingArea.Length > 0) && (destination != Constants.MAIN))
command.Parameters.Add("@TradingArea", SqlDbType.VarChar).Value = tradingArea[0];
command.CommandTimeout = timeout;
command.Connection.Open();
command.ExecuteNonQuery();
}
catch (Exception ex)
{
Console.WriteLine("Error : " + ex.Message);
Logger.LogMessage(Constants.Error, ex.Message);
}
finally
{
connection.Close();
}
}
|