105 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
			
		
		
	
	
			105 lines
		
	
	
		
			4.4 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
| <%@ Template Language="C#" TargetLanguage="Text" %>
 | ||
| <%-- 注册要生成的模板 --%>
 | ||
| <%@ Register Name="basicImplements" Template="basicImplements.cst" MergeProperties="Flase" ExcludeProperties=""%>
 | ||
| <%@ Register Name="basicObject" Template="basicObject.cst" MergeProperties="Flase" ExcludeProperties=""%>
 | ||
| <%@ Register Name="extModelClass" Template="extModelClass.cst" MergeProperties="Flase" ExcludeProperties=""%>
 | ||
| <%@ Register Name="extModelImpl" Template="extModelImpl.cst" MergeProperties="Flase" ExcludeProperties=""%>
 | ||
| <%@ Register Name="logic" Template="logic.cst" MergeProperties="Flase" ExcludeProperties=""%>
 | ||
| <%@ Register Name="wcfData" Template="WCFdata.cst" MergeProperties="Flase" ExcludeProperties=""%>
 | ||
| <%--声明数据库的参数,在左下角的Database属性中,选择要操作的数据库名称--%>
 | ||
| <%@ Property Name="SourceDatabase" Type="DatabaseSchema" DeepLoad="True" Optional="False" Category="Context" Description="Database that the documentation should be based on." %>
 | ||
| <%--Type数据类型为TableSchema,表明参数Table是一个表对象。--%>
 | ||
| <%@ Property Name="SourceTable" Type="TableSchema" DeepLoad="True" Optional="False" Category="Table" Description="Table Name"%>
 | ||
| <%-- 执行输出文件的函数 --%>
 | ||
| <%this.OutPutFile(); %>
 | ||
| <script runat="template">
 | ||
| 
 | ||
| public string getClassName()
 | ||
| { 
 | ||
|     string tablename = this.SourceTable.Name.Substring(2);
 | ||
|     string firstChar = tablename.Substring(0,1);
 | ||
|     string className = firstChar.ToUpper() + tablename.Substring(1);
 | ||
|     return className ;
 | ||
| 	 //return  this.SourceTable.Name.Substring(2);
 | ||
| }
 | ||
| 
 | ||
|     
 | ||
|     //输出文件
 | ||
|     private void OutPutFile()
 | ||
|     {
 | ||
|         //生成列举表名的模板
 | ||
|         CodeTemplate basicImplements =new basicImplements();
 | ||
|         //指定输出路径
 | ||
|         string  filePath = OutputDirectory +"\\data\\basic\\"+ getClassName() + "_base_Imp"   +".cs";
 | ||
|         //给子模板参数赋值
 | ||
|         basicImplements.SetProperty("SourceDatabase",this.SourceDatabase);
 | ||
|         basicImplements.SetProperty("SourceTable",this.SourceTable);
 | ||
|         basicImplements.RenderToFile(filePath,true);
 | ||
|         
 | ||
|         //生成列表表字段的模板
 | ||
|         CodeTemplate basicObject =new basicObject();
 | ||
|         //指定输出路径
 | ||
|           filePath = OutputDirectory +"\\data\\basic\\"+  getClassName() + "_base"   +".cs";
 | ||
|          //给子模板参数赋值
 | ||
|         basicObject.SetProperty("SourceDatabase",this.SourceDatabase);
 | ||
|         basicObject.SetProperty("SourceTable",this.SourceTable);
 | ||
|         basicObject.RenderToFile(filePath,true);
 | ||
|         
 | ||
|         
 | ||
|         
 | ||
|         CodeTemplate extModelImpl =new extModelImpl();
 | ||
|         //指定输出路径
 | ||
|           filePath = OutputDirectory +"\\data\\"+  getClassName() + "_Imp"   +".cs";
 | ||
|          //给子模板参数赋值
 | ||
|         extModelImpl.SetProperty("SourceTable",this.SourceTable);
 | ||
|         extModelImpl.RenderToFile(filePath,false);//not overwrite
 | ||
|         
 | ||
|           CodeTemplate extModelClass =new extModelClass();
 | ||
|         //指定输出路径
 | ||
|           filePath = OutputDirectory +"\\tables\\"+  getClassName()    +".cs";
 | ||
|          //给子模板参数赋值
 | ||
|         extModelClass.SetProperty("SourceTable",this.SourceTable);
 | ||
|         extModelClass.RenderToFile(filePath,false);//not overwrite
 | ||
|         
 | ||
|         
 | ||
|         CodeTemplate logic =new logic();
 | ||
|         //指定输出路径
 | ||
|           filePath = OutputDirectory +"\\logic\\l"+  getClassName()    +".cs";
 | ||
|          //给子模板参数赋值
 | ||
|         logic.SetProperty("SourceTable",this.SourceTable);
 | ||
|         logic.RenderToFile(filePath,false);//not overwrite
 | ||
|         
 | ||
|         
 | ||
|           CodeTemplate wcfData =new wcfData();
 | ||
|         //指定输出路径
 | ||
|           filePath = OutputDirectory +"\\wcfData\\wcf"+  getClassName()    +".cs";
 | ||
|          //给子模板参数赋值
 | ||
|         wcfData.SetProperty("SourceDatabase",this.SourceDatabase);
 | ||
|         wcfData.SetProperty("SourceTable",this.SourceTable);
 | ||
|         wcfData.RenderToFile(filePath,false);//not overwrite
 | ||
|         
 | ||
|         
 | ||
|         
 | ||
|         
 | ||
|         
 | ||
|         
 | ||
|         
 | ||
|     }
 | ||
|     //解决方案输出路径
 | ||
|     private string Directory = String.Empty;
 | ||
|     [Editor(typeof(System.Windows.Forms.Design.FolderNameEditor), typeof(System.Drawing.Design.UITypeEditor))] 
 | ||
|     [Optional, NotChecked]
 | ||
|     [DefaultValue("")]
 | ||
|     public string OutputDirectory 
 | ||
|     { 
 | ||
|         get
 | ||
|         {
 | ||
|             return Directory;
 | ||
|         }
 | ||
|         set
 | ||
|         {
 | ||
|             if (value.EndsWith("\\")) value = value.Substring(0, value.Length -1);
 | ||
|             Directory = value;
 | ||
|         } 
 | ||
|     }
 | ||
| </script> |