Miscellaneous bug fixes (#220)
This commit is contained in:
@@ -400,35 +400,42 @@ namespace Authentication
|
|||||||
|
|
||||||
public int SetPreferences(TUser user, List<UserPreferenceViewModel> model)
|
public int SetPreferences(TUser user, List<UserPreferenceViewModel> model)
|
||||||
{
|
{
|
||||||
List<UserPreferenceViewModel> userPreferences = GetPreferences(user);
|
if (model != null)
|
||||||
|
|
||||||
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
|
||||||
|
|
||||||
foreach (UserPreferenceViewModel modelItem in model)
|
|
||||||
{
|
{
|
||||||
bool prefItemFound = false;
|
List<UserPreferenceViewModel> userPreferences = GetPreferences(user);
|
||||||
foreach (UserPreferenceViewModel existing in userPreferences)
|
|
||||||
|
Database db = new Database(Database.databaseType.MySql, Config.DatabaseConfiguration.ConnectionString);
|
||||||
|
|
||||||
|
foreach (UserPreferenceViewModel modelItem in model)
|
||||||
{
|
{
|
||||||
if (existing.Setting.ToLower() == modelItem.Setting.ToLower())
|
bool prefItemFound = false;
|
||||||
|
foreach (UserPreferenceViewModel existing in userPreferences)
|
||||||
{
|
{
|
||||||
prefItemFound = true;
|
if (existing.Setting.ToLower() == modelItem.Setting.ToLower())
|
||||||
break;
|
{
|
||||||
|
prefItemFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string sql = "INSERT INTO User_Settings (`Id`, `Setting`, `Value`) VALUES (@id, @setting, @value);";
|
||||||
|
if (prefItemFound == true)
|
||||||
|
{
|
||||||
|
sql = "UPDATE User_Settings SET `Value`=@value WHERE `Id`=@id AND `Setting`=@setting";
|
||||||
|
}
|
||||||
|
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
||||||
|
dbDict.Add("id", user.Id);
|
||||||
|
dbDict.Add("setting", modelItem.Setting);
|
||||||
|
dbDict.Add("value", modelItem.Value);
|
||||||
|
db.ExecuteNonQuery(sql, dbDict);
|
||||||
}
|
}
|
||||||
|
|
||||||
string sql = "INSERT INTO User_Settings (`Id`, `Setting`, `Value`) VALUES (@id, @setting, @value);";
|
return model.Count;
|
||||||
if (prefItemFound == true)
|
}
|
||||||
{
|
else
|
||||||
sql = "UPDATE User_Settings SET `Value`=@value WHERE `Id`=@id AND `Setting`=@setting";
|
{
|
||||||
}
|
return 0;
|
||||||
Dictionary<string, object> dbDict = new Dictionary<string, object>();
|
|
||||||
dbDict.Add("id", user.Id);
|
|
||||||
dbDict.Add("setting", modelItem.Setting);
|
|
||||||
dbDict.Add("value", modelItem.Value);
|
|
||||||
db.ExecuteNonQuery(sql, dbDict);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return model.Count;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,6 +45,11 @@ namespace gaseous_server
|
|||||||
DataRow row = data.Rows[0];
|
DataRow row = data.Rows[0];
|
||||||
LibraryItem library = new LibraryItem((int)row["Id"], (string)row["Name"], (string)row["Path"], (long)row["DefaultPlatform"], Convert.ToBoolean((int)row["DefaultLibrary"]));
|
LibraryItem library = new LibraryItem((int)row["Id"], (string)row["Name"], (string)row["Path"], (long)row["DefaultPlatform"], Convert.ToBoolean((int)row["DefaultLibrary"]));
|
||||||
|
|
||||||
|
if (!Directory.Exists(library.Path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(library.Path);
|
||||||
|
}
|
||||||
|
|
||||||
return library;
|
return library;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,6 +66,15 @@ namespace gaseous_server
|
|||||||
{
|
{
|
||||||
LibraryItem library = new LibraryItem((int)row["Id"], (string)row["Name"], (string)row["Path"], (long)row["DefaultPlatform"], Convert.ToBoolean((int)row["DefaultLibrary"]));
|
LibraryItem library = new LibraryItem((int)row["Id"], (string)row["Name"], (string)row["Path"], (long)row["DefaultPlatform"], Convert.ToBoolean((int)row["DefaultLibrary"]));
|
||||||
libraryItems.Add(library);
|
libraryItems.Add(library);
|
||||||
|
|
||||||
|
if (library.IsDefaultLibrary == true)
|
||||||
|
{
|
||||||
|
// check directory exists
|
||||||
|
if (!Directory.Exists(library.Path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(library.Path);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return libraryItems;
|
return libraryItems;
|
||||||
@@ -143,6 +157,11 @@ namespace gaseous_server
|
|||||||
_Path = Path;
|
_Path = Path;
|
||||||
_DefaultPlatformId = DefaultPlatformId;
|
_DefaultPlatformId = DefaultPlatformId;
|
||||||
_IsDefaultLibrary = IsDefaultLibrary;
|
_IsDefaultLibrary = IsDefaultLibrary;
|
||||||
|
|
||||||
|
if (!Directory.Exists(Path))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _Id = 0;
|
int _Id = 0;
|
||||||
|
@@ -402,6 +402,9 @@ gaseous_server.Classes.Metadata.Platforms.GetPlatform(0);
|
|||||||
// extract platform map if not present
|
// extract platform map if not present
|
||||||
PlatformMapping.ExtractPlatformMap();
|
PlatformMapping.ExtractPlatformMap();
|
||||||
|
|
||||||
|
// force load platform map into cache
|
||||||
|
var platformMap = PlatformMapping.PlatformMap;
|
||||||
|
|
||||||
// add background tasks
|
// add background tasks
|
||||||
ProcessQueue.QueueItems.Add(new ProcessQueue.QueueItem(
|
ProcessQueue.QueueItems.Add(new ProcessQueue.QueueItem(
|
||||||
ProcessQueue.QueueItemType.SignatureIngestor,
|
ProcessQueue.QueueItemType.SignatureIngestor,
|
||||||
|
@@ -66,4 +66,11 @@ CREATE TABLE `User_Settings` (
|
|||||||
PRIMARY KEY (`Id`, `Setting`));
|
PRIMARY KEY (`Id`, `Setting`));
|
||||||
|
|
||||||
ALTER TABLE `ServerLogs`
|
ALTER TABLE `ServerLogs`
|
||||||
ADD FULLTEXT INDEX `ft_message` USING BTREE (`Message`) VISIBLE;
|
ADD FULLTEXT INDEX `ft_message` (`Message`) VISIBLE;
|
||||||
|
|
||||||
|
CREATE TABLE `Relation_Game_Platforms` (
|
||||||
|
`GameId` BIGINT NOT NULL,
|
||||||
|
`PlatformsId` BIGINT NOT NULL,
|
||||||
|
PRIMARY KEY (`GameId`, `PlatformsId`),
|
||||||
|
INDEX `idx_PrimaryColumn` (`GameId` ASC) VISIBLE
|
||||||
|
);
|
Reference in New Issue
Block a user