Beispiel #1
0
        private static void GenerateJsonReports()
        {
            var dbContext = new ChemicalsDbContext();

            var listOfProducts = dbContext.Products.ToList();

            JSONReportGenerator.ExportProducts(listOfProducts, "../../../Reports/");

            Console.WriteLine("The reports was successfully generated.");
        }
Beispiel #2
0
        private static void GetAllProducts()
        {
            using (var dbContext = new ChemicalsDbContext())
            {
                var products = dbContext.Products.ToList();

                foreach (var product in products)
                {
                    Console.WriteLine("{0}, {1}, {2}, {3}", product.Id, product.Name, product.Formula, product.PricePerUnit);
                }
            }
        }
Beispiel #3
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();
        }
Beispiel #4
0
        private static void GenerateXmlReports(string pathToSave)
        {
            using (var db = new ChemicalsDbContext())
            {
                var manufacturers = (from man in db.Manufacturers.Include("Name")
                                     join p in db.Produces on man.Id equals p.ManufacturerId
                                     join pr in db.Products.Include("Name").Include("Formula") on p.ProductId equals pr.Id
                                     select new
                {
                    ManufacturerName = man.Name,
                    ProductName = pr.Name,
                    Amount = p.Amount,
                    Formula = pr.Formula
                }).ToList();

                var manufacturersList = new List <XmlManufacturer>();
                var productsList      = new List <XmlProduct>();

                foreach (var manufacturer in manufacturers)
                {
                    productsList.Add(new XmlProduct
                    {
                        Name    = manufacturer.ProductName,
                        Amout   = manufacturer.Amount,
                        Formula = manufacturer.Formula
                    });

                    var currentManufacturer = new XmlManufacturer
                    {
                        Name     = manufacturer.ManufacturerName,
                        Products = productsList
                    };

                    manufacturersList.Add(currentManufacturer);
                }

                var report = new XmlReportModel
                {
                    Manufacturers = manufacturersList
                };

                var reportGenerator = new XmlReportGenerator();
                reportGenerator.ExportXmlReport(report, pathToSave);
            }

            Console.WriteLine("The report was successfully generated.");
        }
Beispiel #5
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);
        }
Beispiel #6
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.");
        }
Beispiel #7
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.");
        }
Beispiel #8
0
        private static void GeneratePdfReports()
        {
            var pdfReportsGenerator = new PdfReportGenerator();

            var dbContext = new ChemicalsDbContext();

            var deals = dbContext.Sales
                        .Select(d => new PdfReportModel
            {
                ProductName  = d.Product.Name,
                Quantity     = (d.Quantity + " " + d.Product.Measure.MeasureName).ToString(),
                PricePerUnit = d.Product.PricePerUnit.ToString(),
                Formula      = d.Product.Formula,
                Address      = d.Trader.Address,
                Total        = (d.Quantity * d.Product.PricePerUnit).ToString()
            }).ToList();

            pdfReportsGenerator.GenerateReport(deals);

            Console.WriteLine("The report was successfully generated.");
        }
Beispiel #9
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.");
        }
Beispiel #10
0
        private static void GenerateJsonReports()
        {
            var dbContext = new ChemicalsDbContext();

            var listOfProducts = dbContext.Products.ToList();

            JSONReportGenerator.ExportProducts(listOfProducts, "../../../Reports/");

            Console.WriteLine("The reports was successfully generated.");
        }
Beispiel #11
0
        private static void GenerateXmlReports(string pathToSave)
        {
            using (var db = new ChemicalsDbContext())
            {
                var manufacturers = (from man in db.Manufacturers.Include("Name")
                                     join p in db.Produces on man.Id equals p.ManufacturerId
                                     join pr in db.Products.Include("Name").Include("Formula") on p.ProductId equals pr.Id
                                     select new
                                     {
                                         ManufacturerName = man.Name,
                                         ProductName = pr.Name,
                                         Amount = p.Amount,
                                         Formula = pr.Formula
                                     }).ToList();

                var manufacturersList = new List<XmlManufacturer>();
                var productsList = new List<XmlProduct>();

                foreach (var manufacturer in manufacturers)
                {
                    productsList.Add(new XmlProduct
                    {
                        Name = manufacturer.ProductName,
                        Amout = manufacturer.Amount,
                        Formula = manufacturer.Formula
                    });

                    var currentManufacturer = new XmlManufacturer
                    {
                        Name = manufacturer.ManufacturerName,
                        Products = productsList
                    };

                    manufacturersList.Add(currentManufacturer);
                }

                var report = new XmlReportModel
                {
                    Manufacturers = manufacturersList
                };

                var reportGenerator = new XmlReportGenerator();
                reportGenerator.ExportXmlReport(report, pathToSave);
            }

            Console.WriteLine("The report was successfully generated.");
        }
Beispiel #12
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);
        }
Beispiel #13
0
        private static void GeneratePdfReports()
        {
            var pdfReportsGenerator = new PdfReportGenerator();

            var dbContext = new ChemicalsDbContext();

            var deals = dbContext.Sales
                    .Select(d => new PdfReportModel
                    {
                        ProductName = d.Product.Name,
                        Quantity = (d.Quantity + " " + d.Product.Measure.MeasureName).ToString(),
                        PricePerUnit = d.Product.PricePerUnit.ToString(),
                        Formula = d.Product.Formula,
                        Address = d.Trader.Address,
                        Total = (d.Quantity * d.Product.PricePerUnit).ToString()
                    }).ToList();

            pdfReportsGenerator.GenerateReport(deals);

            Console.WriteLine("The report was successfully generated.");
        }
Beispiel #14
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.");
        }
Beispiel #15
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();
        }
Beispiel #16
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.");
        }
Beispiel #17
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.");
        }
Beispiel #18
0
        private static void GetAllProducts()
        {
            using (var dbContext = new ChemicalsDbContext())
            {
                var products = dbContext.Products.ToList();

                foreach (var product in products)
                {
                    Console.WriteLine("{0}, {1}, {2}, {3}", product.Id, product.Name, product.Formula, product.PricePerUnit);
                }
            }
        }