ASP.NET三层架构源码(CodeSmith版)之八:View-BLL层

动软代码生成器生成的ASP.NET三层架构代码比较规范,是学习ASP.NET的好例子

此三层架构改造自动软的工厂模式模板,使用CodeSmith进行重写,以方便大家修改模板文件

以下是针对视图BLL层的源码:

<%@ CodeTemplate Language="C#" TargetLanguage="C#" Description="Generates a class including a special informational header" %>  
<%@ Assembly Name="SchemaExplorer" %>  
<%@ Import Namespace="SchemaExplorer" %>  
<%@ Import Namespace="System.Text" %>  

<%@ Property Name="ViewName" Type="ViewSchema"  DeepLoad="True" Optional="False" Category="01. Getting Started - Required" Description="" %>
<%@ Property Name="Namespace" Type="String" Category="Context" Description="NameSpace"%>  
<%@ Property Name="Author" Type="String" Category="Context"  Description="Author" Default="chenr"%>  
<%@ Property Name="ViewPrefix" Type="System.String" Default="T" Category="Context" Description="The prefix to remove from table names" %>  
/*------------------------------------------------ 
// File Name:<%=ClearPrefix(ViewName.Name) %>BLL.cs 
// File Description:<%=ClearPrefix(ViewName.Name) %> Business Logic 
// Author:<%=Author%> 
// Create Time:<%= DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")%> 
//------------------------------------------------*/  
  
using System;  
using System.Text; 
using System.Data;
using System.Collections.Generic;  

using <%=Namespace%>.DBUtility;
using <%=Namespace%>.Model; 
using <%=Namespace%>.DALFactory;
using <%=Namespace%>.IDAL;  
  
namespace <%=Namespace%>.BLL  
{  
    ///   
    /// <%=ClearPrefix(ViewName.Name) %>  
    ///   
    public partial class <%=ClearPrefix(ViewName.Name) %>
    {  
        private readonly I<%=ClearPrefix(ViewName.Name) %> dal = <%=Namespace%>DALFactory.Create<%=ClearPrefix(ViewName.Name) %>();
		public <%=ClearPrefix(ViewName.Name) %>() {}
		
        #region  BasicMethod
        
        /// 
		/// 得到最大ID
		/// 
		public int GetMaxId(string colName)
		{
			return dal.GetMaxId(colName);
		}

		/// 
		/// 是否存在该记录
		/// 
		public bool Exists()
		{
			return dal.Exists();
		}		

		/// 
		/// 获得数据列表
		/// 
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// 
		/// 获得前几行数据
		/// 
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}        

		/// 
		/// 获得数据列表
		/// 
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// 
		/// 分页获取数据列表
		/// 
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// 
		/// 分页获取数据列表
		/// 
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// 
		/// 分页获取数据列表
		/// 
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  BasicMethod
        
		#region  ExtensionMethod

		#endregion  ExtensionMethod
    }  
}