-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreatSingleTable.cst
69 lines (60 loc) · 2.46 KB
/
CreatSingleTable.cst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<%@ CodeTemplate Language="C#" ResponseEncoding="UTF-8" TargetLanguage="Text" Src="" Inherits="" Debug="False" Description="Template description here."
Output="None"%>
<%@ Register Name="Models" Template="Models.cst"
MergeProperties="False" ExcludeProperties="" %>
<%@ Register Name="DAL" Template="DAL.cst"
MergeProperties="False" ExcludeProperties="" %>
<%@ Register Name="BLL" Template="BLL.cst"
MergeProperties="False" ExcludeProperties="" %>
<%@ Register Name="MySqlDBHelper" Template="MySqlDBHelper.cst"
MergeProperties="False" ExcludeProperties="" %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Optional="False"%>
<%@ Property Name="RootNamespace" Default="MysqlNamesapce" Type="System.String" Optional="False"%>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Assembly Name="System.Data" %>
<%@ Import Namespace="SchemaExplorer" %>
<%@ Import Namespace="System.Data" %>
<script runat="template">
private string _outputDirectory = String.Empty;
[Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
[Description("The directory to output the results to.")]
public string OutputDirectory
{
get
{
return _outputDirectory;
}
set
{
if (value != null && !value.EndsWith("\\"))
{
value += "\\";
}
_outputDirectory = value;
}
}
</script>
<%
Models model = this.Create<Models>();
model.ModelsNamespace = this.RootNamespace+".DBModel";
model.TargetTable = this.SourceTable;
model.RenderToFile(this.OutputDirectory+"DBModels/"+model.GetFileName(),true);
DAL dal = this.Create<DAL>();
dal.TargetTable = this.SourceTable;
dal.ModelsNamespace = model.ModelsNamespace;
dal.DALClassNameSurfix = "DAL";
dal.DALNamespace =this.RootNamespace+".DAL";
dal.RenderToFile(this.OutputDirectory+"DAL/"+dal.GetFileName(),true);
BLL bll = this.Create<BLL>();
bll.ModelsNamespace = model.ModelsNamespace;
bll.DALClassNameSurfix = dal.DALClassNameSurfix;
bll.DALNamespace = dal.DALNamespace;
bll.BLLClassNameSurfix = "BLL";
bll.BLLNamespace = this.RootNamespace+".BLL";
bll.TargetTable = this.SourceTable;
bll.RenderToFile(this.OutputDirectory+"BLL/"+bll.GetFileName(),true);
MySqlDBHelper helper=this.Create<MySqlDBHelper>();
helper.Namespace = this.RootNamespace;
helper.RenderToFile(this.OutputDirectory+helper.GetFileName(),true);
Response.Write("ok,see "+this.OutputDirectory+"\r\n");
%>