예제 #1
0
        private bool DoAllDestTableFrnKeyMapColsExist(PairedColumnsOutsideTableConfig pairedColumnsOutsideConfig)
        {
            string connectionString = pairedColumnsOutsideConfig.SourceDestMapping.Last().DestinationConnectionString;
            string fullTableName    = pairedColumnsOutsideConfig.SourceDestMapping.Last().DestinationFullTableName;

            var columnsInSourceTable = pairedColumnsOutsideConfig.ColumnMapping.GetSubListElementsOfIndex(1)
                                       .Concat(pairedColumnsOutsideConfig.SourceDestMapping.Last().ForeignKeyMapping
                                               .GetSubListElementsOfIndex(1));

            DataTable destSchemaTable;

            try
            {
                destSchemaTable = GetTableSchema(connectionString, fullTableName);
            }
            catch (SqlException ex)
            {
                Log.Error($"The mapped database {connectionString} or table {fullTableName} doesn't exist or it is unreachable. " +
                          $"Error message: {ex.Message}");
                return(false);
            }

            if (!DoAllColumnsExist(destSchemaTable, new LoggingInfo {
                ConnectionString = connectionString, TableNameWithSchema = fullTableName
            },
                                   columnsInSourceTable))
            {
                Log.Error($"Error while checking the columns of table: {fullTableName}. " +
                          $"Connection string: {connectionString}. ");
                return(false);
            }

            return(true);
        }
예제 #2
0
        private bool DoAllSourceTableFrnKeyMapColsExist(string connectionString, TableConfig tableConfig,
                                                        PairedColumnsOutsideTableConfig pairedColumnsOutsideConfig)
        {
            var columnsInSourceTable = pairedColumnsOutsideConfig.ColumnMapping.GetSubListElementsOfIndex(0)
                                       .Concat(pairedColumnsOutsideConfig.SourceDestMapping.First().ForeignKeyMapping
                                               .GetSubListElementsOfIndex(0));

            var sourceSchemaTable = GetTableSchema(connectionString, tableConfig.FullTableName);

            if (!DoAllColumnsExist(sourceSchemaTable, new LoggingInfo {
                ConnectionString = connectionString, TableNameWithSchema = tableConfig.FullTableName
            },
                                   columnsInSourceTable))
            {
                Log.Error($"Error while checking the columns of table: {tableConfig.FullTableName}. " +
                          $"Connection string: {connectionString}. ");
                return(false);
            }

            return(true);
        }