private void InitializeCommons(string currentUser) { CurrentUser = currentUser; Metadata = new MetadataCollection(this); if (!File.Exists(DbPath)) { Metadata.CreateInitialRecord(); DbPath.GrantEveryoneFullControl(); } }
// Insertview public void InsertView <T>(DataTable dt, string query = "") where T : RecordObject { using (var con = new SQLiteConnection("Data Source=" + DbPath.GetPath <T>())) { using (var adapter = new SQLiteDataAdapter( (query.Equals("")) ? "SELECT * FROM " + TableList.GetTableName <T>() : query, con)) { adapter.Fill(dt); } con.Dispose(); } }
public int Count <T>(string where = "") { int ret; using (var conn = new SQLiteConnection("Data Source=" + DbPath.GetPath <T>())) { conn.Open(); using (var command = conn.CreateCommand()) { command.CommandText = "SELECT COUNT(*) FROM " + TableList.GetTableName <T>() + " " + where; ret = int.Parse(command.ExecuteScalar().ToString()); } conn.Close(); } return(ret); }
private void InitializeFileWatcher() { var abs = DbPath.MakeAbsolute(); var dir = Path.GetDirectoryName(abs); var nme = Path.GetFileName(abs); _watchr = new FileSystemWatcher(dir, nme); _watchr.NotifyFilter = NotifyFilters.LastWrite; _watchr.Changed += async(s, e) => { if (!_isDelaying) { _isDelaying = true; await Task.Delay(1000); DbChanged.Raise(); _isDelaying = false; } }; _watchr.EnableRaisingEvents = true; }
public List <T> SelectMulti <T>(string where = "") where T : RecordObject { return(QuerySelectImpl <T>( DbPath.GetPath <T>(), "SELECT * FROM " + TableList.GetTableName <T>() + " " + where)); }