feat: added initial Docker support (still testing) and refactored the database for case-sensitive hosts

This commit is contained in:
Michael Green
2023-07-02 01:12:26 +10:00
parent 6c2c093ec9
commit 1b14e697a2
20 changed files with 601 additions and 543 deletions

BIN
.DS_Store vendored

Binary file not shown.

16
Dockerfile Normal file
View File

@@ -0,0 +1,16 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
WORKDIR /App
EXPOSE 80
# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore "gaseous-server/gaseous-server.csproj"
# Build and publish a release
RUN dotnet publish "gaseous-server/gaseous-server.csproj" -c Release -o out
# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:7.0
WORKDIR /App
COPY --from=build-env /App/out .
ENTRYPOINT ["dotnet", "gaseous-server.dll"]

View File

@@ -15,6 +15,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gaseous-tools", "gaseous-to
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gaseous-server", "gaseous-server\gaseous-server.csproj", "{A01D2EFF-C82E-473B-84D7-7C25E736F5D2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{17FA6F12-8532-420C-9489-CB8FDE42137C}"
ProjectSection(SolutionItems) = preProject
docker-compose.yml = docker-compose.yml
Dockerfile = Dockerfile
README.MD = README.MD
LICENSE = LICENSE
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

39
docker-compose.yml Normal file
View File

@@ -0,0 +1,39 @@
version: '2'
services:
gaseous-server:
container_name: gaseous-server
build:
context: ./
restart: unless-stopped
networks:
- gaseous
depends_on:
- gsdb
ports:
- 5198:80
volumes:
- /Users/michaelgreen/.gaseous-server:/root/.gaseous-server
environment:
- dbhost=gsdb
- dbuser=root
- dbpass=gaseous
- igdbclientid=<clientid>
- igdbclientsecret=<clientsecret>
gsdb:
container_name: gsdb
image: mysql:8
restart: unless-stopped
networks:
- gaseous
volumes:
- gsdb:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=gaseous
- MYSQL_USER=gaseous
- MYSQL_PASSWORD=gaseous
networks:
gaseous:
driver: bridge
volumes:
gs:
gsdb:

View File

@@ -61,7 +61,7 @@ namespace gaseous_server.Classes
Common.hashObject hash = new Common.hashObject(GameFileImportPath);
// check to make sure we don't already have this file imported
sql = "SELECT COUNT(Id) AS count FROM games_roms WHERE md5=@md5 AND sha1=@sha1";
sql = "SELECT COUNT(Id) AS count FROM Games_Roms WHERE MD5=@md5 AND SHA1=@sha1";
dbDict.Add("md5", hash.md5hash);
dbDict.Add("sha1", hash.sha1hash);
DataTable importDB = db.ExecuteCMD(sql, dbDict);
@@ -304,7 +304,7 @@ namespace gaseous_server.Classes
if (UpdateId == 0)
{
sql = "INSERT INTO games_roms (platformid, gameid, name, size, crc, md5, sha1, developmentstatus, flags, romtype, romtypemedia, medialabel, path, metadatasource) VALUES (@platformid, @gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @flags, @romtype, @romtypemedia, @medialabel, @path, @metadatasource); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sql = "INSERT INTO Games_Roms (PlatformId, GameId, Name, Size, CRC, MD5, SHA1, DevelopmentStatus, Flags, RomType, RomTypeMedia, MediaLabel, Path, MetadataSource) VALUES (@platformid, @gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @flags, @romtype, @romtypemedia, @medialabel, @path, @metadatasource); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
}
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("platformid", Common.ReturnValueIfNull(determinedPlatform.Id, 0));
@@ -402,7 +402,7 @@ namespace gaseous_server.Classes
// update the db
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "UPDATE games_roms SET path=@path WHERE id=@id";
string sql = "UPDATE Games_Roms SET Path=@path WHERE Id=@id";
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", RomId);
dbDict.Add("path", DestinationPath);
@@ -423,7 +423,7 @@ namespace gaseous_server.Classes
// move rom files to their new location
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT * FROM games_roms";
string sql = "SELECT * FROM Games_Roms";
DataTable romDT = db.ExecuteCMD(sql);
if (romDT.Rows.Count > 0)

View File

@@ -26,7 +26,7 @@ namespace gaseous_server.Classes.Metadata
if (Id == 0)
{
Game returnValue = new Game();
if (Storage.GetCacheStatus("game", 0) == Storage.CacheStatus.NotPresent)
if (Storage.GetCacheStatus("Game", 0) == Storage.CacheStatus.NotPresent)
{
returnValue = new Game
{

View File

@@ -27,7 +27,7 @@ namespace gaseous_server.Classes.Metadata
if (Id == 0)
{
Platform returnValue = new Platform();
if (Storage.GetCacheStatus("platform", 0) == Storage.CacheStatus.NotPresent)
if (Storage.GetCacheStatus("Platform", 0) == Storage.CacheStatus.NotPresent)
{
returnValue = new Platform
{
@@ -63,11 +63,11 @@ namespace gaseous_server.Classes.Metadata
Storage.CacheStatus? cacheStatus = new Storage.CacheStatus();
if (searchUsing == SearchUsing.id)
{
cacheStatus = Storage.GetCacheStatus("platform", (long)searchValue);
cacheStatus = Storage.GetCacheStatus("Platform", (long)searchValue);
}
else
{
cacheStatus = Storage.GetCacheStatus("platform", (string)searchValue);
cacheStatus = Storage.GetCacheStatus("Platform", (string)searchValue);
}
// set up where clause

View File

@@ -9,7 +9,7 @@ namespace gaseous_server.Classes
public static void RefreshMetadata(bool forceRefresh = false)
{
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT id, `name` FROM game;";
string sql = "SELECT Id, `Name` FROM Game;";
DataTable dt = db.ExecuteCMD(sql);
foreach (DataRow dr in dt.Rows)

View File

@@ -9,7 +9,7 @@ namespace gaseous_server.Classes
public static List<GameRomItem> GetRoms(long GameId)
{
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT * FROM games_roms WHERE gameid = @id ORDER BY `name`";
string sql = "SELECT * FROM Games_Roms WHERE GameId = @id ORDER BY `Name`";
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", GameId);
DataTable romDT = db.ExecuteCMD(sql, dbDict);
@@ -33,7 +33,7 @@ namespace gaseous_server.Classes
public static GameRomItem GetRom(long RomId)
{
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT * FROM games_roms WHERE id = @id";
string sql = "SELECT * FROM Games_Roms WHERE Id = @id";
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", RomId);
DataTable romDT = db.ExecuteCMD(sql, dbDict);
@@ -59,7 +59,7 @@ namespace gaseous_server.Classes
IGDB.Models.Game game = Classes.Metadata.Games.GetGame(GameId, false, false);
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "UPDATE games_roms SET platformid=@platformid, gameid=@gameid WHERE id = @id";
string sql = "UPDATE Games_Roms SET PlatformId=@platformid, GameId=@gameid WHERE Id = @id";
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", RomId);
dbDict.Add("platformid", PlatformId);
@@ -80,7 +80,7 @@ namespace gaseous_server.Classes
}
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "DELETE FROM games_roms WHERE id = @id";
string sql = "DELETE FROM Games_Roms WHERE Id = @id";
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("id", RomId);
db.ExecuteCMD(sql, dbDict);

View File

@@ -32,7 +32,7 @@ namespace gaseous_server.SignatureIngestors.TOSEC
// check tosec file md5
Common.hashObject hashObject = new Common.hashObject(tosecXMLFile);
sql = "SELECT * FROM signatures_sources WHERE sourcemd5=@sourcemd5";
sql = "SELECT * FROM Signatures_Sources WHERE SourceMD5=@sourcemd5";
dbDict = new Dictionary<string, object>();
dbDict.Add("sourcemd5", hashObject.md5hash);
sigDB = db.ExecuteCMD(sql, dbDict);
@@ -51,7 +51,7 @@ namespace gaseous_server.SignatureIngestors.TOSEC
bool processGames = false;
if (tosecObject.SourceMd5 != null)
{
sql = "SELECT * FROM signatures_sources WHERE sourcemd5=@sourcemd5";
sql = "SELECT * FROM Signatures_Sources WHERE SourceMD5=@sourcemd5";
dbDict = new Dictionary<string, object>();
dbDict.Add("name", Common.ReturnValueIfNull(tosecObject.Name, ""));
dbDict.Add("description", Common.ReturnValueIfNull(tosecObject.Description, ""));
@@ -69,7 +69,7 @@ namespace gaseous_server.SignatureIngestors.TOSEC
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_sources (name, description, category, version, author, email, homepage, url, sourcetype, sourcemd5, sourcesha1) VALUES (@name, @description, @category, @version, @author, @email, @homepage, @uri, @sourcetype, @sourcemd5, @sourcesha1)";
sql = "INSERT INTO Signatures_Sources (Name, Description, Category, Version, Author, Email, Homepage, Url, SourceType, SourceMD5, SourceSHA1) VALUES (@name, @description, @category, @version, @author, @email, @homepage, @uri, @sourcetype, @sourcemd5, @sourcesha1)";
db.ExecuteCMD(sql, dbDict);
@@ -101,13 +101,13 @@ namespace gaseous_server.SignatureIngestors.TOSEC
int gameSystem = 0;
if (gameObject.System != null)
{
sql = "SELECT id FROM signatures_platforms WHERE platform=@platform";
sql = "SELECT Id FROM Signatures_Platforms WHERE Platform=@platform";
sigDB = db.ExecuteCMD(sql, dbDict);
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_platforms (platform) VALUES (@platform); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sql = "INSERT INTO Signatures_Platforms (Platform) VALUES (@platform); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sigDB = db.ExecuteCMD(sql, dbDict);
gameSystem = Convert.ToInt32(sigDB.Rows[0][0]);
@@ -123,13 +123,13 @@ namespace gaseous_server.SignatureIngestors.TOSEC
int gamePublisher = 0;
if (gameObject.Publisher != null)
{
sql = "SELECT * FROM signatures_publishers WHERE publisher=@publisher";
sql = "SELECT * FROM Signatures_Publishers WHERE Publisher=@publisher";
sigDB = db.ExecuteCMD(sql, dbDict);
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_publishers (publisher) VALUES (@publisher); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sql = "INSERT INTO Signatures_Publishers (Publisher) VALUES (@publisher); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sigDB = db.ExecuteCMD(sql, dbDict);
gamePublisher = Convert.ToInt32(sigDB.Rows[0][0]);
}
@@ -142,14 +142,14 @@ namespace gaseous_server.SignatureIngestors.TOSEC
// store game
int gameId = 0;
sql = "SELECT * FROM signatures_games WHERE name=@name AND year=@year AND publisherid=@publisher AND systemid=@systemid AND country=@country AND language=@language";
sql = "SELECT * FROM Signatures_Games WHERE Name=@name AND Year=@year AND Publisherid=@publisher AND Systemid=@systemid AND Country=@country AND Language=@language";
sigDB = db.ExecuteCMD(sql, dbDict);
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_games " +
"(name, description, year, publisherid, demo, systemid, systemvariant, video, country, language, copyright) VALUES " +
sql = "INSERT INTO Signatures_Games " +
"(Name, Description, Year, PublisherId, Demo, SystemId, SystemVariant, Video, Country, Language, Copyright) VALUES " +
"(@name, @description, @year, @publisherid, @demo, @systemid, @systemvariant, @video, @country, @language, @copyright); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sigDB = db.ExecuteCMD(sql, dbDict);
@@ -166,7 +166,7 @@ namespace gaseous_server.SignatureIngestors.TOSEC
if (romObject.Md5 != null)
{
int romId = 0;
sql = "SELECT * FROM signatures_roms WHERE gameid=@gameid AND md5=@md5";
sql = "SELECT * FROM Signatures_Roms WHERE GameId=@gameid AND MD5=@md5";
dbDict = new Dictionary<string, object>();
dbDict.Add("gameid", gameId);
dbDict.Add("name", Common.ReturnValueIfNull(romObject.Name, ""));
@@ -200,7 +200,7 @@ namespace gaseous_server.SignatureIngestors.TOSEC
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_roms (gameid, name, size, crc, md5, sha1, developmentstatus, flags, romtype, romtypemedia, medialabel, metadatasource) VALUES (@gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @flags, @romtype, @romtypemedia, @medialabel, @metadatasource); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sql = "INSERT INTO Signatures_Roms (GameId, Name, Size, CRC, MD5, SHA1, DevelopmentStatus, Flags, RomType, RomTypeMedia, MediaLabel, MetadataSource) VALUES (@gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @flags, @romtype, @romtypemedia, @medialabel, @metadatasource); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sigDB = db.ExecuteCMD(sql, dbDict);

View File

@@ -25,7 +25,7 @@ namespace gaseous_server.Controllers
// platforms
List<Platform> platforms = new List<Platform>();
string sql = "SELECT platform.id, platform.abbreviation, platform.alternativename, platform.`name`, platform.platformlogo, (SELECT COUNT(games_roms.id) AS RomCount FROM games_roms WHERE games_roms.platformid = platform.id) AS RomCount FROM platform HAVING RomCount > 0 ORDER BY `name`";
string sql = "SELECT Platform.Id, Platform.Abbreviation, Platform.AlternativeName, Platform.`Name`, Platform.PlatformLogo, (SELECT COUNT(Games_Roms.Id) AS RomCount FROM Games_Roms WHERE Games_Roms.PlatformId = Platform.Id) AS RomCount FROM Platform HAVING RomCount > 0 ORDER BY `Name`";
DataTable dbResponse = db.ExecuteCMD(sql);
foreach (DataRow dr in dbResponse.Rows)
@@ -36,7 +36,7 @@ namespace gaseous_server.Controllers
// genres
List<Genre> genres = new List<Genre>();
sql = "SELECT DISTINCT t1.id, t1.`name` FROM genre AS t1 JOIN (SELECT * FROM game WHERE (SELECT COUNT(id) FROM games_roms WHERE gameid = game.id) > 0) AS t2 ON JSON_CONTAINS(t2.genres, CAST(t1.id AS char), '$') ORDER BY t1.`name`";
sql = "SELECT DISTINCT t1.Id, t1.`Name` FROM Genre AS t1 JOIN (SELECT * FROM Game WHERE (SELECT COUNT(Id) FROM Games_Roms WHERE GameId = Game.Id) > 0) AS t2 ON JSON_CONTAINS(t2.Genres, CAST(t1.Id AS char), '$') ORDER BY t1.`Name`";
dbResponse = db.ExecuteCMD(sql);
foreach (DataRow dr in dbResponse.Rows)

View File

@@ -36,14 +36,14 @@ namespace gaseous_server.Controllers
if (name.Length > 0)
{
tempVal = "`name` LIKE @name";
whereParams.Add("@name", "%" + name + "%");
tempVal = "`Name` LIKE @Name";
whereParams.Add("@Name", "%" + name + "%");
havingClauses.Add(tempVal);
}
if (platform.Length > 0)
{
tempVal = "games_roms.platformid IN (";
tempVal = "Games_Roms.PlatformId IN (";
string[] platformClauseItems = platform.Split(",");
for (int i = 0; i < platformClauseItems.Length; i++)
{
@@ -51,7 +51,7 @@ namespace gaseous_server.Controllers
{
tempVal += ", ";
}
string platformLabel = "@platform" + i;
string platformLabel = "@Platform" + i;
tempVal += platformLabel;
whereParams.Add(platformLabel, platformClauseItems[i]);
}
@@ -69,8 +69,8 @@ namespace gaseous_server.Controllers
{
tempVal += " AND ";
}
string genreLabel = "@genre" + i;
tempVal += "JSON_CONTAINS(game.genres, " + genreLabel + ", '$')";
string genreLabel = "@Genre" + i;
tempVal += "JSON_CONTAINS(Game.Genres, " + genreLabel + ", '$')";
whereParams.Add(genreLabel, genreClauseItems[i]);
}
tempVal += ")";
@@ -106,14 +106,14 @@ namespace gaseous_server.Controllers
}
// order by clause
string orderByClause = "ORDER BY `name` ASC";
string orderByClause = "ORDER BY `Name` ASC";
if (sortdescending == true)
{
orderByClause = "ORDER BY `name` DESC";
orderByClause = "ORDER BY `Name` DESC";
}
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT DISTINCT games_roms.gameid AS ROMGameId, game.id, game.ageratings, game.aggregatedrating, game.aggregatedratingcount, game.alternativenames, game.artworks, game.bundles, game.category, game.collection, game.cover, game.dlcs, game.expansions, game.externalgames, game.firstreleasedate, game.`follows`, game.franchise, game.franchises, game.gameengines, game.gamemodes, game.genres, game.hypes, game.involvedcompanies, game.keywords, game.multiplayermodes, game.`name`, game.parentgame, game.platforms, game.playerperspectives, game.rating, game.ratingcount, game.releasedates, game.screenshots, game.similargames, game.slug, game.standaloneexpansions, game.`status`, game.storyline, game.summary, game.tags, game.themes, game.totalrating, game.totalratingcount, game.versionparent, game.versiontitle, game.videos, game.websites FROM gaseous.games_roms LEFT JOIN game ON game.id = games_roms.gameid " + whereClause + " " + havingClause + " " + orderByClause;
string sql = "SELECT DISTINCT Games_Roms.GameId AS ROMGameId, Game.Id, Game.AgeRatings, Game.AggregatedRating, Game.AggregatedRatingCount, Game.AlternativeNames, Game.Artworks, Game.Bundles, Game.Category, Game.Collection, Game.Cover, Game.Dlcs, Game.Expansions, Game.ExternalGames, Game.FirstReleaseDate, Game.`Follows`, Game.Franchise, Game.Franchises, Game.GameEngines, Game.GameModes, Game.Genres, Game.Hypes, Game.InvolvedCompanies, Game.Keywords, Game.MultiplayerModes, Game.`Name`, Game.ParentGame, Game.Platforms, Game.PlayerPerspectives, Game.Rating, Game.RatingCount, Game.ReleaseDates, Game.Screenshots, Game.SimilarGames, Game.Slug, Game.StandaloneExpansions, Game.`Status`, Game.StoryLine, Game.Summary, Game.Tags, Game.Themes, Game.TotalRating, Game.TotalRatingCount, Game.VersionParent, Game.VersionTitle, Game.Videos, Game.Websites FROM gaseous.Games_Roms LEFT JOIN Game ON Game.Id = Games_Roms.GameId " + whereClause + " " + havingClause + " " + orderByClause;
List<IGDB.Models.Game> RetVal = new List<IGDB.Models.Game>();

View File

@@ -24,7 +24,7 @@ namespace gaseous_server.Controllers
{
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT * FROM gaseous.platform WHERE id IN (SELECT DISTINCT platformid FROM games_roms) ORDER BY `name` ASC;";
string sql = "SELECT * FROM gaseous.Platform WHERE Id IN (SELECT DISTINCT PlatformId FROM Games_Roms) ORDER BY `Name` ASC;";
List<Platform> RetVal = new List<Platform>();

View File

@@ -32,10 +32,10 @@ namespace gaseous_server.Controllers
{
if (md5.Length > 0)
{
return _GetSignature("signatures_roms.md5 = @searchstring", md5);
return _GetSignature("Signatures_Roms.md5 = @searchstring", md5);
} else
{
return _GetSignature("signatures_roms.sha1 = @searchstring", sha1);
return _GetSignature("Signatures_Roms.sha1 = @searchstring", sha1);
}
}
@@ -45,7 +45,7 @@ namespace gaseous_server.Controllers
{
if (TosecName.Length > 0)
{
return _GetSignature("signatures_roms.name = @searchstring", TosecName);
return _GetSignature("Signatures_Roms.name = @searchstring", TosecName);
} else
{
return null;
@@ -55,7 +55,7 @@ namespace gaseous_server.Controllers
private List<Models.Signatures_Games> _GetSignature(string sqlWhere, string searchString)
{
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT \n view_signatures_games.*,\n signatures_roms.id AS romid,\n signatures_roms.name AS romname,\n signatures_roms.size,\n signatures_roms.crc,\n signatures_roms.md5,\n signatures_roms.sha1,\n signatures_roms.developmentstatus,\n signatures_roms.flags,\n signatures_roms.romtype,\n signatures_roms.romtypemedia,\n signatures_roms.medialabel,\n signatures_roms.metadatasource\nFROM\n signatures_roms\n INNER JOIN\n view_signatures_games ON signatures_roms.gameid = view_signatures_games.id WHERE " + sqlWhere;
string sql = "SELECT view_Signatures_Games.*, Signatures_Roms.Id AS romid, Signatures_Roms.Name AS romname, Signatures_Roms.Size, Signatures_Roms.CRC, Signatures_Roms.MD5, Signatures_Roms.SHA1, Signatures_Roms.DevelopmentStatus, Signatures_Roms.Flags, Signatures_Roms.RomType, Signatures_Roms.RomTypeMedia, Signatures_Roms.MediaLabel, Signatures_Roms.MetadataSource FROM Signatures_Roms INNER JOIN view_Signatures_Games ON Signatures_Roms.GameId = view_Signatures_Games.Id WHERE " + sqlWhere;
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("searchString", searchString);
@@ -69,33 +69,33 @@ namespace gaseous_server.Controllers
{
Game = new Models.Signatures_Games.GameItem
{
Id = (Int32)sigDbRow["id"],
Name = (string)sigDbRow["name"],
Description = (string)sigDbRow["description"],
Year = (string)sigDbRow["year"],
Publisher = (string)sigDbRow["publisher"],
Demo = (Models.Signatures_Games.GameItem.DemoTypes)(int)sigDbRow["demo"],
System = (string)sigDbRow["platform"],
SystemVariant = (string)sigDbRow["systemvariant"],
Video = (string)sigDbRow["video"],
Country = (string)sigDbRow["country"],
Language = (string)sigDbRow["language"],
Copyright = (string)sigDbRow["copyright"]
Id = (Int32)sigDbRow["Id"],
Name = (string)sigDbRow["Name"],
Description = (string)sigDbRow["Description"],
Year = (string)sigDbRow["Year"],
Publisher = (string)sigDbRow["Publisher"],
Demo = (Models.Signatures_Games.GameItem.DemoTypes)(int)sigDbRow["Demo"],
System = (string)sigDbRow["Platform"],
SystemVariant = (string)sigDbRow["SystemVariant"],
Video = (string)sigDbRow["Video"],
Country = (string)sigDbRow["Country"],
Language = (string)sigDbRow["Language"],
Copyright = (string)sigDbRow["Copyright"]
},
Rom = new Models.Signatures_Games.RomItem
{
Id = (Int32)sigDbRow["romid"],
Name = (string)sigDbRow["romname"],
Size = (Int64)sigDbRow["size"],
Crc = (string)sigDbRow["crc"],
Md5 = (string)sigDbRow["md5"],
Sha1 = (string)sigDbRow["sha1"],
DevelopmentStatus = (string)sigDbRow["developmentstatus"],
flags = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>((string)sigDbRow["flags"]),
RomType = (Models.Signatures_Games.RomItem.RomTypes)(int)sigDbRow["romtype"],
RomTypeMedia = (string)sigDbRow["romtypemedia"],
MediaLabel = (string)sigDbRow["medialabel"],
SignatureSource = (Models.Signatures_Games.RomItem.SignatureSourceType)(Int32)sigDbRow["metadatasource"]
Size = (Int64)sigDbRow["Size"],
Crc = (string)sigDbRow["CRC"],
Md5 = (string)sigDbRow["MD5"],
Sha1 = (string)sigDbRow["SHA1"],
DevelopmentStatus = (string)sigDbRow["SevelopmentStatus"],
flags = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>((string)sigDbRow["Flags"]),
RomType = (Models.Signatures_Games.RomItem.RomTypes)(int)sigDbRow["RomType"],
RomTypeMedia = (string)sigDbRow["RomTypeMedia"],
MediaLabel = (string)sigDbRow["MediaLabel"],
SignatureSource = (Models.Signatures_Games.RomItem.SignatureSourceType)(Int32)sigDbRow["MetadataSource"]
}
};
GamesList.Add(gameItem);

View File

@@ -15,7 +15,7 @@ namespace gaseous_server.Models
public Signatures_Status()
{
Database db = new gaseous_tools.Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "select (select count(*) from signatures_sources) as SourceCount, (select count(*) from signatures_platforms) as PlatformCount, (select count(*) from signatures_games) as GameCount, (select count(*) from signatures_roms) as RomCount;";
string sql = "select (select count(*) from Signatures_Sources) as SourceCount, (select count(*) from Signatures_Platforms) as PlatformCount, (select count(*) from Signatures_Games) as GameCount, (select count(*) from Signatures_Roms) as RomCount;";
DataTable sigDb = db.ExecuteCMD(sql);
if (sigDb.Rows.Count > 0)

View File

@@ -63,13 +63,13 @@ builder.Services.AddHostedService<TimedHostedService>();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
//if (app.Environment.IsDevelopment())
//{
app.UseSwagger();
app.UseSwaggerUI();
}
//}
app.UseHttpsRedirection();
//app.UseHttpsRedirection();
app.UseResponseCaching();

View File

@@ -119,14 +119,6 @@
</ItemGroup>
<ItemGroup>
<Content Remove="Support\PlatformMap.json" />
<Content Remove="wwwroot\" />
<Content Remove="wwwroot\index.html" />
<Content Remove="wwwroot\scripts\" />
<Content Remove="wwwroot\images\" />
<Content Remove="wwwroot\styles\" />
<Content Remove="wwwroot\pages\" />
<Content Remove="wwwroot\fonts\" />
<Content Remove="wwwroot\pages\dialogs\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Support\PlatformMap.json" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'">
@@ -173,7 +165,4 @@
<EmbeddedResource Include="Assets\Ratings\CLASS_IND\CLASS_IND_Ten.svg" />
<EmbeddedResource Include="Assets\Ratings\CLASS_IND\CLASS_IND_Twelve.svg" />
</ItemGroup>
<ItemGroup>
<None Include="wwwroot\index.html" />
</ItemGroup>
</Project>

View File

@@ -86,7 +86,7 @@ if (Directory.Exists(tosecXML))
// check tosec file md5
Console.WriteLine(" ==> Checking input file ");
Common.hashObject hashObject = new Common.hashObject(tosecXMLFile);
sql = "SELECT * FROM signatures_sources WHERE sourcemd5=@sourcemd5";
sql = "SELECT * FROM Signatures_Sources WHERE SourceMD5=@sourcemd5";
dbDict = new Dictionary<string, object>();
dbDict.Add("sourcemd5", hashObject.md5hash);
sigDB = db.ExecuteCMD(sql, dbDict);
@@ -108,7 +108,7 @@ if (Directory.Exists(tosecXML))
Console.SetCursorPosition(0, Console.CursorTop - 1);
Console.WriteLine(" ==> Storing file in database ");
sql = "SELECT * FROM signatures_sources WHERE sourcemd5=@sourcemd5";
sql = "SELECT * FROM Signatures_Sources WHERE SourceMD5=@sourcemd5";
dbDict = new Dictionary<string, object>();
dbDict.Add("name", Common.ReturnValueIfNull(tosecObject.Name, ""));
dbDict.Add("description", Common.ReturnValueIfNull(tosecObject.Description, ""));
@@ -126,7 +126,7 @@ if (Directory.Exists(tosecXML))
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_sources (name, description, category, version, author, email, homepage, url, sourcetype, sourcemd5, sourcesha1) VALUES (@name, @description, @category, @version, @author, @email, @homepage, @uri, @sourcetype, @sourcemd5, @sourcesha1)";
sql = "INSERT INTO Signatures_Sources (Name, Description, Category, Version, Author, Email, Homepage, Url, SourceType, SourceMD5, sourceSHA1) VALUES (@name, @description, @category, @version, @author, @email, @homepage, @uri, @sourcetype, @sourcemd5, @sourcesha1)";
db.ExecuteCMD(sql, dbDict);
@@ -167,13 +167,13 @@ if (Directory.Exists(tosecXML))
int gameSystem = 0;
if (gameObject.System != null)
{
sql = "SELECT id FROM signatures_platforms WHERE platform=@platform";
sql = "SELECT Id FROM Signatures_Platforms WHERE Platform=@platform";
sigDB = db.ExecuteCMD(sql, dbDict);
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_platforms (platform) VALUES (@platform); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sql = "INSERT INTO Signatures_Platforms (Platform) VALUES (@platform); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sigDB = db.ExecuteCMD(sql, dbDict);
gameSystem = Convert.ToInt32(sigDB.Rows[0][0]);
@@ -189,13 +189,13 @@ if (Directory.Exists(tosecXML))
int gamePublisher = 0;
if (gameObject.Publisher != null)
{
sql = "SELECT * FROM signatures_publishers WHERE publisher=@publisher";
sql = "SELECT * FROM Signatures_Publishers WHERE Publisher=@publisher";
sigDB = db.ExecuteCMD(sql, dbDict);
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_publishers (publisher) VALUES (@publisher); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sql = "INSERT INTO Signatures_Publishers (Publisher) VALUES (@publisher); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sigDB = db.ExecuteCMD(sql, dbDict);
gamePublisher = Convert.ToInt32(sigDB.Rows[0][0]);
}
@@ -208,14 +208,14 @@ if (Directory.Exists(tosecXML))
// store game
int gameId = 0;
sql = "SELECT * FROM signatures_games WHERE name=@name AND year=@year AND publisherid=@publisher AND systemid=@systemid AND country=@country AND language=@language";
sql = "SELECT * FROM Signatures_Games WHERE Name=@name AND Year=@year AND PublisherId=@publisher AND SystemId=@systemid AND Country=@country AND Language=@language";
sigDB = db.ExecuteCMD(sql, dbDict);
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_games " +
"(name, description, year, publisherid, demo, systemid, systemvariant, video, country, language, copyright) VALUES " +
sql = "INSERT INTO Signatures_Games " +
"(Name, Description, Year, PublisherId, Demo, SystemId, SystemVariant, Video, Country, Language, Copyright) VALUES " +
"(@name, @description, @year, @publisherid, @demo, @systemid, @systemvariant, @video, @country, @language, @copyright); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sigDB = db.ExecuteCMD(sql, dbDict);
@@ -232,7 +232,7 @@ if (Directory.Exists(tosecXML))
if (romObject.Md5 != null)
{
int romId = 0;
sql = "SELECT * FROM signatures_roms WHERE gameid=@gameid AND md5=@md5";
sql = "SELECT * FROM Signatures_Roms WHERE GameId=@gameid AND MD5=@md5";
dbDict = new Dictionary<string, object>();
dbDict.Add("gameid", gameId);
dbDict.Add("name", Common.ReturnValueIfNull(romObject.Name, ""));
@@ -265,7 +265,7 @@ if (Directory.Exists(tosecXML))
if (sigDB.Rows.Count == 0)
{
// entry not present, insert it
sql = "INSERT INTO signatures_roms (gameid, name, size, crc, md5, sha1, developmentstatus, flags, romtype, romtypemedia, medialabel) VALUES (@gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @flags, @romtype, @romtypemedia, @medialabel); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sql = "INSERT INTO Signatures_Roms (GameId, Name, Size, CRC, MD5, SHA1, DevelopmentStatus, Flags, RomType, RomTypeMedia, MediaLabel) VALUES (@gameid, @name, @size, @crc, @md5, @sha1, @developmentstatus, @flags, @romtype, @romtypemedia, @medialabel); SELECT CAST(LAST_INSERT_ID() AS SIGNED);";
sigDB = db.ExecuteCMD(sql, dbDict);

View File

@@ -127,6 +127,11 @@ namespace gaseous_tools
serializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
string configRaw = Newtonsoft.Json.JsonConvert.SerializeObject(_config, serializerSettings);
if (!Directory.Exists(ConfigurationPath))
{
Directory.CreateDirectory(ConfigurationPath);
}
if (File.Exists(ConfigurationFilePath_Backup))
{
File.Delete(ConfigurationFilePath_Backup);
@@ -143,18 +148,18 @@ namespace gaseous_tools
public static void InitSettings()
{
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT * FROM settings";
string sql = "SELECT * FROM Settings";
DataTable dbResponse = db.ExecuteCMD(sql);
foreach (DataRow dataRow in dbResponse.Rows)
{
if (AppSettings.ContainsKey((string)dataRow["setting"]))
if (AppSettings.ContainsKey((string)dataRow["Setting"]))
{
AppSettings[(string)dataRow["setting"]] = (string)dataRow["value"];
AppSettings[(string)dataRow["Setting"]] = (string)dataRow["Value"];
}
else
{
AppSettings.Add((string)dataRow["setting"], (string)dataRow["value"]);
AppSettings.Add((string)dataRow["Setting"], (string)dataRow["Value"]);
}
}
}
@@ -168,10 +173,10 @@ namespace gaseous_tools
else
{
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "SELECT * FROM settings WHERE setting = @settingname";
string sql = "SELECT * FROM Settings WHERE Setting = @SettingName";
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("settingname", SettingName);
dbDict.Add("value", DefaultValue);
dbDict.Add("SettingName", SettingName);
dbDict.Add("Value", DefaultValue);
try
{
@@ -200,10 +205,10 @@ namespace gaseous_tools
public static void SetSetting(string SettingName, string Value)
{
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
string sql = "REPLACE INTO settings (setting, value) VALUES (@settingname, @value)";
string sql = "REPLACE INTO Settings (Setting, Value) VALUES (@SettingName, @Value)";
Dictionary<string, object> dbDict = new Dictionary<string, object>();
dbDict.Add("settingname", SettingName);
dbDict.Add("value", Value);
dbDict.Add("SettingName", SettingName);
dbDict.Add("Value", Value);
Logging.Log(Logging.LogType.Debug, "Database", "Storing setting '" + SettingName + "' to value: '" + Value + "'");
try

File diff suppressed because it is too large Load Diff