示例#1
0
        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();
        }
示例#2
0
        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);
        }
示例#3
0
        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.");
        }
示例#4
0
        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.");
        }
示例#5
0
        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.");
        }
示例#6
0
        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);
        }
示例#7
0
        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.");
        }
示例#8
0
        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();
        }
示例#9
0
        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.");
        }
示例#10
0
        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.");
        }