public IEnumerable <IGameFile> GetGameFiles(IGameFileGetOptions options) { int limit = -1; if (options != null && options.Limit.HasValue) { limit = options.Limit.Value; } List <IGameFile> ret = new List <IGameFile>(); DirectoryInfo dir = new DirectoryInfo(GameFileDirectory.GetFullPath()); int counter = 0; foreach (FileInfo fi in dir.GetFiles()) { counter++; ret.Add(CreateGameFile(fi)); if (limit > -1 && counter == limit) { break; } } return(ret); }
public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options) { if (options.SearchField.SearchFieldType != GameFileFieldType.MD5) { throw new NotSupportedException("Only GamefileFieldType.MD5 is supported."); } return(new WadArchiveGameFileDataSource[] { this.GetGameFileFromMD5(options.SearchField.SearchText) }); }
public IEnumerable <IGameFile> GetGameFiles(IGameFileGetOptions options, ITagData tag) { DataTable dt; string selectColumns = "GameFiles.*"; string join = string.Empty; string where = string.Empty; if (tag != null) { join = "join TagMapping on TagMapping.FileID = GameFiles.GameFileID"; where = string.Format("TagMapping.TagID = {0}", tag.TagID); } if (options.SelectFields != null) { selectColumns = GetSelectFieldString(options.SelectFields); } if (options.SearchField != null) { string op = s_opLookup[(int)options.SearchField.SearchOp]; if (op == "like") { options.SearchField.SearchText = string.Format("{0}{1}{0}", "%", options.SearchField.SearchText); } string searchCol = options.SearchField.SearchFieldType.ToString("g"); string searchParam = "@search"; if (DataAccess.DbAdapter is SqliteDatabaseAdapter && GameFileSearchField.IsDateTimeField(options.SearchField.SearchFieldType)) //sqlite datetime comparison hack { searchParam = string.Format("Datetime('{0}')", DateTime.Parse(options.SearchField.SearchText).ToString("yyyy-MM-dd")); } if (where != string.Empty) { where = string.Format("and {0}", where); } string query = string.Format("select {2} from GameFiles {5} where {0} {1} {3} {4} {6}", searchCol, op, selectColumns, searchParam, GetLimitOrderString(options), join, where); dt = DataAccess.ExecuteSelect(query, new DbParameter[] { DataAccess.DbAdapter.CreateParameter("search", options.SearchField.SearchText) }).Tables[0]; } else { if (where != string.Empty) { where = string.Format("where {0}", where); } string query = string.Format("select {0} from GameFiles {2} {3} {1}", selectColumns, GetLimitOrderString(options), join, where); dt = DataAccess.ExecuteSelect(query).Tables[0]; } return(Util.TableToStructure(dt, typeof(GameFile)).Cast <IGameFile>()); }
public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options) { if (options == null) { int num = ((options != null) && options.Limit.HasValue) ? options.Limit.Value : 0x19; return(this.GetFiles($"action=latestfiles&limit={num}", "file")); } if (string.IsNullOrEmpty(s_queryLookup[(int)options.SearchField.SearchFieldType])) { return(new List <IGameFileDataSource>()); } return(this.GetFiles(string.Format(s_queryLookup[(int)options.SearchField.SearchFieldType], options.SearchField.SearchText), (options.SearchField.SearchFieldType == GameFileFieldType.GameFileID) ? "content" : "file")); }
private static string GetLimitOrderString(IGameFileGetOptions options) { string str = string.Empty; if (options.OrderBy.HasValue && options.OrderField.HasValue) { str = str + $"order by {options.OrderField.Value.ToString("g")} {options.OrderBy.Value.ToString("g")}"; } if (options.Limit.HasValue) { str = str + $" limit {options.Limit.Value}"; } return(str); }
public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options, ITagDataSource tag) { DataTable table; string selectFieldString = "GameFiles.*"; string str2 = string.Empty; string str3 = string.Empty; if (tag != null) { str2 = "join TagMapping on TagMapping.FileID = GameFiles.GameFileID"; str3 = $"TagMapping.TagID = {tag.TagID}"; } if (options.SelectFields != null) { selectFieldString = this.GetSelectFieldString(options.SelectFields); } if (options.SearchField != null) { string str4 = s_opLookup[(int)options.SearchField.SearchOp]; if (str4 == "like") { options.SearchField.SearchText = string.Format("{0}{1}{0}", "%", options.SearchField.SearchText); } string str5 = options.SearchField.SearchFieldType.ToString("g"); string str6 = "@search"; if ((this.DataAccess.DbAdapter is SqliteDatabaseAdapter) && GameFileSearchField.IsDateTimeField(options.SearchField.SearchFieldType)) { str6 = $"Datetime('{DateTime.Parse(options.SearchField.SearchText).ToString("yyyy-MM-dd")}')"; } if (str3 != string.Empty) { str3 = $"and {str3}"; } string sql = string.Format("select {2} from GameFiles {5} where {0} {1} {3} {4} {6}", new object[] { str5, str4, selectFieldString, str6, GetLimitOrderString(options), str2, str3 }); DbParameter[] parameters = new DbParameter[] { this.DataAccess.DbAdapter.CreateParameter("search", options.SearchField.SearchText) }; table = this.DataAccess.ExecuteSelect(sql, parameters).Tables[0]; } else { if (str3 != string.Empty) { str3 = $"where {str3}"; } string str8 = string.Format("select {0} from GameFiles {2} {3} {1}", new object[] { selectFieldString, GetLimitOrderString(options), str2, str3 }); table = this.DataAccess.ExecuteSelect(str8).Tables[0]; } return(Util.TableToStructure(table, typeof(GameFileDataSource)).Cast <IGameFileDataSource>()); }
private static string GetLimitOrderString(IGameFileGetOptions options) { string ret = string.Empty; if (options.OrderBy.HasValue && options.OrderField.HasValue) { ret += string.Format("order by {0} {1}", options.OrderField.Value.ToString("g"), options.OrderBy.Value.ToString("g")); } if (options.Limit.HasValue) { ret += string.Format(" limit {0}", options.Limit.Value); } return(ret); }
public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options) { int num = options.Limit.HasValue ? options.Limit.Value : -1; List <IGameFileDataSource> list = new List <IGameFileDataSource>(); int num2 = 0; foreach (FileInfo info in new DirectoryInfo(this.GameFileDirectory.GetFullPath()).GetFiles()) { num2++; list.Add(this.FromZipFile(info)); if ((num > -1) && (num2 == num)) { return(list); } } return(list); }
public IEnumerable <IGameFile> GetGameFiles(IGameFileGetOptions options) { if (options == null) { int limit = options != null && options.Limit.HasValue ? options.Limit.Value : 25; return(GetFiles(string.Format("action=latestfiles&limit={0}", limit), "file")); } else { if (string.IsNullOrEmpty(s_queryLookup[(int)options.SearchField.SearchFieldType])) { return(new List <IGameFile>()); } return(GetFiles(string.Format(s_queryLookup[(int)options.SearchField.SearchFieldType], options.SearchField.SearchText), options.SearchField.SearchFieldType == GameFileFieldType.GameFileID ? "content" : "file")); } }
public IEnumerable <IGameFile> GetGameFiles(IGameFileGetOptions options) { if (options == null) { int limit = options != null && options.Limit.HasValue ? options.Limit.Value : 25; string query = $"action=search&field=filename&query=zip&sort=date&dir=desc"; return(GetFiles(query, "file").Take(limit)); } else { if (string.IsNullOrEmpty(s_queryLookup[(int)options.SearchField.SearchFieldType])) { return(new List <IGameFile>()); } return(GetFiles(string.Format(s_queryLookup[(int)options.SearchField.SearchFieldType], options.SearchField.SearchText), options.SearchField.SearchFieldType == GameFileFieldType.GameFileID ? "content" : "file")); } }
public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options, ITagDataSource tag) { throw new NotImplementedException(); }
public IEnumerable <IGameFile> GetGameFiles(IGameFileGetOptions options) { return(GetGameFiles(options, null)); }
public IEnumerable <IGameFileDataSource> GetGameFiles(IGameFileGetOptions options) => this.GetGameFiles(options, null);