diff --git a/gaseous-server/Classes/Auth/Models/SecurityProfileViewModel.cs b/gaseous-server/Classes/Auth/Models/SecurityProfileViewModel.cs index b7e5407..2f8dd85 100644 --- a/gaseous-server/Classes/Auth/Models/SecurityProfileViewModel.cs +++ b/gaseous-server/Classes/Auth/Models/SecurityProfileViewModel.cs @@ -5,13 +5,13 @@ namespace Authentication public class SecurityProfileViewModel { public AgeRestrictionItem AgeRestrictionPolicy { get; set; } = new AgeRestrictionItem{ - MaximumAgeRestriction = gaseous_server.Classes.Metadata.AgeRatings.AgeGroups.AgeRestrictionGroupings.Adult, + MaximumAgeRestriction = gaseous_server.Classes.Metadata.AgeGroups.AgeRestrictionGroupings.Adult, IncludeUnrated = true }; public class AgeRestrictionItem { - public gaseous_server.Classes.Metadata.AgeRatings.AgeGroups.AgeRestrictionGroupings MaximumAgeRestriction { get; set; } + public gaseous_server.Classes.Metadata.AgeGroups.AgeRestrictionGroupings MaximumAgeRestriction { get; set; } public bool IncludeUnrated { get; set; } } } diff --git a/gaseous-server/Classes/Collections.cs b/gaseous-server/Classes/Collections.cs index 3faa4e7..c89685b 100644 --- a/gaseous-server/Classes/Collections.cs +++ b/gaseous-server/Classes/Collections.cs @@ -220,7 +220,7 @@ namespace gaseous_server.Classes } } else { // get all platforms to pull from - Dictionary> FilterDict = Filters.Filter(AgeRatings.AgeGroups.AgeRestrictionGroupings.Adult, true); + Dictionary> FilterDict = Filters.Filter(AgeGroups.AgeRestrictionGroupings.Adult, true); List filteredPlatforms = (List)FilterDict["platforms"]; foreach (Filters.FilterItem filterItem in filteredPlatforms) { platforms.Add(Platforms.GetPlatform(filterItem.Id)); diff --git a/gaseous-server/Classes/Database.cs b/gaseous-server/Classes/Database.cs index 9266d94..2386689 100644 --- a/gaseous-server/Classes/Database.cs +++ b/gaseous-server/Classes/Database.cs @@ -107,20 +107,28 @@ namespace gaseous_server.Classes Logging.Log(Logging.LogType.Information, "Database", "Schema version is " + SchemaVer); if (SchemaVer < i) { - // run pre-upgrade code - DatabaseMigration.PreUpgradeScript(i, _ConnectorType); - - // apply schema! - Logging.Log(Logging.LogType.Information, "Database", "Updating schema to version " + i); - ExecuteCMD(dbScript, dbDict); + try + { + // run pre-upgrade code + DatabaseMigration.PreUpgradeScript(i, _ConnectorType); + + // apply schema! + Logging.Log(Logging.LogType.Information, "Database", "Updating schema to version " + i); + ExecuteCMD(dbScript, dbDict, 180); - sql = "UPDATE schema_version SET schema_version=@schemaver"; - dbDict = new Dictionary(); - dbDict.Add("schemaver", i); - ExecuteCMD(sql, dbDict); + sql = "UPDATE schema_version SET schema_version=@schemaver"; + dbDict = new Dictionary(); + dbDict.Add("schemaver", i); + ExecuteCMD(sql, dbDict); - // run post-upgrade code - DatabaseMigration.PostUpgradeScript(i, _ConnectorType); + // run post-upgrade code + DatabaseMigration.PostUpgradeScript(i, _ConnectorType); + } + catch (Exception ex) + { + Logging.Log(Logging.LogType.Critical, "Database", "Schema upgrade failed! Unable to continue.", ex); + System.Environment.Exit(1); + } } } } diff --git a/gaseous-server/Classes/Filters.cs b/gaseous-server/Classes/Filters.cs index f2fc304..8152272 100644 --- a/gaseous-server/Classes/Filters.cs +++ b/gaseous-server/Classes/Filters.cs @@ -7,7 +7,7 @@ namespace gaseous_server.Classes { public class Filters { - public static Dictionary> Filter(Metadata.AgeRatings.AgeGroups.AgeRestrictionGroupings MaximumAgeRestriction, bool IncludeUnrated) + public static Dictionary> Filter(Metadata.AgeGroups.AgeRestrictionGroupings MaximumAgeRestriction, bool IncludeUnrated) { Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString); @@ -90,13 +90,13 @@ namespace gaseous_server.Classes FilterItem filterAgeGrouping = new FilterItem(); if (dr["AgeGroupId"] == DBNull.Value) { - filterAgeGrouping.Id = (int)(long)AgeRatings.AgeGroups.AgeRestrictionGroupings.Unclassified; - filterAgeGrouping.Name = AgeRatings.AgeGroups.AgeRestrictionGroupings.Unclassified.ToString(); + filterAgeGrouping.Id = (int)(long)AgeGroups.AgeRestrictionGroupings.Unclassified; + filterAgeGrouping.Name = AgeGroups.AgeRestrictionGroupings.Unclassified.ToString(); } else { - long ageGroupLong = (long)dr["AgeGroupId"]; - AgeRatings.AgeGroups.AgeRestrictionGroupings ageGroup = (AgeRatings.AgeGroups.AgeRestrictionGroupings)ageGroupLong; + int ageGroupLong = (int)dr["AgeGroupId"]; + AgeGroups.AgeRestrictionGroupings ageGroup = (AgeGroups.AgeRestrictionGroupings)ageGroupLong; filterAgeGrouping.Id = ageGroupLong; filterAgeGrouping.Name = ageGroup.ToString(); } diff --git a/gaseous-server/Classes/Metadata/AgeGroups.cs b/gaseous-server/Classes/Metadata/AgeGroups.cs new file mode 100644 index 0000000..2d5eda2 --- /dev/null +++ b/gaseous-server/Classes/Metadata/AgeGroups.cs @@ -0,0 +1,304 @@ +using System; +using System.Reflection; +using System.Text.Json.Serialization; +using IGDB; +using IGDB.Models; +using Microsoft.CodeAnalysis.Classification; + +namespace gaseous_server.Classes.Metadata +{ + public class AgeGroups + { + public AgeGroups() + { + + } + + public static AgeGroup? GetAgeGroup(Game? game) + { + if (game == null) + { + return null; + } + else + { + Storage.CacheStatus? cacheStatus = new Storage.CacheStatus(); + cacheStatus = Storage.GetCacheStatus("AgeGroup", (long)game.Id); + + AgeGroup? RetVal = new AgeGroup(); + + switch (cacheStatus) + { + case Storage.CacheStatus.NotPresent: + RetVal = _GetAgeGroup(game); + Storage.NewCacheValue(RetVal, false); + break; + + case Storage.CacheStatus.Expired: + RetVal = _GetAgeGroup(game); + Storage.NewCacheValue(RetVal, true); + break; + + case Storage.CacheStatus.Current: + RetVal = Storage.GetCacheValue(RetVal, "Id", game.Id); + break; + + default: + throw new Exception("How did you get here?"); + } + + return RetVal; + } + } + + public static AgeGroup? _GetAgeGroup(Game game) + { + // compile the maximum age group for the given game + if (game != null) + { + if (game.AgeRatings != null) + { + if (game.AgeRatings.Ids != null) + { + // collect ratings values from metadata + List ageRatings = new List(); + foreach (long ratingId in game.AgeRatings.Ids) + { + AgeRating? rating = AgeRatings.GetAgeRatings(ratingId); + if (rating != null) + { + ageRatings.Add(rating); + } + } + + // compile the ratings values into the ratings groups + AgeRestrictionGroupings highestAgeGroup = AgeRestrictionGroupings.Unclassified; + foreach (AgeRating ageRating in ageRatings) + { + foreach (KeyValuePair ageGroupItem in AgeGroupingsFlat) + { + + PropertyInfo[] groupProps = typeof(AgeGroupItem).GetProperties(); + foreach (PropertyInfo property in groupProps) + { + if (RatingsBoards.Contains(property.Name)) + { + List ratingBoard = (List)property.GetValue(ageGroupItem.Value); + foreach (AgeRatingTitle ratingTitle in ratingBoard) + { + if (ageRating.Rating == ratingTitle) + { + if (highestAgeGroup < ageGroupItem.Key) + { + highestAgeGroup = ageGroupItem.Key; + } + } + } + } + } + } + } + + // return the compiled ratings group + AgeGroup ageGroup = new AgeGroup(); + ageGroup.Id = game.Id; + ageGroup.GameId = game.Id; + if (highestAgeGroup == 0) + { + ageGroup.AgeGroupId = null; + } + else + { + ageGroup.AgeGroupId = highestAgeGroup; + } + + return ageGroup; + } + else + { + AgeGroup ageGroup = new AgeGroup(); + ageGroup.Id = game.Id; + ageGroup.GameId = game.Id; + ageGroup.AgeGroupId = null; + + return ageGroup; + } + } + else + { + AgeGroup ageGroup = new AgeGroup(); + ageGroup.Id = game.Id; + ageGroup.GameId = game.Id; + ageGroup.AgeGroupId = null; + + return ageGroup; + } + } + + return null; + } + + public class AgeGroup + { + public long? Id { get; set; } + public long? GameId { get; set; } + public AgeRestrictionGroupings? AgeGroupId { get; set; } + } + + public static Dictionary> AgeGroupings + { + get + { + return new Dictionary>{ + { + AgeRestrictionGroupings.Adult, new List{ Adult_Item, Mature_Item, Teen_Item, Child_Item } + }, + { + AgeRestrictionGroupings.Mature, new List{ Mature_Item, Teen_Item, Child_Item } + }, + { + AgeRestrictionGroupings.Teen, new List{ Teen_Item, Child_Item } + }, + { + AgeRestrictionGroupings.Child, new List{ Child_Item } + } + }; + } + } + + public static Dictionary AgeGroupingsFlat + { + get + { + return new Dictionary{ + { + AgeRestrictionGroupings.Adult, Adult_Item + }, + { + AgeRestrictionGroupings.Mature, Mature_Item + }, + { + AgeRestrictionGroupings.Teen, Teen_Item + }, + { + AgeRestrictionGroupings.Child, Child_Item + } + }; + } + } + + public enum AgeRestrictionGroupings + { + Adult = 4, + Mature = 3, + Teen = 2, + Child = 1, + Unclassified = 0 + } + + public static List RatingsBoards + { + get + { + List boards = new List{ + "ACB", "CERO", "CLASS_IND", "ESRB", "GRAC", "PEGI", "USK" + }; + + return boards; + } + } + + readonly static AgeGroupItem Adult_Item = new AgeGroupItem{ + ACB = new List{ AgeRatingTitle.ACB_R18, AgeRatingTitle.ACB_RC }, + CERO = new List{ AgeRatingTitle.CERO_Z }, + CLASS_IND = new List{ AgeRatingTitle.CLASS_IND_Eighteen }, + ESRB = new List{ AgeRatingTitle.RP, AgeRatingTitle.AO }, + GRAC = new List{ AgeRatingTitle.GRAC_Eighteen }, + PEGI = new List{ AgeRatingTitle.Eighteen}, + USK = new List{ AgeRatingTitle.USK_18} + }; + + readonly static AgeGroupItem Mature_Item = new AgeGroupItem{ + ACB = new List{ AgeRatingTitle.ACB_M, AgeRatingTitle.ACB_MA15 }, + CERO = new List{ AgeRatingTitle.CERO_C, AgeRatingTitle.CERO_D }, + CLASS_IND = new List{ AgeRatingTitle.CLASS_IND_Sixteen }, + ESRB = new List{ AgeRatingTitle.M }, + GRAC = new List{ AgeRatingTitle.GRAC_Fifteen }, + PEGI = new List{ AgeRatingTitle.Sixteen}, + USK = new List{ AgeRatingTitle.USK_16} + }; + + readonly static AgeGroupItem Teen_Item = new AgeGroupItem{ + ACB = new List{ AgeRatingTitle.ACB_PG }, + CERO = new List{ AgeRatingTitle.CERO_B }, + CLASS_IND = new List{ AgeRatingTitle.CLASS_IND_Twelve, AgeRatingTitle.CLASS_IND_Fourteen }, + ESRB = new List{ AgeRatingTitle.T }, + GRAC = new List{ AgeRatingTitle.GRAC_Twelve }, + PEGI = new List{ AgeRatingTitle.Twelve}, + USK = new List{ AgeRatingTitle.USK_12} + }; + + readonly static AgeGroupItem Child_Item = new AgeGroupItem{ + ACB = new List{ AgeRatingTitle.ACB_G }, + CERO = new List{ AgeRatingTitle.CERO_A }, + CLASS_IND = new List{ AgeRatingTitle.CLASS_IND_L, AgeRatingTitle.CLASS_IND_Ten }, + ESRB = new List{ AgeRatingTitle.E, AgeRatingTitle.E10 }, + GRAC = new List{ AgeRatingTitle.GRAC_All }, + PEGI = new List{ AgeRatingTitle.Three, AgeRatingTitle.Seven}, + USK = new List{ AgeRatingTitle.USK_0, AgeRatingTitle.USK_6} + }; + + public class AgeGroupItem + { + public List ACB { get; set; } + public List CERO { get; set; } + public List CLASS_IND { get; set; } + public List ESRB { get; set; } + public List GRAC { get; set; } + public List PEGI { get; set; } + public List USK { get; set; } + + [JsonIgnore] + [Newtonsoft.Json.JsonIgnore] + public List AgeGroupItemValues + { + get + { + List values = new List(); + { + foreach (AgeRatingTitle ageRatingTitle in ACB) + { + values.Add((long)ageRatingTitle); + } + foreach (AgeRatingTitle ageRatingTitle in CERO) + { + values.Add((long)ageRatingTitle); + } + foreach (AgeRatingTitle ageRatingTitle in CLASS_IND) + { + values.Add((long)ageRatingTitle); + } + foreach (AgeRatingTitle ageRatingTitle in ESRB) + { + values.Add((long)ageRatingTitle); + } + foreach (AgeRatingTitle ageRatingTitle in GRAC) + { + values.Add((long)ageRatingTitle); + } + foreach (AgeRatingTitle ageRatingTitle in PEGI) + { + values.Add((long)ageRatingTitle); + } + foreach (AgeRatingTitle ageRatingTitle in USK) + { + values.Add((long)ageRatingTitle); + } + } + + return values; + } + } + } + } +} \ No newline at end of file diff --git a/gaseous-server/Classes/Metadata/AgeRating.cs b/gaseous-server/Classes/Metadata/AgeRating.cs index 0d35bdb..1f69a41 100644 --- a/gaseous-server/Classes/Metadata/AgeRating.cs +++ b/gaseous-server/Classes/Metadata/AgeRating.cs @@ -186,158 +186,6 @@ namespace gaseous_server.Classes.Metadata } } } - - public class AgeGroups - { - public AgeGroups() - { - - } - - public static Dictionary> AgeGroupings - { - get - { - return new Dictionary>{ - { - AgeRestrictionGroupings.Adult, new List{ Adult_Item, Mature_Item, Teen_Item, Child_Item } - }, - { - AgeRestrictionGroupings.Mature, new List{ Mature_Item, Teen_Item, Child_Item } - }, - { - AgeRestrictionGroupings.Teen, new List{ Teen_Item, Child_Item } - }, - { - AgeRestrictionGroupings.Child, new List{ Child_Item } - } - }; - } - } - - public static Dictionary AgeGroupingsFlat - { - get - { - return new Dictionary{ - { - AgeRestrictionGroupings.Adult, Adult_Item - }, - { - AgeRestrictionGroupings.Mature, Mature_Item - }, - { - AgeRestrictionGroupings.Teen, Teen_Item - }, - { - AgeRestrictionGroupings.Child, Child_Item - } - }; - } - } - - public enum AgeRestrictionGroupings - { - Adult = 4, - Mature = 3, - Teen = 2, - Child = 1, - Unclassified = 0 - } - - readonly static AgeGroupItem Adult_Item = new AgeGroupItem{ - ACB = new List{ AgeRatingTitle.ACB_R18, AgeRatingTitle.ACB_RC }, - CERO = new List{ AgeRatingTitle.CERO_Z }, - CLASS_IND = new List{ AgeRatingTitle.CLASS_IND_Eighteen }, - ESRB = new List{ AgeRatingTitle.RP, AgeRatingTitle.AO }, - GRAC = new List{ AgeRatingTitle.GRAC_Eighteen }, - PEGI = new List{ AgeRatingTitle.Eighteen}, - USK = new List{ AgeRatingTitle.USK_18} - }; - - readonly static AgeGroupItem Mature_Item = new AgeGroupItem{ - ACB = new List{ AgeRatingTitle.ACB_M, AgeRatingTitle.ACB_MA15 }, - CERO = new List{ AgeRatingTitle.CERO_C, AgeRatingTitle.CERO_D }, - CLASS_IND = new List{ AgeRatingTitle.CLASS_IND_Sixteen }, - ESRB = new List{ AgeRatingTitle.M }, - GRAC = new List{ AgeRatingTitle.GRAC_Fifteen }, - PEGI = new List{ AgeRatingTitle.Sixteen}, - USK = new List{ AgeRatingTitle.USK_16} - }; - - readonly static AgeGroupItem Teen_Item = new AgeGroupItem{ - ACB = new List{ AgeRatingTitle.ACB_PG }, - CERO = new List{ AgeRatingTitle.CERO_B }, - CLASS_IND = new List{ AgeRatingTitle.CLASS_IND_Twelve, AgeRatingTitle.CLASS_IND_Fourteen }, - ESRB = new List{ AgeRatingTitle.T }, - GRAC = new List{ AgeRatingTitle.GRAC_Twelve }, - PEGI = new List{ AgeRatingTitle.Twelve}, - USK = new List{ AgeRatingTitle.USK_12} - }; - - readonly static AgeGroupItem Child_Item = new AgeGroupItem{ - ACB = new List{ AgeRatingTitle.ACB_G }, - CERO = new List{ AgeRatingTitle.CERO_A }, - CLASS_IND = new List{ AgeRatingTitle.CLASS_IND_L, AgeRatingTitle.CLASS_IND_Ten }, - ESRB = new List{ AgeRatingTitle.E, AgeRatingTitle.E10 }, - GRAC = new List{ AgeRatingTitle.GRAC_All }, - PEGI = new List{ AgeRatingTitle.Three, AgeRatingTitle.Seven}, - USK = new List{ AgeRatingTitle.USK_0, AgeRatingTitle.USK_6} - }; - - public class AgeGroupItem - { - public List ACB { get; set; } - public List CERO { get; set; } - public List CLASS_IND { get; set; } - public List ESRB { get; set; } - public List GRAC { get; set; } - public List PEGI { get; set; } - public List USK { get; set; } - - [JsonIgnore] - [Newtonsoft.Json.JsonIgnore] - public List AgeGroupItemValues - { - get - { - List values = new List(); - { - foreach (AgeRatingTitle ageRatingTitle in ACB) - { - values.Add((long)ageRatingTitle); - } - foreach (AgeRatingTitle ageRatingTitle in CERO) - { - values.Add((long)ageRatingTitle); - } - foreach (AgeRatingTitle ageRatingTitle in CLASS_IND) - { - values.Add((long)ageRatingTitle); - } - foreach (AgeRatingTitle ageRatingTitle in ESRB) - { - values.Add((long)ageRatingTitle); - } - foreach (AgeRatingTitle ageRatingTitle in GRAC) - { - values.Add((long)ageRatingTitle); - } - foreach (AgeRatingTitle ageRatingTitle in PEGI) - { - values.Add((long)ageRatingTitle); - } - foreach (AgeRatingTitle ageRatingTitle in USK) - { - values.Add((long)ageRatingTitle); - } - } - - return values; - } - } - } - } } } diff --git a/gaseous-server/Classes/Metadata/Games.cs b/gaseous-server/Classes/Metadata/Games.cs index e687e86..3b90faa 100644 --- a/gaseous-server/Classes/Metadata/Games.cs +++ b/gaseous-server/Classes/Metadata/Games.cs @@ -114,7 +114,9 @@ namespace gaseous_server.Classes.Metadata } return returnValue; case Storage.CacheStatus.Current: - return Storage.GetCacheValue(returnValue, "id", (long)searchValue); + returnValue = Storage.GetCacheValue(returnValue, "id", (long)searchValue); + UpdateSubClasses(returnValue, false, false); + return returnValue; default: throw new Exception("How did you get here?"); } @@ -125,7 +127,14 @@ namespace gaseous_server.Classes.Metadata // required metadata if (Game.Cover != null) { - Cover GameCover = Covers.GetCover(Game.Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game)); + try + { + Cover GameCover = Covers.GetCover(Game.Cover.Id, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game)); + } + catch (Exception ex) + { + Logging.Log(Logging.LogType.Critical, "Game Metadata", "Unable to fetch cover artwork.", ex); + } } if (Game.Genres != null) @@ -175,6 +184,7 @@ namespace gaseous_server.Classes.Metadata AgeRating GameAgeRating = AgeRatings.GetAgeRatings(AgeRatingId); } } + AgeGroups.GetAgeGroup(Game); if (Game.ReleaseDates != null) { @@ -199,7 +209,14 @@ namespace gaseous_server.Classes.Metadata { foreach (long ArtworkId in Game.Artworks.Ids) { - Artwork GameArtwork = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game)); + try + { + Artwork GameArtwork = Artworks.GetArtwork(ArtworkId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game)); + } + catch (Exception ex) + { + Logging.Log(Logging.LogType.Critical, "Game Metadata", "Unable to fetch artwork id: " + ArtworkId, ex); + } } } @@ -266,7 +283,14 @@ namespace gaseous_server.Classes.Metadata { foreach (long ScreenshotId in Game.Screenshots.Ids) { + try + { Screenshot GameScreenshot = Screenshots.GetScreenshot(ScreenshotId, Config.LibraryConfiguration.LibraryMetadataDirectory_Game(Game)); + } + catch (Exception ex) + { + Logging.Log(Logging.LogType.Critical, "Game Metadata", "Unable to fetch screenshot id: " + ScreenshotId, ex); + } } } diff --git a/gaseous-server/Classes/Metadata/Storage.cs b/gaseous-server/Classes/Metadata/Storage.cs index 6935fab..d95b6c0 100644 --- a/gaseous-server/Classes/Metadata/Storage.cs +++ b/gaseous-server/Classes/Metadata/Storage.cs @@ -372,9 +372,12 @@ namespace gaseous_server.Classes.Metadata case "[igdb.models.releasedateregion": property.SetValue(EndpointType, (ReleaseDateRegion)dataRow[property.Name]); break; - case "[igdb.models.releasedatecategory": + case "[igdb.models.releasedatecategory": property.SetValue(EndpointType, (ReleaseDateCategory)dataRow[property.Name]); break; + case "[gaseous_server.classes.metadata.agegroups+agerestrictiongroupings": + property.SetValue(EndpointType, (AgeGroups.AgeRestrictionGroupings)dataRow[property.Name]); + break; default: property.SetValue(EndpointType, dataRow[property.Name]); break; diff --git a/gaseous-server/Controllers/V1.0/SystemController.cs b/gaseous-server/Controllers/V1.0/SystemController.cs index 613a3c9..d285dde 100644 --- a/gaseous-server/Controllers/V1.0/SystemController.cs +++ b/gaseous-server/Controllers/V1.0/SystemController.cs @@ -103,7 +103,7 @@ namespace gaseous_server.Controllers "var AgeRatingStrings = " + JsonSerializer.Serialize(AgeRatingsStrings, new JsonSerializerOptions{ WriteIndented = true }) + ";" + Environment.NewLine + - "var AgeRatingGroups = " + JsonSerializer.Serialize(AgeRatings.AgeGroups.AgeGroupingsFlat, new JsonSerializerOptions{ + "var AgeRatingGroups = " + JsonSerializer.Serialize(AgeGroups.AgeGroupingsFlat, new JsonSerializerOptions{ WriteIndented = true }) + ";"; byte[] bytes = Encoding.UTF8.GetBytes(ver); diff --git a/gaseous-server/ProcessQueue.cs b/gaseous-server/ProcessQueue.cs index 7b22b3e..a0957e1 100644 --- a/gaseous-server/ProcessQueue.cs +++ b/gaseous-server/ProcessQueue.cs @@ -113,6 +113,7 @@ namespace gaseous_server _CorrelationId = correlationId.ToString(); CallContext.SetData("CorrelationId", correlationId); CallContext.SetData("CallingProcess", _ItemType.ToString()); + CallContext.SetData("CallingUser", "System"); // log the start Logging.Log(Logging.LogType.Debug, "Timered Event", "Executing " + _ItemType + " with correlation id " + _CorrelationId); diff --git a/gaseous-server/Support/Database/MySQL/gaseous-1011.sql b/gaseous-server/Support/Database/MySQL/gaseous-1011.sql new file mode 100644 index 0000000..defe3d0 --- /dev/null +++ b/gaseous-server/Support/Database/MySQL/gaseous-1011.sql @@ -0,0 +1,18 @@ +CREATE TABLE `AgeGroup` ( + `Id` BIGINT NOT NULL, + `GameId` BIGINT NULL, + `AgeGroupId` INT NULL, + `dateAdded` DATETIME NULL DEFAULT NULL, + `lastUpdated` DATETIME NULL DEFAULT NULL, + PRIMARY KEY (`Id`)); + +ALTER TABLE `Game` +CHANGE COLUMN `Slug` `Slug` VARCHAR(255) NULL DEFAULT NULL; + +CREATE OR REPLACE VIEW `view_Games` AS +SELECT + a.*, b.AgeGroupId +FROM + view_GamesWithRoms a + LEFT JOIN AgeGroup b ON b.GameId = a.Id +ORDER BY NameThe; \ No newline at end of file diff --git a/gaseous-server/gaseous-server.csproj b/gaseous-server/gaseous-server.csproj index c62d8d5..81bddac 100644 --- a/gaseous-server/gaseous-server.csproj +++ b/gaseous-server/gaseous-server.csproj @@ -51,6 +51,7 @@ + @@ -184,5 +185,6 @@ + diff --git a/gaseous-server/wwwroot/pages/dialogs/rominfo.html b/gaseous-server/wwwroot/pages/dialogs/rominfo.html index f1b56b9..440966d 100644 --- a/gaseous-server/wwwroot/pages/dialogs/rominfo.html +++ b/gaseous-server/wwwroot/pages/dialogs/rominfo.html @@ -196,40 +196,56 @@ } }); - $('#properties_fixgame').select2({ - minimumInputLength: 3, - templateResult: DropDownRenderGameOption, - ajax: { - url: '/api/v1.1/Search/Game', - data: function (params) { - fixplatform = $('#properties_fixplatform').select2('data'); + $('#properties_fixplatform').on('select2:select', function (e) { + var platformData = e.params.data; + console.log(platformData); - var query = { - PlatformId: fixplatform[0].id, - SearchString: params.term - } + var gameValue = $('#properties_fixgame').select2('data'); + if (gameValue) { + console.log(gameValue[0]); - // Query parameters will be ?SearchString=[term] - return query; - }, - processResults: function (data) { - var arr = []; - - for (var i = 0; i < data.length; i++) { - arr.push({ - id: data[i].id, - text: data[i].name, - cover: data[i].cover - }); - } - - return { - results: arr - }; - } + setFixGameDropDown(); } }); + function setFixGameDropDown() { + $('#properties_fixgame').empty().select2({ + minimumInputLength: 3, + placeholder: 'Game', + templateResult: DropDownRenderGameOption, + ajax: { + url: '/api/v1.1/Search/Game', + data: function (params) { + fixplatform = $('#properties_fixplatform').select2('data'); + + var query = { + PlatformId: fixplatform[0].id, + SearchString: params.term + } + + // Query parameters will be ?SearchString=[term] + return query; + }, + processResults: function (data) { + var arr = []; + + for (var i = 0; i < data.length; i++) { + arr.push({ + id: data[i].id, + text: data[i].name, + cover: data[i].cover + }); + } + + return { + results: arr + }; + } + } + }); + } + setFixGameDropDown(); + function SaveFixedGame() { var fixplatform = $('#properties_fixplatform').select2('data'); var fixgame = $('#properties_fixgame').select2('data'); diff --git a/gaseous-server/wwwroot/pages/game.html b/gaseous-server/wwwroot/pages/game.html index 6dcbc5a..064bf57 100644 --- a/gaseous-server/wwwroot/pages/game.html +++ b/gaseous-server/wwwroot/pages/game.html @@ -741,41 +741,56 @@ } }); - $('#rom_edit_fixgame').select2({ - minimumInputLength: 3, - templateResult: DropDownRenderGameOption, - placeholder: "Game", - ajax: { - url: '/api/v1.1/Search/Game', - data: function (params) { - fixplatform = $('#rom_edit_fixplatform').select2('data'); + $('#rom_edit_fixplatform').on('select2:select', function (e) { + var platformData = e.params.data; + console.log(platformData); - var query = { - PlatformId: fixplatform[0].id, - SearchString: params.term - } + var gameValue = $('#rom_edit_fixgame').select2('data'); + if (gameValue) { + console.log(gameValue[0]); - // Query parameters will be ?SearchString=[term] - return query; - }, - processResults: function (data) { - var arr = []; - - for (var i = 0; i < data.length; i++) { - arr.push({ - id: data[i].id, - text: data[i].name, - cover: data[i].cover - }); - } - - return { - results: arr - }; - } + setRomFixGameDropDown(); } }); + function setRomFixGameDropDown() { + $('#rom_edit_fixgame').empty().select2({ + minimumInputLength: 3, + templateResult: DropDownRenderGameOption, + placeholder: "Game", + ajax: { + url: '/api/v1.1/Search/Game', + data: function (params) { + fixplatform = $('#rom_edit_fixplatform').select2('data'); + + var query = { + PlatformId: fixplatform[0].id, + SearchString: params.term + } + + // Query parameters will be ?SearchString=[term] + return query; + }, + processResults: function (data) { + var arr = []; + + for (var i = 0; i < data.length; i++) { + arr.push({ + id: data[i].id, + text: data[i].name, + cover: data[i].cover + }); + } + + return { + results: arr + }; + } + } + }); + } + setRomFixGameDropDown(); + var remapCallCounter = 0; var remapCallCounterMax = 0;