<#@ template debug="false" hostspecific="false" language="C#" #> <#@ output extension=".cs" #> <#@ assembly name="System.Xml" #> <#@ assembly name="System.Data" #> <# System.Data.SqlClient.SqlConnection db = new System.Data.SqlClient.SqlConnection("Data Source=192.168.0.66\\EMISAdultDEVELOP; User Id=sa; Password=1; Initial Catalog=AdultDEVELOP"); System.Data.DataTable dtDictionaryItem = new System.Data.DataTable(); System.Data.SqlClient.SqlDataAdapter daDictionaryItem = new System.Data.SqlClient.SqlDataAdapter("select * from Sys_Dictionary", db); db.Open(); daDictionaryItem.Fill(dtDictionaryItem); #> using System; namespace EMIS.ViewModel { [Serializable] public enum DictionaryItem { <# for (int j = 0; j < dtDictionaryItem.Rows.Count; j ++) { System.Data.DataRow dr = dtDictionaryItem.Rows[j]; string enumItem = ""; enumItem += @"/// ///" + dr["Name"] + @" /// "; enumItem += dr["DictionaryCode"]; if (j != dtDictionaryItem.Rows.Count - 1) { enumItem += ","; } #> <#= enumItem#> <#} #>} <# for (int i = 0; i < dtDictionaryItem.Rows.Count; i ++) { System.Data.DataRow dr = dtDictionaryItem.Rows[i]; string enumItem = ""; enumItem += @" /// ///" + dr["Name"] + @" /// [Serializable] "; enumItem += "public enum " + dr["DictionaryCode"]; #> <#= enumItem#> { <# System.Data.SqlClient.SqlDataAdapter daDictionaryItemElement = new System.Data.SqlClient.SqlDataAdapter(@" select di.* from Sys_DictionaryItem di inner join Sys_Dictionary d on di.DictionaryCode=d.DictionaryCode where di.DictionaryCode='" + dr["DictionaryCode"] + "' and (di.IsEditable=0 or d.IsEditable=0)", db); System.Data.DataTable dtDictionaryItemElement = new System.Data.DataTable(); daDictionaryItemElement.Fill(dtDictionaryItemElement); for (int j = 0; j < dtDictionaryItemElement.Rows.Count; j ++) { System.Data.DataRow drElement = dtDictionaryItemElement.Rows[j]; string elementItem = ""; elementItem += @"/// ///" + drElement["Name"] + " -- " + drElement["Value"] + @" /// [System.ComponentModel.Description(""" + drElement["Name"] + @""")] "; elementItem += drElement["Code"] + " = " + drElement["Value"].ToString(); if (j != dtDictionaryItemElement.Rows.Count - 1) { elementItem += ","; }#> <#= elementItem#> <#} #> } <#} #> }