void updateDiscs() { if (!saveDiscs) { return; } if (discBindingSource.Count > 0) { lock (DB.Instance.SyncRoot) { DB.Instance.ExecuteWithoutLock("BEGIN"); for (int x = 0; x < discBindingSource.Count; x++) { GameDisc disc = discBindingSource[x] as GameDisc; if (disc == null) { continue; } disc.Number = x + 1; disc.Save(); } DB.Instance.ExecuteWithoutLock("COMMIT"); } } saveDiscs = false; }
void mergeSelectedRows() { if (importGridView.SelectedRows.Count < 2) { return; } RomMatch romMatch = importGridView.SelectedRows[importGridView.SelectedRows.Count - 1].DataBoundItem as RomMatch; if (romMatch == null) { return; } Game game = romMatch.Game; if (game == null) { return; } List <GameDisc> discs = game.GetDiscs(); List <Game> removeGames = new List <Game>(); for (int x = importGridView.SelectedRows.Count - 2; x > -1; x--) { RomMatch match = importGridView.SelectedRows[x].DataBoundItem as RomMatch; if (match == null || match.Game == null || match.Game.GetDiscs().Count > 1) { continue; } GameDisc disc = new GameDisc(game) { Path = match.Game.Path, LaunchFile = match.Game.LaunchFile, Number = discs.Count + 1 }; discs.Add(disc); removeGames.Add(match.Game); } lock (DB.Instance.SyncRoot) { DB.Instance.ExecuteTransaction(removeGames, removeGame => { importer.Remove(removeGame.GameID); removeGame.Delete(); }); DB.Instance.ExecuteTransaction(discs, disc => disc.Save()); } romMatch.ResetDisplayInfo(); }