private IEnumerable <IGameFileDataSource> GetFiles(string query, string itemName) { WebRequest request1 = WebRequest.Create(string.Format(this.Url + this.ApiPage + "?" + query, new object[0])); request1.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse response = (HttpWebResponse)request1.GetResponse(); StreamReader reader1 = new StreamReader(response.GetResponseStream()); string s = reader1.ReadToEnd(); reader1.Close(); response.Close(); StringReader reader = new StringReader(s); DataSet set = new DataSet(); set.ReadXml(reader); reader.Dispose(); if (set.Tables.Contains("warning") && (set.Tables["warning"].Rows[0]["type"].ToString() == "No Results")) { return(new List <IGameFileDataSource>()); } IEnumerable <IdGamesGameFileDataSource> source = Util.TableToStructure(set.Tables[itemName], typeof(IdGamesGameFileDataSource)).Cast <IdGamesGameFileDataSource>(); foreach (IdGamesGameFileDataSource local1 in source) { local1.Description = local1.Description.Replace("<br>", "\n"); } return(source.Cast <IGameFileDataSource>()); }
public IEnumerable <IGameFile> GetGameFiles(ITagData tag) { DataTable dt = DataAccess.ExecuteSelect(string.Format("select GameFiles.* from GameFiles join TagMapping on TagMapping.FileID = GameFiles.GameFileID where TagID = {0}", tag.TagID)).Tables[0]; return(Util.TableToStructure(dt, typeof(GameFile)).Cast <IGameFile>()); }
private IEnumerable <IGameFile> GetFiles(string query, string itemName) { WebRequest request = WebRequest.Create(string.Format(Url + ApiPage + "?" + query)); request.Credentials = CredentialCache.DefaultCredentials; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string xmlResponse = reader.ReadToEnd(); reader.Close(); response.Close(); StringReader xmlReader = new StringReader(xmlResponse); DataSet ds = new DataSet(); ds.ReadXml(xmlReader); xmlReader.Dispose(); if (ds.Tables.Contains("warning") && ds.Tables["warning"].Rows[0]["type"].ToString() == "No Results") { return(new List <IGameFile>()); } IEnumerable <IdGamesGameFile> files = Util.TableToStructure(ds.Tables[itemName], typeof(IdGamesGameFile)).Cast <IdGamesGameFile>(); foreach (IdGamesGameFile file in files) { file.Description = file.Description.Replace("<br>", "\n"); } return(files.Cast <IGameFile>()); }
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 IGameFileDataSource GetGameFile(string fileName) { List <DbParameter> parameters = new List <DbParameter> { this.DataAccess.DbAdapter.CreateParameter("FileName", fileName) }; DataTable dt = this.DataAccess.ExecuteSelect("select * from GameFiles where Filename = @FileName", parameters).Tables[0]; if (dt.Rows.Count > 0) { return(Util.TableToStructure(dt, typeof(GameFileDataSource)).Cast <GameFileDataSource>().ToList <GameFileDataSource>()[0]); } return(null); }
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>()); }
public IGameFile GetGameFile(string fileName) { List <DbParameter> parameters = new List <DbParameter>(); parameters.Add(DataAccess.DbAdapter.CreateParameter("FileName", fileName)); DataTable dt = DataAccess.ExecuteSelect("select * from GameFiles where Filename = @FileName COLLATE NOCASE", parameters).Tables[0]; if (dt.Rows.Count > 0) { return(Util.TableToStructure(dt, typeof(GameFile)).Cast <GameFile>().ToList()[0]); } else { return(null); } }
public IEnumerable <IGameFile> GetGameFiles() { DataTable dt = DataAccess.ExecuteSelect("select * from GameFiles").Tables[0]; return(Util.TableToStructure(dt, typeof(GameFile)).Cast <IGameFile>()); }
public IEnumerable <IConfigurationData> GetConfiguration() { DataTable dt = DataAccess.ExecuteSelect("select * from Configuration").Tables[0]; return(Util.TableToStructure(dt, typeof(ConfigurationData)).Cast <ConfigurationData>().ToList()); }
public IEnumerable <IFileData> GetFiles(IGameFile gameFile, FileType fileTypeID) { DataTable dt = DataAccess.ExecuteSelect(string.Format("select * from Files where GameFileID = {0} and FileTypeID = {1} order by FileOrder, FileID", gameFile.GameFileID.Value, (int)fileTypeID)).Tables[0]; return(Util.TableToStructure(dt, typeof(FileData)).Cast <FileData>().ToList()); }
public IEnumerable <ITagMappingDataSource> GetTagMappings(int gameFileID) => ((IEnumerable <ITagMappingDataSource>)Util.TableToStructure(this.DataAccess.ExecuteSelect($"select * from TagMapping where FileID = {gameFileID}").Tables[0], typeof(TagMappingDataSource)).Cast <TagMappingDataSource>().ToList <TagMappingDataSource>());
public IEnumerable <IIWadDataSource> GetIWads() => ((IEnumerable <IIWadDataSource>)Util.TableToStructure(this.DataAccess.ExecuteSelect("select * from IWads order by Name collate nocase").Tables[0], typeof(IWadDataSource)).Cast <IWadDataSource>().ToList <IWadDataSource>());
public ISourcePortDataSource GetSourcePort(int sourcePortID) => (Util.TableToStructure(this.DataAccess.ExecuteSelect($"select * from SourcePorts where SourcePortID = {sourcePortID}").Tables[0], typeof(SourcePortDataSource)).First <object>() as SourcePortDataSource);
public IEnumerable <IStatsData> GetStats() { DataTable dt = DataAccess.ExecuteSelect("select * from Stats").Tables[0]; return(Util.TableToStructure(dt, typeof(StatsData)).Cast <StatsData>().ToList()); }
public IEnumerable <IGameFile> GetUntaggedGameFiles() { DataTable dt = DataAccess.ExecuteSelect("select GameFiles.* from GameFiles left join TagMapping on GameFiles.GameFileID = TagMapping.FileID where FileID is null").Tables[0]; return(Util.TableToStructure(dt, typeof(GameFile)).Cast <IGameFile>()); }
public IEnumerable <IStatsDataSource> GetStats(int gameFileID) => ((IEnumerable <IStatsDataSource>)Util.TableToStructure(this.DataAccess.ExecuteSelect($"select * from Stats where GameFileID = {gameFileID}").Tables[0], typeof(StatsDataSource)).Cast <StatsDataSource>().ToList <StatsDataSource>());
public IEnumerable <IStatsDataSource> GetStats() => ((IEnumerable <IStatsDataSource>)Util.TableToStructure(this.DataAccess.ExecuteSelect(string.Format("select * from Stats", new object[0])).Tables[0], typeof(StatsDataSource)).Cast <StatsDataSource>().ToList <StatsDataSource>());
public IEnumerable <IFileDataSource> GetFiles(IGameFileDataSource gameFile, FileType fileTypeID) => ((IEnumerable <IFileDataSource>)Util.TableToStructure(this.DataAccess.ExecuteSelect($"select * from Files where GameFileID = {gameFile.GameFileID.Value} and FileTypeID = {(int) fileTypeID} order by FileOrder, FileID").Tables[0], typeof(FileDataSource)).Cast <FileDataSource>().ToList <FileDataSource>());
public IEnumerable <IConfigurationDataSource> GetConfiguration() => ((IEnumerable <IConfigurationDataSource>)Util.TableToStructure(this.DataAccess.ExecuteSelect("select * from Configuration").Tables[0], typeof(ConfigurationDataSource)).Cast <ConfigurationDataSource>().ToList <ConfigurationDataSource>());
public IEnumerable <ITagDataSource> GetTags() => ((IEnumerable <ITagDataSource>)Util.TableToStructure(this.DataAccess.ExecuteSelect("select * from Tags").Tables[0], typeof(TagDataSource)).Cast <TagDataSource>().ToList <TagDataSource>());
public IEnumerable <ITagMapping> GetTagMappings() { DataTable dt = DataAccess.ExecuteSelect("select * from TagMapping").Tables[0]; return(Util.TableToStructure(dt, typeof(TagMapping)).Cast <TagMapping>().ToList()); }
public IIWadDataSource GetIWad(int gameFileID) => Util.TableToStructure(this.DataAccess.ExecuteSelect($"select * from IWads where GameFileID = {gameFileID} order by Name collate nocase").Tables[0], typeof(IWadDataSource)).Cast <IWadDataSource>().FirstOrDefault <IWadDataSource>();
public IEnumerable <ITagMapping> GetTagMappings(int gameFileID) { DataTable dt = DataAccess.ExecuteSelect(string.Format("select * from TagMapping where FileID = {0}", gameFileID)).Tables[0]; return(Util.TableToStructure(dt, typeof(TagMapping)).Cast <TagMapping>().ToList()); }
public IEnumerable <IIWadData> GetIWads() { DataTable dt = DataAccess.ExecuteSelect("select * from IWads order by Name collate nocase").Tables[0]; return(Util.TableToStructure(dt, typeof(IWadData)).Cast <IWadData>().ToList()); }
public IEnumerable <IStatsData> GetStats(int gameFileID) { DataTable dt = DataAccess.ExecuteSelect(string.Format("select * from Stats where GameFileID = {0}", gameFileID)).Tables[0]; return(Util.TableToStructure(dt, typeof(StatsData)).Cast <StatsData>().ToList()); }
public IIWadData GetIWad(int gameFileID) { DataTable dt = DataAccess.ExecuteSelect(string.Format("select * from IWads where GameFileID = {0} order by Name collate nocase", gameFileID)).Tables[0]; return(Util.TableToStructure(dt, typeof(IWadData)).Cast <IWadData>().FirstOrDefault()); }
public IEnumerable <IGameProfile> GetGameProfiles(int gameFileID) { DataTable dt = DataAccess.ExecuteSelect(string.Format("select * from GameProfiles where GameFileID = {0}", gameFileID)).Tables[0]; return(Util.TableToStructure(dt, typeof(GameProfile)).Cast <IGameProfile>()); }
public IEnumerable <IFileData> GetFiles() { DataTable dt = DataAccess.ExecuteSelect("select * from Files").Tables[0]; return(Util.TableToStructure(dt, typeof(FileData)).Cast <FileData>().ToList()); }
public IEnumerable <IGameFile> GetGameFileIWads() { DataTable dt = DataAccess.ExecuteSelect("select GameFiles.* from GameFiles join IWads on IWads.GameFileID = GameFiles.GameFileID").Tables[0]; return(Util.TableToStructure(dt, typeof(GameFile)).Cast <GameFile>()); }
public IEnumerable <ITagMappingDataSource> GetTagMappings() => ((IEnumerable <ITagMappingDataSource>)Util.TableToStructure(this.DataAccess.ExecuteSelect(string.Format("select * from TagMapping", new object[0])).Tables[0], typeof(TagMappingDataSource)).Cast <TagMappingDataSource>().ToList <TagMappingDataSource>());