//todo: localize log message public void ExecuteCommand(EtlConsoleArguments options) { System.Console.WriteLine("Verifying input parameters..."); var errorMsg = VerifyArguments(options); if (!String.IsNullOrEmpty(errorMsg)) { throw new Exception(String.Format("Input parameters incorrect: {0}", errorMsg)); } var providerFactory = DbProviderFactories.GetFactory(options.CommandOptions[PARAM_NAME_PROVIDER_NAME]); var packageText = String.Empty; System.Console.WriteLine("Receiving package text"); using (var connection = providerFactory.CreateConnection()) { connection.ConnectionString = options.CommandOptions[PARAM_NAME_CONNECTION_STRING]; var command = connection.CreateCommand(); command.CommandText = options.CommandOptions[PARAM_NAME_PACKAGE_QUERY]; command.CommandTimeout = 60; // 1 minute command.CommandType = System.Data.CommandType.Text; connection.Open(); using (var reader = command.ExecuteReader()) { if (reader.Read()) { if (reader.FieldCount == 1) { packageText = reader[0].ToString(); } else { throw new Exception("Package text query result contains more than one element"); } } else { throw new Exception("Package text query result contains no rows"); } if (reader.Read()) { throw new Exception("Package text query result contains multiple rows"); } } } if (String.IsNullOrEmpty(packageText)) { throw new Exception("Package text cannot be null or empty"); } System.Console.WriteLine("Deserializing package"); var etlPackageSerializer = new EtlPackageXmlSerializer(); var package = etlPackageSerializer.Deserialize(packageText); var etlLoggerInfo = new EtlLoggerInfo() { ConnectionString = options.CommandOptions[PARAM_NAME_CONNECTION_STRING], LoggerType = options.CommandOptions[PARAM_NAME_LOGGER_TYPE], SchemaName = options.CommandOptions.ContainsKey(PARAM_NAME_SCHEMA) ? options.CommandOptions[PARAM_NAME_SCHEMA] : String.Empty, }; var packageLogger = EtlLoggers.GetLogger(etlLoggerInfo); System.Console.WriteLine("Executing package in a sub-session"); var result = package.Invoke(packageLogger); System.Console.WriteLine("Package has been executed"); }
//todo: localize log message public void ExecuteCommand(EtlConsoleArguments options) { System.Console.WriteLine("Verifying input parameters..."); var errorMsg = VerifyArguments(options); if (!String.IsNullOrEmpty(errorMsg)) { throw new Exception(String.Format("Input parameters incorrect: {0}", errorMsg)); } var providerFactory = DbProviderFactories.GetFactory(options.CommandOptions[PARAM_NAME_PROVIDER_NAME]); var packageText = String.Empty; System.Console.WriteLine("Receiving package text"); using (var connection = providerFactory.CreateConnection()) { connection.ConnectionString = options.CommandOptions[PARAM_NAME_CONNECTION_STRING]; var command = connection.CreateCommand(); command.CommandText = options.CommandOptions[PARAM_NAME_PACKAGE_QUERY]; command.CommandTimeout = 60; // 1 minute command.CommandType = System.Data.CommandType.Text; connection.Open(); using (var reader = command.ExecuteReader()) { if (reader.Read()) { if (reader.FieldCount == 1) { packageText = reader[0].ToString(); } else { throw new Exception("Package text query result contains more than one element"); } } else { throw new Exception("Package text query result contains no rows"); } if (reader.Read()) { throw new Exception("Package text query result contains multiple rows"); } } } if (String.IsNullOrEmpty(packageText)) { throw new Exception("Package text cannot be null or empty"); } System.Console.WriteLine("Deserializing package"); var etlPackageSerializer = new EtlPackageXmlSerializer(); var package = etlPackageSerializer.Deserialize(packageText); var etlLoggerInfo = new EtlLoggerInfo() { ConnectionString = options.CommandOptions[PARAM_NAME_CONNECTION_STRING], LoggerType = options.CommandOptions[PARAM_NAME_LOGGER_TYPE], SchemaName = options.CommandOptions.ContainsKey(PARAM_NAME_SCHEMA) ? options.CommandOptions[PARAM_NAME_SCHEMA] : String.Empty, }; var packageLogger = EtlLoggers.GetLogger(etlLoggerInfo); System.Console.WriteLine("Executing package in a sub-session"); var result = package.Invoke(packageLogger); System.Console.WriteLine("Package has been executed"); }