internal ProjectionBuilder( ICatalogReader catalogReader, IMappingReader mappingReader, IDiagnosticsCallback diagnosticsCallbackProxy) { _catalogReader = catalogReader; _mappingReader = mappingReader; _diagnosticsCallbackScope = new DiagnosticsCallbackScope(diagnosticsCallbackProxy); }
public static async Task <Projection> BuildAsync(IDiagnosticsCallback diagnosticsCallback, string mappingFile, string connectionString) { SqlConnection connection = null; try { connection = new SqlConnection(connectionString); } catch (InvalidOperationException) { throw new ConnectionStringFormatException(connectionString); } var diagnosticsCallbackScope = new DiagnosticsCallbackScope( diagnosticsCallback, $"{Path.GetFileName(mappingFile)} <-> [{connection.DataSource}].[{connection.Database}] >"); var catalogReader = new CatalogReader(connectionString, diagnosticsCallback); var mappingReader = new MappingReader(mappingFile, diagnosticsCallback); var modelReader = new ProjectionBuilder(catalogReader, mappingReader, diagnosticsCallbackScope); return(await modelReader.BuildAsync()); }
public CatalogReader(string connectionString, IDiagnosticsCallback diagnosticsCallback) { string pattern = Regex.Replace(@"(?:xis);? Max Pool Size\s*=\s*\d+ |;?$", @"\s+", @"\s+"); connectionString = Regex.Replace(connectionString, pattern, ";Max Pool Size=10"); m_connectionString = connectionString; try { var connection = new SqlConnection(connectionString); DataSource = connection.DataSource; Database = connection.Database; m_diagnosticsCallback = new DiagnosticsCallbackScope(diagnosticsCallback, $"[{DataSource}].[{Database}] > "); //TODO: verify sever version using (connection) { connection.Open(); } } catch (SqlException ex) { var message = new StringBuilder($"Could not reach the {Database} database on server {DataSource}."); if (ex.Number == 18487 || ex.Number == 18488) { message.Append(" The specified password has expired or must be reset."); } else { message.Append(" Make sure that the connection string specified in Transaction Script Code Generating tool is valid"); message.Append($" and also that the {DataSource} SQL Server instance is up and running."); } m_diagnosticsCallback.Error(message.ToString()); throw new DatabaseNotAccessibleException(); } catch (ArgumentException) { var message = new StringBuilder("Invalid connection string.") .Append($" Connection string: \"{m_connectionString}\""); m_diagnosticsCallback.Error(message.ToString()); throw new ConnectionStringFormatException(connectionString); } }
public MappingReader(string filePath, IDiagnosticsCallback diagnosticsCallback) { m_filePath = filePath; m_diagnosticsCallback = new DiagnosticsCallbackScope(diagnosticsCallback, $"{Path.GetFileName(filePath)} >"); }
public CatalogSerializer(DiagnosticsCallbackScope host) : base(Resources.Catalog, host) { }