Skip to content

Commit

Permalink
Merge branch 'hotfix/keep-console-open-on-errors'
Browse files Browse the repository at this point in the history
  • Loading branch information
pathartl committed Dec 12, 2018
2 parents 7cc860a + c69f5ce commit 0e4236e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
6 changes: 3 additions & 3 deletions BleemSync/BleemSync.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>BleemSync</RootNamespace>
<Version>0.3.0</Version>
<Version>0.3.1</Version>
<Authors>DoctorDalek</Authors>
<Company>Team Classic+</Company>
<RepositoryUrl>https://github.com/pathartl/BleemSync</RepositoryUrl>
<AssemblyVersion>0.3.0.0</AssemblyVersion>
<FileVersion>0.3.0.0</FileVersion>
<AssemblyVersion>0.3.1.0</AssemblyVersion>
<FileVersion>0.3.1.0</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
63 changes: 36 additions & 27 deletions BleemSync/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,55 @@ class Program
{
static void Main(string[] args)
{
var gameService = new GameService();
try
{
var gameService = new GameService();

var gameIds = Filesystem.GetGameIds();
var gameIds = Filesystem.GetGameIds();

using (var db = new DatabaseContext())
{
foreach (var existingGame in db.Games)
using (var db = new DatabaseContext())
{
db.Remove(existingGame);
}
foreach (var existingGame in db.Games)
{
db.Remove(existingGame);
}

foreach (var existingDisc in db.Discs)
{
db.Remove(existingDisc);
}
foreach (var existingDisc in db.Discs)
{
db.Remove(existingDisc);
}

db.SaveChanges();
db.SaveChanges();

var infos = gameIds.Select(id => gameService.GetGameInfo(id));
var infos = gameIds.Select(id => gameService.GetGameInfo(id));

foreach (var info in infos) {
var game = new Game()
foreach (var info in infos)
{
Id = info.Id,
Title = info.Title,
Publisher = info.Publisher,
Year = info.Year,
Players = info.Players
};
var game = new Game()
{
Id = info.Id,
Title = info.Title,
Publisher = info.Publisher,
Year = info.Year,
Players = info.Players
};

game.Discs = info.DiscIds.Select((discId, index) => new Disc() { GameId = info.Id, DiscNumber = index + 1, DiscBasename = discId}).ToList();
game.Discs = info.DiscIds.Select((discId, index) => new Disc() { GameId = info.Id, DiscNumber = index + 1, DiscBasename = discId }).ToList();

db.Add(game);
db.Add(game);

Console.WriteLine($"Added game [{game.Id}] {game.Title} to the database");
}
Console.WriteLine($"Added game [{game.Id}] {game.Title} to the database");
}

db.SaveChanges();
db.SaveChanges();

Console.WriteLine($"Successfully inserted {gameIds.Count} games");
Console.WriteLine($"Successfully inserted {gameIds.Count} games");
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
}
}
Expand Down

0 comments on commit 0e4236e

Please # to comment.