private async void btnImportDataIntoSqlServer_Click(object sender, EventArgs e) { this.btnImportDataIntoSqlServer.Enabled = false; //const string User = "******"; //const string Pass = "******"; //const string DbHost = "ds029565.mlab.com"; //const int DbPort = 29565; //const string DbName = "appharbor_5cwg75nh"; //var credentials = MongoCredential.CreateCredential(DbName, User, Pass); //var settings = new MongoClientSettings //{ // Server = new MongoServerAddress(DbHost, DbPort), // Credentials = new List<MongoCredential> { credentials } //}; //var client = new MongoClient(settings); //var mongoDb = client.GetDatabase(DbName); try { await ImportIntoSqlServer.ImportFromMongoDB(); string zipPath = $"{this.ExeDirectory}reports.zip"; await ImportIntoSqlServer.ImportFromZipFile(zipPath); // Adding teams //var seasonsSourceRepository = new MongoRepository<SeasonMongo>(mongoDb); //var dbContext = new NBAStatisticsDbContext(); //var teamsRepository = new EfRepository<NBAStatistics.Models.Team>(dbContext); //var teamsUnitOfWork = new EfUnitOfWork(dbContext); //var teamsImporter = new TeamsImporter(seasonsSourceRepository, teamsRepository, teamsUnitOfWork); //await teamsImporter.Import(); //// Adding players //var playersSourceRepository = new MongoRepository<PlayerMongo>(mongoDb); //dbContext = new NBAStatisticsDbContext(); //var playersRepository = new EfRepository<NBAStatistics.Models.Player>(dbContext); //teamsRepository = new EfRepository<NBAStatistics.Models.Team>(dbContext); //var playersUnitOfWork = new EfUnitOfWork(dbContext); //var playersImporter = new PlayersImporter(playersSourceRepository, playersRepository, teamsRepository, playersUnitOfWork); //await playersImporter.Import(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.btnImportDataIntoSqlServer.Enabled = true; }
private async void btnImportDataIntoSqlServer_Click(object sender, EventArgs e) { this.btnImportDataIntoSqlServer.Enabled = false; try { await ImportIntoSqlServer.Import(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.btnImportDataIntoSqlServer.Enabled = true; }