private List <string> AvailableCustomFields(Database.DBCon db) { var result = new List <string>(); var dr = db.ExecuteReader("select fname from CustomLocal"); while (dr.Read()) { result.Add(dr.GetString(0)); } return(result); }
protected List <string> AvailableCustomFields(Database.DBCon db) { var result = new List <string>(); var dr = db.ExecuteReader("select fname from CustomLocal"); while (dr.Read()) { result.Add(dr.GetString(0)); } result.AddRange((from a in ApplicationData.Instance.GSAKCustomGlobals select a.fname).ToArray()); return(result); }
public SqliteSettingsStorage() { _availableKeys = new Hashtable(); try { var sf = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GSAKWrapper"); RootSettingsFolder = sf; if (!Directory.Exists(sf)) { Directory.CreateDirectory(sf); } sf = Path.Combine(sf, "settings.db3"); if (ApplicationRunning) { _dbcon = new Database.DBConSqlite(sf); if (!_dbcon.TableExists("settings")) { _dbcon.ExecuteNonQuery("create table 'settings' (item_name text, item_value text)"); _dbcon.ExecuteNonQuery("create index idx_key on settings (item_name)"); } else { DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from settings"); while (dr.Read()) { _availableKeys[dr[0] as string] = dr[1] as string; } } object o = _dbcon.ExecuteScalar("PRAGMA integrity_check"); if (o as string == "ok") { //what is expected } else { //oeps? _dbcon.Dispose(); _dbcon = null; } } } catch//(Exception e) { _dbcon = null; } }
public SqliteSettingsStorage() { _availableKeys = new Hashtable(); try { var sf = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "GSAKWrapper"); RootSettingsFolder = sf; if (!Directory.Exists(sf)) { Directory.CreateDirectory(sf); } sf = Path.Combine(sf, "settings.db3"); if (ApplicationRunning) { _dbcon = new Database.DBConSqlite(sf); if (!_dbcon.TableExists("settings")) { _dbcon.ExecuteNonQuery("create table 'settings' (item_name text, item_value text)"); _dbcon.ExecuteNonQuery("create index idx_key on settings (item_name)"); } else { DbDataReader dr = _dbcon.ExecuteReader("select item_name, item_value from settings"); while (dr.Read()) { _availableKeys[dr[0] as string] = dr[1] as string; } } if (!_dbcon.TableExists("formulasolv")) { _dbcon.ExecuteNonQuery("create table 'formulasolv' (gccode text, formula text)"); _dbcon.ExecuteNonQuery("create index idx_form on formulasolv (gccode)"); } if (!_dbcon.TableExists("GeocacheCollection")) { _dbcon.ExecuteNonQuery("create table 'GeocacheCollection' (CollectionID integer not null, Name text not null)"); _dbcon.ExecuteNonQuery("create index idx_gckey on GeocacheCollection (CollectionID)"); _dbcon.ExecuteNonQuery("create index idx_gcname on GeocacheCollection (Name)"); } if (!_dbcon.TableExists("GeocacheCollectionItem")) { _dbcon.ExecuteNonQuery("create table 'GeocacheCollectionItem' (CollectionID integer not null, GeocacheCode text not null, Name text not null)"); _dbcon.ExecuteNonQuery("create unique index idx_gcikey on GeocacheCollectionItem (CollectionID, GeocacheCode)"); _dbcon.ExecuteNonQuery("CREATE TRIGGER Delete_GeocacheCollection Delete ON GeocacheCollection BEGIN delete from GeocacheCollectionItem where CollectionID = old.CollectionID; END"); } if (!_dbcon.TableExists("ShapeFileItemV2")) { _dbcon.ExecuteNonQuery("create table 'ShapeFileItemV2' (FileName text, TableName text not null, CoordType text not null, AreaType text not null, NamePrefix text, Encoding text not null, Enabled integer not null)"); } if (!_dbcon.TableExists("Scripts")) { _dbcon.ExecuteNonQuery("create table 'Scripts' (Name text not null, ScriptType integer not null, Code text not null)"); _dbcon.ExecuteNonQuery("create unique index idx_scname on Scripts (Name)"); } object o = _dbcon.ExecuteScalar("PRAGMA integrity_check"); if (o as string == "ok") { //what is expected } else { //oeps? _dbcon.Dispose(); _dbcon = null; } } } catch//(Exception e) { _dbcon = null; } }