Various updates to MyGeneration
Moved ItemInsert code to ItemInsertExt.cs
This commit is contained in:
@@ -70,6 +70,7 @@ public class GeneratedGui : DotNetScriptGui
|
||||
GuiCheckBox chkDrop = MakeGuiCheckBox( "chkDrop", "Drop", true, "Drop Procedures" ,150,chkDelete,200,0);
|
||||
GuiCheckBox chkSelectPK = MakeGuiCheckBox( "chkSelectPK", "Select One", true, "Select One Record" ,150,chkInsert,0,-1);
|
||||
GuiCheckBox chkExists = MakeGuiCheckBox("chkExists","Exists",true,"Check Record Exists",150,chkSelectPK,150,0);
|
||||
GuiCheckBox chkVolian = MakeGuiCheckBox( "chkVolian", "Volian SPs", true, "Include Volian SPs" ,150,chkExists,200,0);
|
||||
GuiCheckBox chkPurge = MakeGuiCheckBox("chkPurge","Purge",true,"Purge All Data",150,chkSelectPK,0,-1);
|
||||
GuiCheckBox chkSelectFKs = MakeGuiCheckBox("chkSelectFKs","Select Group",true,"Select by Foreign Key",150,chkPurge,150,0);
|
||||
|
||||
@@ -223,22 +224,44 @@ public class GeneratedTemplate : DotNetScriptTemplate
|
||||
SaveProcs(db);
|
||||
//SaveTables(db);
|
||||
}
|
||||
private bool IncludeVolian(string sName)
|
||||
{
|
||||
return (!sName.StartsWith("ve") || (bool)input["chkVolian"]);
|
||||
}
|
||||
private void SaveProcsTesting(IDatabase db)
|
||||
{
|
||||
foreach(IProcedure ip in db.Procedures)
|
||||
{
|
||||
if(ip.Name == "vefn_SplitROSearch" || ip.Name == "ve_GetPath" || ip.Name == "getItemAndChildren")
|
||||
{
|
||||
output.writeln(string.Format("Name = '{0}' ",ip.Name));
|
||||
output.writeln(string.Format("Schema = '{0}' ",ip.Schema));
|
||||
foreach(IParameter param in ip.Parameters)
|
||||
{
|
||||
output.writeln(string.Format(" Parameter - {0} = {1}",param.Name,param.ParameterType));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SaveProcs(IDatabase db)
|
||||
{
|
||||
foreach(IProcedure ip in db.Procedures)
|
||||
{
|
||||
if(ip.Schema != "sys"){
|
||||
bool isProc = IsProcedure(ip);
|
||||
string sType = isProc ? "PROCEDURE" : "FUNCTION";
|
||||
string sIsType = isProc ? "Procedure" : (IsTableFunction(ip) ? "TableFunction" : "ScalarFunction");
|
||||
string sName = ip.Name;
|
||||
if((bool)input["chkDrop"]){
|
||||
if(sName.Contains("sp_")==false && sName.Contains("fn_")==false)
|
||||
output.writeln("Drop procedure [" + sName + "]");
|
||||
if(sName.StartsWith("sp_")==false && sName.StartsWith("fn_")==false && IncludeVolian(sName))
|
||||
output.writeln("DROP " + sType + " [" + sName + "]");
|
||||
} else {
|
||||
if(sName.Contains("sp_")==false && sName.Contains("fn_")==false)
|
||||
if(sName.StartsWith("sp_")==false && sName.StartsWith("fn_")==false && IncludeVolian(sName))
|
||||
{
|
||||
%>
|
||||
/****** Object: StoredProcedure [<%=sName%>] ******/
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[<%=sName%>]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
|
||||
DROP PROCEDURE [<%=sName%>];
|
||||
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[<%=sName%>]') AND OBJECTPROPERTY(id,N'Is<%=sIsType%>') = 1)
|
||||
DROP <%=sType%> [<%=sName%>];
|
||||
GO
|
||||
|
||||
<%
|
||||
@@ -246,8 +269,8 @@ GO
|
||||
%>
|
||||
GO
|
||||
-- Display the status of Proc creation
|
||||
IF (@@Error = 0) PRINT 'Procedure Creation: <%=sName%> Succeeded'
|
||||
ELSE PRINT 'Procedure Creation: <%=sName%> Error on Creation'
|
||||
IF (@@Error = 0) PRINT '<%=sIsType%> Creation: <%=sName%> Succeeded'
|
||||
ELSE PRINT '<%=sIsType%> Creation: <%=sName%> Error on Creation'
|
||||
GO
|
||||
<%
|
||||
SaveFile(ip.Name);
|
||||
@@ -256,6 +279,14 @@ GO
|
||||
}
|
||||
}
|
||||
}
|
||||
private bool IsProcedure(IProcedure ip)
|
||||
{
|
||||
return ip.ProcedureText.Contains("CREATE PROCEDURE");
|
||||
}
|
||||
private bool IsTableFunction(IProcedure ip)
|
||||
{
|
||||
return ip.Parameters[0].Name == "@TABLE_RETURN_VALUE";
|
||||
}
|
||||
private void ShowColumns(IColumns cols,int indent,string title)
|
||||
{
|
||||
output.writeln(string.Format("{0}{1}","".PadRight(indent),title));
|
||||
|
Reference in New Issue
Block a user