Represents a configuration of database table initialization behaviors.
Пример #1
0
 /// <summary>
 /// Uses an in-memory schema to initialize a database table according to a set of initialization options.
 /// </summary>
 /// <param name="adapter">Open adapter to a database.</param>
 /// <param name="schema">The schema to use to initialize.</param>
 /// <param name="tableInitializationOptions">A set of options to determine initialization behavior.</param>
 public static void InitializeTable(IDbAdapter adapter, DataTable schema, DbTableInitializationOptions tableInitializationOptions)
 {
     if (tableInitializationOptions.CreateTableDynamically)
     {
         CreateTable(adapter, schema, tableInitializationOptions.IndexesToGenerate);
     }
     if (tableInitializationOptions.UpdateDbTableToMatchSchema)
     {
         UpdateTableToMatchSchema(adapter, schema);
     }
     if (tableInitializationOptions.UpdateSchemaToMatchDbTable)
     {
         UpdateSchemaToMatchTable(adapter, schema);
     }
     if (tableInitializationOptions.UpdateIndexes)
     {
         AddDbIndexesToMatch(adapter, schema, tableInitializationOptions.IndexesToGenerate);
         RemoveDBIndexesToMatch(adapter, schema, tableInitializationOptions.IndexesToGenerate);
         UpdateIndexClusters(adapter, schema, tableInitializationOptions.IndexesToGenerate);
     }
 }
Пример #2
0
 /// <summary>
 /// Uses an in-memory schema to initialize a database table according to a set of initialization options.
 /// </summary>
 /// <param name="adapter">Open adapter to a database.</param>
 /// <param name="schema">The schema to use to initialize.</param>
 /// <param name="tableInitializationOptions">A set of options to determine initialization behavior.</param>
 public static void InitializeTable(IDbAdapter adapter, DataTable schema, DbTableInitializationOptions tableInitializationOptions)
 {
     if (tableInitializationOptions.CreateTableDynamically)
     {
         CreateTable(adapter, schema, tableInitializationOptions.IndexesToGenerate);
     }
     if (tableInitializationOptions.UpdateDbTableToMatchSchema)
     {
         UpdateTableToMatchSchema(adapter, schema);
     }
     if (tableInitializationOptions.UpdateSchemaToMatchDbTable)
     {
         UpdateSchemaToMatchTable(adapter, schema);
     }
     if (tableInitializationOptions.UpdateIndexes)
     {
         AddDbIndexesToMatch(adapter, schema, tableInitializationOptions.IndexesToGenerate);
         RemoveDBIndexesToMatch(adapter, schema, tableInitializationOptions.IndexesToGenerate);
         UpdateIndexClusters(adapter, schema, tableInitializationOptions.IndexesToGenerate);
     }
 }
Пример #3
0
        /// <summary>
        /// Initializes a new Database Writer object using a TabMonConfig.
        /// </summary>
        /// <param name="config">User's TabMon.config file containing the required Db Writer parameters.</param>
        /// <returns>Initialized DataTableDbWriter object.</returns>
        private static DataTableDbWriter LoadDbWriterFromConfig(TabMonConfig config)
        {
            DbDriverType dbDriverType;

            Log.Debug("Loading database configuration..");
            var databaseConfig = config.Database;

            var validDriverType = Enum.TryParse(databaseConfig.Type, true, out dbDriverType);
            if (!validDriverType)
            {
                throw new ConfigurationErrorsException("Invalid database driver type specified!");
            }

            IDbConnectionInfo dbConnInfo = new DbConnectionInfo()
            {
                Server = databaseConfig.Server.Host,
                Port = databaseConfig.Server.Port,
                Username = databaseConfig.User.Login,
                Password = databaseConfig.User.Password,
                DatabaseName = databaseConfig.Name
            };

            var indexes = new Dictionary<string, bool>();
            foreach (Index index in config.Database.Indexes)
            {
                indexes.Add(index.Column, index.Clustered);
            }

            if (!dbConnInfo.Valid())
            {
                throw new ConfigurationErrorsException("Missing required database connection information!");
            }

            var tableInitializationOptions = new DbTableInitializationOptions()
            {
                CreateTableDynamically = true,
                UpdateDbTableToMatchSchema = true,
                UpdateSchemaToMatchDbTable = true,
                UpdateIndexes = databaseConfig.Indexes.Generate,
                IndexesToGenerate = indexes
            };

            Log.Info("Connecting to results database..");
            try
            {
                return new DataTableDbWriter(dbDriverType, dbConnInfo, tableInitializationOptions);
            }
            catch (Exception ex)
            {
                Log.Fatal("Could not initialize writer: " + ex.Message);
                return null;
            }
        }
Пример #4
0
 /// <summary>
 /// Uses an in-memory schema to initialize a database table according to a set of initialization options.
 /// </summary>
 /// <param name="adapter">Open adapter to a database.</param>
 /// <param name="schema">The schema to use to initialize.</param>
 /// <param name="tableInitializationOptions">A set of options to determine initialization behavior.</param>
 public static void InitializeTable(IDbAdapter adapter, DataTable schema, DbTableInitializationOptions tableInitializationOptions)
 {
     if (tableInitializationOptions.CreateTableDynamically)
     {
         CreateTable(adapter, schema);
     }
     if (tableInitializationOptions.UpdateDbTableToMatchSchema)
     {
         UpdateTableToMatchSchema(adapter, schema);
     }
     if (tableInitializationOptions.UpdateSchemaToMatchDbTable)
     {
         UpdateSchemaToMatchTable(adapter, schema);
     }
 }