Пример #1
0
        /// <summary>
        /// Determines whether a new tracking table should be built and catalogued
        /// </summary>
        /// <param name="schema">The name of the audited schema</param>
        /// <param name="tableName">The name of the audited table to check</param>
        /// <param name="targetTableColumns">A list of the columns in the audited table</param>
        /// <param name="updateParameters">Generator parameters</param>
        /// <returns>True of the audited table has different columns (name or type) than the tracking table</returns>
        /// <remarks>
        /// This routine only checks the column names and data types for a match. A change to indexes, relationships, and keys will not affect
        /// the comparison.
        /// </remarks>
        private static bool NewVersionOfTrackingTableNeeded(string schema, string tableName, ICollection <SchemaDataSet.ColumnsRow> targetTableColumns, AuditUpdateParameters updateParameters)
        {
            // check whether we even have a tracking table
            TrackingTable trackingTable = GenerateTableTracking.GetCurrentTrackingTable(schema, tableName, updateParameters);

            if (null == trackingTable)
            {
                return(true);
            }

            // get the columns from the tracking table
            List <SchemaDataSet.ColumnsRow> trackingTableColumns = GetTrackingColumnsForTable(trackingTable, updateParameters);

            // check whether the number of columns match
            if (targetTableColumns.Count != trackingTableColumns.Count)
            {
                return(true);
            }

            // compare each column
            return(AllColumnsMatch(targetTableColumns, trackingTableColumns));
        }
Пример #2
0
        internal static TrackingTable GenerateAuditForTable(string schema, string tableName, SchemaDataSet.SchemaPrimaryKeysDataTable primaryKeysDataTable, StringBuilder sqlBuilder, AuditUpdateParameters updateParameters, Action <string, float?> reportProgress)
        {
            TrackingTable trackingTable;

            reportProgress(String.Format("Generating audit for table {0}", tableName), null);

            List <SchemaDataSet.ColumnsRow> targetTableColumns = GetAuditedColumnsForTable(schema, tableName, updateParameters);
            bool createNewTableVersion = NewVersionOfTrackingTableNeeded(schema, tableName, targetTableColumns, updateParameters);

            if (createNewTableVersion)
            {
                trackingTable = GenerateTableTracking.GenerateNewTrackingTable(schema, tableName, targetTableColumns, updateParameters, sqlBuilder, reportProgress);
            }
            else
            {
                trackingTable = GenerateTableTracking.GetCurrentTrackingTable(schema, tableName, updateParameters);
            }
            GenerateTableTracking.GenerateAuditSupportForTable(schema, tableName, trackingTable, sqlBuilder, targetTableColumns, updateParameters, reportProgress);
            GenerateTableTracking.GenerateInstantSupportForTable(schema, tableName, sqlBuilder, updateParameters);
            GenerateDelta.CreateDeltaProcedures(schema, tableName, trackingTable, targetTableColumns, sqlBuilder, updateParameters, reportProgress);
            reportProgress(String.Format("Generated audit for table {0}", tableName), null);
            return(trackingTable);
        }