public static void SeedBattleLogsToSql(MongoConnection mongoConnection, BoardgameSimulatorData data) { if (data == null) { return; } var logs = new GenericData<DummyBattleLog>(mongoConnection.Database, "battlelogs"); var logsFromMongo = logs.GetAllDataFromCollection(); SeedDataFromMongoDb(data, null, null, null, null, logsFromMongo); }
public static void SeedToMongoDb(MongoConnection mongoConnection) { var database = mongoConnection.Database; Console.WriteLine("Seeding data to MongoDb initialized."); database.DropCollection("skills"); Console.WriteLine(DropCollectionMessage, "skills"); database.DropCollection("units"); Console.WriteLine(DropCollectionMessage, "units"); database.DropCollection("perks"); Console.WriteLine(DropCollectionMessage, "perks"); database.DropCollection("heroes"); Console.WriteLine(DropCollectionMessage, "heroes"); database.DropCollection("battlelogs"); Console.WriteLine(DropCollectionMessage, "battlelogs"); MongoCollection<DummySkill> skills = database.GetCollection<DummySkill>("skills"); MongoCollection<DummyUnit> units = database.GetCollection<DummyUnit>("units"); MongoCollection<DummyAlignmentPerk> perks = database.GetCollection<DummyAlignmentPerk>("perks"); MongoCollection<DummyHero> heroes = database.GetCollection<DummyHero>("heroes"); MongoCollection<DummyBattleLog> battleLogs = database.GetCollection<DummyBattleLog>("battlelogs"); var skillsSeed = DummySkills.GenerateSkillsList(); var unitsSeed = DummyUnits.GenerateUnitsList(200, 1234, 5, 20); var perksSeed = DummyAlignmentPerks.GenerateAlignmentsList(200); var heroesSeed = DummyHeroes.GenerateHeroesList(200); var battleLogsSeed = DummyBattleLogs.GenerateBattleLogsList(); var d = skillsSeed.Count; skills.InsertBatch(skillsSeed); Console.WriteLine(SeedMessage, d, "Skill"); d = unitsSeed.Count; units.InsertBatch(unitsSeed); Console.WriteLine(SeedMessage, d, "Unit"); d = perksSeed.Count; perks.InsertBatch(perksSeed); Console.WriteLine(SeedMessage, d, "Perk"); d = heroesSeed.Count; heroes.InsertBatch(heroesSeed); Console.WriteLine(SeedMessage, d, "Hero"); d = battleLogsSeed.Count; battleLogs.InsertBatch(battleLogsSeed); Console.WriteLine(SeedMessage, d, "BattleLog"); Console.WriteLine("Seeding of MongoDb completed!"); }
public static void SeedToSql(MongoConnection mongoConnection, BoardgameSimulatorData data) { if (data == null) { return; } var skills = new GenericData<DummySkill>(mongoConnection.Database, "skills"); var units = new GenericData<DummyUnit>(mongoConnection.Database, "units"); var perks = new GenericData<DummyAlignmentPerk>(mongoConnection.Database, "perks"); var heroes = new GenericData<DummyHero>(mongoConnection.Database, "heroes"); var skillsFromMongo = skills.GetAllDataFromCollection(); var unitsFromMongo = units.GetAllDataFromCollection(); var perksFromMongo = perks.GetAllDataFromCollection(); var heroesFromMongo = heroes.GetAllDataFromCollection(); SeedDataFromMongoDb(data, skillsFromMongo, unitsFromMongo, perksFromMongo, heroesFromMongo, null); }