/// <summary> /// Try repairing VndbData /// </summary> /// <returns></returns> public async Task RepairVndbData() { try { var result = _windowManager.ShowMessageBox( $"{App.ResMan.GetString("RepairMessage1")}\n{App.ResMan.GetString("RepairMessage2")}", App.ResMan.GetString("RepairVndb"), MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { var parentHost = (ModifyGameHostViewModel)Parent; parentHost.LockControls(); var modifyDelete = _gameDelete(); modifyDelete.SetSelectedGame(SelectedGame); modifyDelete.DeleteVndbContent(); GetVndbData getData = new GetVndbData(); await getData.GetDataAsync(SelectedGame.GameId.Value, true); _events.PublishOnUIThread(new UpdateEvent { ShouldUpdate = true }, EventChannels.RefreshGameGrid.ToString()); parentHost.UnlockControls(); } } catch (Exception e) { App.Logger.Warning(e, "Failed to repair Vndb Data"); SentrySdk.CaptureException(e); } }
/// <summary> /// Create the userData entry for the database /// </summary> /// <param name="addGame"></param> /// <returns></returns> public static async Task SetGameDataEntryAsync(AddGameVndbViewModel addGame) { if (addGame == null) { return; } List <UserDataGames> gamesList = new List <UserDataGames>(); if (addGame.ExeType == ExeType.Collection) { foreach (var entry in addGame.ExeCollection.Select(item => AddGameMainViewModel.GetDefaultUserDataEntry)) { entry.SourceType = AddGameSourceType.Vndb; entry.ExeType = addGame.ExeType; entry.GameId = addGame.VnId; entry.ExePath = addGame.ExePath; entry.IconPath = addGame.IconPath; entry.Arguments = addGame.ExeArguments; gamesList.Add(entry); } } else { var entry = AddGameMainViewModel.GetDefaultUserDataEntry; entry.SourceType = AddGameSourceType.Vndb; entry.ExeType = addGame.ExeType; entry.GameId = addGame.VnId; entry.ExePath = addGame.ExePath; entry.IconPath = addGame.IconPath; entry.Arguments = addGame.ExeArguments; gamesList.Add(entry); } var cred = CredentialManager.GetCredentials(App.CredDb); if (cred == null || cred.UserName.Length < 1) { return; } using (var db = new LiteDatabase($"{App.GetDbStringWithoutPass}'{cred.Password}'")) { var dbUserData = db.GetCollection <UserDataGames>(DbUserData.UserData_Games.ToString()); dbUserData.Insert(gamesList); } GetVndbData getData = new GetVndbData(); await getData.GetDataAsync(addGame.VnId, false); }