public static FromDataRow ( |
||
row | ||
return |
public SearchResultInfo SearchFiles(string query) { IDbCommand command; DataSet ds; int x; SearchResultInfo result; var directories = new List <string>(); var files = new List <SharedFileListing>(); result = new SearchResultInfo(); var queryNode = UserQueryParser.Parse(query, FieldSet); var queryFragment = queryNode.ToSql(FieldSet); var sb = new StringBuilder(); sb.Append("SELECT * FROM directoryitems WHERE "); sb.Append(queryFragment); sb.AppendFormat(" LIMIT {0}", MAX_RESULTS.ToString()); UseConnection(connection => { command = connection.CreateCommand(); command.CommandText = sb.ToString(); ds = ExecuteDataSet(command); for (x = 0; x < ds.Tables[0].Rows.Count; x++) { if (ds.Tables[0].Rows[x]["type"].ToString() == "F") { files.Add(new SharedFileListing(LocalFile.FromDataRow(ds.Tables[0].Rows[x]), false)); } else { LocalDirectory dir = LocalDirectory.FromDataRow(ds.Tables[0].Rows[x]); // FIXME: Ugly: Remove '/local' from begining of path string path = "/" + string.Join("/", dir.FullPath.Split('/').Slice(2)); directories.Add(path); } } }); result.Files = files.ToArray(); result.Directories = directories.ToArray(); return(result); }
static internal LocalFile ById(int id) { return(Core.FileSystem.UseConnection <LocalFile>(delegate(IDbConnection connection) { IDbCommand cmd = connection.CreateCommand(); cmd.CommandText = "SELECT * FROM directoryitems WHERE id=@id AND type = 'F' LIMIT 1"; Core.FileSystem.AddParameter(cmd, "@id", id); DataSet ds = Core.FileSystem.ExecuteDataSet(cmd); if (ds.Tables[0].Rows.Count > 0) { return LocalFile.FromDataRow(ds.Tables[0].Rows[0]); } else { return null; } })); }