public List<FDArchiveDirectory> GetDirectories( FDArchiveDirectory parentDir ) { Int64 parent = parentDir.parent; IDbCommand getDirectories = dbcon.CreateCommand(); List<FDArchiveDirectory> directories = new List<FDArchiveDirectory>(); getDirectories.CommandText = "SELECT * from `directory` WHERE `directory_parent` = " + parent.ToString() + ";"; IDataReader reader = getDirectories.ExecuteReader(); while (reader.Read ()) { FDArchiveDirectory directory = new FDArchiveDirectory( reader.GetInt64 (0), //id reader.GetString (1), //directoryname reader.GetInt64 (2) //parent ); directories.Add(directory); } return directories; }
//gets all items given a parent directory public List<FDArchiveItem> GetItems( FDArchiveDirectory parentDir ) { Int64 parent = parentDir.parent; IDbCommand getItems = dbcon.CreateCommand(); List<FDArchiveItem> items = new List<FDArchiveItem>(); getItems.CommandText = "SELECT * from `file` WHERE `file_directory` = " + parent.ToString() + ";"; IDataReader reader = getItems.ExecuteReader(); while(reader.Read ()) { FDArchiveItem item = new FDArchiveItem( reader.GetInt64 (0), //id reader.GetString (1), //filename reader.GetString (2), //checksum reader.GetString (5), //archive id DateTime.FromBinary(reader.GetInt64 (4)), //modified time DateTime.FromBinary(reader.GetInt64 (7)), //upload time reader.GetInt64 (6) //parent ); items.Add(item); } return items; }
private void LoadDirectories(Gtk.TreeIter parentIter, FDArchiveDirectory parent) { List<FDArchiveDirectory> directories = DataStore.GetDirectories(parent); foreach (FDArchiveDirectory directory in directories) { Gtk.TreeIter iter = TreeModel.AppendValues(parentIter, directory.dirname, null, null, 0, null, null, directory.id, directory.parent); TreeModel.AppendValues(iter, "(loading…)"); //append a "loading" message to force expansion caret } }
private void LoadFiles(Gtk.TreeIter parentIter, FDArchiveDirectory parent) { List<FDArchiveItem> items = DataStore.GetItems(parent); foreach(FDArchiveItem item in items) { TreeModel.AppendValues (parentIter, item.filename, item.modified.ToLocalTime().ToShortDateString() + " " + item.modified.ToLocalTime().ToShortTimeString(), item.stored.ToLocalTime().ToShortDateString() + " " + item.stored.ToLocalTime().ToShortTimeString(), 0, item.checksum, item.archiveID, item.id, item.parent); } RemoveLoadingItem(parentIter); }
protected void OnTreeview1RowExpanded(object o, Gtk.RowExpandedArgs args) { FDArchiveDirectory parent = new FDArchiveDirectory( (Int64)treeview1.Model.GetValue (args.Iter, 7), (string)treeview1.Model.GetValue (args.Iter, 0), (Int64)treeview1.Model.GetValue (args.Iter, 6) ); if((bool)TreeModel.GetValue(args.Iter, 8)) return; TreeModel.SetValue(args.Iter, 8, true); this.LoadDirectories(args.Iter, parent); this.LoadFiles(args.Iter, parent); }