internal static void GenerateAuditSupportForTable(string schema, string tableName, TrackingTable trackingTable, StringBuilder sqlBuilder, List<SchemaDataSet.ColumnsRow> targetTableColumns, AuditUpdateParameters updateParameters, Action<string, float?> reportProgress)
        {
            string trackingTableName = trackingTable.ToString();
            string deltaTableName = trackingTableName + "Δ";

            CreateDeltaTable createDeltaTableTemplate = new CreateDeltaTable(trackingTableName + "Δ", targetTableColumns, updateParameters);
            string sql = createDeltaTableTemplate.TransformText();
            sqlBuilder.AppendLine(sql);

            GenerateAuditTableInsertProcedures(schema, tableName, trackingTableName, deltaTableName, targetTableColumns, sqlBuilder, updateParameters, reportProgress);
            if (updateParameters.GenerateBaseline)
            {
                Baseline(schema, tableName, trackingTable, targetTableColumns, sqlBuilder, updateParameters, reportProgress);
            }
            GenerateAuditTableTriggers(schema, tableName, sqlBuilder, updateParameters, reportProgress);
        }
        internal static void GenerateAuditSupportForTable(string schema, string tableName, TrackingTable trackingTable, StringBuilder sqlBuilder, List <SchemaDataSet.ColumnsRow> targetTableColumns, AuditUpdateParameters updateParameters, Action <string, float?> reportProgress)
        {
            string trackingTableName = trackingTable.ToString();
            string deltaTableName    = trackingTableName + "Δ";

            CreateDeltaTable createDeltaTableTemplate = new CreateDeltaTable(trackingTableName + "Δ", targetTableColumns, updateParameters);
            string           sql = createDeltaTableTemplate.TransformText();

            sqlBuilder.AppendLine(sql);

            GenerateAuditTableInsertProcedures(schema, tableName, trackingTableName, deltaTableName, targetTableColumns, sqlBuilder, updateParameters, reportProgress);
            if (updateParameters.GenerateBaseline)
            {
                Baseline(schema, tableName, trackingTable, targetTableColumns, sqlBuilder, updateParameters, reportProgress);
            }
            GenerateAuditTableTriggers(schema, tableName, sqlBuilder, updateParameters, reportProgress);
        }
        internal static TrackingTable GenerateNewTrackingTable(string schema, string tableName, List <SchemaDataSet.ColumnsRow> targetTableColumns, AuditUpdateParameters updateParameters, StringBuilder sqlBuilder, Action <string, float?> reportProgress)
        {
            int           version;
            SchemaDataSet schemaDataSet = updateParameters.SchemaDataSet;

            if (schemaDataSet.SchemaTables.TableExists(updateParameters.AuditingSchema, "Catalog"))
            {
                EntityConnectionStringBuilder connectionStringBuilder = Generator.GetEntityConnectionStringBuilder(updateParameters);
                AuditFrameworkEntities        context = new AuditFrameworkEntities(connectionStringBuilder.ToString());
                var catalogQuery = from catalog in context.Catalogs
                                   where catalog.AuditedSchema.Equals(schema, StringComparison.OrdinalIgnoreCase) &&
                                   catalog.AuditedTableName.Equals(tableName, StringComparison.OrdinalIgnoreCase)
                                   orderby catalog.Version descending
                                   select catalog;
                var latestCatalog = catalogQuery.FirstOrDefault();
                if (null == latestCatalog)
                {
                    version = 0;
                }
                else
                {
                    version = latestCatalog.Version + 1;
                }
            }
            else
            {
                version = 0;
            }
            TrackingTable trackingTable     = new TrackingTable(schema, tableName, version);
            string        trackingTableName = trackingTable.ToString();

            InsertCatalog insertCatalogTemplate = new InsertCatalog(schema, tableName, version, updateParameters.AuditingSchema, trackingTableName);
            string        sql = insertCatalogTemplate.TransformText();

            sqlBuilder.AppendLine(sql);

            CreateTrackingTable createTrackingTableTemplate = new CreateTrackingTable(schema, tableName, trackingTableName, targetTableColumns, updateParameters);

            sql = createTrackingTableTemplate.TransformText();
            sqlBuilder.AppendLine(sql);

            return(trackingTable);
        }
        internal static TrackingTable GenerateNewTrackingTable(string schema, string tableName, List<SchemaDataSet.ColumnsRow> targetTableColumns, AuditUpdateParameters updateParameters, StringBuilder sqlBuilder, Action<string, float?> reportProgress)
        {
            int version;
            SchemaDataSet schemaDataSet = updateParameters.SchemaDataSet;
            if (schemaDataSet.SchemaTables.TableExists(updateParameters.AuditingSchema, "Catalog"))
            {
                EntityConnectionStringBuilder connectionStringBuilder = Generator.GetEntityConnectionStringBuilder(updateParameters);
                AuditFrameworkEntities context = new AuditFrameworkEntities(connectionStringBuilder.ToString());
                var catalogQuery = from catalog in context.Catalogs
                                   where catalog.AuditedSchema.Equals(schema, StringComparison.OrdinalIgnoreCase)
                                         && catalog.AuditedTableName.Equals(tableName, StringComparison.OrdinalIgnoreCase)
                                   orderby catalog.Version descending
                                   select catalog;
                var latestCatalog = catalogQuery.FirstOrDefault();
                if (null == latestCatalog)
                {
                    version = 0;
                }
                else
                {
                    version = latestCatalog.Version + 1;
                }
            }
            else
            {
                version = 0;
            }
            TrackingTable trackingTable = new TrackingTable(schema, tableName, version);
            string trackingTableName = trackingTable.ToString();

            InsertCatalog insertCatalogTemplate = new InsertCatalog(schema, tableName, version, updateParameters.AuditingSchema, trackingTableName);
            string sql = insertCatalogTemplate.TransformText();
            sqlBuilder.AppendLine(sql);

            CreateTrackingTable createTrackingTableTemplate = new CreateTrackingTable(schema, tableName, trackingTableName, targetTableColumns, updateParameters);
            sql = createTrackingTableTemplate.TransformText();
            sqlBuilder.AppendLine(sql);

            return trackingTable;
        }
Exemple #5
0
        private static List <SchemaDataSet.ColumnsRow> GetTrackingColumnsForTable(TrackingTable trackingTable, AuditUpdateParameters updateParameters)
        {
            IEnumerable <SchemaDataSet.ColumnsRow> columnsRows = GetColumnsForTable(updateParameters.AuditingSchema, trackingTable.ToString(), updateParameters);
            IEnumerable <SchemaDataSet.ColumnsRow> query       = from columnRow in columnsRows
                                                                 where !columnRow.COLUMN_NAME.Equals("TrackºId", StringComparison.Ordinal)
                                                                 select columnRow;

            return(query.ToList());
        }
 private static List<SchemaDataSet.ColumnsRow> GetTrackingColumnsForTable(TrackingTable trackingTable, AuditUpdateParameters updateParameters)
 {
     IEnumerable<SchemaDataSet.ColumnsRow> columnsRows = GetColumnsForTable(updateParameters.AuditingSchema, trackingTable.ToString(), updateParameters);
     IEnumerable<SchemaDataSet.ColumnsRow> query = from columnRow in columnsRows
                                                   where !columnRow.COLUMN_NAME.Equals("TrackºId", StringComparison.Ordinal)
                                                   select columnRow;
     return query.ToList();
 }