public void Run() { accessorFrom = new SqliteAccessor { DataSource = DataSourceFrom, Password = PasswordFrom }; accessorFrom.Open(); accessorTo = new SqliteAccessor { DataSource = DataSourceTo, Password = PasswordTo }; accessorTo.Open(); FetchTables(); tables.ForEach(t => { CreateTable(t.Sql); if (t.HasBlob) { TransferBlob(t); } else { TransferNoBlob(t); } }); accessorFrom.Close(); accessorTo.Close(); }
public static void Register( bool insert, string key, string value, List <object> tags ) { using var accessor = new SqliteAccessor { DataSource = AppBehind.Get.DBFilePath, Password = AppBehind.Get.Password, QueryString = insert ? INSERT : UPDATE }; accessor.Open(); var transaction = accessor.Begin(); try { var command = accessor.CreateCommand(); command.Parameters.AddWithValue(@"@key", key); command.Parameters.AddWithValue(@"@value", value); accessor.Execute(command); StringTags.Register(accessor, key, tags); transaction.Commit(); } catch (Exception) { transaction.Rollback(); throw; } }
protected void CreateTable() { using var accessor = new SqliteAccessor { DataSource = AppBehind.Get.DBFilePath, Password = AppBehind.Get.Password, QueryString = GetQueryCreateTable() }; accessor.Open(); accessor.Execute(accessor.CreateCommand()); }
protected bool TableExists() { using var accessor = new SqliteAccessor { DataSource = AppBehind.Get.DBFilePath, Password = AppBehind.Get.Password, QueryString = GetQueryTableExists() }; accessor.Open(); return(0 < (long)accessor.ExecuteScalar(accessor.CreateCommand())); }
public static void Retrieve(string key, FileStream outputStream) { using var accessor = new SqliteAccessor { DataSource = AppBehind.Get.DBFilePath, Password = AppBehind.Get.Password, QueryString = SELECT_BLOB_WITH_KEY }; accessor.Open(); var command = accessor.CreateCommand(); command.Parameters.AddWithValue(@"@key", key); accessor.RetrieveBlob(command, outputStream, 0); }
protected List <List <object> > Query(string query, Dictionary <string, string> parameters) { using var accessor = new SqliteAccessor { DataSource = AppBehind.Get.DBFilePath, Password = AppBehind.Get.Password, QueryString = query }; accessor.Open(); var command = accessor.CreateCommand(); parameters.ToList().ForEach(p => { command.Parameters.AddWithValue(p.Key, p.Value); }); accessor.Execute(command); return(CloneQueryResult(accessor.QueryResult)); }
public static void Register(bool insert, string newTag, string oldTag) { using var accessor = new SqliteAccessor { DataSource = AppBehind.Get.DBFilePath, Password = AppBehind.Get.Password, QueryString = insert ? INSERT : UPDATE }; accessor.Open(); var command = accessor.CreateCommand(); command.Parameters.AddWithValue(@"@tag", newTag); if (!insert) { command.Parameters.AddWithValue(@"@oldTag", oldTag); } accessor.Execute(command); }
private void PerformQueryWholeTable(string tableName) { if (string.IsNullOrEmpty(tableName)) { return; } var tableInfo = new Schema().QueryTableInfo(tableName); if (0 == tableInfo.Count) { return; } var query = @" SELECT " + '\n'; query += tableInfo .Select((row, index) => new { index, columnName = row[1] }) .Aggregate(@"", (ret, item) => 0 == item.index ? ret + @" " + item.columnName + @" " + '\n' : ret + @" , " + item.columnName + @" " + '\n'); query += @" FROM " + '\n'; query += @" " + tableName + @" " + '\n'; var accessor = new SqliteAccessor { DataSource = AppBehind.Get.DBFilePath, Password = AppBehind.Get.Password, QueryString = query }; accessor.Open(); accessor.Execute(accessor.CreateCommand()); accessor.Close(); AppBehind.Get.SetQueryString(query); AppBehind.Get.AddPage(accessor); }
public static void Register( bool insert, string key, string filePath, string fileName, List <object> tags ) { using var accessor = new SqliteAccessor { DataSource = AppBehind.Get.DBFilePath, Password = AppBehind.Get.Password, QueryString = insert ? INSERT : UPDATE }; accessor.Open(); var transaction = accessor.Begin(); try { var command = accessor.CreateCommand(); command.Parameters.AddWithValue(@"@key", key); command.Parameters.AddWithValue(@"@fileName", fileName); command.Parameters.AddWithValue(@"@length", new FileInfo(filePath).Length); using var inputStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); accessor.WriteBlob( inputStream, @"BINARY_STORAGE", @"VALUE", (long)accessor.ExecuteScalar(command) ); BinaryTags.Register(accessor, key, tags); transaction.Commit(); } catch (Exception) { transaction.Rollback(); throw; } }
public void Open() { accessor.Open(); transaction = null; commands = new List <SqliteCommand>(); }