protected void btnGo_Click(object sender, EventArgs e) { DataProvider provider = DataService.GetInstance(ddlProvider.SelectedValue); if (provider != null) { try { StringBuilder sbIndex = new StringBuilder(); ArrayList fileNames = new ArrayList(); bool outputCode = radOutputType.SelectedIndex == 0; string langIdentifier; ICodeLanguage language; string masterPageText = masterPageName.Text.Trim(); //string langPrefix; string fileExt; if (LanguageAbbreviation.IsCSharp(languageSelect.SelectedValue)) { langIdentifier = "C#"; language = new CSharpCodeLanguage(); fileExt = ".cs"; } else { langIdentifier = "VB"; language = new VBCodeLanguage(); fileExt = ".vb"; } foreach (ListItem item in chkTables.Items) { TurboCompiler turboCompiler = new TurboCompiler(); if (item.Selected) { string tableFileName = item.Value.Replace(" ", ""); string tableName = item.Value; string className = DataService.GetSchema(tableName, provider.Name, TableType.Table).ClassName; string fileNameNoExtension = tbxPrefix.Text.Trim() + FormatTableName(tableFileName) + tbxSuffix.Text.Trim(); string fileName = fileNameNoExtension + FileExtension.DOT_ASPX; string filePath = txtOut.Text + "\\" + fileName; fileNames.Add(filePath); NameValueCollection nVal = new NameValueCollection(); nVal.Add(TemplateVariable.LANGUAGE, langIdentifier); nVal.Add(TemplateVariable.CLASS_NAME, className); nVal.Add(TemplateVariable.TABLE_NAME, tableName); nVal.Add(TemplateVariable.MASTER_PAGE, masterPageText); if (outputCode) { nVal.Add(TemplateVariable.LANGUAGE_EXTENSION, fileExt); nVal.Add(TemplateVariable.PROVIDER, provider.Name); nVal.Add(TemplateVariable.PAGE_FILE, fileNameNoExtension); TurboTemplate scaffoldCodeBehind = CodeService.BuildTemplate(CodeService.TemplateType.GeneratedScaffoldCodeBehind, nVal, language, provider); scaffoldCodeBehind.AddUsingBlock = false; scaffoldCodeBehind.OutputPath = filePath.Replace(FileExtension.DOT_ASPX, (FileExtension.DOT_ASPX + fileExt)); turboCompiler.AddTemplate(scaffoldCodeBehind); TurboTemplate scaffoldMarkup = CodeService.BuildTemplate(CodeService.TemplateType.GeneratedScaffoldMarkup, nVal, language, provider); scaffoldMarkup.AddUsingBlock = false; scaffoldMarkup.OutputPath = filePath; turboCompiler.AddTemplate(scaffoldMarkup); } else { TurboTemplate dynamicScaffold = CodeService.BuildTemplate(CodeService.TemplateType.DynamicScaffold, nVal, language, provider); dynamicScaffold.AddUsingBlock = false; dynamicScaffold.OutputPath = filePath; turboCompiler.AddTemplate(dynamicScaffold); } sbIndex.AppendLine("<a href=\"" + fileName + "\">" + FormatTableName(tableName) + "</a><br/>"); } if (turboCompiler.Templates.Count > 0) { turboCompiler.Run(); foreach (TurboTemplate template in turboCompiler.Templates) { Utility.WriteTrace("Writing " + template.TemplateName + " as " + template.OutputPath.Substring(template.OutputPath.LastIndexOf("\\") + 1)); SubSonic.Sugar.Files.CreateToFile(template.OutputPath, template.FinalCode); } } } if (chkIndexPage.Checked && tbxIndexName.Text != String.Empty) { string before = "<html><head><title>SubSonic Scaffold Index Page</title></head><body>"; string after = "</body></html>"; WriteToFile(txtOut.Text + "\\" + tbxIndexName.Text, before + sbIndex + after); } lblResult.Text = "Finished"; } catch (Exception x) { lblResult.Text = "Error: " + x.Message; } } }