private static void ImportProducesFromExcel() { var db = new ChemicalsDbContext(); IZipExtractor zipExtractor = new ZipExtractor(); ExcelImporter <Produce> k = new ExcelImporter <Produce>(zipExtractor); ICollection <Produce> produces = k.ImportModelsDataFromZipFile("../../../Files/Produces.zip", "./tests1"); foreach (var item in produces) { db.Produces.Add(item); } db.SaveChanges(); }
private static void ImportTradersFromXml(string path) { var xmlImporter = new XmlDataImporter(); var dbContext = new ChemicalsDbContext(); var traders = xmlImporter.LoadTraders(path); foreach (var trader in traders) { dbContext.Traders.Add(trader); } dbContext.SaveChanges(); dbContext.Dispose(); ExportXmlTradersToMongo(traders); }
private static void ImportSalesFromExcel() { var db = new ChemicalsDbContext(); IZipExtractor zipExtractor = new ZipExtractor(); ExcelImporter <Sale> k = new ExcelImporter <Sale>(zipExtractor); ICollection <Sale> sales = k.ImportModelsDataFromZipFile("../../../Files/Sales.zip", "./tests2"); foreach (var item in sales) { db.Sales.Add(item); } db.SaveChanges(); Console.WriteLine("The data was successfully imported to SQL Server."); }
private static void ImportManufacturersFromXml(string path) { var xmlImporter = new XmlDataImporter(); var dbContext = new ChemicalsDbContext(); var manufacturers = xmlImporter.LoadManufecturers(path); foreach (var manufacturer in manufacturers) { dbContext.Manufacturers.Add(manufacturer); } dbContext.SaveChanges(); dbContext.Dispose(); ExportXmlManufacturersToMongo(manufacturers); Console.WriteLine("The data was successfully imported to SQL Server and to MongoDB."); }
private static void ImportDataFromMongo() { var dbContext = new ChemicalsDbContext(); var mongoProvider = new MongoProvider( System.Configuration.ConfigurationManager.ConnectionStrings["MolybdenumDb"].ConnectionString, System.Configuration.ConfigurationManager.ConnectionStrings["MolybdenumDb"].Name); var mongoDatabase = mongoProvider.GetDatabase(); var mongoImporter = new MongoImporter(); var products = mongoImporter.GetAllProducts(mongoDatabase, "Products"); foreach (var product in products) { dbContext.Products.Add(product); } dbContext.SaveChanges(); Console.WriteLine("The data was successfully imported to the SQL Server."); }
private static void ImportSalesFromExcel() { var db = new ChemicalsDbContext(); IZipExtractor zipExtractor = new ZipExtractor(); ExcelImporter<Sale> k = new ExcelImporter<Sale>(zipExtractor); ICollection<Sale> sales = k.ImportModelsDataFromZipFile("../../../Files/Sales.zip", "./tests2"); foreach (var item in sales) { db.Sales.Add(item); } db.SaveChanges(); Console.WriteLine("The data was successfully imported to SQL Server."); }
private static void ImportProducesFromExcel() { var db = new ChemicalsDbContext(); IZipExtractor zipExtractor = new ZipExtractor(); ExcelImporter<Produce> k = new ExcelImporter<Produce>(zipExtractor); ICollection<Produce> produces = k.ImportModelsDataFromZipFile("../../../Files/Produces.zip", "./tests1"); foreach (var item in produces) { db.Produces.Add(item); } db.SaveChanges(); }