[C#] 한 걸음 한 걸음 자신의 자동 코드 생성 도구 개발 6: 업무층 템플릿

삼.BLL 템플릿
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/">
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using <xsl:value-of select="TabelModel/NameSpacePri"/>Model;
using <xsl:value-of select="TabelModel/NameSpacePri"/>DAL;
namespace <xsl:value-of select="TabelModel/NameSpacePri"/>BLL
{
 public partial class <xsl:value-of select="TabelModel/ModelName"/>BLL
 {
  #region  / 
  
  /// <summary>
  ///
  /// </summary>
  private <xsl:value-of select="TabelModel/ModelName"/>DAL DAL = null;
  /// <summary>
  ///
  ///</summary>
  public <xsl:value-of select="TabelModel/ModelName"/>BLL()
  {
   DAL = new <xsl:value-of select="TabelModel/ModelName"/>DAL();
  }
  
  #endregion
  
  #region
  <xsl:if test="TabelModel/HasPK = 'true'">
  /// <summary>
  ///
  ///</summary>
  <xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true']">
  /// <param><xsl:attribute name="name"><xsl:value-of select="VarName"/></xsl:attribute> <xsl:value-of select="VarName"/></param>
  </xsl:for-each> 
  /// <returns>True/False</returns>
  public bool ExistsWithPK(<xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarType"/><xsl:text> </xsl:text><xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true'][position()>1]">, <xsl:value-of select="VarType"/><xsl:text> </xsl:text><xsl:value-of select="VarName"/></xsl:for-each>)
  {
   return DAL.ExistsWithPK(<xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true'][position()>1]">, <xsl:value-of select="VarName"/></xsl:for-each>);
  }
  </xsl:if>
  
  <xsl:if test="TabelModel/HasLogicKey = 'true'">
  /// <summary>
  ///
  ///</summary>
  <xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true']">
  /// <param><xsl:attribute name="name"><xsl:value-of select="VarName"/></xsl:attribute> <xsl:value-of select="VarName"/></param>
  </xsl:for-each> 
  /// <returns>True/False</returns>
  public bool ExistsWithLogicKey(<xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarType"/><xsl:text> </xsl:text><xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][position()>1]">, <xsl:value-of select="VarType"/><xsl:text> </xsl:text><xsl:value-of select="VarName"/></xsl:for-each>)
  {
   return DAL.ExistsWithLogicKey(<xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][position()>1]">, <xsl:value-of select="VarName"/></xsl:for-each>);
  }
  </xsl:if>
  /// <summary>
  ///
  ///</summary>
  /// <param name="strWhere"> ( “Where” )</param>
  /// <returns>True/False</returns>
  public bool ExistsWithParam(string strWhere)
  {
   return DAL.ExistsWithParam(strWhere);
  }
  #endregion
  #region  
  
  <xsl:if test="TabelModel/HasPK = 'true'">
  /// <summary>
  ///
  /// </summary>
  <xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true']">
  /// <param>
   <xsl:attribute name="name">
    <xsl:value-of select="VarName"/>
   </xsl:attribute>
   <xsl:value-of select="VarName"/>
  </param>
  </xsl:for-each>
  /// <returns> </returns>
  public <xsl:value-of select="TabelModel/ModelName"/>Model Get<xsl:value-of select="TabelModel/ModelName"/>ByPK(<xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarType"/><xsl:text> </xsl:text><xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true'][position()>1]">, <xsl:value-of select="VarType"/><xsl:text> </xsl:text><xsl:value-of select="VarName"/></xsl:for-each>)
  {
   return DAL.Get<xsl:value-of select="TabelModel/ModelName"/>ByPK(<xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true'][position()>1]">, <xsl:value-of select="VarName"/></xsl:for-each>);
  }
  </xsl:if>
  
  <xsl:if test="TabelModel/HasLogicKey = 'true'">
  /// <summary>
  ///
  /// </summary>
  <xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true']">
  /// <param>
   <xsl:attribute name="name">
    <xsl:value-of select="VarName"/>
   </xsl:attribute>
   <xsl:value-of select="VarName"/>
  </param>
  </xsl:for-each>
  /// <returns> </returns>
  public <xsl:value-of select="TabelModel/ModelName"/>Model Get<xsl:value-of select="TabelModel/ModelName"/>ByLogicKey(<xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarType"/><xsl:text> </xsl:text><xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][position()>1]">, <xsl:value-of select="VarType"/><xsl:text> </xsl:text><xsl:value-of select="VarName"/></xsl:for-each>)
  {
   return DAL.Get<xsl:value-of select="TabelModel/ModelName"/>ByLogicKey(<xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][position()>1]">, <xsl:value-of select="VarName"/></xsl:for-each>);
  }
  </xsl:if>
  
  /// <summary>
  ///
  /// </summary>
  /// <param name="strWhere"> </param>
  /// <returns> </returns>
  public <xsl:value-of select="TabelModel/ModelName"/>Model Get<xsl:value-of select="TabelModel/ModelName"/>ByParam(string strWhere)
  {
   return DAL.Get<xsl:value-of select="TabelModel/ModelName"/>ByParam(strWhere);
  }
  
  <xsl:if test="TabelModel/HasPK = 'true'">
  /// <summary>
  /// (DataRow)
  /// </summary>
  <xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true']">
  /// <param>
    <xsl:attribute name="name">
     <xsl:value-of select="VarName"/>
    </xsl:attribute>
    <xsl:value-of select="VarName"/>
   </param>
  </xsl:for-each>
  /// <returns> </returns>
  public DataRow GetRowByPK(<xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarType"/><xsl:text> </xsl:text><xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true'][position()>1]">, <xsl:value-of select="VarType"/><xsl:text> </xsl:text><xsl:value-of select="VarName"/></xsl:for-each>)
  {
   return DAL.GetRowByPK(<xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true'][position()>1]">, <xsl:value-of select="VarName"/></xsl:for-each>);
  }
  </xsl:if>
  
  <xsl:if test="TabelModel/HasLogicKey = 'true'">
  /// <summary>
  /// (DataRow)
  /// </summary>
  <xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true']">
  /// <param>
    <xsl:attribute name="name">
     <xsl:value-of select="VarName"/>
    </xsl:attribute>
    <xsl:value-of select="VarName"/>
   </param>
  </xsl:for-each>
  /// <returns> </returns>
  public DataRow GetRowByLogicKey(<xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarType"/><xsl:text> </xsl:text><xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][position()>1]">, <xsl:value-of select="VarType"/><xsl:text> </xsl:text><xsl:value-of select="VarName"/></xsl:for-each>)
  {
   return DAL.GetRowByLogicKey(<xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][position()>1]">, <xsl:value-of select="VarName"/></xsl:for-each>);
  }
  </xsl:if>
  
  /// <summary>
  /// (DataRow)
  /// </summary>
  /// <param name="strWhere"> </param>
  /// <returns> </returns>
  public DataRow GetRowByParam(string strWhere)
  {
   return DAL.GetRowByParam(strWhere);
  }
  /// <summary>
  ///
  /// </summary>
  /// <returns> </returns>
  public List<xsl:text disable-output-escaping="yes">&lt;</xsl:text><xsl:value-of select="TabelModel/ModelName"/>Model<xsl:text disable-output-escaping="yes">&gt;</xsl:text> Get<xsl:value-of select="TabelModel/ModelName"/>List()
  {
   return DAL.Get<xsl:value-of select="TabelModel/ModelName"/>List();
  }
  /// <summary>
  ///
  /// </summary>
  /// <param name="strWhere"> </param>
  /// <returns> </returns>
  public List<xsl:text disable-output-escaping="yes">&lt;</xsl:text><xsl:value-of select="TabelModel/ModelName"/>Model<xsl:text disable-output-escaping="yes">&gt;</xsl:text> Get<xsl:value-of select="TabelModel/ModelName"/>ListByParam(string strWhere)
  {
   return DAL.Get<xsl:value-of select="TabelModel/ModelName"/>ListByParam(strWhere);
  }
  /// <summary>
  /// (DataTable)
  /// </summary>
  /// <returns> </returns>
  public DataTable GetTable()
  {
   return DAL.GetTableByParam(String.Empty);
  }
  /// <summary>
  /// (DataTable)
  /// </summary>
  /// <param name="strWhere"> </param>
  /// <returns> </returns>
  public DataTable GetTableByParam(string strWhere)
  {
   return DAL.GetTableByParam(strWhere);
  }
  #endregion
  <xsl:if test="TabelModel/IsView = 'false'">
  #region / /
  /// <summary>
  ///
  ///</summary>
  /// <param name="model"> </param>
  /// <returns></returns>
  public int Add<xsl:value-of select="TabelModel/ModelName"/>(<xsl:value-of select="TabelModel/ModelName"/>Model model)
  {
   return DAL.Add<xsl:value-of select="TabelModel/ModelName"/>(model);
  }
  <xsl:if test="TabelModel/HasPK = 'true'">
  /// <summary>
  ///
  /// </summary>
  /// <param name="model"> </param>
  /// <returns></returns>
  public int Update<xsl:value-of select="TabelModel/ModelName"/>(<xsl:value-of select="TabelModel/ModelName"/>Model model)
  {
   return DAL.Update<xsl:value-of select="TabelModel/ModelName"/>(model);
  }

  /// <summary>
  ///
  /// </summary>
  /// <param name="model"> </param>
  /// <returns></returns>
  public int Delete<xsl:value-of select="TabelModel/ModelName"/>(<xsl:value-of select="TabelModel/ModelName"/>Model model)
  {
   return DAL.Delete<xsl:value-of select="TabelModel/ModelName"/>(model);
  }

  /// <summary>
  ///
  /// </summary>
  <xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true']">
  /// <param>
    <xsl:attribute name="name">
     <xsl:value-of select="VarName"/>
    </xsl:attribute>
    <xsl:value-of select="VarName"/>
   </param>
  </xsl:for-each>
  /// <returns></returns>
  public int DeleteWithPK(<xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarType"/><xsl:text> </xsl:text><xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true'][position()>1]">, <xsl:value-of select="VarType"/><xsl:text> </xsl:text><xsl:value-of select="VarName"/></xsl:for-each>)
  {
   return DAL.DeleteWithPK(<xsl:value-of select="TabelModel/Fields/FieldModel[IsPK = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsPK = 'true'][position()>1]">, <xsl:value-of select="VarName"/></xsl:for-each>);
  }
  </xsl:if>
  
  <xsl:if test="TabelModel/HasLogicKey = 'true'">
  /// <summary>
  /// ( )
  /// </summary>
  /// <param name="model"> </param>
  /// <returns></returns>
  public int Update<xsl:value-of select="TabelModel/ModelName"/>WithLogicKey(<xsl:value-of select="TabelModel/ModelName"/>Model model)
  {
   return DAL.Update<xsl:value-of select="TabelModel/ModelName"/>WithLogicKey(model);
  }

  /// <summary>
  /// ( )
  /// </summary>
  /// <param name="model"> </param>
  /// <returns></returns>
  public int Delete<xsl:value-of select="TabelModel/ModelName"/>WithLogicKey(<xsl:value-of select="TabelModel/ModelName"/>Model model)
  {
   return DAL.Delete<xsl:value-of select="TabelModel/ModelName"/>WithLogicKey(model);
  }

  /// <summary>
  ///
  /// </summary>
  <xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true']">
  /// <param>
    <xsl:attribute name="name">
     <xsl:value-of select="VarName"/>
    </xsl:attribute>
    <xsl:value-of select="VarName"/>
   </param>
  </xsl:for-each>
  /// <returns></returns>
  public int DeleteWithLogicKey(<xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarType"/><xsl:text> </xsl:text><xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][position()>1]">, <xsl:value-of select="VarType"/><xsl:text> </xsl:text><xsl:value-of select="VarName"/></xsl:for-each>)
  {
   return DAL.DeleteWithLogicKey(<xsl:value-of select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][1]/VarName"/><xsl:for-each select="TabelModel/Fields/FieldModel[IsLogicKey = 'true'][position()>1]">, <xsl:value-of select="VarName"/></xsl:for-each>);
  }
  </xsl:if>
  
  /// <summary>
  ///
  /// </summary>
  /// <param name="strWhere"> </param>
  /// <returns> </returns>
  public int DeleteByParam(string strWhere)
  {
   return DAL.DeleteByParam(strWhere);
  }
  
  #endregion
  </xsl:if>
 }
}
 </xsl:template>
</xsl:stylesheet>

좋은 웹페이지 즐겨찾기