WIP
This commit is contained in:
@@ -370,7 +370,23 @@ namespace gaseous_server.Classes
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for platform " + dr["name"] + " (" + dr["id"] + ")");
|
Logging.Log(Logging.LogType.Information, "Metadata Refresh", "(" + StatusCounter + "/" + dt.Rows.Count + "): Refreshing metadata for platform " + dr["name"] + " (" + dr["id"] + ")");
|
||||||
Metadata.Platforms.GetPlatform((long)dr["id"], MetadataSources.None);
|
|
||||||
|
HasheousClient.Models.MetadataSources metadataSource = HasheousClient.Models.MetadataSources.None;
|
||||||
|
|
||||||
|
// fetch the platform metadata
|
||||||
|
Platform platform = Metadata.Platforms.GetPlatform((long)dr["id"], metadataSource);
|
||||||
|
|
||||||
|
// fetch the platform metadata from Hasheous
|
||||||
|
if (Config.MetadataConfiguration.SignatureSource == HasheousClient.Models.MetadataModel.SignatureSources.Hasheous)
|
||||||
|
{
|
||||||
|
Communications.PopulateHasheousPlatformData((long)dr["id"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// force platformLogo refresh
|
||||||
|
if (platform.PlatformLogo != null)
|
||||||
|
{
|
||||||
|
Metadata.PlatformLogos.GetPlatformLogo(platform.PlatformLogo, metadataSource);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@@ -43,7 +43,7 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
[MapToApiVersion("1.1")]
|
[MapToApiVersion("1.1")]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[ProducesResponseType(typeof(GameReturnPackage), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(GameReturnPackage), StatusCodes.Status200OK)]
|
||||||
public async Task<IActionResult> Game_v1_1(GameSearchModel model, int pageNumber = 0, int pageSize = 0)
|
public async Task<IActionResult> Game_v1_1(GameSearchModel model, int pageNumber = 0, int pageSize = 0, bool returnSummary = true, bool returnGames = true)
|
||||||
{
|
{
|
||||||
var user = await _userManager.GetUserAsync(User);
|
var user = await _userManager.GetUserAsync(User);
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
model.GameAgeRating.IncludeUnrated = false;
|
model.GameAgeRating.IncludeUnrated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(GetGames(model, user.Id, pageNumber, pageSize));
|
return Ok(GetGames(model, user.Id, pageNumber, pageSize, returnSummary, returnGames));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -190,7 +190,7 @@ namespace gaseous_server.Controllers.v1_1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameReturnPackage GetGames(GameSearchModel model, string userid, int pageNumber = 0, int pageSize = 0)
|
public static GameReturnPackage GetGames(GameSearchModel model, string userid, int pageNumber = 0, int pageSize = 0, bool returnSummary = true, bool returnGames = true)
|
||||||
{
|
{
|
||||||
string whereClause = "";
|
string whereClause = "";
|
||||||
string havingClause = "";
|
string havingClause = "";
|
||||||
@@ -551,25 +551,30 @@ FROM
|
|||||||
Relation_Game_Themes ON Game.Id = Relation_Game_Themes.GameId
|
Relation_Game_Themes ON Game.Id = Relation_Game_Themes.GameId
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
Favourites ON Game.MetadataMapId = Favourites.GameId AND Favourites.UserId = @userid " + whereClause + " " + havingClause + " " + orderByClause;
|
Favourites ON Game.MetadataMapId = Favourites.GameId AND Favourites.UserId = @userid " + whereClause + " " + havingClause + " " + orderByClause;
|
||||||
List<Games.MinimalGameItem> RetVal = new List<Games.MinimalGameItem>();
|
|
||||||
|
// if (returnGames == true)
|
||||||
|
// {
|
||||||
|
// sql += " LIMIT @pageOffset, @pageSize";
|
||||||
|
// whereParams.Add("pageOffset", pageSize * (pageNumber - 1));
|
||||||
|
// whereParams.Add("pageSize", pageSize);
|
||||||
|
// }
|
||||||
|
|
||||||
DataTable dbResponse = db.ExecuteCMD(sql, whereParams, new Database.DatabaseMemoryCacheOptions(CacheEnabled: true, ExpirationSeconds: 60));
|
DataTable dbResponse = db.ExecuteCMD(sql, whereParams, new Database.DatabaseMemoryCacheOptions(CacheEnabled: true, ExpirationSeconds: 60));
|
||||||
|
|
||||||
// get count
|
// get count
|
||||||
int RecordCount = dbResponse.Rows.Count;
|
int? RecordCount = null;
|
||||||
|
if (returnSummary == true)
|
||||||
|
{
|
||||||
|
RecordCount = dbResponse.Rows.Count;
|
||||||
|
}
|
||||||
|
|
||||||
// compile data for return
|
// compile data for return
|
||||||
int pageOffset = pageSize * (pageNumber - 1);
|
List<Games.MinimalGameItem>? RetVal = null;
|
||||||
for (int i = pageOffset; i < dbResponse.Rows.Count; i++)
|
if (returnGames == true)
|
||||||
{
|
{
|
||||||
if (pageNumber != 0 && pageSize != 0)
|
RetVal = new List<Games.MinimalGameItem>();
|
||||||
|
foreach (int i in Enumerable.Range(0, dbResponse.Rows.Count))
|
||||||
{
|
{
|
||||||
if (i >= (pageOffset + pageSize))
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Models.Game retGame = Storage.BuildCacheObject<Models.Game>(new Models.Game(), dbResponse.Rows[i]);
|
Models.Game retGame = Storage.BuildCacheObject<Models.Game>(new Models.Game(), dbResponse.Rows[i]);
|
||||||
retGame.MetadataMapId = (long)dbResponse.Rows[i]["MetadataMapId"];
|
retGame.MetadataMapId = (long)dbResponse.Rows[i]["MetadataMapId"];
|
||||||
retGame.MetadataSource = (HasheousClient.Models.MetadataSources)dbResponse.Rows[i]["GameIdType"];
|
retGame.MetadataSource = (HasheousClient.Models.MetadataSources)dbResponse.Rows[i]["GameIdType"];
|
||||||
@@ -595,9 +600,14 @@ FROM
|
|||||||
|
|
||||||
RetVal.Add(retMinGame);
|
RetVal.Add(retMinGame);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, int>? AlphaList = null;
|
||||||
|
if (returnSummary == true)
|
||||||
|
{
|
||||||
|
AlphaList = new Dictionary<string, int>();
|
||||||
|
|
||||||
// build alpha list
|
// build alpha list
|
||||||
Dictionary<string, int> AlphaList = new Dictionary<string, int>();
|
|
||||||
if (orderByField == "NameThe" || orderByField == "Name")
|
if (orderByField == "NameThe" || orderByField == "Name")
|
||||||
{
|
{
|
||||||
int CurrentPage = 1;
|
int CurrentPage = 1;
|
||||||
@@ -638,6 +648,7 @@ FROM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GameReturnPackage gameReturn = new GameReturnPackage
|
GameReturnPackage gameReturn = new GameReturnPackage
|
||||||
{
|
{
|
||||||
@@ -669,9 +680,9 @@ FROM
|
|||||||
this.Games = minimalGames;
|
this.Games = minimalGames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int? Count { get; set; }
|
||||||
public List<Games.MinimalGameItem> Games { get; set; } = new List<Games.MinimalGameItem>();
|
public List<Games.MinimalGameItem>? Games { get; set; } = new List<Games.MinimalGameItem>();
|
||||||
public Dictionary<string, int> AlphaList { get; set; }
|
public Dictionary<string, int>? AlphaList { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -107,11 +107,6 @@ namespace gaseous_server.Models
|
|||||||
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.None, platform);
|
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.None, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.MetadataConfiguration.SignatureSource == HasheousClient.Models.MetadataModel.SignatureSources.Hasheous)
|
|
||||||
{
|
|
||||||
Communications.PopulateHasheousPlatformData(mapItem.IGDBId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.IGDB, "Platform", mapItem.IGDBId) == Storage.CacheStatus.NotPresent)
|
if (Storage.GetCacheStatus(HasheousClient.Models.MetadataSources.IGDB, "Platform", mapItem.IGDBId) == Storage.CacheStatus.NotPresent)
|
||||||
{
|
{
|
||||||
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.IGDB, platform);
|
Storage.NewCacheValue(HasheousClient.Models.MetadataSources.IGDB, platform);
|
||||||
|
@@ -613,6 +613,7 @@ class RomManagement {
|
|||||||
this.#SetupFixPlatformDropDown();
|
this.#SetupFixPlatformDropDown();
|
||||||
|
|
||||||
// add buttons
|
// add buttons
|
||||||
|
if (userProfile.roles.includes("Admin")) {
|
||||||
let platformMappingButton = new ModalButton('Metadata Mapping', 0, this, async function (callingObject) {
|
let platformMappingButton = new ModalButton('Metadata Mapping', 0, this, async function (callingObject) {
|
||||||
let metadataModal = await new Modal('messagebox');
|
let metadataModal = await new Modal('messagebox');
|
||||||
await metadataModal.BuildModal();
|
await metadataModal.BuildModal();
|
||||||
@@ -737,7 +738,9 @@ class RomManagement {
|
|||||||
await metadataModal.open();
|
await metadataModal.open();
|
||||||
});
|
});
|
||||||
this.romsModal.addButton(platformMappingButton);
|
this.romsModal.addButton(platformMappingButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Platform.id != 0) {
|
||||||
let platformEditButton = new ModalButton('Configure Emulator', 0, this, async function (callingObject) {
|
let platformEditButton = new ModalButton('Configure Emulator', 0, this, async function (callingObject) {
|
||||||
let mappingModal = await new Modal('messagebox');
|
let mappingModal = await new Modal('messagebox');
|
||||||
await mappingModal.BuildModal();
|
await mappingModal.BuildModal();
|
||||||
@@ -828,6 +831,7 @@ class RomManagement {
|
|||||||
await mappingModal.open();
|
await mappingModal.open();
|
||||||
});
|
});
|
||||||
this.romsModal.addButton(platformEditButton);
|
this.romsModal.addButton(platformEditButton);
|
||||||
|
}
|
||||||
|
|
||||||
let closeButton = new ModalButton('Close', 0, this, function (callingObject) {
|
let closeButton = new ModalButton('Close', 0, this, function (callingObject) {
|
||||||
callingObject.romsModal.close();
|
callingObject.romsModal.close();
|
||||||
|
Reference in New Issue
Block a user