public DatabaseLoaderTemplate(DatabaseLoaderGenerator g) { this.generator = g; }
private void btnStartGenerate_Click(object sender, EventArgs e) { // TODO: Refactor this code (group generator ->>>>>>) // DESKTOP-1RVEUQ2 // Get list table is selected to generate var tables = listBoxDBTable.SelectedItems.Cast <Table>().ToList(); // Get project information to generate var projectInfo = bindingSourceProjectInfo.Current as ProjectInfo; if (!projectInfo.IsOKToGenerate()) { return; } // Start Generate Project var solution = new SolutionGenerator(projectInfo.SolutionName); var project1 = new ProjectGenerator(projectInfo.ProjectName); NamespaceHelper.Instance.ProjectNamespace = project1.Name; // Generate Form var loginForm = new LoginFormGenerator(); var loginFormDesigner = new LoginFormDesignerGenerator(loginForm); var viewListTableForm = new ViewListTableFormGenerator(); var viewListTableFormDesigner = new ViewListTableFormDesignerGenerator(viewListTableForm); var viewTableForm = new ViewTableFormGenerator(); var viewTableFormDesigner = new ViewTableFormDesignerGenerator(viewTableForm); // Generate Essential Class var dbLoader = new DatabaseLoaderGenerator(tables, DatabaseLoader.Instance.ConnectionStringBuilder); var enumFormType = new EnumFormTypeGenerator(); var program = new ProgramGenerator(viewListTableForm); // Generate Model And Forms foreach (var table in tables) { // Generate Model var modelGen = new ModelGenerator(table); var modelDaoGen = new ModelDaoGenerator(table); // Generate View Table Form var viewConcreteTableForm = new ViewConcreteTableFormGenerator(table, viewTableForm); var viewConreteTableFormDesigner = new ViewConcreteTableFormDesignerGenerator(table.Name, viewConcreteTableForm); // Generate Edit Form var editForm = new EditFormGenerator(table); var editFormDesigner = new EditFormDesignerGenerator(table, editForm); project1.Add(modelGen); project1.Add(modelDaoGen); project1.Add(viewConcreteTableForm); project1.Add(viewConreteTableFormDesigner); project1.Add(editForm); project1.Add(editFormDesigner); } // Generate View Table Form Factory var viewTableFormFactory = new ViewTableFormFactoryGenerator(tables); //------------------------------------------------------------------------------------------------- // Add to project and solution project1.Add(dbLoader); project1.Add(enumFormType); project1.Add(program); project1.Add(loginForm); project1.Add(loginFormDesigner); project1.Add(viewListTableForm); project1.Add(viewListTableFormDesigner); project1.Add(viewTableForm); project1.Add(viewTableFormDesigner); project1.Add(viewTableFormFactory); solution.Add(project1); solution.ExportToFile(projectInfo.Path); // Copy Custom Hibernate SQL to Generated Project CopyHibernateSQLToProject(projectInfo.SolutionPath, project1.Name); Close(); }