Various updates to MyGeneration
Moved ItemInsert code to ItemInsertExt.cs
This commit is contained in:
@@ -64,27 +64,29 @@ public class GeneratedGui : DotNetScriptGui
|
||||
|
||||
GuiCheckBox chkDetail = MakeGuiCheckBox( "chkDetail", "MakeList & FK", true, "Show MakeList and FK",100 );
|
||||
chkDetail.Checked = false;
|
||||
GuiCheckBox chkColumns = MakeGuiCheckBox( "chkColumns", "Columns", true, "Show Columns" ,150,chkDetail,200,0);
|
||||
GuiCheckBox chkColumns = MakeGuiCheckBox( "chkColumns", "Columns", true, "Show Columns" ,150,chkDetail,150,0);
|
||||
chkColumns.Checked = false;
|
||||
GuiCheckBox chkFKCalc1 = MakeGuiCheckBox( "chkFKCalc1", "FK Calc 1", true, "FK Calc 1" ,150,chkDetail,400,0);
|
||||
GuiCheckBox chkFKCalc1 = MakeGuiCheckBox( "chkFKCalc1", "FK Calc 1", true, "FK Calc 1" ,150,chkDetail,300,0);
|
||||
chkFKCalc1.Checked = false;
|
||||
GuiCheckBox chkProc = MakeGuiCheckBox( "chkProc", "Procedures", true, "Procedures" ,150,chkDetail,450,0);
|
||||
chkProc.Checked = false;
|
||||
GuiCheckBox chkUnique = MakeGuiCheckBox( "chkUnique", "Unique", true, "Unique Indexes" ,150,chkDetail,0, -1);
|
||||
chkUnique.Checked = false;
|
||||
GuiCheckBox chkFKCalc2 = MakeGuiCheckBox( "chkFKCalc2", "FK Calc 2", true, "FK Calc 2" ,150,chkDetail,200, -1);
|
||||
GuiCheckBox chkFKCalc2 = MakeGuiCheckBox( "chkFKCalc2", "FK Calc 2", true, "FK Calc 2" ,150,chkDetail,150, -1);
|
||||
chkFKCalc2.Checked = false;
|
||||
GuiCheckBox chkColumns2 = MakeGuiCheckBox("chkColumns2","PrimFK",true,"Primary Foreign Key",150,chkDetail,400, -1);
|
||||
GuiCheckBox chkColumns2 = MakeGuiCheckBox("chkColumns2","PrimFK",true,"Primary Foreign Key",150,chkDetail,300, -1);
|
||||
chkColumns2.Checked = false;
|
||||
GuiCheckBox chkRelated = MakeGuiCheckBox("chkRelated","Related",true,"Related",150,chkDetail,0,-2);
|
||||
chkRelated.Checked = false;
|
||||
GuiCheckBox chkOne2One = MakeGuiCheckBox("chkOne2One","One to One",true,"One to Many and One to One",150,chkDetail,200, -2);
|
||||
GuiCheckBox chkOne2One = MakeGuiCheckBox("chkOne2One","One to One",true,"One to Many and One to One",150,chkDetail,150, -2);
|
||||
chkOne2One.Checked = false;
|
||||
GuiCheckBox chkIndexes = MakeGuiCheckBox("chkIndexes","Indexes",true,"Compare Foreign Keys to Indexes",150,chkDetail,400, -2);
|
||||
GuiCheckBox chkIndexes = MakeGuiCheckBox("chkIndexes","Indexes",true,"Compare Foreign Keys to Indexes",150,chkDetail,300, -2);
|
||||
chkIndexes.Checked = false;
|
||||
GuiCheckBox chkInternal = MakeGuiCheckBox("chkInternal","Internal",true,"Internal Relationships",150,chkDetail, 0, -3);
|
||||
chkInternal.Checked = false;
|
||||
GuiCheckBox chkAlias = MakeGuiCheckBox("chkAlias","Alias",true,"Aliases",150,chkDetail, 200, -3);
|
||||
GuiCheckBox chkAlias = MakeGuiCheckBox("chkAlias","Alias",true,"Aliases",150,chkDetail, 150, -3);
|
||||
chkAlias.Checked = false;
|
||||
GuiCheckBox chkNames = MakeGuiCheckBox("chkNames","Names",true,"Names",150,chkDetail, 400, -3);
|
||||
GuiCheckBox chkNames = MakeGuiCheckBox("chkNames","Names",true,"Names",150,chkDetail, 300, -3);
|
||||
chkNames.Checked = false;
|
||||
// Setup Tables selection multi-select listbox.
|
||||
GuiLabel label7 = ui.AddLabel( "label7", "Select tables:", "Select tables from the listbox below." );
|
||||
@@ -113,6 +115,7 @@ public class GeneratedGui : DotNetScriptGui
|
||||
chkInternal.AttachEvent( "onclick", "checkbox_onclick" );
|
||||
chkAlias.AttachEvent( "onclick", "checkbox_onclick" );
|
||||
chkNames.AttachEvent( "onclick", "checkbox_onclick" );
|
||||
chkProc.AttachEvent( "onclick", "checkbox_onclick" );
|
||||
chooseTables.AttachEvent( "onchange", "chooseTable_onclick" );
|
||||
ui.ShowGui = true;
|
||||
GuiButton btnOK = ui.AddButton( "OK", "OK", "Generate Code" );
|
||||
@@ -226,6 +229,7 @@ public class GeneratedGui : DotNetScriptGui
|
||||
GuiCheckBox chkInternal= ui["chkInternal"] as GuiCheckBox;
|
||||
GuiCheckBox chkAlias= ui["chkAlias"] as GuiCheckBox;
|
||||
GuiCheckBox chkNames= ui["chkNames"] as GuiCheckBox;
|
||||
GuiCheckBox chkProc = ui["chkProc"] as GuiCheckBox;
|
||||
GuiLabel labelTest = ui["labelTest"] as GuiLabel;
|
||||
string status = "";
|
||||
if(chkDetail.Checked)status+=", " + chkDetail.Text;
|
||||
@@ -240,6 +244,7 @@ public class GeneratedGui : DotNetScriptGui
|
||||
if(chkInternal.Checked)status+=", " + chkInternal.Text;
|
||||
if(chkAlias.Checked)status+=", " + chkAlias.Text;
|
||||
if(chkNames.Checked)status+=", " + chkNames.Text;
|
||||
if(chkProc.Checked)status+=", " + chkProc.Text;
|
||||
if(status == "")
|
||||
{
|
||||
btnOK.Enabled = false;
|
||||
@@ -326,21 +331,28 @@ public class GeneratedTemplate : DotNetScriptTemplate
|
||||
_selectedTables = input["chooseTables"] as ArrayList;
|
||||
dicIndexes = new Hashtable();
|
||||
dicDrop = new Hashtable();
|
||||
foreach( string _newTable in _selectedTables )
|
||||
if((bool)input["chkProc"])
|
||||
{
|
||||
_workingTable = MyMeta.Databases[_dbName].Tables[_newTable];
|
||||
if((bool)input["chkDetail"])ShowTable1( _workingTable );
|
||||
if((bool)input["chkColumns"])ShowTable2( _workingTable );
|
||||
if((bool)input["chkFKCalc1"])ShowTable3( _workingTable );
|
||||
if((bool)input["chkUnique"])ShowTable4( _workingTable );
|
||||
if((bool)input["chkFKCalc2"])ShowTable5( _workingTable );
|
||||
if((bool)input["chkColumns2"])ShowTable6( _workingTable );
|
||||
if((bool)input["chkRelated"])ShowTable7( _workingTable );
|
||||
if((bool)input["chkOne2One"])ShowTable8( _workingTable );
|
||||
if((bool)input["chkIndexes"])ShowTable9( _workingTable );
|
||||
if((bool)input["chkInternal"])ShowInternalRelated( _workingTable );
|
||||
if((bool)input["chkAlias"])ShowAlias( _workingTable );
|
||||
if((bool)input["chkNames"])ShowNames( _workingTable );
|
||||
ShowProcs(db);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach( string _newTable in _selectedTables )
|
||||
{
|
||||
_workingTable = MyMeta.Databases[_dbName].Tables[_newTable];
|
||||
if((bool)input["chkDetail"])ShowTable1( _workingTable );
|
||||
if((bool)input["chkColumns"])ShowTable2( _workingTable );
|
||||
if((bool)input["chkFKCalc1"])ShowTable3( _workingTable );
|
||||
if((bool)input["chkUnique"])ShowTable4( _workingTable );
|
||||
if((bool)input["chkFKCalc2"])ShowTable5( _workingTable );
|
||||
if((bool)input["chkColumns2"])ShowTable6( _workingTable );
|
||||
if((bool)input["chkRelated"])ShowTable7( _workingTable );
|
||||
if((bool)input["chkOne2One"])ShowTable8( _workingTable );
|
||||
if((bool)input["chkIndexes"])ShowTable9( _workingTable );
|
||||
if((bool)input["chkInternal"])ShowInternalRelated( _workingTable );
|
||||
if((bool)input["chkAlias"])ShowAlias( _workingTable );
|
||||
if((bool)input["chkNames"])ShowNames( _workingTable );
|
||||
}
|
||||
}
|
||||
//foreach(ITable tbl in db.Tables)
|
||||
//{
|
||||
@@ -355,6 +367,22 @@ public class GeneratedTemplate : DotNetScriptTemplate
|
||||
//}
|
||||
//SaveFile();
|
||||
}
|
||||
private void ShowProcs(IDatabase db)
|
||||
{
|
||||
foreach(IProcedure ip in db.Procedures)
|
||||
{
|
||||
//if(ip.Schema != "sys")
|
||||
if(ip.Name=="purgeData" || ip.Name=="ve_GetPath")
|
||||
{
|
||||
%>
|
||||
/****** Object: StoredProcedure [<%=ip.Name%>] Schema <%=ip.Schema%> Type <%=ip.Type.ToString()%> ******/
|
||||
<%
|
||||
bool isFunction=ip.ProcedureText.Contains("CREATE FUNCTION");
|
||||
output.writeln(string.Format("IsFunction = {0}",isFunction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string ForeignKeyCheck(IColumn col)
|
||||
{
|
||||
if(col.IsInForeignKey)
|
||||
|
Reference in New Issue
Block a user