private static IDbConnectionProvider InitDb(DirectoryInfo directory, QueueName queueName) { var dbPath = Path.Combine(directory.FullName, queueName + ".db"); var connectionStringSettings = new ConnectionStringSettings { Name = dbPath, ConnectionString = "Data Source=" + dbPath + "; Version=3", ProviderName = "System.Data.SQLite" }; var connectionProvider = new SingletonConnectionProvider(connectionStringSettings); var connection = connectionProvider.GetConnection(); try { using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = new SQLiteDialect().CreateMessageQueueingServiceObjectsCommand; command.ExecuteNonQuery(); } } finally { connectionProvider.ReleaseConnection(connection); } return connectionProvider; }
private static IDbConnectionProvider InitDb(DirectoryInfo baseDirectory) { if (baseDirectory == null) { var appdomainDirectory = AppDomain.CurrentDomain.BaseDirectory; baseDirectory = new DirectoryInfo(Path.Combine(appdomainDirectory, "platibus", "subscriptions")); } var dbPath = Path.Combine(baseDirectory.FullName, "subscriptions.db"); var connectionStringSettings = new ConnectionStringSettings { Name = dbPath, ConnectionString = "Data Source=" + dbPath + "; Version=3", ProviderName = "System.Data.SQLite" }; var connectionProvider = new SingletonConnectionProvider(connectionStringSettings); var connection = connectionProvider.GetConnection(); try { using (var command = connection.CreateCommand()) { command.CommandType = CommandType.Text; command.CommandText = new SQLiteDialect().CreateSubscriptionTrackingServiceObjectsCommand; command.ExecuteNonQuery(); } } finally { connectionProvider.ReleaseConnection(connection); } return connectionProvider; }