public static void InitCache(IDbConnectionSupplier connectionSupplier, string databaseFilename) { if (File.Exists(databaseFilename)) { return; } SQLiteConnection.CreateFile(databaseFilename); using (var connection = connectionSupplier.GetConnection($"Data Source={databaseFilename};Version=3;")) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "CREATE TABLE TransactionCache (Hash TEXT NOT NULL PRIMARY KEY, TransactionTrytes TEXT NOT NULL)"; command.ExecuteNonQuery(); } using (var command = connection.CreateCommand()) { command.CommandText = "CREATE TABLE AddressCache (TransactionHash TEXT NOT NULL PRIMARY KEY, Address TEXT NOT NULL)"; command.ExecuteNonQuery(); } using (var command = connection.CreateCommand()) { command.CommandText = "CREATE TABLE BundleCache (TransactionHash TEXT NOT NULL PRIMARY KEY, Bundle TEXT NOT NULL)"; command.ExecuteNonQuery(); } } }
public SqlLiteSearchRepository( FhirJsonParser jsonParser, IDbConnectionSupplier connectionSupplier = null, string databaseFilename = "resources.sqlite") { this.JsonParser = jsonParser; this.ConnectionSupplier = connectionSupplier ?? new DefaultDbConnectionSupplier(); this.ConnectionString = $"Data Source={databaseFilename};Version=3;"; this.Init(databaseFilename); }
/// <inheritdoc /> public CachedIotaRestRepository( IIotaClient client, IPoWService powService, IAddressGenerator addressGenerator = null, IDbConnectionSupplier connectionSupplier = null, string databaseFilename = "iotacache.sqlite") : base(client, powService, addressGenerator) { this.ConnectionSupplier = connectionSupplier ?? new DefaultDbConnectionSupplier(); this.ConnectionString = $"Data Source={databaseFilename};Version=3;"; DatabaseInitializer.InitCache(this.ConnectionSupplier, databaseFilename); }
/// <inheritdoc /> public CachedIotaRestRepository( IRestClient client, IPoWService powService = null, string username = null, string password = null, IDbConnectionSupplier connectionSupplier = null, string databaseFilename = "iotacache.sqlite") : base(client, powService, username, password) { this.ConnectionSupplier = connectionSupplier ?? new DefaultDbConnectionSupplier(); this.ConnectionString = $"Data Source={databaseFilename};Version=3;"; DatabaseInitializer.InitCache(this.ConnectionSupplier, databaseFilename); }
public SqlLiteResourceTracker( MamChannelFactory channelFactory, MamChannelSubscriptionFactory subscriptionFactory, IEncryption encryption, IDbConnectionSupplier connectionSupplier = null, string databaseFilename = "iotafhir.sqlite") { this.ChannelFactory = channelFactory; this.SubscriptionFactory = subscriptionFactory; this.Encryption = encryption; this.ConnectionSupplier = connectionSupplier ?? new DefaultDbConnectionSupplier(); this.ConnectionString = $"Data Source={databaseFilename};Version=3;"; DatabaseInitializer.InitFhirDatabase(this.ConnectionSupplier, databaseFilename); }
/// <inheritdoc /> public SqlLiteDeterministicSeedManager( IResourceTracker resourceTracker, ISigningHelper signingHelper, IAddressGenerator addressGenerator, IIotaRepository repository, IEncryption encryption, IDbConnectionSupplier connectionSupplier = null, string databaseFilename = "iotafhir.sqlite") : base(resourceTracker, signingHelper, addressGenerator, repository) { this.Encryption = encryption; this.ConnectionSupplier = connectionSupplier ?? new DefaultDbConnectionSupplier(); this.ConnectionString = $"Data Source={databaseFilename};Version=3;"; DatabaseInitializer.InitFhirDatabase(this.ConnectionSupplier, databaseFilename); }
public static void InitFhirDatabase(IDbConnectionSupplier connectionSupplier, string databaseFilename) { if (File.Exists(databaseFilename)) { return; } SQLiteConnection.CreateFile(databaseFilename); using (var connection = connectionSupplier.GetConnection($"Data Source={databaseFilename};Version=3;")) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = "CREATE TABLE Resource (Id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, Channel TEXT NULL, Subscription TEXT NOT NULL)"; command.ExecuteNonQuery(); } using (var command = connection.CreateCommand()) { command.CommandText = "CREATE TABLE StreamHash (Hash VARCHAR(81) NOT NULL PRIMARY KEY, ResourceId INTEGER NOT NULL, FOREIGN KEY (ResourceId) REFERENCES Resource(Id))"; command.ExecuteNonQuery(); } using (var command = connection.CreateCommand()) { command.CommandText = "CREATE TABLE CredentialIndex (CurrentIndex INTEGER NOT NULL, Seed TEXT NOT NULL)"; command.ExecuteNonQuery(); } using (var command = connection.CreateCommand()) { command.CommandText = "CREATE TABLE ResourceResolver (Reference TEXT NOT NULL PRIMARY KEY, Seed TEXT NOT NULL)"; command.ExecuteNonQuery(); } } }