public bool LoadAllReportsDataFromSQLServer() { try { var reportEngine = new ReportsEngine(new CoffeeCompanyData()); var reportInfo = reportEngine.GetOrderInfo(); this.AddReports(reportInfo); return true; } catch (Exception) { return false; } }
private void ParseExportCommand() { renderer.PrintExportLegend(); this.ReportGenerator = new ReportsEngine(Data); this.ExcelManager = new ExcelManager(); string command = Console.ReadLine(); switch (command.ToLower()) { case "json": { this.ReportGenerator.GetJsonOrderInfoReport(); this.renderer.CompletedMessage(); ParseExportCommand(); break; } case "xml": { ParseXmlExport(); this.renderer.CompletedMessage(); ParseExportCommand(); break; } case "excel": { this.ExcelManager.CreateExcelReport(); this.renderer.CompletedMessage(); ParseExportCommand(); break; } case "mysql": { MySqlManager.LoadAllReportsDataFromSQLServer(); this.renderer.CompletedMessage(); ParseExportCommand(); break; } case "back": InitiateCommandMenu(); break; default: renderer.InvalidCommandMessage(); break; } }
private void ToMySQLButton_Click(object sender, RoutedEventArgs e) { bool result = false; var mySqlManager = new MySQLManager(); mySqlManager.ClearMySqlDb(); result = mySqlManager.LoadAllReportsDataFromSQLServer(); var sqLiteManager = new SQLiteManager(); sqLiteManager.DeleteAllEntities("Discounts"); var reportsEngine = new ReportsEngine(); var discounts = reportsEngine.GetDiscountsInfo(); foreach (var discount in discounts) { result = sqLiteManager.CreateDiscountForCompany(discount.CompanyId, discount.TypeID); } if (result) { Result.Text = "Import to MySQL has been successfully completed!"; Result.Foreground = Brushes.Green; } else { Result.Text = "Import to MySQL failed!"; Result.Foreground = Brushes.Red; } }