public static void Task3() { //Button - Create XML Report var context = new ComputersFactoryContext(); var path = @"..\..\..\"; var xmlReporter = new XmlExporter(context); xmlReporter.GenerateReport(path); }
public static void Task2() { //Button - Create PDF Rerpot var context = new ComputersFactoryContext(); var pdf = new PdfExporter(context); pdf.GenerateReport("../../../Pdf-Reports"); }
private void button8_Click(object sender, RoutedEventArgs e) { ComputersFactoryContext context = new ComputersFactoryContext(); var rootNode = XMLHandler.ReadXMLFile("../../../../XMLFile/Manufacturers.xml"); MongoDBHanlder mongoDbHandler = new MongoDBHanlder("ScrewdriverDB"); XMLHandler.TransferXMLToSQLServer(context, rootNode); XMLHandler.TransferXMLToMongoDB(mongoDbHandler, rootNode); }
private void button9_Click(object sender, RoutedEventArgs e) { SQLiteHandler.TransferSQLiteData(); var excelHandler = new ExcelHandler(); var context = new ComputersFactoryContext(); var mySqlHandler = new MySQLHandler(context); var excelExporter = new ExcelExporter(excelHandler, mySqlHandler); excelExporter.GenerateReport("../../../Excel-Reports/Reports.xlsx"); }
public static void Task5() { ComputersFactoryContext context = new ComputersFactoryContext(); var rootNode = XMLHandler.ReadXMLFile("../../../../XMLFile/Manufacturers.xml"); MongoDBHanlder mongoDbHandler = new MongoDBHanlder("ScrewdriverDB"); XMLHandler.TransferXMLToSQLServer(context, rootNode); XMLHandler.TransferXMLToMongoDB(mongoDbHandler, rootNode); }
public static void Task6() { SQLiteHandler.TransferSQLiteData(); var excelHandler = new ExcelHandler(); var context = new ComputersFactoryContext(); var mySqlHandler = new MySQLHandler(context); var excelExporter = new ExcelExporter(excelHandler, mySqlHandler); excelExporter.GenerateReport("../../../Excel-Reports/Reports.xlsx"); }
public static void TransferXMLToSQLServer(ComputersFactoryContext context, XmlNode rootNode) { foreach (XmlNode node in rootNode.ChildNodes) { context.Manufacturers.Add(new Manufacturer() { Name = node["name"].InnerText }); } context.SaveChanges(); }
public static void Task4() { //Button - Create JSON Report and Load data to MySQL var context = new ComputersFactoryContext(); var mySql = new MySQLHandler(context); var dataGenerator = new DataReportGenerator(); mySql.LoadReportsInMySql(dataGenerator); var exporter = new JsonExporter(context); exporter.GenerateReport("../../../Json-Reports"); }
public static void Task1() { //Button - Create Database Database.SetInitializer(new MigrateDatabaseToLatestVersion <ComputersFactoryContext, Configuration>()); var context = new ComputersFactoryContext(); context.Database.CreateIfNotExists(); //Button - Extract from Zip ZipHanlder.ExtractExcelFiles(@"..\..\..\..\Excel\Excel.zip"); //Button - Load Data from MongoDB to MSSQL var mongo = new MongoDBHanlder("ScrewdriverDB"); mongo.TransferToMSSQL().Wait(); //Button - Load data from Excel to MSSQL ExcelHandler.TransferAllData(); }
public List <Report> FillWithData(ComputersFactoryContext context) { var reports = new List <Report>(); foreach (var manufacturer in context.Manufacturers) { var report = new Report { ID = this.Id, ManufacturerName = manufacturer.Name, MemoryManufacturer = context.Manufacturers .SelectMany(m => m.Memorycards) .Select(m => m.Manufacturer.Name) .FirstOrDefault(), MemoryCapacity = context.Manufacturers .SelectMany(m => m.Memorycards) .Select(m => m.Capacity) .FirstOrDefault(), ProcessorModel = context.Manufacturers .SelectMany(p => p.Processors) .Select(p => p.Model) .FirstOrDefault(), ProcessorMhz = context.Manufacturers .SelectMany(p => p.Processors) .Select(p => p.MhZ) .FirstOrDefault(), VideoCardModel = context.Manufacturers .SelectMany(v => v.Videocards) .Select(v => v.Model) .FirstOrDefault(), VideoCardMemory = context.Manufacturers .SelectMany(v => v.Videocards) .Select(v => v.Memory) .FirstOrDefault() }; reports.Add(report); } return(reports); }
public static void TransferItems(Dictionary <string, List <string> > data, Type dataType) { using (var factoryContext = new ComputersFactoryContext()) { var itemSet = factoryContext.Set(dataType); int count = data[data.Keys.FirstOrDefault()].Count; for (int i = 0; i < count; i++) { var item = Activator.CreateInstance(dataType); foreach (var key in data.Keys) { var itemProperty = item.GetType().GetProperty(key); Type propertyType = itemProperty.PropertyType; var value = Convert.ChangeType(data[key][i], propertyType); itemProperty.SetValue(item, value); } itemSet.Add(item); } factoryContext.SaveChanges(); } }
public PdfExporter(ComputersFactoryContext context) { this.dbContext = context; }
public JsonExporter(ComputersFactoryContext context) { this.context = context; }
public MySQLHandler(ComputersFactoryContext context) { this.dbContext = context; }
public MainWindow() { InitializeComponent(); this.dbContext = new ComputersFactoryContext(); }
public async Task TransferToMSSQL() { var factoryContext = new ComputersFactoryContext(); var manufacturers = (await this.GetData <Manufacturer>("Manufacturers")).ToList(); var processors = (await this.GetData <Processor>("Processors")).ToList(); var memorycards = (await this.GetData <Memorycard>("Memorycards")).ToList(); var videocards = (await this.GetData <Videocard>("Videocards")).ToList(); var computerTypes = (await this.GetData <ComputerType>("ComputerTypes")).ToList(); var computers = (await this.GetData <Computer>("Computers")).ToList(); try { using (factoryContext) { foreach (var manufacturer in manufacturers) { factoryContext.Manufacturers.Add(manufacturer); } foreach (var processor in processors) { factoryContext.Processors.Add(processor); } foreach (var memorycard in memorycards) { factoryContext.Memorycards.Add(memorycard); } foreach (var videocard in videocards) { factoryContext.Videocards.Add(videocard); } foreach (var type in computerTypes) { factoryContext.ComputerTypes.Add(type); } factoryContext.SaveChanges(); foreach (var computer in computers) { factoryContext.Computers.Add(computer); } factoryContext.SaveChanges(); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } }