¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <configuration> |
| | | <connectionStrings> |
| | | <add name="æ¬å°_MySql_CMS" connectionString="Server=localhost;Database=4b25b01c1f7f49d19153de6b0906eafc_project;Uid=root;Pwd=123abc.com;" /> |
| | | <add name="LA22012_æ¦æ±ç§é_ç产åº_伿¬ç¯å¢" connectionString="Data Source=10.10.40.166;Initial Catalog=WHMY_Prod_Test;Persist Security Info=True;User ID=sa;Password=123abc.com" /> |
| | | <add name="LA22012_æ¦æ±ç§é_ç产åº_26æµè¯ç¯å¢" connectionString="Data Source=172.27.96.26;Initial Catalog=WHMY_Prod_Test;Persist Security Info=True;User ID=sa;Password=MJC!2022@wms" /> |
| | | <add name="LA22012_æ¦æ±ç§é_å¤ä»¶åº_伿¬ç¯å¢" connectionString="Data Source=10.10.40.166;Initial Catalog=WHMY_Admin.NET;Persist Security Info=True;User ID=sa;Password=123abc.com" /> |
| | | <add name="LA22012_æ¦æ±ç§é_å¤ä»¶åº_26æµè¯ç¯å¢" connectionString="Data Source=172.27.96.26;Initial Catalog=WHMY_Admin.NET;Persist Security Info=True;User ID=sa;Password=MJC!2022@wms" /> |
| | | <add name="LA21030_æ¦æ±ç§é_ç产" connectionString="Data Source=172.27.105.59;Initial Catalog=WHMY_Admin.NET;Persist Security Info=True;User ID=sa;Password=123abc.com" /> |
| | | <add name="LA21030_æ¦æ±ç§é_æ¬å°" connectionString="Data Source=localhost;Initial Catalog=WHMY_Admin.NET;Persist Security Info=True;User ID=sa;Password=123abc.com" /> |
| | | <add name="LA18032_AoSinWms_äº" connectionString="Data Source=120.53.244.200;Initial Catalog=LA18032_AoSinWms;Persist Security Info=True;User ID=sa;Password=123abc.com" /> |
| | | <add name="GSiemens_LES" connectionString="Data Source=localhost;Initial Catalog=GSiemens_LES;Persist Security Info=True;User ID=sa;Password=123abc.com" /> |
| | | <add name="GSiemens_WIP" connectionString="Data Source=.;Initial Catalog=GSiemens_WIP;Persist Security Info=True;User ID=sa;Password=123abc.com" /> |
| | | <add name="LocalhostConn" connectionString="Data Source=shaocx;Initial Catalog=SOADB;User ID=sa;Password=1111" /> |
| | | </connectionStrings> |
| | | <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup> |
| | | <runtime> |
| | | <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
| | | <dependentAssembly> |
| | | <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> |
| | | <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> |
| | | </dependentAssembly> |
| | | </assemblyBinding> |
| | | </runtime> |
| | | </configuration> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using GenerateCode_GEBrilliantFactory; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_WeiBen_WMS.DataBaseFactory |
| | | { |
| | | public class DataBaseServiceFactory |
| | | { |
| | | public static DataBaseServiceHandle GetHandle(DataBaseEnum meterialType) |
| | | { |
| | | DataBaseServiceHandle handle = null; |
| | | switch (meterialType) |
| | | { |
| | | case DataBaseEnum.SqlServer: |
| | | handle = new SqlServerDataBaseServiceHandle(); |
| | | break; |
| | | case DataBaseEnum.MySql: |
| | | handle = new MySqlDataBaseServiceHandle(); |
| | | break; |
| | | } |
| | | return handle; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using GenerateCode_GEBrilliantFactory; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_WeiBen_WMS.DataBaseFactory |
| | | { |
| | | public class DataBaseServiceHandle |
| | | { |
| | | #region èæ¹æ³ |
| | | |
| | | /// <summary> |
| | | /// è·åæ°æ®åºè¡¨å表 |
| | | /// </summary> |
| | | /// <param name="tableName"></param> |
| | | /// <param name="connStr"></param> |
| | | /// <returns></returns> |
| | | public virtual List<ColumnModel> GetColumnList(string tableName, string connStr) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è½¬æ¢ |
| | | /// </summary> |
| | | /// <param name="dt"></param> |
| | | /// <returns></returns> |
| | | public virtual List<ColumnModel> DataTableToList(DataTable dt) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using GenerateCode_GEBrilliantFactory; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_WeiBen_WMS.DataBaseFactory |
| | | { |
| | | public class MySqlDataBaseServiceHandle : DataBaseServiceHandle |
| | | { |
| | | public override List<ColumnModel> GetColumnList(string tableName, string connStr) |
| | | { |
| | | //string strSql = $"SELECT COLUMN_NAME as ColumnName, COLUMN_TYPE as DataType, IS_NULLABLE as IsNullable, CHARACTER_MAXIMUM_LENGTH as DataLength,COLUMN_COMMENT as Description " + |
| | | // $"FROM INFORMATION_SCHEMA.COLUMNS " + |
| | | // $"WHERE TABLE_NAME = '{tableName}'"; |
| | | string strSql = $"SELECT c.COLUMN_NAME as ColumnName, c.COLUMN_TYPE as DataType, c.IS_NULLABLE as IsNullable, c.CHARACTER_MAXIMUM_LENGTH as DataLength, c.COLUMN_COMMENT as Description, " + |
| | | $"CASE WHEN kcu.COLUMN_NAME IS NOT NULL THEN 'true' ELSE 'false' END AS IsPrimaryKey " + |
| | | $"FROM INFORMATION_SCHEMA.COLUMNS c " + |
| | | $"LEFT JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE kcu " + |
| | | $"ON c.TABLE_SCHEMA = kcu.TABLE_SCHEMA " + |
| | | $"AND c.TABLE_NAME = kcu.TABLE_NAME " + |
| | | $"AND c.COLUMN_NAME = kcu.COLUMN_NAME " + |
| | | $"AND kcu.CONSTRAINT_NAME = 'PRIMARY' " + |
| | | $"WHERE c.TABLE_NAME = '{tableName}'"; |
| | | |
| | | |
| | | List<ColumnModel> columnList = new List<ColumnModel>(); |
| | | try |
| | | { |
| | | DataSet ds = MySqlHelper.Query(connStr, strSql); |
| | | columnList = DataTableToList(ds.Tables[0]); |
| | | } |
| | | catch |
| | | { |
| | | throw; |
| | | } |
| | | finally |
| | | { |
| | | } |
| | | return columnList; |
| | | } |
| | | |
| | | public override List<ColumnModel> DataTableToList(DataTable dt) |
| | | { |
| | | try |
| | | { |
| | | List<ColumnModel> modelList = new List<ColumnModel>(); |
| | | int rowsCount = dt.Rows.Count; |
| | | if (rowsCount > 0) |
| | | { |
| | | ColumnModel model; |
| | | for (int n = 0; n < rowsCount; n++) |
| | | { |
| | | model = new ColumnModel(); |
| | | //if (dt.Rows[n]["Precision"]!=null && dt.Rows[n]["Precision"].ToString() != "") |
| | | //{ |
| | | // model.Precision = int.Parse(dt.Rows[n]["Precision"].ToString()); |
| | | //} |
| | | //if (dt.Rows[n]["Scale"].ToString() != "") |
| | | //{ |
| | | // model.Scale = int.Parse(dt.Rows[n]["Scale"].ToString()); |
| | | //} |
| | | model.ColumnName = dt.Rows[n]["ColumnName"].ToString(); |
| | | model.DataLength = dt.Rows[n]["DataLength"].ToString(); |
| | | model.DataType = dt.Rows[n]["DataType"].ToString(); |
| | | |
| | | if (model.DataType.ToUpper() == "nvarchar".ToUpper()) |
| | | { |
| | | if (model.DataLength != "-1") |
| | | { |
| | | model.DataLength = ((int)Convert.ToInt32(model.DataLength) / 2).ToString(); |
| | | } |
| | | } |
| | | |
| | | model.Description = dt.Rows[n]["Description"].ToString(); |
| | | if (dt.Rows[n]["IsNullable"].ToString() != "") |
| | | { |
| | | if ((dt.Rows[n]["IsNullable"].ToString() == "1") || (dt.Rows[n]["IsNullable"].ToString().ToLower() == "true")) |
| | | { |
| | | model.IsNullable = true; |
| | | } |
| | | else |
| | | { |
| | | model.IsNullable = false; |
| | | } |
| | | } |
| | | if (dt.Rows[n]["IsPrimaryKey"].ToString() != "") |
| | | { |
| | | if ((dt.Rows[n]["IsPrimaryKey"].ToString() == "1") || (dt.Rows[n]["IsPrimaryKey"].ToString().ToLower() == "true")) |
| | | { |
| | | model.IsPrimaryKey = true; |
| | | } |
| | | else |
| | | { |
| | | model.IsPrimaryKey = false; |
| | | } |
| | | } |
| | | |
| | | modelList.Add(model); |
| | | } |
| | | } |
| | | return modelList; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using GenerateCode_GEBrilliantFactory; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_WeiBen_WMS.DataBaseFactory |
| | | { |
| | | public class SqlServerDataBaseServiceHandle : DataBaseServiceHandle |
| | | { |
| | | public override List<ColumnModel> GetColumnList(string tableName, string connStr) |
| | | { |
| | | string strSql = @" select |
| | | col.name as ColumnName, |
| | | t.name as DataType, |
| | | ep.value as Description, |
| | | col.max_length as DataLength, |
| | | col.is_nullable as IsNullable, |
| | | |
| | | ( |
| | | select top 1 ind.is_primary_key from sys.index_columns ic |
| | | left join sys.indexes ind |
| | | on ic.object_id=ind.object_id |
| | | and ic.index_id=ind.index_id |
| | | and ind.name like 'PK_%' |
| | | where ic.object_id=obj.object_id |
| | | and ic.column_id=col.column_id |
| | | ) as IsPrimaryKey, |
| | | col.Precision, |
| | | col.Scale |
| | | from sys.objects obj |
| | | inner join sys.columns col |
| | | on obj.object_id=col.object_id |
| | | left join sys.types t |
| | | on t.user_type_id=col.user_type_id |
| | | left join sys.extended_properties ep |
| | | on ep.major_id=obj.object_id |
| | | and ep.minor_id=col.column_id |
| | | and ep.name='MS_Description' |
| | | where obj.name='" + tableName + "' "; |
| | | |
| | | |
| | | List<ColumnModel> columnList = new List<ColumnModel>(); |
| | | try |
| | | { |
| | | DataSet ds = SqlHelper.Query(connStr, strSql); |
| | | columnList = DataTableToList(ds.Tables[0]); |
| | | } |
| | | catch |
| | | { |
| | | throw; |
| | | } |
| | | finally |
| | | { |
| | | } |
| | | return columnList; |
| | | } |
| | | |
| | | public override List<ColumnModel> DataTableToList(DataTable dt) |
| | | { |
| | | try |
| | | { |
| | | List<ColumnModel> modelList = new List<ColumnModel>(); |
| | | int rowsCount = dt.Rows.Count; |
| | | if (rowsCount > 0) |
| | | { |
| | | ColumnModel model; |
| | | for (int n = 0; n < rowsCount; n++) |
| | | { |
| | | model = new ColumnModel(); |
| | | if (dt.Rows[n]["Precision"].ToString() != "") |
| | | { |
| | | model.Precision = int.Parse(dt.Rows[n]["Precision"].ToString()); |
| | | } |
| | | if (dt.Rows[n]["Scale"].ToString() != "") |
| | | { |
| | | model.Scale = int.Parse(dt.Rows[n]["Scale"].ToString()); |
| | | } |
| | | model.ColumnName = dt.Rows[n]["ColumnName"].ToString(); |
| | | model.DataLength = dt.Rows[n]["DataLength"].ToString(); |
| | | model.DataType = dt.Rows[n]["DataType"].ToString(); |
| | | |
| | | if (model.DataType.ToUpper() == "nvarchar".ToUpper()) |
| | | { |
| | | if (model.DataLength != "-1") |
| | | { |
| | | model.DataLength = ((int)Convert.ToInt32(model.DataLength) / 2).ToString(); |
| | | } |
| | | } |
| | | |
| | | model.Description = dt.Rows[n]["Description"].ToString(); |
| | | if (dt.Rows[n]["IsNullable"].ToString() != "") |
| | | { |
| | | if ((dt.Rows[n]["IsNullable"].ToString() == "1") || (dt.Rows[n]["IsNullable"].ToString().ToLower() == "true")) |
| | | { |
| | | model.IsNullable = true; |
| | | } |
| | | else |
| | | { |
| | | model.IsNullable = false; |
| | | } |
| | | } |
| | | if (dt.Rows[n]["IsPrimaryKey"].ToString() != "") |
| | | { |
| | | if ((dt.Rows[n]["IsPrimaryKey"].ToString() == "1") || (dt.Rows[n]["IsPrimaryKey"].ToString().ToLower() == "true")) |
| | | { |
| | | model.IsPrimaryKey = true; |
| | | } |
| | | else |
| | | { |
| | | model.IsPrimaryKey = false; |
| | | } |
| | | } |
| | | |
| | | modelList.Add(model); |
| | | } |
| | | } |
| | | return modelList; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | using System.Collections.Generic; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// çæBLL |
| | | /// </summary> |
| | | public class BLL_Generate : BaseGenerate |
| | | { |
| | | public static string CreateBLLText(string filePrefixName, string TableName, string entityName, string Author, |
| | | string ChinaComment, string primaryKey, string primaryKeyDesc, string Modulelogo, string tableAlias, |
| | | string addEntityParam, |
| | | List<ColumnModel> columnNameList) |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\BLL模æ¿.txt"); |
| | | |
| | | CommonReplace(ref str); |
| | | |
| | | str = str.Replace("$TableName$", TableName);//表å |
| | | str = str.Replace("$Author$", Author);//ä½è
|
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str = str.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | str = str.Replace("$EntityName$", entityName);//å®ä½ç±»å |
| | | |
| | | str = str.Replace("$FilePrefixName$", filePrefixName);//模åå |
| | | str = str.Replace("$Modulelogo$", Modulelogo);//模åç®å |
| | | str = str.Replace("$PrimaryKey$", primaryKey);//ä¸»é® |
| | | str = str.Replace("$PrimaryKeyDesc$", primaryKeyDesc);//æè¿° |
| | | str = str.Replace("$TableAlias$", tableAlias);//表å«å |
| | | |
| | | str = str.Replace("$AddEntityParam$", addEntityParam); |
| | | |
| | | str = str.Replace("$ToSingleModel$", StructStrHelper.GetToModelStr(columnNameList));//卿ç»å®ä½ç±»èµå¼ |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | public class BaseGenerate |
| | | { |
| | | public static void CommonReplace(ref string str) |
| | | { |
| | | str = str.Replace("$ProjectNamePrefix$", MainForm.projectNamePrefix); |
| | | str = str.Replace("$DataBaseName$", MainForm.dataBaseName); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// çæControllerç±» |
| | | /// </summary> |
| | | public class Controller_Generate : BaseGenerate |
| | | { |
| | | public static string CreateText(string Modulelogo, |
| | | string ChinaComment, List<ColumnModel> columnNameList, string entityName, string orderByName = "") |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\Controller模æ¿.txt"); |
| | | CommonReplace(ref str); |
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str = str.Replace("$EntityName$", entityName); |
| | | str = str.Replace("$Modulelogo$", Modulelogo);//模åç®å |
| | | str = str.Replace("$OrderByName$", orderByName == "" ? "Id" : orderByName);//模åç®å |
| | | |
| | | str = str.Replace("$ValidateEmptyForInsert$", StructStrHelper.GetValidateEmptyStrForController(columnNameList)); |
| | | str = str.Replace("$ValidateEmptyForUpdate$", StructStrHelper.GetValidateEmptyStrForController(columnNameList, false)); |
| | | |
| | | |
| | | |
| | | var pageStr = StructStrHelper.GetPageFilterStrForController(columnNameList); |
| | | str = str.Replace("$PageSearchFilter$", pageStr); |
| | | |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System.Collections.Generic; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// çæDAL |
| | | /// </summary> |
| | | public class DAL_Generate : BaseGenerate |
| | | { |
| | | public static string CreateDALText(string filePrefixName, string TableName, string entityName, string Author, |
| | | string ChinaComment, string primaryKey, string primaryKeyDesc, string Modulelogo,string tableAlias, |
| | | List<ColumnModel> columnNameList) |
| | | { |
| | | |
| | | var str = TextHelper.ReadText(@"Templete\DAL模æ¿.txt"); |
| | | |
| | | CommonReplace(ref str); |
| | | |
| | | //åå¨è¿ç¨å |
| | | ProcName procName = CommonHelper.GetProcName(Modulelogo); |
| | | str = str.Replace("$AddProcName$", procName.AddProc); |
| | | str = str.Replace("$UpdateProcName$", procName.UpdateProc); |
| | | str = str.Replace("$GetSingleProcName$", procName.GetSingleProc); |
| | | str = str.Replace("$GetListProcName$", procName.ListProc); |
| | | str = str.Replace("$GetPageListProcName$", procName.PageListProc); |
| | | |
| | | |
| | | |
| | | str = str.Replace("$TableName$", TableName);//表å |
| | | str = str.Replace("$Author$", Author);//ä½è
|
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str = str.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | str = str.Replace("$EntityName$", entityName);//å®ä½ç±»å |
| | | str = str.Replace("$TableAlias$", tableAlias);//表å«å |
| | | |
| | | str = str.Replace("$FilePrefixName$", filePrefixName);//模åå |
| | | str = str.Replace("$Modulelogo$", Modulelogo);//模åç®å |
| | | str = str.Replace("$PrimaryKey$", primaryKey);//ä¸»é® |
| | | str = str.Replace("$PrimaryKeyDesc$", primaryKeyDesc);//ä¸»é®æè¿° |
| | | |
| | | |
| | | |
| | | str = str.Replace("$ToSingleModel$", StructStrHelper.GetToModelStr(columnNameList));//卿ç»å®ä½ç±»èµå¼ |
| | | str = str.Replace("$AddSqlParameter$", StructStrHelper.GetParameterForAddDAL(columnNameList)); |
| | | str = str.Replace("$UpdateSqlParameter$", StructStrHelper.GetParameterForUpdateDAL(columnNameList)); |
| | | str = str.Replace("$QueryPageSqlParameter$", StructStrHelper.GetParameterForQueryPageDAL(columnNameList)); |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// çææ°å¢åæ°å®ä½ç±» |
| | | /// </summary> |
| | | public class AddModel_Generate : BaseGenerate |
| | | { |
| | | public static string CreateAddModelLText(string addEntityParam, |
| | | string ChinaComment, List<ColumnModel> columnNameList) |
| | | { |
| | | //var str = TextHelper.ReadText(@"Templete\Entity\AddModel模æ¿.txt"); |
| | | var str = TextHelper.ReadText(@"Templete\Entity\InputModel模æ¿.txt"); |
| | | CommonReplace(ref str); |
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | |
| | | str = str.Replace("$AddEntityParam$", addEntityParam); |
| | | |
| | | string attrString = ""; |
| | | |
| | | List<ColumnModel> newColumnNameList = ListHelper.RemoveIdCreatorModifier(columnNameList); |
| | | for (int i = 0; i < newColumnNameList.Count; ++i) |
| | | { |
| | | attrString += StructStrHelper.GenerateAttributeForAddModel(newColumnNameList[i]); |
| | | } |
| | | str = str.Replace("$AddAttributes$", attrString); |
| | | |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// çææ¥è¯¢å®ä½ç±» |
| | | /// </summary> |
| | | public class InputModel_Generate : BaseGenerate |
| | | { |
| | | public static string CreateQueryModelLText(string Modulelogo, |
| | | string ChinaComment, List<ColumnModel> columnNameList, string entityName) |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\Entity\InputModel模æ¿.txt"); |
| | | CommonReplace(ref str); |
| | | |
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str = str.Replace("$EntityName$", entityName); |
| | | |
| | | str = str.Replace("$Modulelogo$", Modulelogo);//模åç®å |
| | | |
| | | //å¤ç å页æ¥è¯¢é¨å |
| | | string attrString = ""; |
| | | |
| | | List<ColumnModel> newColumnNameList = ListHelper.OnlyRemoveId(columnNameList); |
| | | for (int i = 0; i < newColumnNameList.Count; ++i) |
| | | { |
| | | attrString += StructStrHelper.GenerateAttributeForQueryModel(newColumnNameList[i]); |
| | | attrString += StructStrHelper.GenerateAttributeForQueryModelMode(newColumnNameList[i]); |
| | | } |
| | | str = str.Replace("$QueryAttributes$", attrString); |
| | | |
| | | //å¤ç æ°å¢é¨å |
| | | attrString = ""; |
| | | newColumnNameList = ListHelper.RemoveIdCreatorModifier(columnNameList); |
| | | for (int i = 0; i < newColumnNameList.Count; ++i) |
| | | { |
| | | attrString += StructStrHelper.GenerateAttribute(i,newColumnNameList[i]); |
| | | } |
| | | str = str.Replace("$AddAttributes$", attrString); |
| | | |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// è¾åºåæ°- çææ¥è¯¢å®ä½ç±» |
| | | /// </summary> |
| | | public class OutputModel_Generate : BaseGenerate |
| | | { |
| | | public static string CreateQueryModelLText(string Modulelogo, |
| | | string ChinaComment, List<ColumnModel> columnNameList, string entityName) |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\Entity\OutputModel模æ¿.txt"); |
| | | CommonReplace(ref str); |
| | | |
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str = str.Replace("$EntityName$", entityName); |
| | | |
| | | str = str.Replace("$Modulelogo$", Modulelogo);//模åç®å |
| | | |
| | | //å¤ç å页æ¥è¯¢è¿åé¨å |
| | | string attrString = ""; |
| | | List<ColumnModel> newColumnNameList = ListHelper.RemoveCreatedTimeUpdatedTimeCreatedUserIdCreatedUserNameUpdatedUserIdUpdatedUserName(columnNameList); |
| | | for (int i = 0; i < newColumnNameList.Count; ++i) |
| | | { |
| | | attrString += StructStrHelper.GenerateAttribute(i, newColumnNameList[i]); |
| | | } |
| | | str = str.Replace("$QueryOutputAttributes$", attrString); |
| | | |
| | | //å¤ç 导åºè¿åé¨å |
| | | attrString = ""; |
| | | newColumnNameList = ListHelper.RemoveIdCreateIdModifyIdDelFlag(columnNameList); |
| | | for (int i = 0; i < newColumnNameList.Count; ++i) |
| | | { |
| | | attrString += StructStrHelper.GenerateAttribute(i, newColumnNameList[i], true); |
| | | } |
| | | str = str.Replace("$ExportOutputAttributes$", attrString); |
| | | |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// InsertSQLæä»¶çæ |
| | | /// </summary> |
| | | public class InsertSQL_Generate : BaseGenerate |
| | | { |
| | | /// <summary> |
| | | /// çæInsertSQL |
| | | /// </summary> |
| | | /// <param name="TableName"></param> |
| | | /// <param name="Author"></param> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static string CreateInsertSQLText(string TableName, string Author, string ChinaComment, |
| | | List<ColumnModel> columnNameList) |
| | | { |
| | | try |
| | | { |
| | | StringBuilder sbText = new StringBuilder(); |
| | | |
| | | sbText.Append(GetInsertSQLStr(TableName, Author,ChinaComment, columnNameList)); |
| | | |
| | | return sbText.ToString(); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// çæInsertSQL |
| | | /// </summary> |
| | | /// <param name="TableName"></param> |
| | | /// <param name="Author"></param> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | private static string GetInsertSQLStr(string TableName, string Author, string ChinaComment, List<ColumnModel> columnNameList) |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\InitSQL模æ¿.txt"); |
| | | |
| | | CommonReplace(ref str); |
| | | |
| | | str = str.Replace("$TableName$", TableName);//表å |
| | | str = str.Replace("$Author$", Author);//ä½è
|
| | | str = str.Replace("$TableName$", TableName);//表å |
| | | str = str.Replace("$Author$", Author);//ä½è
|
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | |
| | | str = str.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | |
| | | |
| | | string str_insert_cols = StructStrHelper.GetColumnsStrNoIDForAdd(columnNameList, ""); |
| | | str = str.Replace("$insert_cols$", str_insert_cols); |
| | | str = str.Replace("$insert_cols_values$", StructStrHelper.GetColumnsStrNoIDForInsertSQL(columnNameList)); |
| | | |
| | | return str; |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | public class Model_Generate : BaseGenerate |
| | | { |
| | | |
| | | /// <summary> |
| | | /// å建å®ä½ç±» |
| | | /// </summary> |
| | | /// <param name="tableName">表å</param> |
| | | /// <param name="columnNameList"></param> |
| | | /// <param name="filePrefixName">æä»¶åç¼å</param> |
| | | /// <param name="nameSpacePath">ç±»å½å空é´</param> |
| | | /// <param name="createPerson">å建人</param> |
| | | /// <param name="chinaComment">ä¸ææ³¨é</param> |
| | | /// <param name="entityName">å®ä½ç±»å</param> |
| | | /// <returns></returns> |
| | | public static string GenerateModel(string tableName, List<ColumnModel> columnNameList, string filePrefixName, string nameSpacePath, |
| | | string createPerson, string chinaComment, string entityName |
| | | ) |
| | | { |
| | | string header = "using System;\n" |
| | | + "using System.Runtime.Serialization; \n" |
| | | + " \n" |
| | | + "namespace WIP_Models \n" |
| | | + "{\n" |
| | | + " /// <summary>\n" |
| | | + " /// " + chinaComment + "å®ä½ç±»\n" |
| | | + " /// </summary>\n" |
| | | + " [DataContract]\n" |
| | | + " public class $entityName$ \n" |
| | | + " {\n\n"; |
| | | int columnCount = columnNameList.Count; |
| | | string attrString = ""; |
| | | for (int i = 0; i < columnCount; ++i) |
| | | { |
| | | attrString += StructStrHelper.GenerateAttribute(i, columnNameList[i]); |
| | | } |
| | | string footer = " }\n" |
| | | + "}"; |
| | | |
| | | string modelContent = header + attrString + footer; |
| | | modelContent = modelContent.Replace( |
| | | "$NowTimeStr$", DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day |
| | | + " " |
| | | + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);//å建æ¶é´ |
| | | modelContent = modelContent.Replace("$CreatePerson$", createPerson);//å建人 |
| | | modelContent = modelContent.Replace("$nameSpacePath$", nameSpacePath);//å½åç©ºé´ |
| | | modelContent = modelContent.Replace("$entityName$", entityName);//å®ä½ç±»å |
| | | |
| | | CommonReplace(ref modelContent); |
| | | |
| | | return modelContent; |
| | | |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// å建å®ä½ç±» |
| | | /// </summary> |
| | | /// <param name="tableName">表å</param> |
| | | /// <param name="columnNameList"></param> |
| | | /// <param name="filePrefixName">æä»¶åç¼å</param> |
| | | /// <param name="nameSpacePath">ç±»å½å空é´</param> |
| | | /// <param name="createPerson">å建人</param> |
| | | /// <param name="chinaComment">ä¸ææ³¨é</param> |
| | | /// <param name="entityName">å®ä½ç±»å</param> |
| | | /// <returns></returns> |
| | | public static string GenerateModelParam(string tableName, List<ColumnModel> columnNameList, string filePrefixName, string nameSpacePath, |
| | | string createPerson, string chinaComment, string entityName |
| | | ) |
| | | { |
| | | string header = "using System;\n" |
| | | + "using System.Runtime.Serialization; \n" |
| | | + " \n" |
| | | + "namespace " + MainForm.projectNamePrefix + ".Core.Model.ParamModels \n" |
| | | + "{\n" |
| | | + " /// <summary>\n" |
| | | + " /// " + chinaComment + "å®ä½ç±»\n" |
| | | + " /// </summary>\n" |
| | | + " public class $entityName$Param : PageParam \n" |
| | | + " {\n\n"; |
| | | int columnCount = columnNameList.Count; |
| | | string attrString = ""; |
| | | for (int i = 0; i < columnCount; ++i) |
| | | { |
| | | attrString += StructStrHelper.GenerateAttribute(i, columnNameList[i]); |
| | | } |
| | | string footer = " }\n" |
| | | + "}"; |
| | | |
| | | string modelContent = header + attrString + footer; |
| | | modelContent = modelContent.Replace( |
| | | "$NowTimeStr$", DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day |
| | | + " " |
| | | + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second);//å建æ¶é´ |
| | | modelContent = modelContent.Replace("$CreatePerson$", createPerson);//å建人 |
| | | modelContent = modelContent.Replace("$nameSpacePath$", nameSpacePath);//å½åç©ºé´ |
| | | modelContent = modelContent.Replace("$entityName$", entityName);//å®ä½ç±»å |
| | | |
| | | CommonReplace(ref modelContent); |
| | | |
| | | return modelContent; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// åå¨è¿ç¨æä»¶çæ |
| | | /// </summary> |
| | | public class Procedure_Generate : BaseGenerate |
| | | { |
| | | /// <summary> |
| | | /// çæåå¨è¿ç¨æä»¶ |
| | | /// </summary> |
| | | /// <param name="TableName"></param> |
| | | /// <param name="TableAlias"></param> |
| | | /// <param name="Author"></param> |
| | | /// <param name="ChinaComment"></param> |
| | | /// <param name="PimaryKey"></param> |
| | | /// <param name="filePrefixName"></param> |
| | | /// <param name="orderByName"></param> |
| | | /// <param name="Modulelogo">模åç®å</param> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static string CreateProcText(string TableName, string TableAlias, string Author, |
| | | string ChinaComment, string PimaryKey, string filePrefixName, string orderByName, string Modulelogo, |
| | | List<ColumnModel> columnNameList) |
| | | { |
| | | try |
| | | { |
| | | StringBuilder sbText = new StringBuilder(); |
| | | |
| | | var str_query_1 = StructStrHelper.GetQueryColumnsStr(columnNameList); |
| | | var str_query_2 = StructStrHelper.GetQueryColumnsStr(columnNameList, TableAlias);//带åç¼ |
| | | |
| | | //1ãå页åå¨è¿ç¨ |
| | | |
| | | sbText.Append(GetPageProcStr(columnNameList,TableName, TableAlias, Author, ChinaComment, str_query_1, str_query_2, filePrefixName)); |
| | | sbText.Append("\n\n"); |
| | | |
| | | //2ãå表åå¨è¿ç¨ |
| | | |
| | | sbText.Append(GetListProcStr(TableName, TableAlias, Author, ChinaComment, str_query_2, filePrefixName, orderByName)); |
| | | sbText.Append("\n\n"); |
| | | |
| | | //2ãå¾å°ä¸ä¸ªå®ä½åå¨è¿ç¨ |
| | | sbText.Append(GetSingleObjectProcStr(TableName, TableAlias, Author, ChinaComment, str_query_2, PimaryKey, filePrefixName, columnNameList)); |
| | | sbText.Append("\n\n"); |
| | | |
| | | //3ãå¢å 䏿¡è®°å½åå¨è¿ç¨ |
| | | sbText.Append(GetAddProcStr(TableName, TableAlias, Author, ChinaComment,filePrefixName, columnNameList)); |
| | | sbText.Append("\n\n"); |
| | | |
| | | //4ãæ´æ°ä¸æ¡è®°å½åå¨è¿ç¨ |
| | | sbText.Append(GetUpdateProcStr(TableName, TableAlias, Author, ChinaComment, PimaryKey, filePrefixName, columnNameList)); |
| | | sbText.Append("\n\n"); |
| | | |
| | | //5ãæ´æ°ä¸æ¡è®°å½åå¨è¿ç¨2 |
| | | sbText.Append(GetUpdateProcStr2(TableName, TableAlias, Author, ChinaComment, PimaryKey, filePrefixName, columnNameList)); |
| | | sbText.Append("\n\n"); |
| | | |
| | | |
| | | //åå¨è¿ç¨å |
| | | ProcName procName = CommonHelper.GetProcName(Modulelogo); |
| | | sbText = sbText.Replace("$AddProcName$", procName.AddProc); |
| | | sbText = sbText.Replace("$UpdateProcName$", procName.UpdateProc); |
| | | sbText = sbText.Replace("$GetSingleProcName$", procName.GetSingleProc); |
| | | sbText = sbText.Replace("$GetListProcName$", procName.ListProc); |
| | | sbText = sbText.Replace("$GetPageListProcName$", procName.PageListProc); |
| | | |
| | | |
| | | |
| | | return sbText.ToString(); |
| | | } |
| | | catch (Exception) |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å页åå¨è¿ç¨ |
| | | /// </summary> |
| | | /// <param name="TableName"></param> |
| | | /// <param name="TableAlias"></param> |
| | | /// <param name="Author"></param> |
| | | /// <param name="ChinaComment"></param> |
| | | /// <param name="str_query_1"></param> |
| | | /// <param name="str_query_2"></param> |
| | | /// <returns></returns> |
| | | private static string GetPageProcStr(List<ColumnModel> columnNameList,string TableName, string TableAlias, string Author, string ChinaComment, |
| | | string str_query_1, string str_query_2, string filePrefixName) |
| | | { |
| | | var str_page_proc = TextHelper.ReadText(@"Templete\proc\å页åå¨è¿ç¨.txt"); |
| | | |
| | | str_page_proc = str_page_proc.Replace("$ProcName$", filePrefixName + "_GetPageList");//åå¨è¿ç¨å |
| | | str_page_proc = str_page_proc.Replace("$TableName$", TableName);//表å |
| | | str_page_proc = str_page_proc.Replace("$TableAlias$", TableAlias);//å«å |
| | | str_page_proc = str_page_proc.Replace("$Author$", Author);//ä½è
|
| | | str_page_proc = str_page_proc.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str_page_proc = str_page_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | |
| | | |
| | | str_page_proc = str_page_proc.Replace("$page_cols_params$", StructStrHelper.GetInputParamColumnsStrForQueryPage(columnNameList)); |
| | | str_page_proc = str_page_proc.Replace("$where_cols_params$", StructStrHelper.GetCols_AssignmentStrForWherePage(TableAlias, columnNameList)); |
| | | |
| | | str_page_proc = str_page_proc.Replace("$strQueryCol_1$", str_query_1); |
| | | str_page_proc = str_page_proc.Replace("$strQueryCol_2$", str_query_2); |
| | | return str_page_proc; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å表åå¨è¿ç¨(ä¸å页) |
| | | /// </summary> |
| | | /// <param name="TableName"></param> |
| | | /// <param name="TableAlias"></param> |
| | | /// <param name="Author"></param> |
| | | /// <param name="ChinaComment"></param> |
| | | /// <param name="str_query"></param> |
| | | /// <returns></returns> |
| | | private static string GetListProcStr(string TableName, string TableAlias, string Author, string ChinaComment, |
| | | string str_query, string filePrefixName, string orderByName) |
| | | { |
| | | var str_list_proc = TextHelper.ReadText(@"Templete\proc\å表åå¨è¿ç¨.txt"); |
| | | |
| | | str_list_proc = str_list_proc.Replace("$ProcName$", filePrefixName + "_GetList");//åå¨è¿ç¨å |
| | | str_list_proc = str_list_proc.Replace("$TableName$", TableName);//表å |
| | | str_list_proc = str_list_proc.Replace("$TableAlias$", TableAlias);//å«å |
| | | str_list_proc = str_list_proc.Replace("$Author$", Author);//ä½è
|
| | | str_list_proc = str_list_proc.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str_list_proc = str_list_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | |
| | | str_list_proc = str_list_proc.Replace("$strQueryCol$", str_query); |
| | | str_list_proc = str_list_proc.Replace("$orderByName$", orderByName); |
| | | return str_list_proc; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¾å°ä¸ä¸ªå®ä½åå¨è¿ç¨ |
| | | /// </summary> |
| | | /// <param name="TableName"></param> |
| | | /// <param name="TableAlias"></param> |
| | | /// <param name="Author"></param> |
| | | /// <param name="ChinaComment"></param> |
| | | /// <param name="str_query_2"></param> |
| | | /// <param name="PimaryKey"></param> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | private static string GetSingleObjectProcStr(string TableName, string TableAlias, string Author, string ChinaComment, |
| | | string str_query_2, string PimaryKey, string filePrefixName, List<ColumnModel> columnNameList) |
| | | { |
| | | try |
| | | { |
| | | var str_single_proc = TextHelper.ReadText(@"Templete\proc\å¾å°ä¸ä¸ªå®ä½åå¨è¿ç¨.txt"); |
| | | |
| | | str_single_proc = str_single_proc.Replace("$ProcName$", filePrefixName + "_GetModel");//åå¨è¿ç¨å |
| | | str_single_proc = str_single_proc.Replace("$TableName$", TableName);//表å |
| | | str_single_proc = str_single_proc.Replace("$TableAlias$", TableAlias);//å«å |
| | | str_single_proc = str_single_proc.Replace("$Author$", Author);//ä½è
|
| | | str_single_proc = str_single_proc.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str_single_proc = str_single_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | |
| | | str_single_proc = str_single_proc.Replace("$Primary$", PimaryKey); |
| | | str_single_proc = str_single_proc.Replace("$strQueryCol$", str_query_2); |
| | | var columnModel = StructStrHelper.GetColumnModelByName(PimaryKey, columnNameList); |
| | | if (columnModel == null) |
| | | throw new Exception("æ²¡ææ¾å°ç¸åºç主é®å¼ï¼"); |
| | | if (columnModel.DataType.ToUpper() == "INT" || columnModel.DataType.ToUpper() == "BIGINT") |
| | | { |
| | | str_single_proc = str_single_proc.Replace("$DataType$", columnModel.DataType); |
| | | } |
| | | else |
| | | { |
| | | str_single_proc = str_single_proc.Replace("$DataType$", columnModel.DataType + "(" + columnModel.DataLength + ")"); |
| | | } |
| | | |
| | | return str_single_proc; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¢å 䏿¡è®°å½åå¨è¿ç¨ |
| | | /// </summary> |
| | | /// <param name="TableName"></param> |
| | | /// <param name="TableAlias"></param> |
| | | /// <param name="Author"></param> |
| | | /// <param name="ChinaComment"></param> |
| | | /// <param name="str_query_2"></param> |
| | | /// <param name="PimaryKey"></param> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | private static string GetAddProcStr(string TableName, string TableAlias, string Author, string ChinaComment, |
| | | string filePrefixName, List<ColumnModel> columnNameList) |
| | | { |
| | | var str_proc = TextHelper.ReadText(@"Templete\proc\å¢å 䏿¡è®°å½åå¨è¿ç¨.txt"); |
| | | |
| | | str_proc = str_proc.Replace("$ProcName$", filePrefixName + "_ADD");//åå¨è¿ç¨å |
| | | str_proc = str_proc.Replace("$TableName$", TableName);//表å |
| | | str_proc = str_proc.Replace("$TableAlias$", TableAlias);//å«å |
| | | str_proc = str_proc.Replace("$Author$", Author);//ä½è
|
| | | str_proc = str_proc.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str_proc = str_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | |
| | | |
| | | string str_insert_cols = StructStrHelper.GetColumnsStrNoIDForAdd(columnNameList, ""); |
| | | str_proc = str_proc.Replace("$insert_cols$", str_insert_cols); |
| | | str_proc = str_proc.Replace("$insert_cols_values$", StructStrHelper.GetColumnsStrNoIDForAdd(columnNameList, "@")); |
| | | str_proc = str_proc.Replace("$insert_cols_params$", StructStrHelper.GetInputParamColumnsStrForAdd(columnNameList)); |
| | | |
| | | return str_proc; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ç¼è¾ä¸æ¡è®°å½åå¨è¿ç¨ |
| | | /// </summary> |
| | | /// <param name="TableName"></param> |
| | | /// <param name="TableAlias"></param> |
| | | /// <param name="Author"></param> |
| | | /// <param name="ChinaComment"></param> |
| | | /// <param name="PimaryKey"></param> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | private static string GetUpdateProcStr(string TableName, string TableAlias, string Author, string ChinaComment, |
| | | string PimaryKey, string filePrefixName, List<ColumnModel> columnNameList) |
| | | { |
| | | var str_proc = TextHelper.ReadText(@"Templete\proc\ä¿®æ¹ä¸æ¡è®°å½åå¨è¿ç¨.txt"); |
| | | |
| | | str_proc = str_proc.Replace("$ProcName$", filePrefixName + "_Update");//åå¨è¿ç¨å |
| | | str_proc = str_proc.Replace("$TableName$", TableName);//表å |
| | | str_proc = str_proc.Replace("$TableAlias$", TableAlias);//å«å |
| | | str_proc = str_proc.Replace("$Author$", Author);//ä½è
|
| | | str_proc = str_proc.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str_proc = str_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | |
| | | str_proc = str_proc.Replace("$Primary$", PimaryKey); |
| | | |
| | | str_proc = str_proc.Replace("$update_cols_params$", StructStrHelper.GetInputParamColumnsStrForUpdate(columnNameList)); |
| | | str_proc = str_proc.Replace("$update_cols_assignment$", StructStrHelper.GetCols_AssignmentStrForUpdate(columnNameList)); |
| | | |
| | | return str_proc; |
| | | } |
| | | |
| | | private static string GetUpdateProcStr2(string TableName, string TableAlias, string Author, string ChinaComment, |
| | | string PimaryKey, string filePrefixName, List<ColumnModel> columnNameList) |
| | | { |
| | | var str_proc = TextHelper.ReadText(@"Templete\proc\ä¿®æ¹ä¸æ¡è®°å½åå¨è¿ç¨2.txt"); |
| | | |
| | | str_proc = str_proc.Replace("$ProcName$", filePrefixName + "_Update");//åå¨è¿ç¨å |
| | | str_proc = str_proc.Replace("$TableName$", TableName);//表å |
| | | str_proc = str_proc.Replace("$TableAlias$", TableAlias);//å«å |
| | | str_proc = str_proc.Replace("$Author$", Author);//ä½è
|
| | | str_proc = str_proc.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str_proc = str_proc.Replace("$CurDate$", CommonHelper.GetCurDate());//å½åæ¶é´ |
| | | |
| | | str_proc = str_proc.Replace("$Primary$", PimaryKey); |
| | | |
| | | str_proc = str_proc.Replace("$update_cols_params$", StructStrHelper.GetInputParamColumnsStrForUpdate(columnNameList)); |
| | | str_proc = str_proc.Replace("$update_cols_assignment2$", StructStrHelper.GetCols_AssignmentStrForUpdate2(columnNameList)); |
| | | |
| | | return str_proc; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// çæServicesçæ¥å£å®ç°æä»¶ |
| | | /// </summary> |
| | | public class Services_InterfaceRealize_Generate : BaseGenerate |
| | | { |
| | | public static string CreateText(string Wcf_NameSpacePath, string Modulelogo, string entityName, |
| | | string ChinaComment, string filePrefixName, string primaryKey, string TableAlias, string addEntityParam, |
| | | List<ColumnModel> columnList,string groupName) |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\Servicesæ¥å£å®ç°æ¨¡æ¿.txt"); |
| | | |
| | | str = str.Replace("$ValidateEmptyStrForPrimaryKey$", StructStrHelper.GetValidateEmptyStrForPrimaryKey(columnList, primaryKey)); |
| | | str = str.Replace("$Wcf_NameSpacePath$", Wcf_NameSpacePath);//WCF项ç®çå½åç©ºé´ |
| | | str = str.Replace("$GroupName$", groupName);//åç»å |
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str = str.Replace("$EntityName$", entityName);//å®ä½ç±»å |
| | | str = str.Replace("$EntityName_FirstLetterLower$", CommonHelper.FirstLowercase(entityName));//é¦åæ¯å°åï¼å±é¨åéå |
| | | str = str.Replace("$Modulelogo$", Modulelogo);//模åç®å |
| | | str = str.Replace("$FilePrefixName$", filePrefixName);//模åå |
| | | str = str.Replace("$PrimaryKey$", primaryKey);//主é®å |
| | | |
| | | str = str.Replace("$ValidateEmptyForInsert$", StructStrHelper.GetValidateEmptyStr(columnList)); |
| | | str = str.Replace("$ValidateEmptyForUpdate$", StructStrHelper.GetValidateEmptyStr(columnList, false)); |
| | | str = str.Replace("$WhereQuery$", StructStrHelper.GetStrForWhereQuery(columnList)); |
| | | str = str.Replace("$AddEntityParam$", addEntityParam); |
| | | |
| | | str = str.Replace("$TableAlias$", TableAlias);//表å«å |
| | | |
| | | CommonReplace(ref str); |
| | | |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// çæServicesçæ¥å£æä»¶ |
| | | /// </summary> |
| | | public class Services_Interface_Generate : BaseGenerate |
| | | { |
| | | public static string CreateText(string Wcf_NameSpacePath, string Modulelogo, string entityName, |
| | | string ChinaComment, string addEntityParam) |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\Servicesæ¥å£æ¨¡æ¿.txt"); |
| | | |
| | | str = str.Replace("$Wcf_NameSpacePath$", Wcf_NameSpacePath);//WCF项ç®çå½åç©ºé´ |
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str = str.Replace("$EntityName$", entityName);//å®ä½ç±»å |
| | | str = str.Replace("$Modulelogo$", Modulelogo);//模åç®å |
| | | str = str.Replace("$AddEntityParam$", addEntityParam); |
| | | |
| | | CommonReplace(ref str); |
| | | |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// VUEæ¹æ³é
ç½® |
| | | /// </summary> |
| | | public class VUE_FunConfig_Generate : BaseGenerate |
| | | { |
| | | /// <summary> |
| | | /// VUEæ¹æ³é
ç½® |
| | | /// </summary> |
| | | /// <param name="Modulelogo">模åç®å</param> |
| | | /// <param name="ChinaComment">ä¸ææ³¨é</param> |
| | | /// <param name="routePrefix">WCFè·¯ç±åç¼</param> |
| | | /// <returns></returns> |
| | | public static string CreateText(string Modulelogo, |
| | | string ChinaComment, string routePrefix,string entityName) |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\VUE\VUEæ¹æ³é
ç½®.txt"); |
| | | CommonReplace(ref str); |
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | str = str.Replace("$Modulelogo$", Modulelogo);//模åç®å |
| | | str = str.Replace("$RoutePrefix$", routePrefix);//模åç®å |
| | | str = str.Replace("$EntityName$", entityName);//模åç®å |
| | | |
| | | |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// VUEæä»¶ |
| | | /// </summary> |
| | | public class VUE_Generate : BaseGenerate |
| | | { |
| | | public static string CreateText(string TableAlias, string modulelogo, string primaryKey, |
| | | List<ColumnModel> columnNameList, string ChinaComment |
| | | , string emport_templeteFileDownName, string emport_excelCategroy) |
| | | { |
| | | var str = TextHelper.ReadText(@"Templete\VUE\VUEæä»¶æ¨¡æ¿.txt"); |
| | | |
| | | CommonReplace(ref str); |
| | | str = str.Replace("$el-table-column$", StructStrHelper.GetElTableColumnStr(columnNameList));//å表项 |
| | | |
| | | //æ°å¢/ç¼è¾çé¢ |
| | | str = str.Replace("$el-item$", StructStrHelper.GetElFormItemStrForAddEditForm(columnNameList)); |
| | | |
| | | //æ¥ççé¢ |
| | | str = str.Replace("$el-item-view$", StructStrHelper.GetElFormItemStrForViewForm(columnNameList)); |
| | | |
| | | str = str.Replace("$el-form-itemForSearch$", StructStrHelper.GetElFormItemForSearchStr(columnNameList)); |
| | | |
| | | //导åºå符串 |
| | | str = str.Replace("$VueExportColumnHeaderStr$", StructStrHelper.GetVueExportTHeaderArrayStr(columnNameList)); |
| | | |
| | | |
| | | //å
Œ
±æ¥è¯¢çå |
| | | var SearchFormInputPlaceholderNameStr = ""; |
| | | str = str.Replace("$SearchFormInputPlaceholderStr$", StructStrHelper.GetVueSearchFormInputPlaceholderStr(columnNameList, ref SearchFormInputPlaceholderNameStr)); |
| | | str = str.Replace("$SearchFormInputPlaceholderNameStr$", SearchFormInputPlaceholderNameStr); |
| | | |
| | | //é«çº§æ¥è¯¢ |
| | | str = str.Replace("$FormOptionsStr$", StructStrHelper.GetVueFormOptionsStr(columnNameList)); |
| | | |
| | | str = str.Replace("$ChinaComment$", ChinaComment);//ä¸ææ³¨é |
| | | |
| | | |
| | | str = str.Replace("$Modulelogo$", modulelogo);//表å«å(ä»ä¸å®è¦å¨æåæ¿æ¢) |
| | | str = str.Replace("$TableAlias$", TableAlias);//表å«å(ä»ä¸å®è¦å¨æåæ¿æ¢) |
| | | str = str.Replace("$PrimaryKey$", primaryKey);//ä¸»é® |
| | | |
| | | //æ¿æ¢å¯¼å
¥åè½ |
| | | str = str.Replace("$emport_templeteFileDownName$", emport_templeteFileDownName); |
| | | str = str.Replace("$emport_excelCategroy$", emport_excelCategroy); |
| | | |
| | | return str; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
| | | <PropertyGroup> |
| | | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
| | | <Platform Condition=" '$(Platform)' == '' ">x86</Platform> |
| | | <ProductVersion>8.0.30703</ProductVersion> |
| | | <SchemaVersion>2.0</SchemaVersion> |
| | | <ProjectGuid>{004A790A-7F45-4D97-95E3-478FD73FB434}</ProjectGuid> |
| | | <OutputType>WinExe</OutputType> |
| | | <AppDesignerFolder>Properties</AppDesignerFolder> |
| | | <RootNamespace>GenerateCode_WeiBen_WMS</RootNamespace> |
| | | <AssemblyName>GenerateCode_WeiBen_WMS</AssemblyName> |
| | | <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> |
| | | <FileAlignment>512</FileAlignment> |
| | | <PublishUrl>publish\</PublishUrl> |
| | | <Install>true</Install> |
| | | <InstallFrom>Disk</InstallFrom> |
| | | <UpdateEnabled>false</UpdateEnabled> |
| | | <UpdateMode>Foreground</UpdateMode> |
| | | <UpdateInterval>7</UpdateInterval> |
| | | <UpdateIntervalUnits>Days</UpdateIntervalUnits> |
| | | <UpdatePeriodically>false</UpdatePeriodically> |
| | | <UpdateRequired>false</UpdateRequired> |
| | | <MapFileExtensions>true</MapFileExtensions> |
| | | <ApplicationRevision>0</ApplicationRevision> |
| | | <ApplicationVersion>1.0.0.%2a</ApplicationVersion> |
| | | <IsWebBootstrapper>false</IsWebBootstrapper> |
| | | <UseApplicationTrust>false</UseApplicationTrust> |
| | | <BootstrapperEnabled>true</BootstrapperEnabled> |
| | | <TargetFrameworkProfile /> |
| | | </PropertyGroup> |
| | | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> |
| | | <PlatformTarget>x86</PlatformTarget> |
| | | <DebugSymbols>true</DebugSymbols> |
| | | <DebugType>full</DebugType> |
| | | <Optimize>false</Optimize> |
| | | <OutputPath>bin\Debug\</OutputPath> |
| | | <DefineConstants>DEBUG;TRACE</DefineConstants> |
| | | <ErrorReport>prompt</ErrorReport> |
| | | <WarningLevel>4</WarningLevel> |
| | | <Prefer32Bit>false</Prefer32Bit> |
| | | </PropertyGroup> |
| | | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> |
| | | <PlatformTarget>x86</PlatformTarget> |
| | | <DebugType>pdbonly</DebugType> |
| | | <Optimize>true</Optimize> |
| | | <OutputPath>bin\Release\</OutputPath> |
| | | <DefineConstants>TRACE</DefineConstants> |
| | | <ErrorReport>prompt</ErrorReport> |
| | | <WarningLevel>4</WarningLevel> |
| | | <Prefer32Bit>false</Prefer32Bit> |
| | | </PropertyGroup> |
| | | <PropertyGroup> |
| | | <ApplicationIcon>Robot.ico</ApplicationIcon> |
| | | </PropertyGroup> |
| | | <ItemGroup> |
| | | <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
| | | <HintPath>packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> |
| | | <HintPath>packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.2, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL"> |
| | | <HintPath>packages\Microsoft.Extensions.Logging.Abstractions.8.0.2\lib\net462\Microsoft.Extensions.Logging.Abstractions.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="MySqlConnector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d33d3e53aa5f8c92, processorArchitecture=MSIL"> |
| | | <HintPath>packages\MySqlConnector.2.4.0\lib\net48\MySqlConnector.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
| | | <HintPath>packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="System" /> |
| | | <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
| | | <HintPath>packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="System.configuration" /> |
| | | <Reference Include="System.Core" /> |
| | | <Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
| | | <HintPath>packages\System.Diagnostics.DiagnosticSource.8.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
| | | <HintPath>packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="System.Numerics" /> |
| | | <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
| | | <HintPath>packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> |
| | | <HintPath>packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL"> |
| | | <HintPath>packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="System.Transactions" /> |
| | | <Reference Include="System.Xml.Linq" /> |
| | | <Reference Include="System.Data.DataSetExtensions" /> |
| | | <Reference Include="System.Data" /> |
| | | <Reference Include="System.Deployment" /> |
| | | <Reference Include="System.Drawing" /> |
| | | <Reference Include="System.Windows.Forms" /> |
| | | <Reference Include="System.Xml" /> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <Compile Include="DataBaseFactory\DataBaseServiceHandle.cs" /> |
| | | <Compile Include="DataBaseFactory\DataBaseServiceFactory.cs" /> |
| | | <Compile Include="DataBaseFactory\Default\SqlServerDataBaseServiceHandle.cs" /> |
| | | <Compile Include="DataBaseFactory\Default\MySqlDataBaseServiceHandle.cs" /> |
| | | <Compile Include="Generate\BaseGenerate.cs" /> |
| | | <Compile Include="Generate\Controller\Controller_Generate.cs" /> |
| | | <Compile Include="Generate\Entity\AddModel_Generate.cs" /> |
| | | <Compile Include="Generate\Entity\OutputModel_Generate.cs" /> |
| | | <Compile Include="Generate\InsertSQL_Generate.cs" /> |
| | | <Compile Include="Generate\VUE\VUE_Generate.cs" /> |
| | | <Compile Include="Generate\Services_InterfaceRealize_Generate.cs" /> |
| | | <Compile Include="Generate\VUE\VUE_FunConfig_Generate.cs" /> |
| | | <Compile Include="Generate\Services_Interface_Generate.cs" /> |
| | | <Compile Include="Generate\Entity\InputModel_Generate.cs" /> |
| | | <Compile Include="Generate\BLL_Generate.cs" /> |
| | | <Compile Include="Generate\DAL_Generate.cs" /> |
| | | <Compile Include="Generate\Procedure_Generate.cs" /> |
| | | <Compile Include="Model\Enum\DataBaseEnum.cs" /> |
| | | <Compile Include="Model\Enum\DataTypeEnum.cs" /> |
| | | <Compile Include="Model\ListItem.cs" /> |
| | | <Compile Include="Model\Proc.cs" /> |
| | | <Compile Include="Model\SystemCommonVar.cs" /> |
| | | <Compile Include="Utility\CommonHelper.cs" /> |
| | | <Compile Include="Model\ColumnModell.cs" /> |
| | | <Compile Include="Generate\Model_Generate.cs" /> |
| | | <Compile Include="Program.cs" /> |
| | | <Compile Include="Properties\AssemblyInfo.cs" /> |
| | | <Compile Include="Utility\ListHelper.cs" /> |
| | | <Compile Include="Utility\MySqlHelper.cs" /> |
| | | <Compile Include="Utility\SQLHelper.cs" /> |
| | | <Compile Include="MainForm.cs"> |
| | | <SubType>Form</SubType> |
| | | </Compile> |
| | | <Compile Include="MainForm.Designer.cs"> |
| | | <DependentUpon>MainForm.cs</DependentUpon> |
| | | </Compile> |
| | | <Compile Include="Utility\StructStrHelper.cs" /> |
| | | <Compile Include="Utility\TextHelper.cs" /> |
| | | <EmbeddedResource Include="Properties\Resources.resx"> |
| | | <Generator>ResXFileCodeGenerator</Generator> |
| | | <LastGenOutput>Resources.Designer.cs</LastGenOutput> |
| | | <SubType>Designer</SubType> |
| | | </EmbeddedResource> |
| | | <Compile Include="Properties\Resources.Designer.cs"> |
| | | <AutoGen>True</AutoGen> |
| | | <DependentUpon>Resources.resx</DependentUpon> |
| | | <DesignTime>True</DesignTime> |
| | | </Compile> |
| | | <EmbeddedResource Include="MainForm.resx"> |
| | | <DependentUpon>MainForm.cs</DependentUpon> |
| | | </EmbeddedResource> |
| | | <None Include="App.config" /> |
| | | <None Include="packages.config" /> |
| | | <None Include="Properties\Settings.settings"> |
| | | <Generator>SettingsSingleFileGenerator</Generator> |
| | | <LastGenOutput>Settings.Designer.cs</LastGenOutput> |
| | | </None> |
| | | <Compile Include="Properties\Settings.Designer.cs"> |
| | | <AutoGen>True</AutoGen> |
| | | <DependentUpon>Settings.settings</DependentUpon> |
| | | <DesignTimeSharedInput>True</DesignTimeSharedInput> |
| | | </Compile> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> |
| | | <Visible>False</Visible> |
| | | <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> |
| | | <Install>false</Install> |
| | | </BootstrapperPackage> |
| | | <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> |
| | | <Visible>False</Visible> |
| | | <ProductName>.NET Framework 3.5 SP1</ProductName> |
| | | <Install>true</Install> |
| | | </BootstrapperPackage> |
| | | <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> |
| | | <Visible>False</Visible> |
| | | <ProductName>Windows Installer 3.1</ProductName> |
| | | <Install>true</Install> |
| | | </BootstrapperPackage> |
| | | </ItemGroup> |
| | | <ItemGroup> |
| | | <Content Include="Robot.ico" /> |
| | | <Content Include="Templete\Controller模æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Entity\AddModel模æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Entity\OutputModel模æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Proc\ä¿®æ¹ä¸æ¡è®°å½åå¨è¿ç¨2.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Proc\ä¿®æ¹ä¸æ¡è®°å½åå¨è¿ç¨.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Proc\å表åå¨è¿ç¨.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Proc\å¢å 䏿¡è®°å½åå¨è¿ç¨.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\VUE\VUEæä»¶æ¨¡æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Servicesæ¥å£å®ç°æ¨¡æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\VUE\VUEæ¹æ³é
ç½®.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Servicesæ¥å£æ¨¡æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Entity\InputModel模æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\BLL模æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\DAL模æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Proc\å¾å°ä¸ä¸ªå®ä½åå¨è¿ç¨.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\Proc\å页åå¨è¿ç¨.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | <Content Include="Templete\InitSQL模æ¿.txt"> |
| | | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
| | | </Content> |
| | | </ItemGroup> |
| | | <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
| | | <!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
| | | Other similar extension points exist, see Microsoft.Common.targets. |
| | | <Target Name="BeforeBuild"> |
| | | </Target> |
| | | <Target Name="AfterBuild"> |
| | | </Target> |
| | | --> |
| | | </Project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | Microsoft Visual Studio Solution File, Format Version 12.00 |
| | | # Visual Studio Version 17 |
| | | VisualStudioVersion = 17.4.33213.308 |
| | | MinimumVisualStudioVersion = 10.0.40219.1 |
| | | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenerateCode_WeiBen_CMS", "GenerateCode_WeiBen_CMS.csproj", "{004A790A-7F45-4D97-95E3-478FD73FB434}" |
| | | EndProject |
| | | Global |
| | | GlobalSection(SolutionConfigurationPlatforms) = preSolution |
| | | Debug|Any CPU = Debug|Any CPU |
| | | Debug|x86 = Debug|x86 |
| | | Release|Any CPU = Release|Any CPU |
| | | Release|x86 = Release|x86 |
| | | EndGlobalSection |
| | | GlobalSection(ProjectConfigurationPlatforms) = postSolution |
| | | {004A790A-7F45-4D97-95E3-478FD73FB434}.Debug|Any CPU.ActiveCfg = Debug|x86 |
| | | {004A790A-7F45-4D97-95E3-478FD73FB434}.Debug|x86.ActiveCfg = Debug|x86 |
| | | {004A790A-7F45-4D97-95E3-478FD73FB434}.Debug|x86.Build.0 = Debug|x86 |
| | | {004A790A-7F45-4D97-95E3-478FD73FB434}.Release|Any CPU.ActiveCfg = Release|x86 |
| | | {004A790A-7F45-4D97-95E3-478FD73FB434}.Release|x86.ActiveCfg = Release|x86 |
| | | {004A790A-7F45-4D97-95E3-478FD73FB434}.Release|x86.Build.0 = Release|x86 |
| | | EndGlobalSection |
| | | GlobalSection(SolutionProperties) = preSolution |
| | | HideSolutionNode = FALSE |
| | | EndGlobalSection |
| | | GlobalSection(ExtensibilityGlobals) = postSolution |
| | | SolutionGuid = {5076F6A8-79EC-4DE9-82F3-7095D2B9E409} |
| | | EndGlobalSection |
| | | EndGlobal |
¶Ô±ÈÐÂÎļþ |
| | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | partial class MainForm |
| | | { |
| | | /// <summary> |
| | | /// å¿
éç设计å¨åéã |
| | | /// </summary> |
| | | private System.ComponentModel.IContainer components = null; |
| | | |
| | | /// <summary> |
| | | /// æ¸
çæææ£å¨ä½¿ç¨çèµæºã |
| | | /// </summary> |
| | | /// <param name="disposing">妿åºéæ¾æç®¡èµæºï¼ä¸º trueï¼å¦å为 falseã</param> |
| | | protected override void Dispose(bool disposing) |
| | | { |
| | | if (disposing && (components != null)) |
| | | { |
| | | components.Dispose(); |
| | | } |
| | | base.Dispose(disposing); |
| | | } |
| | | |
| | | #region Windows çªä½è®¾è®¡å¨çæç代ç |
| | | |
| | | /// <summary> |
| | | /// è®¾è®¡å¨æ¯ææéçæ¹æ³ - ä¸è¦ |
| | | /// 使ç¨ä»£ç ç¼è¾å¨ä¿®æ¹æ¤æ¹æ³çå
容ã |
| | | /// </summary> |
| | | private void InitializeComponent() |
| | | { |
| | | this.btnPath = new System.Windows.Forms.Button(); |
| | | this.lblds = new System.Windows.Forms.Label(); |
| | | this.tbPath = new System.Windows.Forms.TextBox(); |
| | | this.btnExit = new System.Windows.Forms.Button(); |
| | | this.btn_CreateFile = new System.Windows.Forms.Button(); |
| | | this.tb_TableName = new System.Windows.Forms.TextBox(); |
| | | this.tb_FileName = new System.Windows.Forms.TextBox(); |
| | | this.label1 = new System.Windows.Forms.Label(); |
| | | this.tb_WCF_NameSpacePath = new System.Windows.Forms.TextBox(); |
| | | this.label2 = new System.Windows.Forms.Label(); |
| | | this.tb_ChinaComment = new System.Windows.Forms.TextBox(); |
| | | this.label4 = new System.Windows.Forms.Label(); |
| | | this.tb_CreatePerson = new System.Windows.Forms.TextBox(); |
| | | this.label5 = new System.Windows.Forms.Label(); |
| | | this.tb_Primary = new System.Windows.Forms.TextBox(); |
| | | this.label6 = new System.Windows.Forms.Label(); |
| | | this.tb_EntityProName = new System.Windows.Forms.TextBox(); |
| | | this.label7 = new System.Windows.Forms.Label(); |
| | | this.tb_EntityName = new System.Windows.Forms.TextBox(); |
| | | this.label8 = new System.Windows.Forms.Label(); |
| | | this.label9 = new System.Windows.Forms.Label(); |
| | | this.tb_OrderBy = new System.Windows.Forms.TextBox(); |
| | | this.label10 = new System.Windows.Forms.Label(); |
| | | this.tb_PrimaryDesc = new System.Windows.Forms.TextBox(); |
| | | this.label11 = new System.Windows.Forms.Label(); |
| | | this.tb_Modulelogo = new System.Windows.Forms.TextBox(); |
| | | this.label3 = new System.Windows.Forms.Label(); |
| | | this.btn_InsertSql = new System.Windows.Forms.Button(); |
| | | this.tb_RoutePrefix = new System.Windows.Forms.TextBox(); |
| | | this.label13 = new System.Windows.Forms.Label(); |
| | | this.groupBox1 = new System.Windows.Forms.GroupBox(); |
| | | this.lbl_DataSource = new System.Windows.Forms.Label(); |
| | | this.cmb_DataSource = new System.Windows.Forms.ComboBox(); |
| | | this.groupBox2 = new System.Windows.Forms.GroupBox(); |
| | | this.tb_GroupName = new System.Windows.Forms.TextBox(); |
| | | this.label16 = new System.Windows.Forms.Label(); |
| | | this.label15 = new System.Windows.Forms.Label(); |
| | | this.tb_ProjectNamePrefix = new System.Windows.Forms.TextBox(); |
| | | this.groupBox3 = new System.Windows.Forms.GroupBox(); |
| | | this.tb_importExcelCategroy = new System.Windows.Forms.TextBox(); |
| | | this.ck_IsShowImport = new System.Windows.Forms.CheckBox(); |
| | | this.label12 = new System.Windows.Forms.Label(); |
| | | this.tb_templeteFileDownName = new System.Windows.Forms.TextBox(); |
| | | this.label14 = new System.Windows.Forms.Label(); |
| | | this.cmb_DataBase = new System.Windows.Forms.ComboBox(); |
| | | this.label17 = new System.Windows.Forms.Label(); |
| | | this.groupBox1.SuspendLayout(); |
| | | this.groupBox2.SuspendLayout(); |
| | | this.groupBox3.SuspendLayout(); |
| | | this.SuspendLayout(); |
| | | // |
| | | // btnPath |
| | | // |
| | | this.btnPath.Location = new System.Drawing.Point(425, 570); |
| | | this.btnPath.Name = "btnPath"; |
| | | this.btnPath.Size = new System.Drawing.Size(97, 23); |
| | | this.btnPath.TabIndex = 1; |
| | | this.btnPath.Text = "éæ©çæè·¯å¾"; |
| | | this.btnPath.UseVisualStyleBackColor = true; |
| | | this.btnPath.Click += new System.EventHandler(this.button1_Click); |
| | | // |
| | | // lblds |
| | | // |
| | | this.lblds.AutoSize = true; |
| | | this.lblds.Location = new System.Drawing.Point(22, 72); |
| | | this.lblds.Name = "lblds"; |
| | | this.lblds.Size = new System.Drawing.Size(35, 12); |
| | | this.lblds.TabIndex = 2; |
| | | this.lblds.Text = "表å:"; |
| | | // |
| | | // tbPath |
| | | // |
| | | this.tbPath.Location = new System.Drawing.Point(106, 566); |
| | | this.tbPath.Name = "tbPath"; |
| | | this.tbPath.ReadOnly = true; |
| | | this.tbPath.Size = new System.Drawing.Size(253, 21); |
| | | this.tbPath.TabIndex = 7; |
| | | // |
| | | // btnExit |
| | | // |
| | | this.btnExit.Location = new System.Drawing.Point(649, 600); |
| | | this.btnExit.Name = "btnExit"; |
| | | this.btnExit.Size = new System.Drawing.Size(171, 67); |
| | | this.btnExit.TabIndex = 8; |
| | | this.btnExit.Text = "éåº"; |
| | | this.btnExit.UseVisualStyleBackColor = true; |
| | | this.btnExit.Click += new System.EventHandler(this.btnExit_Click); |
| | | // |
| | | // btn_CreateFile |
| | | // |
| | | this.btn_CreateFile.Location = new System.Drawing.Point(106, 600); |
| | | this.btn_CreateFile.Name = "btn_CreateFile"; |
| | | this.btn_CreateFile.Size = new System.Drawing.Size(157, 67); |
| | | this.btn_CreateFile.TabIndex = 14; |
| | | this.btn_CreateFile.Text = "çææä»¶"; |
| | | this.btn_CreateFile.UseVisualStyleBackColor = true; |
| | | this.btn_CreateFile.Click += new System.EventHandler(this.btn_CreateFile_Click); |
| | | // |
| | | // tb_TableName |
| | | // |
| | | this.tb_TableName.Location = new System.Drawing.Point(92, 69); |
| | | this.tb_TableName.Name = "tb_TableName"; |
| | | this.tb_TableName.Size = new System.Drawing.Size(183, 21); |
| | | this.tb_TableName.TabIndex = 15; |
| | | this.tb_TableName.TextChanged += new System.EventHandler(this.tb_TableName_TextChanged); |
| | | // |
| | | // tb_FileName |
| | | // |
| | | this.tb_FileName.Location = new System.Drawing.Point(221, 152); |
| | | this.tb_FileName.Name = "tb_FileName"; |
| | | this.tb_FileName.Size = new System.Drawing.Size(199, 21); |
| | | this.tb_FileName.TabIndex = 17; |
| | | // |
| | | // label1 |
| | | // |
| | | this.label1.AutoSize = true; |
| | | this.label1.Location = new System.Drawing.Point(25, 154); |
| | | this.label1.Name = "label1"; |
| | | this.label1.Size = new System.Drawing.Size(191, 12); |
| | | this.label1.TabIndex = 16; |
| | | this.label1.Text = "æä»¶åç§°(ç¨äºç»å个类åçåç¼):"; |
| | | // |
| | | // tb_WCF_NameSpacePath |
| | | // |
| | | this.tb_WCF_NameSpacePath.Location = new System.Drawing.Point(563, 247); |
| | | this.tb_WCF_NameSpacePath.Name = "tb_WCF_NameSpacePath"; |
| | | this.tb_WCF_NameSpacePath.Size = new System.Drawing.Size(197, 21); |
| | | this.tb_WCF_NameSpacePath.TabIndex = 19; |
| | | // |
| | | // label2 |
| | | // |
| | | this.label2.AutoSize = true; |
| | | this.label2.Location = new System.Drawing.Point(455, 249); |
| | | this.label2.Name = "label2"; |
| | | this.label2.Size = new System.Drawing.Size(101, 12); |
| | | this.label2.TabIndex = 18; |
| | | this.label2.Text = "WCF项ç®å½å空é´:"; |
| | | // |
| | | // tb_ChinaComment |
| | | // |
| | | this.tb_ChinaComment.Location = new System.Drawing.Point(221, 234); |
| | | this.tb_ChinaComment.Name = "tb_ChinaComment"; |
| | | this.tb_ChinaComment.Size = new System.Drawing.Size(197, 21); |
| | | this.tb_ChinaComment.TabIndex = 23; |
| | | // |
| | | // label4 |
| | | // |
| | | this.label4.AutoSize = true; |
| | | this.label4.Location = new System.Drawing.Point(26, 234); |
| | | this.label4.Name = "label4"; |
| | | this.label4.Size = new System.Drawing.Size(83, 12); |
| | | this.label4.TabIndex = 22; |
| | | this.label4.Text = "表çä¸ææ³¨è§£:"; |
| | | // |
| | | // tb_CreatePerson |
| | | // |
| | | this.tb_CreatePerson.Location = new System.Drawing.Point(221, 279); |
| | | this.tb_CreatePerson.Name = "tb_CreatePerson"; |
| | | this.tb_CreatePerson.Size = new System.Drawing.Size(199, 21); |
| | | this.tb_CreatePerson.TabIndex = 25; |
| | | // |
| | | // label5 |
| | | // |
| | | this.label5.AutoSize = true; |
| | | this.label5.Location = new System.Drawing.Point(26, 289); |
| | | this.label5.Name = "label5"; |
| | | this.label5.Size = new System.Drawing.Size(107, 12); |
| | | this.label5.TabIndex = 24; |
| | | this.label5.Text = "ä½ çååæ¼é³ç¼©å:"; |
| | | // |
| | | // tb_Primary |
| | | // |
| | | this.tb_Primary.Location = new System.Drawing.Point(338, 69); |
| | | this.tb_Primary.Name = "tb_Primary"; |
| | | this.tb_Primary.Size = new System.Drawing.Size(145, 21); |
| | | this.tb_Primary.TabIndex = 27; |
| | | // |
| | | // label6 |
| | | // |
| | | this.label6.AutoSize = true; |
| | | this.label6.Location = new System.Drawing.Point(298, 72); |
| | | this.label6.Name = "label6"; |
| | | this.label6.Size = new System.Drawing.Size(35, 12); |
| | | this.label6.TabIndex = 26; |
| | | this.label6.Text = "主é®:"; |
| | | // |
| | | // tb_EntityProName |
| | | // |
| | | this.tb_EntityProName.Location = new System.Drawing.Point(560, 141); |
| | | this.tb_EntityProName.Name = "tb_EntityProName"; |
| | | this.tb_EntityProName.Size = new System.Drawing.Size(183, 21); |
| | | this.tb_EntityProName.TabIndex = 31; |
| | | this.tb_EntityProName.TextChanged += new System.EventHandler(this.tb_EntityProName_TextChanged); |
| | | // |
| | | // label7 |
| | | // |
| | | this.label7.AutoSize = true; |
| | | this.label7.Location = new System.Drawing.Point(436, 149); |
| | | this.label7.Name = "label7"; |
| | | this.label7.Size = new System.Drawing.Size(125, 12); |
| | | this.label7.TabIndex = 30; |
| | | this.label7.Text = "å®ä½ç±»å¯¹è±¡å/表å«å:"; |
| | | // |
| | | // tb_EntityName |
| | | // |
| | | this.tb_EntityName.Location = new System.Drawing.Point(92, 108); |
| | | this.tb_EntityName.Name = "tb_EntityName"; |
| | | this.tb_EntityName.Size = new System.Drawing.Size(183, 21); |
| | | this.tb_EntityName.TabIndex = 29; |
| | | // |
| | | // label8 |
| | | // |
| | | this.label8.AutoSize = true; |
| | | this.label8.Location = new System.Drawing.Point(22, 111); |
| | | this.label8.Name = "label8"; |
| | | this.label8.Size = new System.Drawing.Size(59, 12); |
| | | this.label8.TabIndex = 28; |
| | | this.label8.Text = "å®ä½ç±»å:"; |
| | | // |
| | | // label9 |
| | | // |
| | | this.label9.AutoSize = true; |
| | | this.label9.Location = new System.Drawing.Point(463, 210); |
| | | this.label9.Name = "label9"; |
| | | this.label9.Size = new System.Drawing.Size(35, 12); |
| | | this.label9.TabIndex = 34; |
| | | this.label9.Text = "æåº:"; |
| | | // |
| | | // tb_OrderBy |
| | | // |
| | | this.tb_OrderBy.Location = new System.Drawing.Point(503, 207); |
| | | this.tb_OrderBy.Name = "tb_OrderBy"; |
| | | this.tb_OrderBy.Size = new System.Drawing.Size(145, 21); |
| | | this.tb_OrderBy.TabIndex = 35; |
| | | // |
| | | // label10 |
| | | // |
| | | this.label10.AutoSize = true; |
| | | this.label10.Location = new System.Drawing.Point(668, 210); |
| | | this.label10.Name = "label10"; |
| | | this.label10.Size = new System.Drawing.Size(65, 12); |
| | | this.label10.TabIndex = 36; |
| | | this.label10.Text = "(é»è®¤éåº)"; |
| | | // |
| | | // tb_PrimaryDesc |
| | | // |
| | | this.tb_PrimaryDesc.Location = new System.Drawing.Point(569, 69); |
| | | this.tb_PrimaryDesc.Name = "tb_PrimaryDesc"; |
| | | this.tb_PrimaryDesc.Size = new System.Drawing.Size(145, 21); |
| | | this.tb_PrimaryDesc.TabIndex = 38; |
| | | // |
| | | // label11 |
| | | // |
| | | this.label11.AutoSize = true; |
| | | this.label11.Location = new System.Drawing.Point(508, 72); |
| | | this.label11.Name = "label11"; |
| | | this.label11.Size = new System.Drawing.Size(59, 12); |
| | | this.label11.TabIndex = 37; |
| | | this.label11.Text = "ä¸»é®æè¿°:"; |
| | | // |
| | | // tb_Modulelogo |
| | | // |
| | | this.tb_Modulelogo.Location = new System.Drawing.Point(221, 202); |
| | | this.tb_Modulelogo.Name = "tb_Modulelogo"; |
| | | this.tb_Modulelogo.Size = new System.Drawing.Size(199, 21); |
| | | this.tb_Modulelogo.TabIndex = 41; |
| | | // |
| | | // label3 |
| | | // |
| | | this.label3.AutoSize = true; |
| | | this.label3.Location = new System.Drawing.Point(25, 206); |
| | | this.label3.Name = "label3"; |
| | | this.label3.Size = new System.Drawing.Size(167, 12); |
| | | this.label3.TabIndex = 40; |
| | | this.label3.Text = "模åç®å(ç¨äºç»åä¸ªæ¹æ³å):"; |
| | | // |
| | | // btn_InsertSql |
| | | // |
| | | this.btn_InsertSql.Location = new System.Drawing.Point(385, 600); |
| | | this.btn_InsertSql.Name = "btn_InsertSql"; |
| | | this.btn_InsertSql.Size = new System.Drawing.Size(157, 67); |
| | | this.btn_InsertSql.TabIndex = 42; |
| | | this.btn_InsertSql.Text = "çæInitSQL"; |
| | | this.btn_InsertSql.UseVisualStyleBackColor = true; |
| | | this.btn_InsertSql.Visible = false; |
| | | this.btn_InsertSql.Click += new System.EventHandler(this.btn_InsertSql_Click); |
| | | // |
| | | // tb_RoutePrefix |
| | | // |
| | | this.tb_RoutePrefix.Location = new System.Drawing.Point(538, 276); |
| | | this.tb_RoutePrefix.Name = "tb_RoutePrefix"; |
| | | this.tb_RoutePrefix.Size = new System.Drawing.Size(145, 21); |
| | | this.tb_RoutePrefix.TabIndex = 44; |
| | | this.tb_RoutePrefix.Text = "1111"; |
| | | // |
| | | // label13 |
| | | // |
| | | this.label13.AutoSize = true; |
| | | this.label13.Location = new System.Drawing.Point(463, 282); |
| | | this.label13.Name = "label13"; |
| | | this.label13.Size = new System.Drawing.Size(77, 12); |
| | | this.label13.TabIndex = 43; |
| | | this.label13.Text = "WCFè·¯ç±åç¼:"; |
| | | this.label13.Click += new System.EventHandler(this.label13_Click); |
| | | // |
| | | // groupBox1 |
| | | // |
| | | this.groupBox1.Controls.Add(this.label17); |
| | | this.groupBox1.Controls.Add(this.cmb_DataBase); |
| | | this.groupBox1.Controls.Add(this.lbl_DataSource); |
| | | this.groupBox1.Controls.Add(this.cmb_DataSource); |
| | | this.groupBox1.Location = new System.Drawing.Point(51, 12); |
| | | this.groupBox1.Name = "groupBox1"; |
| | | this.groupBox1.Size = new System.Drawing.Size(819, 72); |
| | | this.groupBox1.TabIndex = 45; |
| | | this.groupBox1.TabStop = false; |
| | | this.groupBox1.Text = "æ°æ®åºé
ç½®"; |
| | | // |
| | | // lbl_DataSource |
| | | // |
| | | this.lbl_DataSource.AutoSize = true; |
| | | this.lbl_DataSource.Location = new System.Drawing.Point(10, 48); |
| | | this.lbl_DataSource.Name = "lbl_DataSource"; |
| | | this.lbl_DataSource.Size = new System.Drawing.Size(89, 12); |
| | | this.lbl_DataSource.TabIndex = 1; |
| | | this.lbl_DataSource.Text = "ææ¯é¾æ¥å符串"; |
| | | // |
| | | // cmb_DataSource |
| | | // |
| | | this.cmb_DataSource.FormattingEnabled = true; |
| | | this.cmb_DataSource.Location = new System.Drawing.Point(6, 20); |
| | | this.cmb_DataSource.Name = "cmb_DataSource"; |
| | | this.cmb_DataSource.Size = new System.Drawing.Size(206, 20); |
| | | this.cmb_DataSource.TabIndex = 0; |
| | | this.cmb_DataSource.SelectedIndexChanged += new System.EventHandler(this.cmb_DataSource_SelectedIndexChanged); |
| | | // |
| | | // groupBox2 |
| | | // |
| | | this.groupBox2.Controls.Add(this.tb_GroupName); |
| | | this.groupBox2.Controls.Add(this.label16); |
| | | this.groupBox2.Controls.Add(this.label15); |
| | | this.groupBox2.Controls.Add(this.tb_ProjectNamePrefix); |
| | | this.groupBox2.Controls.Add(this.groupBox3); |
| | | this.groupBox2.Controls.Add(this.tb_FileName); |
| | | this.groupBox2.Controls.Add(this.lblds); |
| | | this.groupBox2.Controls.Add(this.tb_RoutePrefix); |
| | | this.groupBox2.Controls.Add(this.tb_TableName); |
| | | this.groupBox2.Controls.Add(this.label13); |
| | | this.groupBox2.Controls.Add(this.label1); |
| | | this.groupBox2.Controls.Add(this.label2); |
| | | this.groupBox2.Controls.Add(this.tb_Modulelogo); |
| | | this.groupBox2.Controls.Add(this.tb_WCF_NameSpacePath); |
| | | this.groupBox2.Controls.Add(this.label3); |
| | | this.groupBox2.Controls.Add(this.label4); |
| | | this.groupBox2.Controls.Add(this.tb_ChinaComment); |
| | | this.groupBox2.Controls.Add(this.tb_PrimaryDesc); |
| | | this.groupBox2.Controls.Add(this.label5); |
| | | this.groupBox2.Controls.Add(this.label11); |
| | | this.groupBox2.Controls.Add(this.tb_CreatePerson); |
| | | this.groupBox2.Controls.Add(this.label10); |
| | | this.groupBox2.Controls.Add(this.label6); |
| | | this.groupBox2.Controls.Add(this.tb_OrderBy); |
| | | this.groupBox2.Controls.Add(this.tb_Primary); |
| | | this.groupBox2.Controls.Add(this.label9); |
| | | this.groupBox2.Controls.Add(this.label8); |
| | | this.groupBox2.Controls.Add(this.tb_EntityProName); |
| | | this.groupBox2.Controls.Add(this.tb_EntityName); |
| | | this.groupBox2.Controls.Add(this.label7); |
| | | this.groupBox2.Location = new System.Drawing.Point(51, 90); |
| | | this.groupBox2.Name = "groupBox2"; |
| | | this.groupBox2.Size = new System.Drawing.Size(819, 470); |
| | | this.groupBox2.TabIndex = 46; |
| | | this.groupBox2.TabStop = false; |
| | | this.groupBox2.Text = "èªå®ä¹é
ç½®"; |
| | | // |
| | | // tb_GroupName |
| | | // |
| | | this.tb_GroupName.Location = new System.Drawing.Point(350, 108); |
| | | this.tb_GroupName.Name = "tb_GroupName"; |
| | | this.tb_GroupName.Size = new System.Drawing.Size(183, 21); |
| | | this.tb_GroupName.TabIndex = 50; |
| | | // |
| | | // label16 |
| | | // |
| | | this.label16.AutoSize = true; |
| | | this.label16.Location = new System.Drawing.Point(298, 111); |
| | | this.label16.Name = "label16"; |
| | | this.label16.Size = new System.Drawing.Size(47, 12); |
| | | this.label16.TabIndex = 49; |
| | | this.label16.Text = "åç»å:"; |
| | | // |
| | | // label15 |
| | | // |
| | | this.label15.AutoSize = true; |
| | | this.label15.Location = new System.Drawing.Point(26, 24); |
| | | this.label15.Name = "label15"; |
| | | this.label15.Size = new System.Drawing.Size(71, 12); |
| | | this.label15.TabIndex = 47; |
| | | this.label15.Text = "项ç®ååç¼:"; |
| | | // |
| | | // tb_ProjectNamePrefix |
| | | // |
| | | this.tb_ProjectNamePrefix.Location = new System.Drawing.Point(104, 21); |
| | | this.tb_ProjectNamePrefix.Name = "tb_ProjectNamePrefix"; |
| | | this.tb_ProjectNamePrefix.Size = new System.Drawing.Size(183, 21); |
| | | this.tb_ProjectNamePrefix.TabIndex = 48; |
| | | // |
| | | // groupBox3 |
| | | // |
| | | this.groupBox3.Controls.Add(this.tb_importExcelCategroy); |
| | | this.groupBox3.Controls.Add(this.ck_IsShowImport); |
| | | this.groupBox3.Controls.Add(this.label12); |
| | | this.groupBox3.Controls.Add(this.tb_templeteFileDownName); |
| | | this.groupBox3.Controls.Add(this.label14); |
| | | this.groupBox3.Location = new System.Drawing.Point(28, 316); |
| | | this.groupBox3.Margin = new System.Windows.Forms.Padding(2); |
| | | this.groupBox3.Name = "groupBox3"; |
| | | this.groupBox3.Padding = new System.Windows.Forms.Padding(2); |
| | | this.groupBox3.Size = new System.Drawing.Size(272, 118); |
| | | this.groupBox3.TabIndex = 46; |
| | | this.groupBox3.TabStop = false; |
| | | this.groupBox3.Text = "导å
¥åè½"; |
| | | // |
| | | // tb_importExcelCategroy |
| | | // |
| | | this.tb_importExcelCategroy.Location = new System.Drawing.Point(143, 86); |
| | | this.tb_importExcelCategroy.Name = "tb_importExcelCategroy"; |
| | | this.tb_importExcelCategroy.Size = new System.Drawing.Size(113, 21); |
| | | this.tb_importExcelCategroy.TabIndex = 50; |
| | | // |
| | | // ck_IsShowImport |
| | | // |
| | | this.ck_IsShowImport.AutoSize = true; |
| | | this.ck_IsShowImport.Location = new System.Drawing.Point(21, 30); |
| | | this.ck_IsShowImport.Margin = new System.Windows.Forms.Padding(2); |
| | | this.ck_IsShowImport.Name = "ck_IsShowImport"; |
| | | this.ck_IsShowImport.Size = new System.Drawing.Size(108, 16); |
| | | this.ck_IsShowImport.TabIndex = 45; |
| | | this.ck_IsShowImport.Text = "æ¯å¦æå¯¼å
¥åè½"; |
| | | this.ck_IsShowImport.UseVisualStyleBackColor = true; |
| | | this.ck_IsShowImport.Visible = false; |
| | | this.ck_IsShowImport.CheckedChanged += new System.EventHandler(this.ck_IsShowImport_CheckedChanged); |
| | | // |
| | | // label12 |
| | | // |
| | | this.label12.AutoSize = true; |
| | | this.label12.Location = new System.Drawing.Point(9, 94); |
| | | this.label12.Name = "label12"; |
| | | this.label12.Size = new System.Drawing.Size(119, 12); |
| | | this.label12.TabIndex = 49; |
| | | this.label12.Text = "ä¸ä¼ æä»¶ç请æ±åç±»:"; |
| | | // |
| | | // tb_templeteFileDownName |
| | | // |
| | | this.tb_templeteFileDownName.Location = new System.Drawing.Point(143, 58); |
| | | this.tb_templeteFileDownName.Name = "tb_templeteFileDownName"; |
| | | this.tb_templeteFileDownName.Size = new System.Drawing.Size(113, 21); |
| | | this.tb_templeteFileDownName.TabIndex = 48; |
| | | // |
| | | // label14 |
| | | // |
| | | this.label14.AutoSize = true; |
| | | this.label14.Location = new System.Drawing.Point(10, 60); |
| | | this.label14.Name = "label14"; |
| | | this.label14.Size = new System.Drawing.Size(83, 12); |
| | | this.label14.TabIndex = 47; |
| | | this.label14.Text = "æä»¶ä¸è½½åå:"; |
| | | // |
| | | // cmb_DataBase |
| | | // |
| | | this.cmb_DataBase.FormattingEnabled = true; |
| | | this.cmb_DataBase.Location = new System.Drawing.Point(581, 20); |
| | | this.cmb_DataBase.Name = "cmb_DataBase"; |
| | | this.cmb_DataBase.Size = new System.Drawing.Size(206, 20); |
| | | this.cmb_DataBase.TabIndex = 2; |
| | | this.cmb_DataBase.SelectedIndexChanged += new System.EventHandler(this.cmb_DataBase_SelectedIndexChanged); |
| | | // |
| | | // label17 |
| | | // |
| | | this.label17.AutoSize = true; |
| | | this.label17.Location = new System.Drawing.Point(478, 23); |
| | | this.label17.Name = "label17"; |
| | | this.label17.Size = new System.Drawing.Size(65, 12); |
| | | this.label17.TabIndex = 3; |
| | | this.label17.Text = "æ°æ®åºç±»å"; |
| | | // |
| | | // MainForm |
| | | // |
| | | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); |
| | | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; |
| | | this.ClientSize = new System.Drawing.Size(927, 672); |
| | | this.Controls.Add(this.groupBox2); |
| | | this.Controls.Add(this.groupBox1); |
| | | this.Controls.Add(this.btn_InsertSql); |
| | | this.Controls.Add(this.btn_CreateFile); |
| | | this.Controls.Add(this.btnExit); |
| | | this.Controls.Add(this.tbPath); |
| | | this.Controls.Add(this.btnPath); |
| | | this.Name = "MainForm"; |
| | | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; |
| | | this.Text = "伿¬-CMS-代ç çæå¨(伿¬ä¸ç¨)V1.0"; |
| | | this.Load += new System.EventHandler(this.MainForm_Load); |
| | | this.groupBox1.ResumeLayout(false); |
| | | this.groupBox1.PerformLayout(); |
| | | this.groupBox2.ResumeLayout(false); |
| | | this.groupBox2.PerformLayout(); |
| | | this.groupBox3.ResumeLayout(false); |
| | | this.groupBox3.PerformLayout(); |
| | | this.ResumeLayout(false); |
| | | this.PerformLayout(); |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | private System.Windows.Forms.Button btnPath; |
| | | private System.Windows.Forms.Label lblds; |
| | | private System.Windows.Forms.TextBox tbPath; |
| | | private System.Windows.Forms.Button btnExit; |
| | | private System.Windows.Forms.Button btn_CreateFile; |
| | | private System.Windows.Forms.TextBox tb_TableName; |
| | | private System.Windows.Forms.TextBox tb_FileName; |
| | | private System.Windows.Forms.Label label1; |
| | | private System.Windows.Forms.TextBox tb_WCF_NameSpacePath; |
| | | private System.Windows.Forms.Label label2; |
| | | private System.Windows.Forms.TextBox tb_ChinaComment; |
| | | private System.Windows.Forms.Label label4; |
| | | private System.Windows.Forms.TextBox tb_CreatePerson; |
| | | private System.Windows.Forms.Label label5; |
| | | private System.Windows.Forms.TextBox tb_Primary; |
| | | private System.Windows.Forms.Label label6; |
| | | private System.Windows.Forms.TextBox tb_EntityProName; |
| | | private System.Windows.Forms.Label label7; |
| | | private System.Windows.Forms.TextBox tb_EntityName; |
| | | private System.Windows.Forms.Label label8; |
| | | private System.Windows.Forms.Label label9; |
| | | private System.Windows.Forms.TextBox tb_OrderBy; |
| | | private System.Windows.Forms.Label label10; |
| | | private System.Windows.Forms.TextBox tb_PrimaryDesc; |
| | | private System.Windows.Forms.Label label11; |
| | | private System.Windows.Forms.TextBox tb_Modulelogo; |
| | | private System.Windows.Forms.Label label3; |
| | | private System.Windows.Forms.Button btn_InsertSql; |
| | | private System.Windows.Forms.TextBox tb_RoutePrefix; |
| | | private System.Windows.Forms.Label label13; |
| | | private System.Windows.Forms.GroupBox groupBox1; |
| | | private System.Windows.Forms.Label lbl_DataSource; |
| | | private System.Windows.Forms.ComboBox cmb_DataSource; |
| | | private System.Windows.Forms.GroupBox groupBox2; |
| | | private System.Windows.Forms.CheckBox ck_IsShowImport; |
| | | private System.Windows.Forms.GroupBox groupBox3; |
| | | private System.Windows.Forms.TextBox tb_importExcelCategroy; |
| | | private System.Windows.Forms.Label label12; |
| | | private System.Windows.Forms.TextBox tb_templeteFileDownName; |
| | | private System.Windows.Forms.Label label14; |
| | | private System.Windows.Forms.Label label15; |
| | | private System.Windows.Forms.TextBox tb_ProjectNamePrefix; |
| | | private System.Windows.Forms.Label label16; |
| | | private System.Windows.Forms.TextBox tb_GroupName; |
| | | private System.Windows.Forms.ComboBox cmb_DataBase; |
| | | private System.Windows.Forms.Label label17; |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using System.Windows.Forms; |
| | | using System.IO; |
| | | using Newtonsoft.Json; |
| | | using System.Windows.Forms.VisualStyles; |
| | | using GenerateCode_WeiBen_WMS.DataBaseFactory; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | public partial class MainForm : Form |
| | | { |
| | | public static string projectNamePrefix = ""; |
| | | public static string dataBaseName = ""; |
| | | public static DataBaseEnum dataBaseEnum = DataBaseEnum.MySql; |
| | | public MainForm() |
| | | { |
| | | InitializeComponent(); |
| | | |
| | | this.tbPath.Text = "D:\\C#AutoCreateCodeFile"; |
| | | |
| | | this.tb_Primary.Text = "id";//主é®å |
| | | this.tb_PrimaryDesc.Text = "主é®"; |
| | | this.tb_OrderBy.Text = "ModifyTime";//æåºå段 |
| | | |
| | | this.tb_ProjectNamePrefix.Text = "Test"; |
| | | this.tb_TableName.Text = "scms_auditlogs";//表å |
| | | this.tb_WCF_NameSpacePath.Text = "WIP_";//WCF项ç®å½åç©ºé´ |
| | | this.tb_FileName.Text = "Xiangzi";//æä»¶åç¼å |
| | | this.tb_ChinaComment.Text = "表çä¸ææ³¨è§£";//ä¸ææ³¨é |
| | | this.tb_CreatePerson.Text = "shaocx";//å建人 |
| | | this.tb_EntityName.Text = "XiangziEntity";//å®ä½ç±»å |
| | | this.tb_EntityProName.Text = "xiangzi";//å®ä½ç±»å¯¹è±¡å |
| | | |
| | | this.cmb_DataSource.DropDownStyle = ComboBoxStyle.DropDownList; |
| | | List<ListItem> itemList = CommonHelper.GetDataSources(); |
| | | foreach (var item in itemList) |
| | | { |
| | | this.cmb_DataSource.Items.Add(item); |
| | | } |
| | | this.cmb_DataSource.SelectedIndex = 0; |
| | | |
| | | this.cmb_DataBase.DropDownStyle = ComboBoxStyle.DropDownList; |
| | | List<ListItem> itemList_Db = CommonHelper.GetDataBase(); |
| | | foreach (var item in itemList_Db) |
| | | { |
| | | this.cmb_DataBase.Items.Add(item); |
| | | } |
| | | this.cmb_DataBase.SelectedIndex = 0; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¿åè·¯å¾å¯¹è¯æ¡ |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void button1_Click(object sender, EventArgs e) |
| | | { |
| | | FolderBrowserDialog fbd = new FolderBrowserDialog(); |
| | | if (DialogResult.OK == fbd.ShowDialog()) |
| | | { |
| | | tbPath.Text = fbd.SelectedPath; |
| | | } |
| | | } |
| | | |
| | | private void btnExit_Click(object sender, EventArgs e) |
| | | { |
| | | Application.Exit(); |
| | | } |
| | | |
| | | //ä¸é®çææææä»¶ |
| | | private void btn_CreateFile_Click(object sender, EventArgs e) |
| | | { |
| | | try |
| | | { |
| | | projectNamePrefix = this.tb_ProjectNamePrefix.Text; |
| | | if (projectNamePrefix == "") |
| | | { |
| | | MessageBox.Show("请è¾å
¥é¡¹ç®ååç¼ï¼"); |
| | | this.tb_ProjectNamePrefix.Focus(); |
| | | return; |
| | | } |
| | | |
| | | if (dataBaseName == "") |
| | | { |
| | | MessageBox.Show("è¯·éæ©æ°æ®åºï¼"); |
| | | return; |
| | | } |
| | | |
| | | string primaryKey = this.tb_Primary.Text.Trim();//主é®å |
| | | string primaryKeyDesc = this.tb_PrimaryDesc.Text.Trim();//ä¸»é®æè¿° |
| | | string tableName = this.tb_TableName.Text.Trim();//表å |
| | | string wcf_NameSpacePath = this.tb_WCF_NameSpacePath.Text.Trim();//WCF项ç®å½åç©ºé´ |
| | | string filePrefixName = this.tb_FileName.Text.Trim();//æä»¶åç¼å |
| | | string modulelogo = this.tb_Modulelogo.Text.Trim();//模åç®å |
| | | string chinaComment = this.tb_ChinaComment.Text.Trim();//ä¸ææ³¨é |
| | | string createPerson = this.tb_CreatePerson.Text.Trim();//å建人 |
| | | string entityName = this.tb_EntityName.Text.Trim();//å®ä½ç±»å |
| | | string tableAlias = this.tb_EntityProName.Text.Trim();//å®ä½ç±»å¯¹è±¡å/表å«å |
| | | string orderByName = this.tb_OrderBy.Text.Trim();//æåºå段åç§° |
| | | string routePrefix = this.tb_RoutePrefix.Text.Trim();//WCFè·¯ç±åç¼ |
| | | string connStr = this.lbl_DataSource.Text.Trim();//æ°æ®åºè¿æ¥å符串 |
| | | if (connStr == "") |
| | | { |
| | | MessageBox.Show("è¯·éæ©æ°æ®åºæºï¼"); |
| | | this.cmb_DataSource.Focus(); |
| | | return; |
| | | } |
| | | if (tableName == "") |
| | | { |
| | | MessageBox.Show("请è¾å
¥è¡¨åï¼"); |
| | | this.tb_TableName.Focus(); |
| | | return; |
| | | } |
| | | if (primaryKey == "") |
| | | { |
| | | MessageBox.Show("请è¾å
¥ä¸»é®åï¼"); |
| | | this.tb_Primary.Focus(); |
| | | return; |
| | | } |
| | | if (routePrefix == "") |
| | | { |
| | | MessageBox.Show("请è¾å
¥WCFè·¯ç±åç¼ï¼"); |
| | | this.tb_RoutePrefix.Focus(); |
| | | return; |
| | | } |
| | | |
| | | //读åMysql |
| | | var handler = DataBaseServiceFactory.GetHandle(dataBaseEnum); |
| | | List<ColumnModel> columnList = handler.GetColumnList(tableName, connStr); |
| | | if (columnList.Count == 0) |
| | | { |
| | | MessageBox.Show("没æè·åå°è¡¨ä¸é¢çåéåï¼"); |
| | | return; |
| | | } |
| | | |
| | | string groupName = this.tb_GroupName.Text.Trim(); |
| | | if (groupName == "") |
| | | { |
| | | MessageBox.Show("请è¾å
¥åç»åï¼"); |
| | | this.tb_GroupName.Focus(); |
| | | return; |
| | | } |
| | | |
| | | string addEntityParam = "Add" + modulelogo + "Param";//æ°å¢åæ°ç±»å |
| | | string str_generate = ""; |
| | | bool tf; |
| | | |
| | | //çæModel |
| | | //CreateModelFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo); |
| | | //CreateModelParamFile(columnList, tableName, filePrefixName, wcf_NameSpacePath, createPerson, chinaComment, entityName, modulelogo); |
| | | |
| | | //çæ InputModel æä»¶ |
| | | str_generate = InputModel_Generate.CreateQueryModelLText(modulelogo, chinaComment, columnList, entityName); |
| | | tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.InputModel, filePrefixName, entityName, modulelogo); |
| | | |
| | | //çæ OutputModel æä»¶ |
| | | str_generate = OutputModel_Generate.CreateQueryModelLText(modulelogo, chinaComment, columnList, entityName); |
| | | tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.OutputModel, filePrefixName, entityName, modulelogo); |
| | | |
| | | //çæControlleræä»¶ |
| | | //str_generate = Controller_Generate.CreateText(modulelogo, chinaComment, columnList, entityName, orderByName); |
| | | //tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.Controller, filePrefixName, entityName, modulelogo); |
| | | |
| | | //çæServicesæ¥å£æä»¶ |
| | | str_generate = Services_Interface_Generate.CreateText(wcf_NameSpacePath, modulelogo, entityName, chinaComment, addEntityParam); |
| | | tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.WCF_InterFace, filePrefixName, entityName, modulelogo); |
| | | |
| | | |
| | | //çæServicesæ¥å£å®ç°æä»¶ |
| | | str_generate = Services_InterfaceRealize_Generate.CreateText(wcf_NameSpacePath, modulelogo, |
| | | entityName, chinaComment, filePrefixName, primaryKey, tableAlias, addEntityParam, columnList, groupName); |
| | | tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.WCF_InterFaceRealize, filePrefixName, entityName, modulelogo); |
| | | |
| | | /* |
| | | //çæåå¨è¿ç¨æä»¶ |
| | | str_generate = Procedure_Generate.CreateProcText(tableName, tableAlias, createPerson, chinaComment, |
| | | primaryKey, filePrefixName, orderByName, modulelogo, columnList); |
| | | tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.Proc, filePrefixName, entityName, modulelogo); |
| | | |
| | | //çæDALæä»¶ |
| | | str_generate = DAL_Generate.CreateDALText(filePrefixName, tableName, entityName, createPerson, |
| | | chinaComment, primaryKey, primaryKeyDesc, modulelogo, tableAlias, columnList); |
| | | tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.DAL, filePrefixName, entityName, modulelogo); |
| | | |
| | | //çæBLLæä»¶ |
| | | str_generate = BLL_Generate.CreateBLLText(filePrefixName, tableName, entityName, createPerson, |
| | | chinaComment, primaryKey, primaryKeyDesc, modulelogo, tableAlias, addEntityParam, columnList); |
| | | tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.BLL, filePrefixName, entityName, modulelogo); |
| | | |
| | | |
| | | |
| | | //çæAddModelæä»¶ |
| | | str_generate = AddModel_Generate.CreateAddModelLText(addEntityParam, chinaComment, columnList); |
| | | tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.AddModelParam, filePrefixName, entityName, modulelogo); |
| | | |
| | | |
| | | |
| | | |
| | | //*/ |
| | | |
| | | //VUEæ¹æ³é
ç½® |
| | | //str_generate = VUE_FunConfig_Generate.CreateText(modulelogo, chinaComment, routePrefix, entityName); |
| | | //tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.VUE_FunConfig, filePrefixName, entityName, modulelogo); |
| | | |
| | | //VUEæä»¶ |
| | | //str_generate = VUE_Generate.CreateText(tableAlias, modulelogo, primaryKey, columnList, chinaComment |
| | | // , this.tb_templeteFileDownName.Text, this.tb_importExcelCategroy.Text); |
| | | //tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.VUEFile, filePrefixName, entityName, modulelogo); |
| | | |
| | | //btn_InsertSql_Click(null, null); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show("çææä»¶å¤±è´¥ï¼" + ex.Message); |
| | | return; |
| | | } |
| | | //MessageBox.Show("çææä»¶æåï¼"); |
| | | //æåä¹åæå¼æä»¶å¤¹ |
| | | using (System.Diagnostics.Process.Start(this.tbPath.Text + "\\" + this.tb_TableName.Text)) |
| | | { |
| | | |
| | | } |
| | | //*/ |
| | | } |
| | | |
| | | #region åç±»æä»¶ |
| | | |
| | | /// <summary> |
| | | /// çæModel |
| | | /// </summary> |
| | | /// <param name="_tableName"></param> |
| | | private void CreateModelFile(List<ColumnModel> strList, string _tableName, string filePrefixName, string nameSpacePath, |
| | | string createPerson, string chinaComment, string entityName, string modulelogo) |
| | | { |
| | | bool tf = TextHelper.Export2File(tbPath.Text, _tableName, |
| | | Model_Generate.GenerateModel(_tableName, strList, filePrefixName, nameSpacePath, createPerson, chinaComment, entityName), |
| | | FileType.Model, filePrefixName, entityName, modulelogo); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæModelåæ° |
| | | /// </summary> |
| | | /// <param name="_tableName"></param> |
| | | private void CreateModelParamFile(List<ColumnModel> strList, string _tableName, string filePrefixName, string nameSpacePath, |
| | | string createPerson, string chinaComment, string entityName, string modulelogo) |
| | | { |
| | | bool tf = TextHelper.Export2File(tbPath.Text, _tableName, |
| | | Model_Generate.GenerateModelParam(_tableName, strList, filePrefixName, nameSpacePath, createPerson, chinaComment, entityName), |
| | | FileType.Model, filePrefixName, entityName, modulelogo); |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// ææ¬æ¹åäºä»¶ |
| | | /// </summary> |
| | | /// <param name="sender"></param> |
| | | /// <param name="e"></param> |
| | | private void tb_TableName_TextChanged(object sender, EventArgs e) |
| | | { |
| | | string tableName = this.tb_TableName.Text.Trim();//表å |
| | | if (tableName != "") |
| | | { |
| | | var str = CommonHelper.TitleToUpper(tableName); |
| | | this.tb_FileName.Text = this.tb_EntityName.Text = str; |
| | | var index = tableName.IndexOf('_'); |
| | | if (index > -1) |
| | | { |
| | | var moule_str = tableName.Substring(index + 1, tableName.Length - index - 1); |
| | | this.tb_Modulelogo.Text = moule_str; |
| | | this.tb_EntityProName.Text = CommonHelper.TitleToLower(moule_str); |
| | | } |
| | | else |
| | | { |
| | | this.tb_Modulelogo.Text = tableName; |
| | | this.tb_EntityProName.Text = CommonHelper.TitleToLower(tableName); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void btn_InsertSql_Click(object sender, EventArgs e) |
| | | { |
| | | string connStr = this.lbl_DataSource.Text.Trim();//æ°æ®åºè¿æ¥å符串 |
| | | if (connStr == "") |
| | | { |
| | | MessageBox.Show("è¯·éæ©æ°æ®åºæºï¼"); |
| | | this.cmb_DataSource.Focus(); |
| | | return; |
| | | } |
| | | var tableName = this.tb_TableName.Text.Trim(); |
| | | if (tableName == string.Empty) |
| | | { |
| | | MessageBox.Show("请è¾å
¥è¡¨å!"); |
| | | return; |
| | | } |
| | | List<ColumnModel> columnList = StructStrHelper.GetColumnList(tableName, connStr); |
| | | if (columnList.Count == 0) |
| | | { |
| | | MessageBox.Show("没æè·åå°è¡¨ä¸é¢çåéåï¼"); |
| | | return; |
| | | } |
| | | string chinaComment = this.tb_ChinaComment.Text.Trim();//ä¸ææ³¨é |
| | | string createPerson = this.tb_CreatePerson.Text.Trim();//å建人 |
| | | var str_generate = InsertSQL_Generate.CreateInsertSQLText(tableName, createPerson, chinaComment, columnList); |
| | | bool tf = TextHelper.Export2File(tbPath.Text, tableName, str_generate, FileType.SQL_Insert, "", "", ""); |
| | | //MessageBox.Show("çææä»¶æåï¼"); |
| | | //æåä¹åæå¼æä»¶å¤¹ |
| | | using (System.Diagnostics.Process.Start(this.tbPath.Text + "\\" + this.tb_TableName.Text)) |
| | | { |
| | | |
| | | } |
| | | } |
| | | |
| | | private void label13_Click(object sender, EventArgs e) |
| | | { |
| | | |
| | | } |
| | | |
| | | private void MainForm_Load(object sender, EventArgs e) |
| | | { |
| | | tb_EntityProName.Enabled = false; |
| | | tb_FileName.Enabled = false; |
| | | tb_Modulelogo.Enabled = false; |
| | | tb_WCF_NameSpacePath.Enabled = false; |
| | | tb_RoutePrefix.Enabled = false; |
| | | } |
| | | |
| | | private void cmb_DataSource_SelectedIndexChanged(object sender, EventArgs e) |
| | | { |
| | | string connStr = (this.cmb_DataSource.SelectedItem as ListItem).Value; |
| | | var name = (this.cmb_DataSource.SelectedItem as ListItem).Text; |
| | | this.lbl_DataSource.Text = connStr; |
| | | dataBaseName = name; |
| | | if (name == "GSiemens_LES") |
| | | { |
| | | this.tb_ProjectNamePrefix.Text = "LES"; |
| | | } |
| | | else if (name == "GSiemens_WIP") |
| | | { |
| | | this.tb_ProjectNamePrefix.Text = "WIP"; |
| | | } |
| | | else if (name.Contains("AoSinWms")) |
| | | { |
| | | this.tb_ProjectNamePrefix.Text = "AoSinWms"; |
| | | } |
| | | else |
| | | { |
| | | this.tb_ProjectNamePrefix.Text = "Test"; |
| | | } |
| | | } |
| | | |
| | | private void ck_IsShowImport_CheckedChanged(object sender, EventArgs e) |
| | | { |
| | | //this.tb_templeteFileDownName.Enabled = false; |
| | | //this.tb_importExcelCategroy.Enabled = false; |
| | | //if (this.ck_IsShowImport.Checked) |
| | | //{ |
| | | // this.tb_templeteFileDownName.Enabled = true; |
| | | // this.tb_importExcelCategroy.Enabled = true; |
| | | //} |
| | | } |
| | | |
| | | private void tb_EntityProName_TextChanged(object sender, EventArgs e) |
| | | { |
| | | |
| | | } |
| | | |
| | | private void cmb_DataBase_SelectedIndexChanged(object sender, EventArgs e) |
| | | { |
| | | string connStr = (this.cmb_DataBase.SelectedItem as ListItem).Value; |
| | | var name = (this.cmb_DataBase.SelectedItem as ListItem).Text; |
| | | |
| | | dataBaseEnum = (DataBaseEnum)Enum.Parse(typeof(DataBaseEnum), name); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | | The primary goals of this format is to allow a simple XML format |
| | | that is mostly human readable. The generation and parsing of the |
| | | various data types are done through the TypeConverter classes |
| | | associated with the data types. |
| | | |
| | | Example: |
| | | |
| | | ... ado.net/XML headers & schema ... |
| | | <resheader name="resmimetype">text/microsoft-resx</resheader> |
| | | <resheader name="version">2.0</resheader> |
| | | <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
| | | <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
| | | <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
| | | <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
| | | <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
| | | <value>[base64 mime encoded serialized .NET Framework object]</value> |
| | | </data> |
| | | <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
| | | <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
| | | <comment>This is a comment</comment> |
| | | </data> |
| | | |
| | | There are any number of "resheader" rows that contain simple |
| | | name/value pairs. |
| | | |
| | | Each data row contains a name, and value. The row also contains a |
| | | type or mimetype. Type corresponds to a .NET class that support |
| | | text/value conversion through the TypeConverter architecture. |
| | | Classes that don't support this are serialized and stored with the |
| | | mimetype set. |
| | | |
| | | The mimetype is used for serialized objects, and tells the |
| | | ResXResourceReader how to depersist the object. This is currently not |
| | | extensible. For a given mimetype the value must be set accordingly: |
| | | |
| | | Note - application/x-microsoft.net.object.binary.base64 is the format |
| | | that the ResXResourceWriter will generate, however the reader can |
| | | read any of the formats listed below. |
| | | |
| | | mimetype: application/x-microsoft.net.object.binary.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | mimetype: application/x-microsoft.net.object.soap.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | mimetype: application/x-microsoft.net.object.bytearray.base64 |
| | | value : The object must be serialized into a byte array |
| | | : using a System.ComponentModel.TypeConverter |
| | | : and then encoded with base64 encoding. |
| | | --> |
| | | <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
| | | <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
| | | <xsd:element name="root" msdata:IsDataSet="true"> |
| | | <xsd:complexType> |
| | | <xsd:choice maxOccurs="unbounded"> |
| | | <xsd:element name="metadata"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" use="required" type="xsd:string" /> |
| | | <xsd:attribute name="type" type="xsd:string" /> |
| | | <xsd:attribute name="mimetype" type="xsd:string" /> |
| | | <xsd:attribute ref="xml:space" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="assembly"> |
| | | <xsd:complexType> |
| | | <xsd:attribute name="alias" type="xsd:string" /> |
| | | <xsd:attribute name="name" type="xsd:string" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="data"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
| | | <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
| | | <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
| | | <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
| | | <xsd:attribute ref="xml:space" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="resheader"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" use="required" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | </xsd:choice> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | </xsd:schema> |
| | | <resheader name="resmimetype"> |
| | | <value>text/microsoft-resx</value> |
| | | </resheader> |
| | | <resheader name="version"> |
| | | <value>2.0</value> |
| | | </resheader> |
| | | <resheader name="reader"> |
| | | <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | <resheader name="writer"> |
| | | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | </root> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// å对象 |
| | | /// </summary> |
| | | public class ColumnModel |
| | | { |
| | | /// <summary> |
| | | /// åå |
| | | /// </summary> |
| | | public string ColumnName { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ°æ®ç±»å |
| | | /// </summary> |
| | | public string DataType { get; set; } |
| | | |
| | | /// <summary> |
| | | /// 注é |
| | | /// </summary> |
| | | public string Description { get; set; } |
| | | |
| | | /// <summary> |
| | | /// åæ®µé¿åº¦ |
| | | /// </summary> |
| | | public string DataLength { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦å¯ä¸ºnull |
| | | /// </summary> |
| | | public bool IsNullable { get; set; } |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦æ¯ä¸»é® |
| | | /// </summary> |
| | | public bool IsPrimaryKey { get; set; } |
| | | |
| | | public int Precision { get; set; } |
| | | |
| | | public int Scale { get; set; } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// æ°æ®åºæä¸¾ |
| | | /// </summary> |
| | | public enum DataBaseEnum |
| | | { |
| | | SqlServer = 0, |
| | | MySql = 1, |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// æ°æ®ç±»åæä¸¾ |
| | | /// </summary> |
| | | public enum DataTypeEnum |
| | | { |
| | | dt_char = 0, |
| | | dt_varchar = 1, |
| | | dt_datetime = 2, |
| | | dt_datetime2 = 3, |
| | | dt_int = 4, |
| | | dt_bigint = 5, |
| | | dt_decimal = 6, |
| | | dt_nvarchar = 7, |
| | | dt_Varchar_Desc = 8, |
| | | dt_Varchar_Ext_Link = 9, |
| | | dt_bit = 10, |
| | | /// <summary> |
| | | /// å¯ä¸ç±»å |
| | | /// uniqueidentifieræ°æ®ç±»åå¯åå¨16åèçäºè¿å¶å¼ï¼å
¶ä½ç¨ä¸å
¨å±å¯ä¸æ 记符(GUID)䏿 ·ãGUIDæ¯å¯ä¸çäºè¿å¶æ°:ä¸çä¸çä»»ä½ä¸¤å°è®¡ç®æºé½ä¸ä¼çæéå¤çGUIDå¼ãGUID主è¦ç¨äºå¨ç¨äºå¤ä¸ªèç¹ï¼å¤å°è®¡ç®æºçç½ç»ä¸ï¼åé
å¿
é¡»å
·æå¯ä¸æ§çæ è¯ç¬¦ã |
| | | /// </summary> |
| | | dt_uniqueidentifier = 11, |
| | | dt_float = 12, |
| | | |
| | | /// <summary> |
| | | /// æ¥æ |
| | | /// </summary> |
| | | dt_datetimeoffset = 13 |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// ListItemç¨äºComboBoxæ§ä»¶æ·»å 项 |
| | | /// </summary> |
| | | public class ListItem |
| | | { |
| | | public string Text |
| | | { |
| | | get; |
| | | set; |
| | | } |
| | | public string Value |
| | | { |
| | | get; |
| | | set; |
| | | } |
| | | |
| | | |
| | | |
| | | public override string ToString() |
| | | { |
| | | return this.Text; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | /* |
| | | * CLR Versionï¼4.0.30319.42000 |
| | | * NameSpaceï¼GenerateCode_GEBrilliantFactory.Model |
| | | * FileNameï¼Proc |
| | | * CurrentYearï¼2018 |
| | | * CurrentTimeï¼2018/8/31 16:46:26 |
| | | * Authorï¼shaocx |
| | | * |
| | | * <æ´æ°è®°å½> |
| | | * ver 1.0.0.0 2018/8/31 16:46:26 æ°è¦ä½æ (by shaocx) |
| | | */ |
| | | |
| | | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// åå¨è¿ç¨å |
| | | /// </summary> |
| | | public class ProcName |
| | | { |
| | | /// <summary> |
| | | /// æ°å¢çåå¨è¿ç¨å |
| | | /// </summary> |
| | | public string AddProc { get; set; } |
| | | |
| | | /// <summary> |
| | | /// ç¼è¾çåå¨è¿ç¨å |
| | | /// </summary> |
| | | public string UpdateProc { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å表çåå¨è¿ç¨å |
| | | /// </summary> |
| | | public string ListProc { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å页å表çåå¨è¿ç¨å |
| | | /// </summary> |
| | | public string PageListProc { get; set; } |
| | | |
| | | /// <summary> |
| | | /// å¾å°ä¸ä¸ªå®ä½çåå¨è¿ç¨å |
| | | /// </summary> |
| | | public string GetSingleProc { get; set; } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory.Model |
| | | { |
| | | public static class SystemCommonVar |
| | | { |
| | | //public const string c_Id = "Id"; |
| | | |
| | | //public const string c_creator = "creator"; |
| | | |
| | | //public const string c_createTime = "createTime"; |
| | | |
| | | //public const string c_lastModifier = "lastModifier"; |
| | | |
| | | //public const string c_ModifyTime = "ModifyTime"; |
| | | |
| | | //public const string c_lastModifyTime = "lastModifyTime"; |
| | | |
| | | //public const string c_delFlag = "delFlag"; |
| | | |
| | | //public const string c_CreateId = "CreateId"; |
| | | |
| | | //public const string c_ModifyId = "ModifyId"; |
| | | |
| | | |
| | | public const string c_Id = "Id"; |
| | | |
| | | public const string c_creator = "CreatedUserName"; |
| | | |
| | | public const string c_createTime = "CreatedTime"; |
| | | |
| | | public const string c_lastModifier = "UpdatedUserName"; |
| | | |
| | | public const string c_ModifyTime = "UpdatedTime"; |
| | | |
| | | public const string c_lastModifyTime = "UpdatedTime"; |
| | | |
| | | public const string c_delFlag = "IsDeleted"; |
| | | |
| | | public const string c_CreateId = "CreatedUserId"; |
| | | |
| | | public const string c_ModifyId = "UpdatedUserId"; |
| | | |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | static class Program |
| | | { |
| | | /// <summary> |
| | | /// åºç¨ç¨åºç主å
¥å£ç¹ã |
| | | /// </summary> |
| | | [STAThread] |
| | | static void Main() |
| | | { |
| | | Application.EnableVisualStyles(); |
| | | Application.SetCompatibleTextRenderingDefault(false); |
| | | Application.Run(new MainForm()); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System.Reflection; |
| | | using System.Runtime.CompilerServices; |
| | | using System.Runtime.InteropServices; |
| | | |
| | | // æå
³ç¨åºéç常è§ä¿¡æ¯éè¿ä»¥ä¸ |
| | | // ç¹æ§éæ§å¶ãæ´æ¹è¿äºç¹æ§å¼å¯ä¿®æ¹ |
| | | // ä¸ç¨åºéå
³èçä¿¡æ¯ã |
| | | [assembly: AssemblyTitle("GenerateModel")] |
| | | [assembly: AssemblyDescription("")] |
| | | [assembly: AssemblyConfiguration("")] |
| | | [assembly: AssemblyCompany("Microsoft")] |
| | | [assembly: AssemblyProduct("GenerateModel")] |
| | | [assembly: AssemblyCopyright("Copyright © Microsoft 2012")] |
| | | [assembly: AssemblyTrademark("")] |
| | | [assembly: AssemblyCulture("")] |
| | | |
| | | // å° ComVisible 设置为 false 使æ¤ç¨åºéä¸çç±»å |
| | | // 对 COM ç»ä»¶ä¸å¯è§ã妿éè¦ä» COM è®¿é®æ¤ç¨åºéä¸çç±»åï¼ |
| | | // åå°è¯¥ç±»åä¸ç ComVisible ç¹æ§è®¾ç½®ä¸º trueã |
| | | [assembly: ComVisible(false)] |
| | | |
| | | // 妿æ¤é¡¹ç®å COM å
¬å¼ï¼åä¸å GUID ç¨äºç±»ååºç ID |
| | | [assembly: Guid("9e79a0fb-3e1e-47cb-b0e0-4c969655489f")] |
| | | |
| | | // ç¨åºéççæ¬ä¿¡æ¯ç±ä¸é¢å个å¼ç»æ: |
| | | // |
| | | // ä¸»çæ¬ |
| | | // æ¬¡çæ¬ |
| | | // å
é¨çæ¬å· |
| | | // ä¿®è®¢å· |
| | | // |
| | | // å¯ä»¥æå®ææè¿äºå¼ï¼ä¹å¯ä»¥ä½¿ç¨âå
é¨çæ¬å·âåâ修订å·âçé»è®¤å¼ï¼ |
| | | // æ¹æ³æ¯æå¦ä¸æç¤ºä½¿ç¨â*â: |
| | | // [assembly: AssemblyVersion("1.0.*")] |
| | | [assembly: AssemblyVersion("1.0.0.0")] |
| | | [assembly: AssemblyFileVersion("1.0.0.0")] |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <auto-generated> |
| | | // æ¤ä»£ç ç±å·¥å
·çæã |
| | | // è¿è¡æ¶çæ¬:4.0.30319.42000 |
| | | // |
| | | // å¯¹æ¤æä»¶çæ´æ¹å¯è½ä¼å¯¼è´ä¸æ£ç¡®çè¡ä¸ºï¼å¹¶ä¸å¦æ |
| | | // éæ°çæä»£ç ï¼è¿äºæ´æ¹å°ä¼ä¸¢å¤±ã |
| | | // </auto-generated> |
| | | //------------------------------------------------------------------------------ |
| | | |
| | | namespace GenerateCode_WeiBen_WMS.Properties { |
| | | using System; |
| | | |
| | | |
| | | /// <summary> |
| | | /// ä¸ä¸ªå¼ºç±»åçèµæºç±»ï¼ç¨äºæ¥æ¾æ¬å°åçå符串çã |
| | | /// </summary> |
| | | // æ¤ç±»æ¯ç± StronglyTypedResourceBuilder |
| | | // ç±»éè¿ç±»ä¼¼äº ResGen æ Visual Studio çå·¥å
·èªå¨çæçã |
| | | // è¥è¦æ·»å æç§»é¤æåï¼è¯·ç¼è¾ .ResX æä»¶ï¼ç¶åéæ°è¿è¡ ResGen |
| | | // (以 /str ä½ä¸ºå½ä»¤é项)ï¼æéæ°çæ VS 项ç®ã |
| | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] |
| | | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
| | | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
| | | internal class Resources { |
| | | |
| | | private static global::System.Resources.ResourceManager resourceMan; |
| | | |
| | | private static global::System.Globalization.CultureInfo resourceCulture; |
| | | |
| | | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
| | | internal Resources() { |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¿åæ¤ç±»ä½¿ç¨çç¼åç ResourceManager å®ä¾ã |
| | | /// </summary> |
| | | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
| | | internal static global::System.Resources.ResourceManager ResourceManager { |
| | | get { |
| | | if (object.ReferenceEquals(resourceMan, null)) { |
| | | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("GenerateCode_WeiBen_WMS.Properties.Resources", typeof(Resources).Assembly); |
| | | resourceMan = temp; |
| | | } |
| | | return resourceMan; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éåå½å线ç¨ç CurrentUICulture 屿§ï¼å¯¹ |
| | | /// ä½¿ç¨æ¤å¼ºç±»åèµæºç±»çææèµæºæ¥æ¾æ§è¡éåã |
| | | /// </summary> |
| | | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
| | | internal static global::System.Globalization.CultureInfo Culture { |
| | | get { |
| | | return resourceCulture; |
| | | } |
| | | set { |
| | | resourceCulture = value; |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <root> |
| | | <!-- |
| | | Microsoft ResX Schema |
| | | |
| | | Version 2.0 |
| | | |
| | | The primary goals of this format is to allow a simple XML format |
| | | that is mostly human readable. The generation and parsing of the |
| | | various data types are done through the TypeConverter classes |
| | | associated with the data types. |
| | | |
| | | Example: |
| | | |
| | | ... ado.net/XML headers & schema ... |
| | | <resheader name="resmimetype">text/microsoft-resx</resheader> |
| | | <resheader name="version">2.0</resheader> |
| | | <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
| | | <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
| | | <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
| | | <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
| | | <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
| | | <value>[base64 mime encoded serialized .NET Framework object]</value> |
| | | </data> |
| | | <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
| | | <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
| | | <comment>This is a comment</comment> |
| | | </data> |
| | | |
| | | There are any number of "resheader" rows that contain simple |
| | | name/value pairs. |
| | | |
| | | Each data row contains a name, and value. The row also contains a |
| | | type or mimetype. Type corresponds to a .NET class that support |
| | | text/value conversion through the TypeConverter architecture. |
| | | Classes that don't support this are serialized and stored with the |
| | | mimetype set. |
| | | |
| | | The mimetype is used for serialized objects, and tells the |
| | | ResXResourceReader how to depersist the object. This is currently not |
| | | extensible. For a given mimetype the value must be set accordingly: |
| | | |
| | | Note - application/x-microsoft.net.object.binary.base64 is the format |
| | | that the ResXResourceWriter will generate, however the reader can |
| | | read any of the formats listed below. |
| | | |
| | | mimetype: application/x-microsoft.net.object.binary.base64 |
| | | value : The object must be serialized with |
| | | : System.Serialization.Formatters.Binary.BinaryFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | mimetype: application/x-microsoft.net.object.soap.base64 |
| | | value : The object must be serialized with |
| | | : System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
| | | : and then encoded with base64 encoding. |
| | | |
| | | mimetype: application/x-microsoft.net.object.bytearray.base64 |
| | | value : The object must be serialized into a byte array |
| | | : using a System.ComponentModel.TypeConverter |
| | | : and then encoded with base64 encoding. |
| | | --> |
| | | <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
| | | <xsd:element name="root" msdata:IsDataSet="true"> |
| | | <xsd:complexType> |
| | | <xsd:choice maxOccurs="unbounded"> |
| | | <xsd:element name="metadata"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" /> |
| | | <xsd:attribute name="type" type="xsd:string" /> |
| | | <xsd:attribute name="mimetype" type="xsd:string" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="assembly"> |
| | | <xsd:complexType> |
| | | <xsd:attribute name="alias" type="xsd:string" /> |
| | | <xsd:attribute name="name" type="xsd:string" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="data"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
| | | <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
| | | <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
| | | <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | <xsd:element name="resheader"> |
| | | <xsd:complexType> |
| | | <xsd:sequence> |
| | | <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
| | | </xsd:sequence> |
| | | <xsd:attribute name="name" type="xsd:string" use="required" /> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | </xsd:choice> |
| | | </xsd:complexType> |
| | | </xsd:element> |
| | | </xsd:schema> |
| | | <resheader name="resmimetype"> |
| | | <value>text/microsoft-resx</value> |
| | | </resheader> |
| | | <resheader name="version"> |
| | | <value>2.0</value> |
| | | </resheader> |
| | | <resheader name="reader"> |
| | | <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | <resheader name="writer"> |
| | | <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
| | | </resheader> |
| | | </root> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //------------------------------------------------------------------------------ |
| | | // <auto-generated> |
| | | // æ¤ä»£ç ç±å·¥å
·çæã |
| | | // è¿è¡æ¶çæ¬:4.0.30319.42000 |
| | | // |
| | | // å¯¹æ¤æä»¶çæ´æ¹å¯è½ä¼å¯¼è´ä¸æ£ç¡®çè¡ä¸ºï¼å¹¶ä¸å¦æ |
| | | // éæ°çæä»£ç ï¼è¿äºæ´æ¹å°ä¼ä¸¢å¤±ã |
| | | // </auto-generated> |
| | | //------------------------------------------------------------------------------ |
| | | |
| | | namespace GenerateCode_WeiBen_WMS.Properties { |
| | | |
| | | |
| | | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
| | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0")] |
| | | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { |
| | | |
| | | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
| | | |
| | | public static Settings Default { |
| | | get { |
| | | return defaultInstance; |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version='1.0' encoding='utf-8'?> |
| | | <SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"> |
| | | <Profiles> |
| | | <Profile Name="(Default)" /> |
| | | </Profiles> |
| | | <Settings /> |
| | | </SettingsFile> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using WIP_common; |
| | | using WIP_DAL; |
| | | using WIP_Models; |
| | | |
| | | namespace WIP_BLL |
| | | { |
| | | /// <summary> |
| | | /// $ChinaComment$ä¸å¡å¤çç±» |
| | | /// </summary> |
| | | public class $FilePrefixName$BLL |
| | | { |
| | | private readonly $FilePrefixName$DAL $TableAlias$DAL = new $FilePrefixName$DAL(); |
| | | |
| | | #region Add |
| | | |
| | | /// <summary> |
| | | /// å¢å 䏿¡$ChinaComment$æ°æ® |
| | | /// </summary> |
| | | /// <param name="param">è¦å¢å ç$ChinaComment$åæ°ç±»</param> |
| | | /// <param name="creator">å建人</param> |
| | | /// <returns>æå
¥çææ°ä¸»é®å¼</returns> |
| | | public int Add($AddEntityParam$ param,string creator) |
| | | { |
| | | $EntityName$ model = null; |
| | | model = WIPCommon.T1ToT2<$AddEntityParam$, $EntityName$>(param); |
| | | model.creator = model.lastModifier = creator; |
| | | model.createTime = model.lastModifyTime = DateTime.Now; |
| | | model.delFlag=false; |
| | | return $TableAlias$DAL.Add(model); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Edit |
| | | |
| | | /// <summary> |
| | | /// æ´æ°ä¸æ¡$ChinaComment$æ°æ® |
| | | /// </summary> |
| | | /// <param name="model">è¦æ´æ°ç$ChinaComment$å®ä½</param> |
| | | /// <param name="lastModifier">æåä¿®æ¹äºº</param> |
| | | /// <returns>æ´æ°æ¯å¦æå</returns> |
| | | public bool Update($EntityName$ model,string lastModifier) |
| | | { |
| | | model.lastModifier = lastModifier; |
| | | model.lastModifyTime = DateTime.Now; |
| | | return $TableAlias$DAL.Update(model); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Del |
| | | |
| | | /// <summary> |
| | | /// å é¤ä¸æ¡$ChinaComment$æ°æ® |
| | | /// </summary> |
| | | /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> |
| | | /// <returns>æ¯å¦å 餿å</returns> |
| | | public bool Delete(string $PrimaryKey$) |
| | | { |
| | | return $TableAlias$DAL.Delete($PrimaryKey$); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Enable |
| | | |
| | | /// <summary> |
| | | /// ç¦å¯ç¨$ChinaComment$æ°æ® |
| | | /// </summary> |
| | | /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> |
| | | /// <param name="delFlag">ç¦ç¨1/å¯ç¨0</param> |
| | | /// <param name="lastModifier">æåä¿®æ¹äºº</param> |
| | | /// <param name="transModel">äºå¡ç±»</param> |
| | | /// <returns>æ¯å¦ç¦å¯ç¨æå</returns> |
| | | public bool Enable(string $PrimaryKey$, string delFlag, string lastModifier) |
| | | { |
| | | return $TableAlias$DAL.Enable($PrimaryKey$,delFlag,lastModifier); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region QueryList(Page) |
| | | |
| | | /// <summary> |
| | | /// è·å¾$ChinaComment$æ°æ®å表(å页) |
| | | /// </summary> |
| | | /// <param name="pageParam">æ¥è¯¢åæ°</param> |
| | | /// <returns>$ChinaComment$åé¡µæ°æ®</returns> |
| | | public PageResultModel<$EntityName$> GetModelListForPage(Query$Modulelogo$Param pageParam) |
| | | { |
| | | DataSet ds = $TableAlias$DAL.GetModelListForPage(pageParam); |
| | | List<$EntityName$> list = DataTableToList(ds.Tables[0]); |
| | | int total = Convert.ToInt32(ds.Tables[1].Rows[0]["COUNT"]); |
| | | PageResultModel<$EntityName$> result = new PageResultModel<$EntityName$>(); |
| | | result.total = total; |
| | | result.rows = list; |
| | | return result; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region QueryList |
| | | |
| | | /// <summary> |
| | | /// è·å¾$ChinaComment$æ°æ®å表 |
| | | /// </summary> |
| | | /// <param name="strWhere">æ¥è¯¢æ¡ä»¶</param> |
| | | /// <returns>$ChinaComment$æ°æ®éå</returns> |
| | | public List<$EntityName$> GetModelList(string strWhere) |
| | | { |
| | | DataSet ds = $TableAlias$DAL.GetList(strWhere); |
| | | return DataTableToList(ds.Tables[0]); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Query(Single) |
| | | |
| | | /// <summary> |
| | | /// å¾å°ä¸ä¸ª$ChinaComment$å®ä½ |
| | | /// </summary> |
| | | /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> |
| | | /// <returns>$ChinaComment$å®ä½</returns> |
| | | public $EntityName$ GetModel(string $PrimaryKey$) |
| | | { |
| | | |
| | | return $TableAlias$DAL.GetModel($PrimaryKey$); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Other |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦åå¨è¯¥$ChinaComment$è®°å½ |
| | | /// </summary> |
| | | /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> |
| | | /// <returns></returns> |
| | | public bool Exists(string $PrimaryKey$, int? id = null) |
| | | { |
| | | return $TableAlias$DAL.Exists($PrimaryKey$,id); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Common |
| | | |
| | | /// <summary> |
| | | /// è·å¾$ChinaComment$æ°æ®å表 |
| | | /// </summary> |
| | | private List<$EntityName$> DataTableToList(DataTable dt) |
| | | { |
| | | List<$EntityName$> modelList = new List<$EntityName$>(); |
| | | int rowsCount = dt.Rows.Count; |
| | | if (rowsCount > 0) |
| | | { |
| | | $EntityName$ model; |
| | | for (int n = 0; n < rowsCount; n++) |
| | | { |
| | | model = new $EntityName$(); |
| | | var dataRow = dt.Rows[n]; |
| | | |
| | | $ToSingleModel$ |
| | | |
| | | |
| | | modelList.Add(model); |
| | | } |
| | | } |
| | | return modelList; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using $ProjectNamePrefix$.Core.Common.HttpContextUser; |
| | | using $ProjectNamePrefix$.Core.Extensions.Others; |
| | | using $ProjectNamePrefix$.Core.IServices; |
| | | using $ProjectNamePrefix$.Core.Model; |
| | | using $ProjectNamePrefix$.Core.Model.CommonModel; |
| | | using $ProjectNamePrefix$.Core.Model.Models; |
| | | using $ProjectNamePrefix$.Core.Model.ParamModels; |
| | | using $ProjectNamePrefix$.Core.Utility; |
| | | using Microsoft.AspNetCore.Authorization; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.Extensions.Logging; |
| | | using Newtonsoft.Json; |
| | | using System.Collections.Generic; |
| | | using System.Threading.Tasks; |
| | | using System; |
| | | |
| | | namespace $ProjectNamePrefix$.Core.Api.Controllers |
| | | { |
| | | /// <summary> |
| | | /// $ChinaComment$ |
| | | /// </summary> |
| | | [Route("api/[controller]/[action]")] |
| | | [ApiController] |
| | | [Authorize(Permissions.Name)] |
| | | public class $EntityName$Controller : ControllerBase |
| | | { |
| | | private readonly I$EntityName$Services _$EntityName$Services; |
| | | private readonly IUser _user; |
| | | private readonly ILogger<$EntityName$Controller> _logger; |
| | | |
| | | public $EntityName$Controller(I$EntityName$Services $EntityName$Services, IUser user, ILogger<$EntityName$Controller> logger) |
| | | { |
| | | _$EntityName$Services = $EntityName$Services; |
| | | _user = user; |
| | | _logger = logger; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å页è·å$ChinaComment$å表 |
| | | /// </summary> |
| | | /// <param name="param">ç鿡件</param> |
| | | /// <returns>è·åç»æ</returns> |
| | | [HttpPost] |
| | | public async Task<MessageModel<PageModel<$EntityName$>>> Get([FromBody] $EntityName$Param param) |
| | | { |
| | | if (string.IsNullOrEmpty(param.searchVal) || string.IsNullOrWhiteSpace(param.searchVal)) |
| | | { |
| | | param.searchVal = string.Empty; |
| | | } |
| | | |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<$EntityName$, $EntityName$Param>(param); |
| | | if (!whereConditions.IsSuccess) { |
| | | return new MessageModel<PageModel<$EntityName$>>() |
| | | { |
| | | msg = whereConditions.ErrMsg, |
| | | success = false, |
| | | response = null |
| | | }; |
| | | } |
| | | var data = await _$EntityName$Services.QueryPage(whereConditions.data, param.page, param.pageSize, " $OrderByName$ desc "); |
| | | return new MessageModel<PageModel<$EntityName$>>() |
| | | { |
| | | msg = "è·åæå", |
| | | success = true, |
| | | response = data |
| | | }; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åå个$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="id">主é®</param> |
| | | /// <returns>è·åç»æ</returns> |
| | | [HttpGet] |
| | | public async Task<MessageModel<$EntityName$>> Get(int id = 0) |
| | | { |
| | | return new MessageModel<$EntityName$>() |
| | | { |
| | | msg = "è·åæå", |
| | | success = true, |
| | | response = await _$EntityName$Services.QueryById(id) |
| | | }; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ°å¢$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="request">è¦æ°å¢ç$ChinaComment$对象</param> |
| | | /// <returns></returns> |
| | | [HttpPost] |
| | | public async Task<MessageModel<string>> Post([FromBody] $EntityName$ request) |
| | | { |
| | | try |
| | | { |
| | | #region éªè¯ |
| | | MessageModel<string> retBody = null; |
| | | retBody = ValidateDataHelper.CommonValidateIsNULL<$EntityName$, string>(request); |
| | | if (retBody != null) |
| | | { |
| | | return retBody; |
| | | } |
| | | |
| | | List<ValidateModel> columnsList = null; |
| | | columnsList = new List<ValidateModel>() { |
| | | $ValidateEmptyForInsert$ |
| | | }; |
| | | retBody = ValidateDataHelper.CommonValidate<$EntityName$, string>(request, columnsList); |
| | | if (retBody != null) |
| | | { |
| | | return retBody; |
| | | } |
| | | #endregion |
| | | |
| | | request.CreateTime = request.ModifyTime = DateTime.Now; |
| | | request.CreateBy = request.ModifyBy = _user.Name; |
| | | request.CreateId = request.ModifyId = _user.ID; |
| | | request.OperationRemark = "æ·»å "; |
| | | var id = await _$EntityName$Services.Add(request); |
| | | var success = id > 0; |
| | | |
| | | if (success) |
| | | { |
| | | return MessageModel<string>.Success("æ·»å æå", id.ObjToString()); |
| | | } |
| | | return MessageModel<string>.Fail("æ·»å 失败"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogError(ex,"æ°å¢$ChinaComment$åºç°å¼å¸¸:" + ex.Message); |
| | | return MessageModel<string>.Fail("æ°å¢$ChinaComment$åºç°å¼å¸¸:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ°$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="request">è¦æ´æ°ç$ChinaComment$对象</param> |
| | | /// <returns>æ´æ°ç»æ</returns> |
| | | [HttpPut] |
| | | public async Task<MessageModel<string>> Put([FromBody] $EntityName$ request) |
| | | { |
| | | try |
| | | { |
| | | #region éªè¯ |
| | | MessageModel<string> retBody = null; |
| | | retBody = ValidateDataHelper.CommonValidateIsNULL<$EntityName$, string>(request); |
| | | if (retBody != null) |
| | | { |
| | | return retBody; |
| | | } |
| | | |
| | | List<ValidateModel> columnsList = null; |
| | | columnsList = new List<ValidateModel>() |
| | | { |
| | | $ValidateEmptyForUpdate$ |
| | | }; |
| | | retBody = ValidateDataHelper.CommonValidate<$EntityName$, string>(request, columnsList); |
| | | if (retBody != null) |
| | | { |
| | | return retBody; |
| | | } |
| | | #endregion |
| | | |
| | | var dbObj = await _$EntityName$Services.QueryById(request.Id); |
| | | if (dbObj == null) |
| | | { |
| | | return MessageModel<string>.Fail("æ°æ®ä¸åå¨!"); |
| | | } |
| | | |
| | | request.ModifyTime = DateTime.Now; |
| | | request.ModifyBy = _user.Name; |
| | | request.ModifyId = _user.ID; |
| | | request.OperationRemark = "æ´æ°"; |
| | | var success = await _$EntityName$Services.Update(request); |
| | | |
| | | if (success) |
| | | { |
| | | return MessageModel<string>.Success("æ´æ°æå", request.Id.ObjToString()); |
| | | } |
| | | return MessageModel<string>.Fail("æ´æ°å¤±è´¥"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogError(ex,"æ´æ°$ChinaComment$åºç°å¼å¸¸:" + ex.Message); |
| | | return MessageModel<string>.Fail("æ´æ°$ChinaComment$åºç°å¼å¸¸:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å é¤$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="id">主é®</param> |
| | | /// <returns>å é¤ç»æ</returns> |
| | | [HttpDelete] |
| | | public async Task<MessageModel<string>> Delete(int id = 0) |
| | | { |
| | | try |
| | | { |
| | | var data = new MessageModel<string>(); |
| | | if (id > 0) |
| | | { |
| | | var detail = await _$EntityName$Services.QueryById(id); |
| | | if (detail != null) |
| | | { |
| | | data.success = await _$EntityName$Services.DeleteById(detail.Id); |
| | | if (data.success) |
| | | { |
| | | data.msg = "å 餿å"; |
| | | data.response = detail?.Id.ObjToString(); |
| | | } |
| | | } |
| | | else { |
| | | return MessageModel<string>.Fail("æ°æ®ä¸åå¨!"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | data.success = false; |
| | | data.msg = "å é¤å¤±è´¥,$ChinaComment$ä¸åå¨"; |
| | | } |
| | | return data; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogError(ex,"å é¤$ChinaComment$åºç°å¼å¸¸:" + ex.Message); |
| | | return MessageModel<string>.Fail("å é¤$ChinaComment$åºç°å¼å¸¸:" + ex.Message); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// é»è¾å é¤$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="id">主é®</param> |
| | | /// <returns>å é¤ç»æ</returns> |
| | | [HttpDelete] |
| | | public async Task<MessageModel<string>> LogicDelete(int id = 0) |
| | | { |
| | | try |
| | | { |
| | | var data = new MessageModel<string>(); |
| | | if (id > 0) |
| | | { |
| | | var detail = await _$EntityName$Services.QueryById(id); |
| | | if (detail != null) |
| | | { |
| | | detail.ModifyTime = DateTime.Now; |
| | | detail.ModifyBy = _user.Name; |
| | | detail.ModifyId = _user.ID; |
| | | detail.IsDeleted = true; |
| | | detail.OperationRemark = "å é¤"; |
| | | data.success = await _$EntityName$Services.Update(detail); |
| | | if (data.success) |
| | | { |
| | | data.msg = "å 餿å"; |
| | | data.response = detail?.Id.ObjToString(); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | data.success = false; |
| | | data.msg = "å é¤å¤±è´¥,æ°æ®ä¸åå¨"; |
| | | } |
| | | return data; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | _logger.LogError(ex,"é»è¾å é¤$ChinaComment$åºç°å¼å¸¸:" + ex.Message); |
| | | return MessageModel<string>.Fail("é»è¾å é¤$ChinaComment$åºç°å¼å¸¸:" + ex.Message); |
| | | } |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Text; |
| | | using System.Data.SqlClient; |
| | | using System.Data; |
| | | using WIP_Models; |
| | | |
| | | namespace WIP_DAL |
| | | { |
| | | /// <summary> |
| | | /// $ChinaComment$æ°æ®è®¿é®ç±» |
| | | /// </summary> |
| | | public class $FilePrefixName$DAL |
| | | { |
| | | #region Add |
| | | |
| | | /// <summary> |
| | | /// å¢å 䏿¡$ChinaComment$æ°æ® |
| | | /// </summary> |
| | | /// <param name="model">è¦æå
¥ç$ChinaComment$å®ä½</param> |
| | | /// <param name="transModel">äºå¡ç±»</param> |
| | | /// <returns>æå
¥çæçææ°ä¸»é®å¼</returns> |
| | | public int Add($EntityName$ model,TransactionModel transModel = null) |
| | | { |
| | | SqlParameter param_id = new SqlParameter(); |
| | | param_id.ParameterName = "@id"; |
| | | param_id.SqlDbType = SqlDbType.Int; |
| | | param_id.Direction = ParameterDirection.Output; |
| | | |
| | | $AddSqlParameter$ |
| | | |
| | | int rowsAffected; |
| | | if (transModel != null) |
| | | { |
| | | DbHelperSQL.RunProcedure(transModel.conn,transModel.trans, "$AddProcName$", parameters, out rowsAffected); |
| | | } |
| | | else |
| | | { |
| | | DbHelperSQL.RunProcedure("$AddProcName$", parameters, out rowsAffected); |
| | | } |
| | | return (int)parameters[parameters.Length - 1].Value; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Edit |
| | | |
| | | /// <summary> |
| | | /// æ´æ°ä¸æ¡$ChinaComment$æ°æ® |
| | | /// </summary> |
| | | /// <param name="model">è¦æ´æ°ç$ChinaComment$å®ä½</param> |
| | | /// <param name="transModel">äºå¡ç±»</param> |
| | | /// <returns>æ¯å¦æ´æ°æå</returns> |
| | | public bool Update($EntityName$ model,TransactionModel transModel = null) |
| | | { |
| | | $UpdateSqlParameter$ |
| | | |
| | | int rowsAffected = 0; |
| | | if (transModel != null) |
| | | { |
| | | DbHelperSQL.RunProcedure(transModel.conn,transModel.trans, "$UpdateProcName$", parameters, out rowsAffected); |
| | | } |
| | | else |
| | | { |
| | | DbHelperSQL.RunProcedure("$UpdateProcName$", parameters, out rowsAffected); |
| | | } |
| | | if (rowsAffected > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Del |
| | | |
| | | /// <summary> |
| | | /// å é¤ä¸æ¡$ChinaComment$æ°æ® |
| | | /// </summary> |
| | | /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> |
| | | /// <param name="transModel">äºå¡ç±»</param> |
| | | /// <returns>æ¯å¦å 餿å</returns> |
| | | public bool Delete(string $PrimaryKey$,TransactionModel transModel = null) |
| | | { |
| | | |
| | | StringBuilder strSql = new StringBuilder(); |
| | | strSql.Append("DELETE FROM $TableName$ "); |
| | | strSql.Append(" WHERE $PrimaryKey$=@$PrimaryKey$"); |
| | | SqlParameter[] parameters = { |
| | | new SqlParameter("@$PrimaryKey$", SqlDbType.NVarChar,50) |
| | | }; |
| | | parameters[0].Value = $PrimaryKey$; |
| | | |
| | | int rows = 0; |
| | | if (transModel != null) |
| | | { |
| | | rows = DbHelperSQL.ExecuteSql(transModel.conn, transModel.trans, strSql.ToString(), parameters); |
| | | } |
| | | else |
| | | { |
| | | rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); |
| | | } |
| | | if (rows > 0) |
| | | { |
| | | return true; |
| | | } |
| | | else |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Enable |
| | | |
| | | /// <summary> |
| | | /// ç¦å¯ç¨$ChinaComment$æ°æ® |
| | | /// </summary> |
| | | /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> |
| | | /// <param name="delFlag">ç¦ç¨1/å¯ç¨0</param> |
| | | /// <param name="lastModifier">æåä¿®æ¹äºº</param> |
| | | /// <param name="transModel">äºå¡ç±»</param> |
| | | /// <returns>æ¯å¦ç¦å¯ç¨æå</returns> |
| | | public bool Enable(string $PrimaryKey$, string delFlag, string lastModifier, TransactionModel transModel = null) |
| | | { |
| | | StringBuilder strSql = new StringBuilder(); |
| | | strSql.Append(" UPDATE $TableName$ SET delflag=@delFlag "); |
| | | strSql.Append(" ,lastModifier=@lastModifier "); |
| | | strSql.Append(" ,lastModifyTime=@lastModifyTime "); |
| | | strSql.Append(" WHERE $PrimaryKey$=@$PrimaryKey$"); |
| | | SqlParameter[] parameters = { |
| | | new SqlParameter("@delFlag", SqlDbType.NVarChar,10) , |
| | | new SqlParameter("@lastModifier", SqlDbType.NVarChar,20) , |
| | | new SqlParameter("@lastModifyTime", SqlDbType.DateTime) , |
| | | new SqlParameter("@$PrimaryKey$", SqlDbType.NVarChar,50) |
| | | }; |
| | | parameters[0].Value = delFlag; |
| | | parameters[1].Value = lastModifier; |
| | | parameters[2].Value = DateTime.Now; |
| | | parameters[3].Value = $PrimaryKey$; |
| | | |
| | | int rows = 0; |
| | | if (transModel != null) |
| | | { |
| | | rows = DbHelperSQL.ExecuteSql(transModel.conn, transModel.trans, strSql.ToString(), parameters); |
| | | } |
| | | else |
| | | { |
| | | rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); |
| | | } |
| | | return rows > 0 ? true : false; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region QueryList(Page) |
| | | |
| | | /// <summary> |
| | | /// è·å¾$ChinaComment$æ°æ®å表(å页) |
| | | /// </summary> |
| | | /// <param name="pageParam">å页å®ä½æ°æ®</param> |
| | | /// <returns>$ChinaComment$å表DataSet</returns> |
| | | public DataSet GetModelListForPage(Query$Modulelogo$Param pageParam) |
| | | { |
| | | $QueryPageSqlParameter$ |
| | | |
| | | return DbHelperSQL.RunProcedure("$GetPageListProcName$", parameters, "pagetable"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region QueryList |
| | | |
| | | /// <summary> |
| | | /// è·å¾$ChinaComment$æ°æ®å表 |
| | | /// </summary> |
| | | /// <param name="strWhere">æ¥è¯¢æ¡ä»¶</param> |
| | | /// <returns>$ChinaComment$å表DataSet</returns> |
| | | public DataSet GetList(string strWhere) |
| | | { |
| | | SqlParameter[] parameters = { |
| | | new SqlParameter("@strWhere", SqlDbType.NVarChar,500) |
| | | }; |
| | | parameters[0].Value = strWhere; |
| | | return DbHelperSQL.RunProcedure("$GetListProcName$", parameters, "table"); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Query(Single) |
| | | |
| | | /// <summary> |
| | | /// å¾å°ä¸ä¸ª$ChinaComment$å®ä½ |
| | | /// </summary> |
| | | /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> |
| | | /// <returns>$ChinaComment$å®ä½</returns> |
| | | public $EntityName$ GetModel(string $PrimaryKey$) |
| | | { |
| | | SqlParameter[] parameters = { |
| | | new SqlParameter("@$PrimaryKey$", SqlDbType.VarChar,50) |
| | | }; |
| | | parameters[0].Value = $PrimaryKey$; |
| | | |
| | | DataSet ds = DbHelperSQL.RunProcedure("$GetSingleProcName$", parameters, "pagetable"); |
| | | |
| | | $EntityName$ model = new $EntityName$(); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 1) |
| | | { |
| | | var dataRow = ds.Tables[0].Rows[0]; |
| | | |
| | | $ToSingleModel$ |
| | | |
| | | return model; |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region Other |
| | | |
| | | /// <summary> |
| | | /// æ¯å¦åå¨è¯¥$ChinaComment$è®°å½ |
| | | /// </summary> |
| | | /// <param name="$PrimaryKey$">$PrimaryKeyDesc$</param> |
| | | /// <returns>æ¯å¦åå¨è¯¥$ChinaComment$è®°å½</returns> |
| | | public bool Exists(string $PrimaryKey$, int? id = null) |
| | | { |
| | | StringBuilder strSql = new StringBuilder(); |
| | | strSql.Append("SELECT COUNT(1) FROM $TableName$"); |
| | | strSql.Append(" WHERE "); |
| | | strSql.Append(" $PrimaryKey$ = @$PrimaryKey$ "); |
| | | if (id != null) |
| | | { |
| | | strSql.Append(" AND id <> " + id.ToString()); |
| | | } |
| | | SqlParameter[] parameters = { |
| | | new SqlParameter("@$PrimaryKey$", SqlDbType.NVarChar,50) }; |
| | | parameters[0].Value = $PrimaryKey$; |
| | | |
| | | return DbHelperSQL.Exists(strSql.ToString(), parameters); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |
| | | |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Runtime.Serialization; |
| | | |
| | | namespace WIP_Models |
| | | { |
| | | /// <summary> |
| | | /// æ°å¢$ChinaComment$åæ°ç±» |
| | | /// </summary> |
| | | [DataContract] |
| | | public class $AddEntityParam$ |
| | | { |
| | | $AddAttributes$ |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Furion.Extras.Admin.NET; |
| | | using Furion.Extras.Admin.NET.Extension; |
| | | using Furion.Extras.Admin.NET.Service; |
| | | using System.ComponentModel.DataAnnotations; |
| | | |
| | | namespace Admin.NET.Application |
| | | { |
| | | /// <summary> |
| | | /// å页æ¥è¯¢$ChinaComment$è¾å
¥åæ° |
| | | /// </summary> |
| | | public class $EntityName$PageInput : PageInputCustomBase |
| | | { |
| | | $QueryAttributes$ |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ°å¢$ChinaComment$è¾å
¥åæ° |
| | | /// </summary> |
| | | public class Add$EntityName$Input : BasicsDEntity |
| | | { |
| | | $AddAttributes$ |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ°$ChinaComment$è¾å
¥åæ° |
| | | /// </summary> |
| | | public class Update$EntityName$Input : Add$EntityName$Input |
| | | { |
| | | [Required(ErrorMessage = "Id主é®ä¸è½ä¸ºç©º")] |
| | | public virtual new long Id { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å é¤$ChinaComment$è¾å
¥åæ° |
| | | /// </summary> |
| | | public class Delete$EntityName$Input |
| | | { |
| | | public List<long> Id { get; set; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å个æ¥è¯¢$ChinaComment$è¾å
¥åæ° |
| | | /// </summary> |
| | | public class Query$EntityName$Input : BaseId |
| | | { |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Admin.NET.Core.Helper.ExcelHelper; |
| | | using Furion.Extras.Admin.NET; |
| | | using Microsoft.EntityFrameworkCore; |
| | | |
| | | namespace Admin.NET.Application |
| | | { |
| | | /// <summary> |
| | | /// æ¥è¯¢$ChinaComment$è¾åºåæ° |
| | | /// </summary> |
| | | public class $EntityName$Output : BasicsDEntity |
| | | { |
| | | $QueryOutputAttributes$ |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 导åº$ChinaComment$è¾åºåæ° |
| | | /// </summary> |
| | | public class Export$EntityName$Output |
| | | { |
| | | $ExportOutputAttributes$ |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | USE $DataBaseName$ |
| | | GO |
| | | ------------------------------------ |
| | | --ç¨éï¼åå§åæ¥å£ç®¡ç表-$ChinaComment$ |
| | | --说æï¼ |
| | | --ä½è
: $Author$ |
| | | --æ¶é´ï¼$CurDate$ |
| | | ------------------------------------ |
| | | INSERT INTO Modules ([IsDeleted], [Name], [LinkUrl], [Area], [Controller], [Action], [Icon], [Code], [OrderSort], [Description], [IsMenu], [Enabled], [CreateId], [CreateBy], [CreateTime], [ModifyId], [ModifyBy], [ModifyTime], [ParentId]) VALUES ('0', N'æ¥è¯¢$ChinaComment$', N'/api/$TableName$/get', NULL, NULL, NULL, NULL, NULL, '0', NULL, '0', '1', '12', N'sys', GETDATE(), NULL, NULL,GETDATE(), '0'); |
| | | INSERT INTO Modules ([IsDeleted], [Name], [LinkUrl], [Area], [Controller], [Action], [Icon], [Code], [OrderSort], [Description], [IsMenu], [Enabled], [CreateId], [CreateBy], [CreateTime], [ModifyId], [ModifyBy], [ModifyTime], [ParentId]) VALUES ('0', N'æ°å¢$ChinaComment$', N'/api/$TableName$/post', NULL, NULL, NULL, NULL, NULL, '0', NULL, '0', '1', '12', N'sys', GETDATE(), NULL, NULL, GETDATE(), '0'); |
| | | INSERT INTO Modules ([IsDeleted], [Name], [LinkUrl], [Area], [Controller], [Action], [Icon], [Code], [OrderSort], [Description], [IsMenu], [Enabled], [CreateId], [CreateBy], [CreateTime], [ModifyId], [ModifyBy], [ModifyTime], [ParentId]) VALUES ('0', N'ä¿®æ¹$ChinaComment$', N'/api/$TableName$/put', NULL, NULL, NULL, NULL, NULL, '0', NULL, '0', '1', '12', N'sys', GETDATE(), NULL, NULL, GETDATE(), '0'); |
| | | INSERT INTO Modules ([IsDeleted], [Name], [LinkUrl], [Area], [Controller], [Action], [Icon], [Code], [OrderSort], [Description], [IsMenu], [Enabled], [CreateId], [CreateBy], [CreateTime], [ModifyId], [ModifyBy], [ModifyTime], [ParentId]) VALUES ('0', N'å é¤$ChinaComment$', N'/api/$TableName$/delete', NULL, NULL, NULL, NULL, NULL, '0', NULL, '0', '1', '12', N'sys', GETDATE(), NULL, NULL, GETDATE(), '0'); |
| | | GO |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$UpdateProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) |
| | | DROP PROCEDURE [$UpdateProcName$] |
| | | GO |
| | | ------------------------------------ |
| | | --ç¨éï¼ä¿®æ¹ä¸æ¡$ChinaComment$è®°å½ |
| | | --说æï¼ |
| | | --ä½è
: $Author$ |
| | | --æ¶é´ï¼$CurDate$ |
| | | ------------------------------------ |
| | | CREATE PROCEDURE $UpdateProcName$ |
| | | $update_cols_params$ |
| | | AS |
| | | UPDATE [$TableName$] SET |
| | | $update_cols_assignment$ |
| | | WHERE $Primary$=@$Primary$ |
| | | |
| | | GO |
¶Ô±ÈÐÂÎļþ |
| | |
| | | IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$UpdateProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) |
| | | DROP PROCEDURE [$UpdateProcName$] |
| | | GO |
| | | ------------------------------------ |
| | | --ç¨éï¼ä¿®æ¹ä¸æ¡$ChinaComment$è®°å½ |
| | | --说æï¼ |
| | | --ä½è
: $Author$ |
| | | --æ¶é´ï¼$CurDate$ |
| | | ------------------------------------ |
| | | CREATE PROCEDURE $UpdateProcName$ |
| | | $update_cols_params$ |
| | | AS |
| | | UPDATE [$TableName$] SET |
| | | $update_cols_assignment2$ |
| | | WHERE $Primary$=@$Primary$ |
| | | |
| | | GO |
¶Ô±ÈÐÂÎļþ |
| | |
| | | IF EXISTS (SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$GetPageListProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) |
| | | DROP PROCEDURE [$GetPageListProcName$] |
| | | GO |
| | | ------------------------------------ |
| | | --ç¨éï¼è·å¾$ChinaComment$æ°æ®å表(å页) |
| | | --说æï¼ |
| | | --ä½è
: $Author$ |
| | | --æ¶é´ï¼$CurDate$ |
| | | ------------------------------------ |
| | | CREATE PROCEDURE $GetPageListProcName$ |
| | | $page_cols_params$ |
| | | @pageIndex int, |
| | | @pageSize int |
| | | AS |
| | | DECLARE @startRow int, @endRow int |
| | | |
| | | SET nocount ON; |
| | | |
| | | SET @startRow = (@pageIndex - 1) * @pageSize +1 |
| | | SET @endRow = @startRow + @pageSize -1 |
| | | |
| | | -- æ¥è¯¢åé¡µæ°æ® |
| | | SELECT $strQueryCol_1$ |
| | | FROM |
| | | ( |
| | | SELECT ROW_NUMBER() Over(order by id desc ) AS row_num, |
| | | $strQueryCol_2$ |
| | | FROM $TableName$ AS $TableAlias$ WITH(NOLOCK) |
| | | WHERE $where_cols_params$ |
| | | ) AS tabledata |
| | | WHERE row_num BETWEEN cast(@startRow as nvarchar(20)) AND +cast(@endRow as nvarchar(20)) |
| | | |
| | | -- æ¥è¯¢æ»æ¡æ° |
| | | SELECT COUNT(1) AS COUNT FROM $TableName$ AS $TableAlias$ WITH(NOLOCK) |
| | | WHERE $where_cols_params$ |
| | | |
| | | SET nocount OFF; |
| | | GO |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$GetListProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) |
| | | DROP PROCEDURE [$GetListProcName$] |
| | | GO |
| | | ------------------------------------ |
| | | --ç¨éï¼è·å¾$ChinaComment$æ°æ®å表 |
| | | --说æï¼ |
| | | --ä½è
: $Author$ |
| | | --æ¶é´ï¼$CurDate$ |
| | | ------------------------------------ |
| | | CREATE PROCEDURE $GetListProcName$ |
| | | @strWhere nvarchar(500) -- æ¥è¯¢æ¡ä»¶ |
| | | AS |
| | | DECLARE @strQueryCol nvarchar(max), |
| | | @strSql nvarchar(max) |
| | | |
| | | |
| | | SET nocount ON; |
| | | |
| | | SET @strQueryCol=' $strQueryCol$ ' |
| | | |
| | | SET @strSql= ' SELECT '+@strQueryCol |
| | | +' FROM $TableName$ AS $TableAlias$ WITH(NOLOCK) WHERE 1=1 ' |
| | | |
| | | IF(@strWhere <> '') |
| | | BEGIN |
| | | SET @strSql=@strSql+' AND '+@strWhere |
| | | END |
| | | |
| | | SET @strSql=@strSql+' ORDER BY $TableAlias$.$orderByName$ DESC ' |
| | | EXEC SP_EXECUTESQL @strSql |
| | | |
| | | SET nocount OFF; |
| | | GO |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$AddProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) |
| | | DROP PROCEDURE [$AddProcName$] |
| | | GO |
| | | ------------------------------------ |
| | | --ç¨éï¼å¢å 䏿¡$ChinaComment$è®°å½ |
| | | --说æï¼ |
| | | --ä½è
: $Author$ |
| | | --æ¶é´ï¼$CurDate$ |
| | | ------------------------------------ |
| | | CREATE PROCEDURE $AddProcName$ |
| | | @id int output, |
| | | $insert_cols_params$ |
| | | AS |
| | | INSERT INTO [$TableName$]( |
| | | $insert_cols$ |
| | | )VALUES( |
| | | $insert_cols_values$ |
| | | ) |
| | | SET @id = @@IDENTITY |
| | | RETURN @id |
| | | GO |
¶Ô±ÈÐÂÎļþ |
| | |
| | | IF EXISTS ( SELECT 1 FROM dbo.sysobjects WHERE id = object_id(N'[$GetSingleProcName$]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) |
| | | DROP PROCEDURE [$GetSingleProcName$] |
| | | GO |
| | | ------------------------------------ |
| | | --ç¨éï¼å¾å°ä¸ä¸ª$ChinaComment$å®ä½ |
| | | --说æï¼ |
| | | --ä½è
: $Author$ |
| | | --æ¶é´ï¼$CurDate$ |
| | | ------------------------------------ |
| | | CREATE PROCEDURE $GetSingleProcName$ |
| | | @$Primary$ $DataType$ |
| | | AS |
| | | SET nocount ON; |
| | | |
| | | SELECT $strQueryCol$ |
| | | FROM $TableName$ AS $TableAlias$ WITH(NOLOCK) WHERE $Primary$=@$Primary$ |
| | | |
| | | SET nocount OFF; |
| | | GO |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Admin.NET.Core.BasicInformation.Entity; |
| | | using Furion.DatabaseAccessor; |
| | | using Furion.DependencyInjection; |
| | | using Furion.DynamicApiController; |
| | | using Furion.Extras.Admin.NET; |
| | | using Furion.Extras.Admin.NET.Extension; |
| | | using Furion.FriendlyException; |
| | | using Mapster; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | using Microsoft.EntityFrameworkCore; |
| | | using Microsoft.EntityFrameworkCore.ChangeTracking; |
| | | using PandaWork.Infrastructure; |
| | | using System.Data; |
| | | using System.Linq.Dynamic.Core; |
| | | using Furion.LinqBuilder; |
| | | using System.Linq.Expressions; |
| | | using Admin.NET.Core.Helper.ExcelHelper; |
| | | |
| | | namespace Admin.NET.Application |
| | | { |
| | | /// <summary> |
| | | /// $ChinaComment$æå¡æ¥å£å®ç° |
| | | /// </summary> |
| | | [ApiDescriptionSettings("$GroupName$", Name = "$ChinaComment$", Order = 100)] |
| | | public class $EntityName$Service : ControllerBase, I$EntityName$Service, IDynamicApiController, ITransient |
| | | { |
| | | private readonly IRepository<$EntityName$, MasterDbContextLocator> _$EntityName_FirstLetterLower$Rep; |
| | | /// <summary> |
| | | /// $ChinaComment$æå¡æé 彿° |
| | | /// </summary> |
| | | /// <param name="$EntityName_FirstLetterLower$Rep">$ChinaComment$æå¡ä»å¨å¯¹è±¡</param> |
| | | public $EntityName$Service(IRepository<$EntityName$, MasterDbContextLocator> $EntityName_FirstLetterLower$Rep) |
| | | { |
| | | _$EntityName_FirstLetterLower$Rep = $EntityName_FirstLetterLower$Rep; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å页æ¥è¯¢$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">å页æ¥è¯¢åæ°</param> |
| | | /// <returns></returns> |
| | | [HttpGet("/$EntityName$/page")] |
| | | [DisableOpLog] |
| | | public async Task<PageResult<$EntityName$Output>> Page([FromQuery] $EntityName$PageInput input) |
| | | { |
| | | if (input == null) |
| | | { |
| | | throw Oops.Oh(ErrorCode.D4008); |
| | | } |
| | | |
| | | #region 卿æé æ¥è¯¢æ¡ä»¶ |
| | | |
| | | //卿æé æ¥è¯¢æ¡ä»¶ |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | var pageList= await _$EntityName_FirstLetterLower$Rep.DetachedEntities |
| | | .Where(whereConditions.data) |
| | | .OrderBy(PageInputOrder.OrderBuilder<$EntityName$PageInput>(input)) |
| | | .ProjectToType<$EntityName$Output>() |
| | | .ToADPagedListAsync(input.PageNo, input.PageSize); |
| | | return pageList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å¢å $ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">å¢å åæ°</param> |
| | | /// <returns></returns> |
| | | [HttpPost("/$EntityName$/add")] |
| | | public async Task<long> Add([FromBody] Add$EntityName$Input input) |
| | | { |
| | | if (input == null) |
| | | { |
| | | throw Oops.Oh(ErrorCode.D4008); |
| | | } |
| | | var $EntityName_FirstLetterLower$ = input.Adapt<$EntityName$>(); |
| | | EntityEntry<$EntityName$> entityEntry = await _$EntityName_FirstLetterLower$Rep.InsertAsync($EntityName_FirstLetterLower$); |
| | | return entityEntry.Entity.Id; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ´æ°$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">æ´æ°åæ°</param> |
| | | /// <returns></returns> |
| | | [HttpPost("/$EntityName$/update")] |
| | | public async Task<long> Update([FromBody] Update$EntityName$Input input) |
| | | { |
| | | if (input == null || (input.Id) <= 0) |
| | | { |
| | | throw Oops.Oh(ErrorCode.D1012); |
| | | } |
| | | var isExist = await _$EntityName_FirstLetterLower$Rep.AnyAsync(u => u.Id == input.Id, false); |
| | | if (!isExist) |
| | | { |
| | | throw Oops.Oh(ErrorCode.D1002); |
| | | } |
| | | var $EntityName_FirstLetterLower$ = input.Adapt<$EntityName$>(); |
| | | await _$EntityName_FirstLetterLower$Rep.UpdateAsync($EntityName_FirstLetterLower$, ignoreNullValues: true); |
| | | return input.Id; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å é¤$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">å é¤åæ°</param> |
| | | /// <returns></returns> |
| | | [HttpPost("/$EntityName$/delete")] |
| | | public async Task<int> Delete([FromBody] Delete$EntityName$Input input) |
| | | { |
| | | if (input == null || input.Id.Count == 0) |
| | | { |
| | | throw Oops.Oh(ErrorCode.D4008); |
| | | } |
| | | List<$EntityName$> list = new(); |
| | | foreach (var item in input.Id) |
| | | { |
| | | list.Add(new $EntityName$() { Id = item }); |
| | | } |
| | | await _$EntityName_FirstLetterLower$Rep.DeleteAsync(list); |
| | | return input.Id.Count; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·å$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">è·åå¯¹è±¡åæ°</param> |
| | | /// <returns></returns> |
| | | [HttpGet("/$EntityName$/detail")] |
| | | [DisableOpLog] |
| | | public async Task<$EntityName$Output> Get([FromQuery] Query$EntityName$Input input) |
| | | { |
| | | if (input == null || input.Id <= 0) |
| | | { |
| | | throw Oops.Oh(ErrorCode.D1012); |
| | | } |
| | | return (await _$EntityName_FirstLetterLower$Rep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id)).Adapt<$EntityName$Output>(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 导åº$ChinaComment$Excel |
| | | /// </summary> |
| | | /// <param name="input">ç鿡件</param> |
| | | /// <returns></returns> |
| | | [HttpPost("/$EntityName$/export")] |
| | | [DisableOpLog] |
| | | public async Task<ActionResult> Export([FromQuery] $EntityName$PageInput input) |
| | | { |
| | | if (input == null) |
| | | { |
| | | throw Oops.Oh(ErrorCode.D4008); |
| | | } |
| | | |
| | | #region 卿æé æ¥è¯¢æ¡ä»¶ |
| | | |
| | | //卿æé æ¥è¯¢æ¡ä»¶ |
| | | var whereConditions = DynamicGetQueryParams(input); |
| | | |
| | | #endregion |
| | | |
| | | var deliveryOrderExportExcel = await _$EntityName_FirstLetterLower$Rep.DetachedEntities |
| | | .Where(whereConditions.data) |
| | | .ProjectToType<Export$EntityName$Output>() |
| | | .ToListAsync(); |
| | | var excelBaseResult = new Excel2003Result<Export$EntityName$Output>(deliveryOrderExportExcel, "$ChinaComment$è®°å½" + DateTime.Now.ToString("yyyyMMdd"), false, "$ChinaComment$è®°å½"); |
| | | return File(excelBaseResult.GetExcelStream(), "application/vnd.ms-excel"); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 卿æé æ¥è¯¢æ¡ä»¶ |
| | | /// </summary> |
| | | /// <param name="input">è¾å
¥åæ°</param> |
| | | /// <returns></returns> |
| | | private FunReturnResultModel<Expression<Func<$EntityName$, bool>>> DynamicGetQueryParams($EntityName$PageInput input) |
| | | { |
| | | //卿æé æ¥è¯¢æ¡ä»¶ |
| | | var whereConditions = WhereConditionsExtensions.GetWhereConditions<$EntityName$, $EntityName$PageInput>(input); |
| | | if (!whereConditions.IsSuccess) |
| | | { |
| | | throw Oops.Oh("卿æé æ¥è¯¢æ¡ä»¶å¤±è´¥:" + whereConditions.ErrMsg); |
| | | } |
| | | |
| | | //ä¹å¯å次èªå®ä¹æå»ºæ¥è¯¢æ¡ä»¶ |
| | | Expression<Func<$EntityName$, bool>> extendExpression = a => a.IsDeleted == false; |
| | | whereConditions.data = whereConditions.data.And(extendExpression); |
| | | |
| | | return whereConditions; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using Furion.Extras.Admin.NET; |
| | | using Microsoft.AspNetCore.Mvc; |
| | | |
| | | namespace Admin.NET.Application |
| | | { |
| | | /// <summary> |
| | | /// $ChinaComment$æå¡æ¥å£ |
| | | /// </summary> |
| | | public interface I$EntityName$Service |
| | | { |
| | | /// <summary> |
| | | /// å页æ¥è¯¢$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">å页æ¥è¯¢åæ°</param> |
| | | /// <returns></returns> |
| | | Task<PageResult<$EntityName$Output>> Page([FromQuery] $EntityName$PageInput input); |
| | | |
| | | |
| | | /// <summary> |
| | | /// å¢å $ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">å¢å åæ°</param> |
| | | /// <returns></returns> |
| | | Task<long> Add([FromBody] Add$EntityName$Input input); |
| | | |
| | | |
| | | /// <summary> |
| | | /// æ´æ°$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">æ´æ°åæ°</param> |
| | | /// <returns></returns> |
| | | Task<long> Update([FromBody] Update$EntityName$Input input); |
| | | |
| | | |
| | | /// <summary> |
| | | /// å é¤$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">å é¤åæ°</param> |
| | | /// <returns></returns> |
| | | Task<int> Delete([FromBody] Delete$EntityName$Input input); |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·å$ChinaComment$ |
| | | /// </summary> |
| | | /// <param name="input">è·åå¯¹è±¡åæ°</param> |
| | | /// <returns></returns> |
| | | Task<$EntityName$Output> Get([FromQuery] Query$EntityName$Input input); |
| | | |
| | | |
| | | /// <summary> |
| | | /// 导åº$ChinaComment$Excel |
| | | /// </summary> |
| | | /// <param name="input">ç鿡件</param> |
| | | /// <returns></returns> |
| | | Task<ActionResult> Export([FromQuery] $EntityName$PageInput input); |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <section> |
| | | <!--å·¥å
·æ¡--> |
| | | <el-col :span="24" |
| | | class="toolbar" |
| | | style="padding-bottom: 0px;"> |
| | | <el-form :inline="true" |
| | | @submit.native.prevent> |
| | | <toolbar :buttonList="buttonList" |
| | | @callFunction="callFunction"> |
| | | </toolbar> |
| | | <!-- æç´¢ --> |
| | | <SearchForm :commonSearchOptionSet="c_commonSearchOptionSet" |
| | | :searchValControlStyle="c_searchValControlStyle" |
| | | :searchFormInputPlaceholder="c_searchFormInputPlaceholder" |
| | | :searchFormInputAttrs="c_searchFormInputAttrs" |
| | | :formOptions="h_formOptions" |
| | | :drawerSize="h_drawerSize" |
| | | :labelWidth="h_labelWidth" |
| | | :controlStyle="h_controlStyle" |
| | | ref="ChildSearchForm" |
| | | @onSearch="_get$Modulelogo$s" /> |
| | | </el-form> |
| | | </el-col> |
| | | |
| | | <!--å表--> |
| | | <el-table :data="$Modulelogo$s" |
| | | :max-height="tableHeight" |
| | | highlight-current-row |
| | | size="small" |
| | | :height="tableHeight" |
| | | @current-change="selectCurrentRow" |
| | | v-loading="listLoading" |
| | | @selection-change="selsChange" |
| | | style="width: 99%;"> |
| | | <el-table-column type="index" |
| | | :index="indexMethod" |
| | | label="#" |
| | | align="center" |
| | | width="50"> |
| | | </el-table-column> |
| | | $el-table-column$ |
| | | <el-table-column label="æä½" |
| | | fixed="right" |
| | | width="180" |
| | | v-if="isShowOperatorColumn"> |
| | | <template scope="scope"> |
| | | <el-button size="small" |
| | | icon="el-icon-edit" |
| | | type="primary" |
| | | v-if="isShowOperatorButton('edit')" |
| | | @click="handleEdit(scope.row)">ç¼è¾</el-button> |
| | | <el-button type="danger" |
| | | size="small" |
| | | icon="el-icon-delete" |
| | | v-if="isShowOperatorButton('del')" |
| | | @click="handleDel(scope.row)">å é¤</el-button> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <!--å·¥å
·æ¡--> |
| | | <el-col :span="24" |
| | | style="margin:10px 10px 10px 0px;" |
| | | class="toolbar"> |
| | | <el-pagination @size-change="handleSizeChange" |
| | | @current-change="handleCurrentChange" |
| | | :current-page="page" |
| | | background |
| | | :page-sizes="[5,10,50,100, 200, 300, 400]" |
| | | :page-size="pageSize" |
| | | layout="total, sizes, prev, pager, next, jumper" |
| | | :total="total"> |
| | | </el-pagination> |
| | | </el-col> |
| | | <!--æ°å¢/ç¼è¾çé¢--> |
| | | <el-dialog :title="dialogTitle" |
| | | :visible.sync="addFormVisible" |
| | | :close-on-click-modal="false" |
| | | :before-close="cancelHandle"> |
| | | <el-form :model="addForm" |
| | | size="small" |
| | | label-width="120px" |
| | | ref="addForm"> |
| | | $el-item$ |
| | | </el-form> |
| | | <div slot="footer" |
| | | class="dialog-footer"> |
| | | <el-button @click.native="cancelHandle" icon="fa fa-power-off">åæ¶</el-button> |
| | | <el-button type="primary" |
| | | @click.native="submitDataHandle" |
| | | :loading="addLoading" icon="fa fa-send">æäº¤</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--æ¥ççé¢--> |
| | | <el-dialog title="æ¥ç" |
| | | :visible.sync="viewDetailVisible" |
| | | :before-close="cancelHandle"> |
| | | <el-form :model="viewDetailForm" |
| | | size="small" |
| | | disabled="true" |
| | | label-width="120px" |
| | | ref="viewDetailForm"> |
| | | $el-item-view$ |
| | | </el-form> |
| | | <div slot="footer" |
| | | class="dialog-footer"> |
| | | <el-button @click.native="closeViewHandle" icon="fa fa-power-off">å
³é</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!-- 导åºç»ä»¶ --> |
| | | <ToolbarExport ref="cmToolbarExport" |
| | | :exportFileName="export_exportFileName" |
| | | :currentPageData="export_currentPageData" |
| | | :exportColumnHeader="export_columnHeader" /> |
| | | <!-- 导å
¥Excelç»ä»¶ --> |
| | | <ToolbarImportExcel ref="tbImportExcel" |
| | | :importExcelCategroy="emport_excelCategroy" |
| | | :templeteFileDownName="emport_templeteFileDownName"></ToolbarImportExcel> |
| | | </section> |
| | | </template> |
| | | |
| | | <script> |
| | | import util from '../../../util/date' |
| | | import { get$Modulelogo$ListPage, remove$Modulelogo$, edit$Modulelogo$, add$Modulelogo$ } from '../../api/api'; |
| | | import { getButtonList } from "../../promissionRouter"; |
| | | import Toolbar from "../../components/ToolbarButton"; |
| | | import SearchForm from "../../components/SearchForm"; |
| | | import ToolbarExport from "../../components/ToolbarExport"; |
| | | import ToolbarImportExcel from "../../components/ToolbarImportExcel"; |
| | | import { formatDate, setformOptionsNewValue } from '../../../util/tools' |
| | | import { isShowOperatorButtonCommon, isNeedShowOperatorColumn, isMobile } from '../../../util/common' |
| | | |
| | | |
| | | export default { |
| | | components: { Toolbar, SearchForm, ToolbarExport,ToolbarImportExcel },//注ååç»ä»¶ |
| | | data () { |
| | | return { |
| | | //导å
¥Excelæ°æ®ç¸å
³ |
| | | emport_templeteFileDownName: '$emport_templeteFileDownName$.xlsx',//æä»¶ä¸è½½åå |
| | | emport_excelCategroy: "$emport_excelCategroy$",//ä¸ä¼ æä»¶ç请æ±åç±» |
| | | //导åºç»ä»¶ç¸å
³ |
| | | export_exportFileName: '$ChinaComment$ä¿¡æ¯',//è¦å¯¼åºçæä»¶å |
| | | export_currentPageData: [],//å½å页é¢çåè¡¨æ°æ® |
| | | export_columnHeader: {$VueExportColumnHeaderStr$},//å½å页é¢å表ç表头æ±åå屿§æ°ç»ï¼å¯¼åºç¨ |
| | | |
| | | //æç´¢æ¡ç¸å
³ |
| | | c_commonSearchOptionSet: "模ç³",//éç¨æ¥è¯¢çé»è®¤é
ç½®,"模ç³"æ"ç²¾å" |
| | | c_searchValControlStyle: {//设置éç¨æç´¢æ¡çé¿åº¦çæ ·å¼ |
| | | width: '300px', |
| | | }, |
| | | c_searchFormInputPlaceholder: '请è¾å
¥$SearchFormInputPlaceholderStr$',//è¦ç»åæç´¢ç»ä»¶ä¼ éçå¼ |
| | | c_searchFormInputAttrs: [$SearchFormInputPlaceholderNameStr$],//è¦ç»åæç´¢ç»ä»¶ä¼ éç屿§å |
| | | h_controlStyle: {//设置é«çº§æç´¢æ§ä»¶çé¿åº¦çæ ·å¼ |
| | | width: '350px', |
| | | }, |
| | | h_labelWidth: "100px",//æ¾ç¤ºLabelç宽度 |
| | | h_drawerSize: "600px",//drawner宽度设置 |
| | | h_formOptions: [ |
| | | $FormOptionsStr$ |
| | | ], |
| | | |
| | | isShowOperatorColumn: true,// æ¯å¦æ¾ç¤ºãæä½ãå,trueæ¾ç¤º false䏿¾ç¤º |
| | | tableHeight: window.innerHeight - 180, // æ§å¶è¡¨æ ¼çé«åº¦ |
| | | |
| | | isAdd: false, // æ¯å¦æ¯æ°å¢ |
| | | dialogTitle: '', |
| | | |
| | | //æ¥çæå
³ |
| | | viewDetailVisible: false, |
| | | viewDetailForm: {}, |
| | | |
| | | filters: { |
| | | name: '' |
| | | }, |
| | | $Modulelogo$s: [], |
| | | total: 0, |
| | | buttonList: [], |
| | | currentRow: null, |
| | | page: 1, |
| | | pageSize: 10, |
| | | listLoading: false, |
| | | sels: [],//å表éä¸å |
| | | |
| | | addFormVisible: false,//æ°å¢ç颿¯å¦æ¾ç¤º |
| | | addLoading: false, |
| | | //æ°å¢æç¼è¾ç颿°æ® |
| | | addForm: { |
| | | //注æï¼è¿éä¸éè¦ååå§å¼ï¼åå§å¼é½åå¨ init_addFormä¸ |
| | | }, |
| | | init_addForm: { |
| | | //注æï¼è¿éååå§å¼ |
| | | } |
| | | } |
| | | }, |
| | | methods: { |
| | | //æ¯å¦æ¾ç¤ºæä¸ªæä½æé® |
| | | isShowOperatorButton (flag) { |
| | | return isShowOperatorButtonCommon(this.isShowOperatorColumn, flag, this.buttonList) |
| | | }, |
| | | // è®¾ç½®ç´¢å¼ |
| | | indexMethod (index) { |
| | | return (this.page - 1) * this.pageSize + 1 + index |
| | | }, |
| | | // æ¶é´æ ¼å¼å |
| | | formatterDateTime (row, column, cellValue, index) { |
| | | if (cellValue === null || cellValue === '') { |
| | | return '' |
| | | } |
| | | var NewDtime = new Date(Date.parse(cellValue)) |
| | | return formatDate(NewDtime, 'yyyy-MM-dd hh:mm:ss') |
| | | }, |
| | | selectCurrentRow (val) { |
| | | this.currentRow = val; |
| | | }, |
| | | callFunction (item) { |
| | | this.filters = { |
| | | name: item.search |
| | | }; |
| | | this[item.Func].apply(this, item); |
| | | }, |
| | | handleCurrentChange (val) { |
| | | this.page = val; |
| | | this.get$Modulelogo$s(); |
| | | }, |
| | | handleSizeChange (val) { |
| | | this.pageSize = val; |
| | | this.get$Modulelogo$s(); |
| | | }, |
| | | /** |
| | | * è·å请æ±åæ° |
| | | * flag:æ è®°ï¼1代表æ®éå页æ¥è¯¢ï¼2代表ä¸å页ï¼è·åå
¨é¨æ°æ® |
| | | */ |
| | | getPostParam (flag) { |
| | | let para = Object.assign({}, this.$refs.ChildSearchForm.getFormData()); |
| | | para.page = this.page |
| | | para.pageSize = this.pageSize |
| | | if (flag === '2') { // å
¨é¨å¯¼åº |
| | | para.page = 1 |
| | | para.pageSize = 10000 |
| | | } |
| | | return para |
| | | }, |
| | | //ç¹å»æé®ãæ¥è¯¢ã |
| | | _get$Modulelogo$s () { |
| | | this.page = 1 |
| | | this.get$Modulelogo$s() |
| | | }, |
| | | //è·åå表 |
| | | get$Modulelogo$s (formValue) { |
| | | //this.total = 0 |
| | | //this.$Modulelogo$s = null |
| | | let para = this.getPostParam('1'); |
| | | this.listLoading = true; |
| | | get$Modulelogo$ListPage(para).then((res) => { |
| | | if (res.data.success) { |
| | | this.total = res.data.response.dataCount; |
| | | this.$Modulelogo$s = res.data.response.data; |
| | | } else { |
| | | this.$message({ |
| | | message: res.data.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | this.listLoading = false; |
| | | }); |
| | | }, |
| | | //è·åå
¨é¨å表 |
| | | exportAllData () { |
| | | let para = this.getPostParam('2'); |
| | | this.listLoading = true; |
| | | get$Modulelogo$ListPage(para).then((res) => { |
| | | var allData = res.data.response.data; |
| | | this.$refs.cmToolbarExport.export2Excel(allData); |
| | | this.listLoading = false; |
| | | }); |
| | | }, |
| | | //å é¤ |
| | | handleDel (selRow) { |
| | | let row = {}; |
| | | if (selRow && selRow != undefined) { |
| | | this.currentRow = selRow; |
| | | } |
| | | row = this.currentRow; |
| | | if (!row) { |
| | | this.$message({ |
| | | message: "è¯·éæ©è¦å é¤çä¸è¡æ°æ®ï¼", |
| | | type: "warning" |
| | | }); |
| | | return; |
| | | } |
| | | this.$confirm('确认å é¤è¯¥è®°å½å?', 'æç¤º', { |
| | | type: 'warning' |
| | | }).then(() => { |
| | | this.listLoading = true; |
| | | let para = { id: row.Id }; |
| | | remove$Modulelogo$(para).then((res) => { |
| | | |
| | | if (util.isEmt.format(res)) { |
| | | this.listLoading = false; |
| | | return; |
| | | } |
| | | this.listLoading = false; |
| | | if (res.data.success) { |
| | | this.$message({ |
| | | message: 'å 餿å', |
| | | type: 'success' |
| | | }); |
| | | |
| | | } else { |
| | | this.$message({ |
| | | message: res.data.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | |
| | | this._get$Modulelogo$s(); |
| | | }); |
| | | }).catch(() => { |
| | | |
| | | }); |
| | | }, |
| | | //æ¾ç¤ºç¼è¾çé¢ |
| | | handleEdit (selRow) { |
| | | let row = {}; |
| | | if (selRow && selRow != undefined) { |
| | | this.currentRow = selRow; |
| | | } |
| | | row = this.currentRow; |
| | | if (!row) { |
| | | this.$message({ |
| | | message: "è¯·éæ©è¦ç¼è¾çä¸è¡æ°æ®ï¼", |
| | | type: "warning" |
| | | }); |
| | | |
| | | return; |
| | | } |
| | | this.isAdd = false |
| | | this.dialogTitle = 'ç¼è¾' |
| | | this.addFormVisible = true; |
| | | this.addForm = Object.assign({}, row); |
| | | }, |
| | | //æ¾ç¤ºæ°å¢çé¢ |
| | | handleAdd () { |
| | | this.isAdd = true |
| | | this.dialogTitle = 'æ°å¢' |
| | | this.addFormVisible = true; |
| | | this.setInitAddForm() |
| | | }, |
| | | //åæ¶æäº¤æ°æ®æä½ |
| | | cancelHandle (done) { |
| | | this.setInitAddForm() |
| | | this.addFormVisible = false |
| | | |
| | | done() //done ç¨äºå
³é Dialog |
| | | }, |
| | | // æäº¤æ°æ® |
| | | submitDataHandle (formName) { |
| | | this.submitDisabled = true |
| | | |
| | | this.$refs.addForm.validate((valid) => { |
| | | if (valid) { |
| | | this.$confirm('确认æäº¤åï¼', 'æç¤º', {}).then(() => { |
| | | this.addLoading = true; |
| | | let para = Object.assign({}, this.addForm); |
| | | if (this.isAdd) {//æ°å¢ |
| | | add$Modulelogo$(para).then((res) => { |
| | | if (util.isEmt.format(res)) { |
| | | this.addLoading = false; |
| | | return; |
| | | } |
| | | |
| | | if (res.data.success) { |
| | | this.addLoading = false; |
| | | this.$message({ |
| | | message: res.data.msg, |
| | | type: 'success' |
| | | }); |
| | | this.$refs['addForm'].resetFields(); |
| | | this.addFormVisible = false; |
| | | this._get$Modulelogo$s(); |
| | | } |
| | | else { |
| | | this.addLoading = false; |
| | | this.$message({ |
| | | message: res.data.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | |
| | | }); |
| | | } else {//ç¼è¾ |
| | | edit$Modulelogo$(para).then((res) => { |
| | | if (util.isEmt.format(res)) { |
| | | this.addLoading = false; |
| | | return; |
| | | } |
| | | if (res.data.success) { |
| | | this.addLoading = false; |
| | | //NProgress.done(); |
| | | this.$message({ |
| | | message: res.data.msg, |
| | | type: 'success' |
| | | }); |
| | | this.$refs['addForm'].resetFields(); |
| | | this.addFormVisible = false; |
| | | this._get$Modulelogo$s(); |
| | | } |
| | | else { |
| | | this.addLoading = false; |
| | | this.$message({ |
| | | message: res.data.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }, |
| | | selsChange: function (sels) { |
| | | this.sels = sels; |
| | | }, |
| | | //å¯¼åº |
| | | handleExport () { |
| | | this.export_currentPageData = this.$Modulelogo$s |
| | | this.$refs.cmToolbarExport.showPrintPage() |
| | | }, |
| | | //导å
¥ |
| | | handleImport () { |
| | | this.$refs.tbImportExcel.showPage() |
| | | }, |
| | | /******************************************[æ¥ççé¢]å¼å§*********************************************************** */ |
| | | //æ¾ç¤ºæ¥ççé¢ |
| | | handleView (selRow) { |
| | | let row = {}; |
| | | if (selRow && selRow != undefined) { |
| | | this.currentRow = selRow; |
| | | } |
| | | row = this.currentRow; |
| | | if (!row) { |
| | | this.$message({ |
| | | message: "è¯·éæ©è¦æ¥ççä¸è¡æ°æ®ï¼", |
| | | type: "warning" |
| | | }); |
| | | return; |
| | | } |
| | | this.viewDetailVisible = true |
| | | this.viewDetailForm = { |
| | | }; |
| | | this.viewDetailForm = Object.assign({}, row); |
| | | }, |
| | | //å
³éæ¥ççé¢ |
| | | closeViewHandle () { |
| | | this.viewDetailVisible = false |
| | | }, |
| | | /******************************************[æ¥ççé¢]ç»æ*********************************************************** */ |
| | | //addFormèµåå§å¼ |
| | | setInitAddForm () { |
| | | this.addForm = Object.assign({}, this.init_addForm) |
| | | } |
| | | }, |
| | | mounted () { |
| | | if (isMobile()) { |
| | | this.h_drawerSize = "99%"//drawner宽度设置 |
| | | } else { |
| | | this.h_drawerSize = "600px"//drawner宽度设置 |
| | | } |
| | | this.setInitAddForm() |
| | | this._get$Modulelogo$s(); |
| | | |
| | | let routers = window.localStorage.router |
| | | ? JSON.parse(window.localStorage.router) |
| | | : []; |
| | | this.buttonList = getButtonList(this.$route.path, routers); |
| | | let isShow = isNeedShowOperatorColumn(this.buttonList);//æ§å¶æ¯å¦è¦æ¾ç¤ºãæä½ãå |
| | | this.isShowOperatorColumn = isShow; |
| | | } |
| | | } |
| | | |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | </style> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | // é
ç½®$ChinaComment$æ¹æ³ |
| | | //å页è·å$ChinaComment$å表 |
| | | export const get$Modulelogo$ListPage = params => { |
| | | return axios.post(`${base}/api/$EntityName$/get`, params); |
| | | }; |
| | | //å é¤$ChinaComment$ |
| | | export const remove$Modulelogo$ = params => { |
| | | return axios.delete(`${base}/api/$EntityName$/delete`, { params: params }); |
| | | }; |
| | | //ç¼è¾$ChinaComment$ |
| | | export const edit$Modulelogo$ = params => { |
| | | return axios.put(`${base}/api/$EntityName$/put`, params); |
| | | }; |
| | | //æ·»å $ChinaComment$ |
| | | export const add$Modulelogo$ = params => { |
| | | return axios.post(`${base}/api/$EntityName$/post`, params); |
| | | }; |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Linq; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// å
Œ
±ç±» |
| | | /// </summary> |
| | | public class CommonHelper |
| | | { |
| | | |
| | | |
| | | /// <summary> |
| | | /// é¦åæ¯å°å |
| | | /// </summary> |
| | | /// <param name="str"></param> |
| | | /// <returns></returns> |
| | | public static string FirstLowercase(string str) |
| | | { |
| | | if (string.IsNullOrEmpty(str)) |
| | | { |
| | | return str; |
| | | } |
| | | str = str.Substring(0, 1).ToLower() + str.Substring(1); |
| | | return str; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·ååå¨è¿ç¨å |
| | | /// </summary> |
| | | /// <param name="moduleName"></param> |
| | | /// <returns></returns> |
| | | public static ProcName GetProcName(string moduleName) |
| | | { |
| | | string procPrefix = "uspWip_"; |
| | | ProcName procName = new ProcName() |
| | | { |
| | | AddProc = procPrefix + "Add" + moduleName, |
| | | UpdateProc = procPrefix + "Update" + moduleName, |
| | | GetSingleProc = procPrefix + "GetSingle" + moduleName, |
| | | ListProc = procPrefix + "Get" + moduleName + "List", |
| | | PageListProc = procPrefix + "Get" + moduleName + "PageList", |
| | | }; |
| | | return procName; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å车符 |
| | | /// </summary> |
| | | public const string enterStr = "\n"; |
| | | |
| | | /// <summary> |
| | | /// å个å车符çå符串 |
| | | /// </summary> |
| | | /// <param name="content"></param> |
| | | /// <returns></returns> |
| | | public static string GetSinleEnterStr(string content) |
| | | { |
| | | return content + enterStr; |
| | | } |
| | | /// <summary> |
| | | /// 两个å车符çå符串 |
| | | /// </summary> |
| | | /// <param name="content"></param> |
| | | /// <returns></returns> |
| | | public static string GetDoubleEnterStr(string content) |
| | | { |
| | | return content + enterStr + enterStr; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å½åæ¶é´å符串 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static string GetCurDate() |
| | | { |
| | | return DateTime.Now.Year + "-" + DateTime.Now.Month + "-" + DateTime.Now.Day |
| | | + " " |
| | | + DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// é¦åæ¯å¤§å |
| | | /// </summary> |
| | | /// <param name="str"></param> |
| | | /// <returns></returns> |
| | | public static string TitleToUpper(string str) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(str)) |
| | | return string.Empty; |
| | | |
| | | char[] s = str.ToCharArray(); |
| | | char c = s[0]; |
| | | |
| | | if ('a' <= c && c <= 'z') |
| | | c = (char)(c & ~0x20); |
| | | |
| | | s[0] = c; |
| | | |
| | | return new string(s); |
| | | } |
| | | /// <summary> |
| | | /// é¦åæ¯å°å |
| | | /// </summary> |
| | | /// <param name="str"></param> |
| | | /// <returns></returns> |
| | | public static string TitleToLower(string str) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(str)) |
| | | return string.Empty; |
| | | |
| | | char[] s = str.ToCharArray(); |
| | | char c = s[0]; |
| | | |
| | | if ('A' <= c && c <= 'Z') |
| | | c = char.ToLower(c); |
| | | |
| | | |
| | | s[0] = c; |
| | | |
| | | return new string(s); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæ°æ®åºè¿æ¥å符串å表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<ListItem> GetDataSources() |
| | | { |
| | | List<ListItem> list = new List<ListItem>(); |
| | | ConnectionStringSettingsCollection conn = ConfigurationManager.ConnectionStrings; |
| | | foreach (ConnectionStringSettings item in conn) |
| | | { |
| | | if (item.Name == "LocalSqlServer") |
| | | continue; |
| | | ListItem listItem = new ListItem() |
| | | { |
| | | Text = item.Name, |
| | | Value = item.ConnectionString |
| | | }; |
| | | list.Add(listItem); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæ°æ®åºç±»åå表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public static List<ListItem> GetDataBase() |
| | | { |
| | | List<ListItem> list = new List<ListItem>(); |
| | | |
| | | |
| | | ListItem listItem = new ListItem() |
| | | { |
| | | Text = DataBaseEnum.MySql.ToString(), |
| | | Value = DataBaseEnum.MySql.ToString() |
| | | }; |
| | | list.Add(listItem); |
| | | listItem = new ListItem() |
| | | { |
| | | Text = DataBaseEnum.SqlServer.ToString(), |
| | | Value = DataBaseEnum.SqlServer.ToString() |
| | | }; |
| | | list.Add(listItem); |
| | | |
| | | return list; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æä»¶ç±»å |
| | | /// </summary> |
| | | public enum FileType |
| | | { |
| | | /// <summary> |
| | | /// å®ä½ç±»æä»¶ |
| | | /// </summary> |
| | | Model = 0, |
| | | /// <summary> |
| | | /// DAOæä»¶ |
| | | /// </summary> |
| | | DAO = 1, |
| | | /// <summary> |
| | | /// IBLLæä»¶ |
| | | /// </summary> |
| | | IBLL = 2, |
| | | /// <summary> |
| | | /// BLLæä»¶ |
| | | /// </summary> |
| | | BLL = 3, |
| | | /// <summary> |
| | | /// Controlleræä»¶ |
| | | /// </summary> |
| | | Controller = 4, |
| | | /// <summary> |
| | | /// JSæä»¶ |
| | | /// </summary> |
| | | JS = 5, |
| | | /// <summary> |
| | | /// åè¡¨é¡µé¢ |
| | | /// </summary> |
| | | CSHTML_List = 6, |
| | | /// <summary> |
| | | /// XMLæä»¶ |
| | | /// </summary> |
| | | XML = 7, |
| | | /// <summary> |
| | | /// 详æ
é¡µé¢ |
| | | /// </summary> |
| | | CSHTML_Detail = 8, |
| | | /// <summary> |
| | | /// åå¨è¿ç¨æä»¶ |
| | | /// </summary> |
| | | Proc = 9, |
| | | /// <summary> |
| | | /// DAL æä»¶ |
| | | /// </summary> |
| | | DAL = 10, |
| | | /// <summary> |
| | | /// InputModel |
| | | /// </summary> |
| | | InputModel = 11, |
| | | /// <summary> |
| | | /// WCFæ¥å£æä»¶ |
| | | /// </summary> |
| | | WCF_InterFace = 12, |
| | | /// <summary> |
| | | /// WCFæ¥å£å®ç°æä»¶ |
| | | /// </summary> |
| | | WCF_InterFaceRealize = 13, |
| | | /// <summary> |
| | | /// InsertSQL |
| | | /// </summary> |
| | | SQL_Insert = 14, |
| | | /// <summary> |
| | | /// VUEæ¹æ³é
ç½® |
| | | /// </summary> |
| | | VUE_FunConfig = 15, |
| | | /// <summary> |
| | | /// VUEæä»¶ |
| | | /// </summary> |
| | | VUEFile = 16, |
| | | /// <summary> |
| | | /// æ°å¢å®ä½åæ°ç±» |
| | | /// </summary> |
| | | AddModelParam = 17, |
| | | |
| | | /// <summary> |
| | | /// OutputModel |
| | | /// </summary> |
| | | OutputModel = 18, |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using GenerateCode_GEBrilliantFactory.Model; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | public class ListHelper |
| | | { |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(廿 creatoråcreateTime) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> RemoveCreator(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | {//éè¦å»æ å建人åå建æ¶é´ |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper()) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(ç§»é¤å
¨é¨) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> RemoveAll(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | {//éè¦å»æ å建人åå建æ¶é´ |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifier.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifyTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_delFlag.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() |
| | | ) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(CreatedTimeãUpdatedTimeãCreatedUserIdãCreatedUserNameãUpdatedUserIdãUpdatedUserName) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> RemoveCreatedTimeUpdatedTimeCreatedUserIdCreatedUserNameUpdatedUserIdUpdatedUserName(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | {//éè¦å»æ å建人åå建æ¶é´ |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_CreateId.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyId.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifier.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifyTime.ToUpper() |
| | | ) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(廿 delFlagãcreatorãcreateTimeãlastModifierãlastModifyTime) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> RemoveDelFlagCreatorModifier(List<ColumnModel> columnNameList) |
| | | { |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifier.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifyTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_delFlag.ToUpper() |
| | | ) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(廿 Idï¼OperationRemarkãCreateIdï¼ModifyId) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> RemoveIdOperationRemarkCreateIdModifyId(List<ColumnModel> columnNameList) |
| | | { |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == "OperationRemark".ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_CreateId.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyId.ToUpper() |
| | | ) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(廿 Idï¼CreateIdï¼ModifyId) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> RemoveIdCreateIdModifyId(List<ColumnModel> columnNameList) |
| | | { |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_CreateId.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyId.ToUpper() |
| | | ) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(廿 Idï¼CreateIdï¼ModifyId,DelFlag) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> RemoveIdCreateIdModifyIdDelFlag(List<ColumnModel> columnNameList) |
| | | { |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_CreateId.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyId.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_delFlag.ToUpper() |
| | | ) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(åªä¿ç å符串类åçåæ®µ) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> OnlyStringProValue(List<ColumnModel> columnNameList) |
| | | { |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | //è·åæ°æ®ç±»å |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | newList.Add(columnModel); |
| | | break; |
| | | } |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(廿 idãcreatorãcreateTimeãlastModifierãlastModifyTime) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> RemoveIdCreatorModifier(List<ColumnModel> columnNameList) |
| | | { |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_creator.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_createTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifier.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_lastModifyTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_ModifyTime.ToUpper() |
| | | || columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper() |
| | | ) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åææ°çåListéå(廿 ID) |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> OnlyRemoveId(List<ColumnModel> columnNameList) |
| | | { |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.ColumnName.ToUpper() == SystemCommonVar.c_Id.ToUpper()) |
| | | { |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | return newList; |
| | | } |
| | | |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //=============================================================================== |
| | | // This file is based on the Microsoft Data Access Application Block for .NET |
| | | // For more information please go to |
| | | // http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp |
| | | //=============================================================================== |
| | | |
| | | using System; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using MySqlConnector; |
| | | using System.Collections; |
| | | |
| | | /// <summary> |
| | | /// The MySqlHelper class is intended to encapsulate high performance, |
| | | /// scalable best practices for common uses of MySqlConnector. |
| | | /// </summary> |
| | | public abstract class MySqlHelper |
| | | { |
| | | //Database connection strings |
| | | public static readonly string ConnectionString = ""; |
| | | |
| | | // Hashtable to store cached parameters |
| | | private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable()); |
| | | |
| | | /// <summary> |
| | | /// Execute a MySqlCommand (that returns no resultset) against the database specified in the connection string |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="connectionString">a valid connection string for a MySqlConnection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> |
| | | /// <returns>an int representing the number of rows affected by the command</returns> |
| | | public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) |
| | | { |
| | | MySqlCommand cmd = new MySqlCommand(); |
| | | |
| | | using (MySqlConnection conn = new MySqlConnection(connectionString)) |
| | | { |
| | | PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); |
| | | int val = cmd.ExecuteNonQuery(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a MySqlCommand (that returns no resultset) against an existing database connection |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="conn">an existing database connection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> |
| | | /// <returns>an int representing the number of rows affected by the command</returns> |
| | | public static int ExecuteNonQuery(MySqlConnection connection, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) |
| | | { |
| | | MySqlCommand cmd = new MySqlCommand(); |
| | | |
| | | PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); |
| | | int val = cmd.ExecuteNonQuery(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a MySqlCommand (that returns no resultset) using an existing SQL Transaction |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="trans">an existing sql transaction</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> |
| | | /// <returns>an int representing the number of rows affected by the command</returns> |
| | | public static int ExecuteNonQuery(MySqlTransaction trans, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) |
| | | { |
| | | MySqlCommand cmd = new MySqlCommand(); |
| | | PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters); |
| | | int val = cmd.ExecuteNonQuery(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a MySqlCommand that returns a resultset against the database specified in the connection string |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// MySqlDataReader r = ExecuteReader(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="connectionString">a valid connection string for a MySqlConnection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> |
| | | /// <returns>A MySqlDataReader containing the results</returns> |
| | | public static MySqlDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) |
| | | { |
| | | MySqlCommand cmd = new MySqlCommand(); |
| | | MySqlConnection conn = new MySqlConnection(connectionString); |
| | | |
| | | // we use a try/catch here because if the method throws an exception we want to |
| | | // close the connection throw code, because no datareader will exist, hence the |
| | | // commandBehaviour.CloseConnection will not work |
| | | try |
| | | { |
| | | PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); |
| | | MySqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); |
| | | cmd.Parameters.Clear(); |
| | | return rdr; |
| | | } |
| | | catch |
| | | { |
| | | conn.Close(); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ§è¡æ¥è¯¢è¯å¥ï¼è¿åDataSet |
| | | /// </summary> |
| | | /// <param name="SQLString">æ¥è¯¢è¯å¥</param> |
| | | /// <returns>DataSet</returns> |
| | | public static DataSet Query(string connectionString, string SQLString) |
| | | { |
| | | using (MySqlConnection connection = new MySqlConnection(connectionString)) |
| | | { |
| | | DataSet ds = new DataSet(); |
| | | try |
| | | { |
| | | connection.Open(); |
| | | MySqlDataAdapter command = new MySqlDataAdapter(SQLString, connection); |
| | | command.Fill(ds, "ds"); |
| | | } |
| | | catch (MySqlException ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | return ds; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a MySqlCommand that returns the first column of the first record against the database specified in the connection string |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="connectionString">a valid connection string for a MySqlConnection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> |
| | | /// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns> |
| | | public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) |
| | | { |
| | | MySqlCommand cmd = new MySqlCommand(); |
| | | |
| | | using (MySqlConnection connection = new MySqlConnection(connectionString)) |
| | | { |
| | | PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); |
| | | object val = cmd.ExecuteScalar(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a MySqlCommand that returns the first column of the first record against an existing database connection |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new MySqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="conn">an existing database connection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of MySqlParamters used to execute the command</param> |
| | | /// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns> |
| | | public static object ExecuteScalar(MySqlConnection connection, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters) |
| | | { |
| | | MySqlCommand cmd = new MySqlCommand(); |
| | | |
| | | PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); |
| | | object val = cmd.ExecuteScalar(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// add parameter array to the cache |
| | | /// </summary> |
| | | /// <param name="cacheKey">Key to the parameter cache</param> |
| | | /// <param name="cmdParms">an array of MySqlParamters to be cached</param> |
| | | public static void CacheParameters(string cacheKey, params MySqlParameter[] commandParameters) |
| | | { |
| | | parmCache[cacheKey] = commandParameters; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Retrieve cached parameters |
| | | /// </summary> |
| | | /// <param name="cacheKey">key used to lookup parameters</param> |
| | | /// <returns>Cached MySqlParamters array</returns> |
| | | public static MySqlParameter[] GetCachedParameters(string cacheKey) |
| | | { |
| | | MySqlParameter[] cachedParms = (MySqlParameter[])parmCache[cacheKey]; |
| | | |
| | | if (cachedParms == null) |
| | | return null; |
| | | |
| | | MySqlParameter[] clonedParms = new MySqlParameter[cachedParms.Length]; |
| | | |
| | | for (int i = 0, j = cachedParms.Length; i < j; i++) |
| | | clonedParms[i] = (MySqlParameter)((ICloneable)cachedParms[i]).Clone(); |
| | | |
| | | return clonedParms; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Prepare a command for execution |
| | | /// </summary> |
| | | /// <param name="cmd">MySqlCommand object</param> |
| | | /// <param name="conn">MySqlConnection object</param> |
| | | /// <param name="trans">MySqlTransaction object</param> |
| | | /// <param name="cmdType">Cmd type e.g. stored procedure or text</param> |
| | | /// <param name="cmdText">Command text, e.g. Select * from Products</param> |
| | | /// <param name="cmdParms">MySqlParameters to use in the command</param> |
| | | private static void PrepareCommand(MySqlCommand cmd, MySqlConnection conn, MySqlTransaction trans, CommandType cmdType, string cmdText, MySqlParameter[] cmdParms) |
| | | { |
| | | if (conn.State != ConnectionState.Open) |
| | | conn.Open(); |
| | | |
| | | cmd.Connection = conn; |
| | | cmd.CommandText = cmdText; |
| | | |
| | | if (trans != null) |
| | | cmd.Transaction = trans; |
| | | |
| | | cmd.CommandType = cmdType; |
| | | |
| | | if (cmdParms != null) |
| | | { |
| | | foreach (MySqlParameter parm in cmdParms) |
| | | cmd.Parameters.Add(parm); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | //=============================================================================== |
| | | // This file is based on the Microsoft Data Access Application Block for .NET |
| | | // For more information please go to |
| | | // http://msdn.microsoft.com/library/en-us/dnbda/html/daab-rm.asp |
| | | //=============================================================================== |
| | | |
| | | using System; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Data.Odbc; |
| | | using System.Collections; |
| | | |
| | | |
| | | /// <summary> |
| | | /// The SqlHelper class is intended to encapsulate high performance, |
| | | /// scalable best practices for common uses of SqlClient. |
| | | /// </summary> |
| | | public abstract class SqlHelper { |
| | | |
| | | //Database connection strings |
| | | public static readonly string ConnectionString = ""; |
| | | |
| | | // Hashtable to store cached parameters |
| | | private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable()); |
| | | |
| | | /// <summary> |
| | | /// Execute a SqlCommand (that returns no resultset) against the database specified in the connection string |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="connectionString">a valid connection string for a SqlConnection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> |
| | | /// <returns>an int representing the number of rows affected by the command</returns> |
| | | public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { |
| | | |
| | | SqlCommand cmd = new SqlCommand(); |
| | | |
| | | using (SqlConnection conn = new SqlConnection(connectionString)) { |
| | | PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); |
| | | int val = cmd.ExecuteNonQuery(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a SqlCommand (that returns no resultset) against an existing database connection |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="conn">an existing database connection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> |
| | | /// <returns>an int representing the number of rows affected by the command</returns> |
| | | public static int ExecuteNonQuery(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { |
| | | |
| | | SqlCommand cmd = new SqlCommand(); |
| | | |
| | | PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); |
| | | int val = cmd.ExecuteNonQuery(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a SqlCommand (that returns no resultset) using an existing SQL Transaction |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="trans">an existing sql transaction</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> |
| | | /// <returns>an int representing the number of rows affected by the command</returns> |
| | | public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { |
| | | SqlCommand cmd = new SqlCommand(); |
| | | PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters); |
| | | int val = cmd.ExecuteNonQuery(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a SqlCommand that returns a resultset against the database specified in the connection string |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// SqlDataReader r = ExecuteReader(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="connectionString">a valid connection string for a SqlConnection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> |
| | | /// <returns>A SqlDataReader containing the results</returns> |
| | | public static SqlDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { |
| | | SqlCommand cmd = new SqlCommand(); |
| | | SqlConnection conn = new SqlConnection(connectionString); |
| | | |
| | | // we use a try/catch here because if the method throws an exception we want to |
| | | // close the connection throw code, because no datareader will exist, hence the |
| | | // commandBehaviour.CloseConnection will not work |
| | | try { |
| | | PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); |
| | | SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection); |
| | | cmd.Parameters.Clear(); |
| | | return rdr; |
| | | } |
| | | catch { |
| | | conn.Close(); |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ§è¡æ¥è¯¢è¯å¥ï¼è¿åDataSet |
| | | /// </summary> |
| | | /// <param name="SQLString">æ¥è¯¢è¯å¥</param> |
| | | /// <returns>DataSet</returns> |
| | | public static DataSet Query(string connectionString, string SQLString) |
| | | { |
| | | using (SqlConnection connection = new SqlConnection(connectionString)) |
| | | { |
| | | DataSet ds = new DataSet(); |
| | | try |
| | | { |
| | | connection.Open(); |
| | | SqlDataAdapter command = new SqlDataAdapter(SQLString, connection); |
| | | command.Fill(ds, "ds"); |
| | | } |
| | | catch (System.Data.SqlClient.SqlException ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | return ds; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a SqlCommand that returns the first column of the first record against the database specified in the connection string |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="connectionString">a valid connection string for a SqlConnection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> |
| | | /// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns> |
| | | public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { |
| | | SqlCommand cmd = new SqlCommand(); |
| | | |
| | | using (SqlConnection connection = new SqlConnection(connectionString)) { |
| | | PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); |
| | | object val = cmd.ExecuteScalar(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Execute a SqlCommand that returns the first column of the first record against an existing database connection |
| | | /// using the provided parameters. |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// e.g.: |
| | | /// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24)); |
| | | /// </remarks> |
| | | /// <param name="conn">an existing database connection</param> |
| | | /// <param name="commandType">the CommandType (stored procedure, text, etc.)</param> |
| | | /// <param name="commandText">the stored procedure name or T-SQL command</param> |
| | | /// <param name="commandParameters">an array of SqlParamters used to execute the command</param> |
| | | /// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns> |
| | | public static object ExecuteScalar(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters) { |
| | | |
| | | SqlCommand cmd = new SqlCommand(); |
| | | |
| | | PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters); |
| | | object val = cmd.ExecuteScalar(); |
| | | cmd.Parameters.Clear(); |
| | | return val; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// add parameter array to the cache |
| | | /// </summary> |
| | | /// <param name="cacheKey">Key to the parameter cache</param> |
| | | /// <param name="cmdParms">an array of SqlParamters to be cached</param> |
| | | public static void CacheParameters(string cacheKey, params SqlParameter[] commandParameters) { |
| | | parmCache[cacheKey] = commandParameters; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Retrieve cached parameters |
| | | /// </summary> |
| | | /// <param name="cacheKey">key used to lookup parameters</param> |
| | | /// <returns>Cached SqlParamters array</returns> |
| | | public static SqlParameter[] GetCachedParameters(string cacheKey) { |
| | | SqlParameter[] cachedParms = (SqlParameter[])parmCache[cacheKey]; |
| | | |
| | | if (cachedParms == null) |
| | | return null; |
| | | |
| | | SqlParameter[] clonedParms = new SqlParameter[cachedParms.Length]; |
| | | |
| | | for (int i = 0, j = cachedParms.Length; i < j; i++) |
| | | clonedParms[i] = (SqlParameter)((ICloneable)cachedParms[i]).Clone(); |
| | | |
| | | return clonedParms; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Prepare a command for execution |
| | | /// </summary> |
| | | /// <param name="cmd">SqlCommand object</param> |
| | | /// <param name="conn">SqlConnection object</param> |
| | | /// <param name="trans">SqlTransaction object</param> |
| | | /// <param name="cmdType">Cmd type e.g. stored procedure or text</param> |
| | | /// <param name="cmdText">Command text, e.g. Select * from Products</param> |
| | | /// <param name="cmdParms">SqlParameters to use in the command</param> |
| | | private static void PrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[] cmdParms) { |
| | | |
| | | if (conn.State != ConnectionState.Open) |
| | | conn.Open(); |
| | | |
| | | cmd.Connection = conn; |
| | | cmd.CommandText = cmdText; |
| | | |
| | | if (trans != null) |
| | | cmd.Transaction = trans; |
| | | |
| | | cmd.CommandType = cmdType; |
| | | |
| | | if (cmdParms != null) { |
| | | foreach (SqlParameter parm in cmdParms) |
| | | cmd.Parameters.Add(parm); |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Configuration; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Text; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | /// <summary> |
| | | /// æé å符串帮å©ç±» |
| | | /// </summary> |
| | | public class StructStrHelper |
| | | { |
| | | /// <summary> |
| | | /// æ ¹æ®è¡¨åè·ååéå |
| | | /// </summary> |
| | | /// <param name="tableName"></param> |
| | | /// <returns></returns> |
| | | public static List<ColumnModel> GetColumnList(string tableName, string connStr) |
| | | { |
| | | string strSql = @" select |
| | | col.name as ColumnName, |
| | | t.name as DataType, |
| | | ep.value as Description, |
| | | col.max_length as DataLength, |
| | | col.is_nullable as IsNullable, |
| | | |
| | | ( |
| | | select top 1 ind.is_primary_key from sys.index_columns ic |
| | | left join sys.indexes ind |
| | | on ic.object_id=ind.object_id |
| | | and ic.index_id=ind.index_id |
| | | and ind.name like 'PK_%' |
| | | where ic.object_id=obj.object_id |
| | | and ic.column_id=col.column_id |
| | | ) as IsPrimaryKey, |
| | | col.Precision, |
| | | col.Scale |
| | | from sys.objects obj |
| | | inner join sys.columns col |
| | | on obj.object_id=col.object_id |
| | | left join sys.types t |
| | | on t.user_type_id=col.user_type_id |
| | | left join sys.extended_properties ep |
| | | on ep.major_id=obj.object_id |
| | | and ep.minor_id=col.column_id |
| | | and ep.name='MS_Description' |
| | | where obj.name='" + tableName + "' "; |
| | | |
| | | |
| | | List<ColumnModel> columnList = new List<ColumnModel>(); |
| | | try |
| | | { |
| | | DataSet ds = SqlHelper.Query(connStr, strSql); |
| | | columnList = DataTableToList(ds.Tables[0]); |
| | | } |
| | | catch |
| | | { |
| | | throw; |
| | | } |
| | | finally |
| | | { |
| | | } |
| | | return columnList; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·å¾æ°æ®å表 |
| | | /// </summary> |
| | | private static List<ColumnModel> DataTableToList(DataTable dt) |
| | | { |
| | | try |
| | | { |
| | | List<ColumnModel> modelList = new List<ColumnModel>(); |
| | | int rowsCount = dt.Rows.Count; |
| | | if (rowsCount > 0) |
| | | { |
| | | ColumnModel model; |
| | | for (int n = 0; n < rowsCount; n++) |
| | | { |
| | | model = new ColumnModel(); |
| | | if (dt.Rows[n]["Precision"].ToString() != "") |
| | | { |
| | | model.Precision = int.Parse(dt.Rows[n]["Precision"].ToString()); |
| | | } |
| | | if (dt.Rows[n]["Scale"].ToString() != "") |
| | | { |
| | | model.Scale = int.Parse(dt.Rows[n]["Scale"].ToString()); |
| | | } |
| | | model.ColumnName = dt.Rows[n]["ColumnName"].ToString(); |
| | | model.DataLength = dt.Rows[n]["DataLength"].ToString(); |
| | | model.DataType = dt.Rows[n]["DataType"].ToString(); |
| | | |
| | | if (model.DataType.ToUpper() == "nvarchar".ToUpper()) |
| | | { |
| | | if (model.DataLength != "-1") |
| | | { |
| | | model.DataLength = ((int)Convert.ToInt32(model.DataLength) / 2).ToString(); |
| | | } |
| | | } |
| | | |
| | | model.Description = dt.Rows[n]["Description"].ToString(); |
| | | if (dt.Rows[n]["IsNullable"].ToString() != "") |
| | | { |
| | | if ((dt.Rows[n]["IsNullable"].ToString() == "1") || (dt.Rows[n]["IsNullable"].ToString().ToLower() == "true")) |
| | | { |
| | | model.IsNullable = true; |
| | | } |
| | | else |
| | | { |
| | | model.IsNullable = false; |
| | | } |
| | | } |
| | | if (dt.Rows[n]["IsPrimaryKey"].ToString() != "") |
| | | { |
| | | if ((dt.Rows[n]["IsPrimaryKey"].ToString() == "1") || (dt.Rows[n]["IsPrimaryKey"].ToString().ToLower() == "true")) |
| | | { |
| | | model.IsPrimaryKey = true; |
| | | } |
| | | else |
| | | { |
| | | model.IsPrimaryKey = false; |
| | | } |
| | | } |
| | | |
| | | modelList.Add(model); |
| | | } |
| | | } |
| | | return modelList; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå±æ§å符串 |
| | | /// </summary> |
| | | /// <param name="columnModel"></param> |
| | | /// <returns></returns> |
| | | public static string GenerateAttribute(int index, ColumnModel columnModel, bool isShowExcelDataOptionAttribute = false) |
| | | { |
| | | try |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | string str_NullFlag = " "; |
| | | |
| | | //è·åæ°æ®ç±»å |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | string attrStr = ""; |
| | | |
| | | attrStr += " /// <summary>\n"; |
| | | attrStr += " /// " + columnModel.Description + "\n"; |
| | | attrStr += " /// </summary>\n"; |
| | | |
| | | if (isShowExcelDataOptionAttribute) |
| | | { |
| | | attrStr += " [ExcelDataOptionAttribute(DisplayName = \"" + columnModel.Description + "\", ColumnIndex = " + index + ")]\n"; |
| | | } |
| | | |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | attrStr += " public string" + str_NullFlag + attr + " { get; set; }\n"; |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public DateTime" + str_NullFlag + attr + " { get; set; }\n"; |
| | | break; |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public DateTimeOffset" + str_NullFlag + attr + " { get; set; }\n"; |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public int" + str_NullFlag + attr + " { get; set; }\n"; |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public long" + str_NullFlag + attr + " { get; set; }\n"; |
| | | break; |
| | | case DataTypeEnum.dt_decimal: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public decimal" + str_NullFlag + attr + " { get; set; }\n"; |
| | | break; |
| | | case DataTypeEnum.dt_float: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public float" + str_NullFlag + attr + " { get; set; }\n"; |
| | | break; |
| | | case DataTypeEnum.dt_bit: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public bool" + str_NullFlag + attr + " { get; set; }\n"; |
| | | break; |
| | | } |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | return attrStr; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå±æ§å符串ForAddModel-æ°å¢å®ä½ä¸ç¨ |
| | | /// </summary> |
| | | /// <param name="columnModel"></param> |
| | | /// <returns></returns> |
| | | public static string GenerateAttributeForAddModel(ColumnModel columnModel) |
| | | { |
| | | try |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | //if (attr.ToUpper() == "DBId".ToUpper()) |
| | | //{ |
| | | // var bb = ""; |
| | | //} |
| | | string str_NullFlag = " "; |
| | | |
| | | string attrStr = ""; |
| | | attrStr += " /// <summary>\n"; |
| | | attrStr += " /// " + columnModel.Description + "\n"; |
| | | attrStr += " /// </summary>\n"; |
| | | |
| | | DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); |
| | | switch (myDataType) |
| | | { |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | attrStr += " //è¡¨ç¤ºæ¯ é«çº§æ¥è¯¢èå´æ¥è¯¢ç¹æ§\n"; |
| | | attrStr += " [HighSearchRangeAttribute]\n"; |
| | | attrStr += " public List<string>" + str_NullFlag + attr + " { get; set; }\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public long" + str_NullFlag + attr + " { get; set; }\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | if (columnModel.IsNullable) { str_NullFlag = "? "; } |
| | | attrStr += " public int" + str_NullFlag + attr + " { get; set; }\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | default: |
| | | attrStr += " public string" + str_NullFlag + attr + " { get; set; }\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | } |
| | | |
| | | return attrStr; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå±æ§å符串ForQueryModel- æ¥è¯¢å®ä½ä¸ç¨ |
| | | /// </summary> |
| | | /// <param name="columnModel"></param> |
| | | /// <returns></returns> |
| | | public static string GenerateAttributeForQueryModel(ColumnModel columnModel) |
| | | { |
| | | try |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | //if (attr.ToUpper() == "DBId".ToUpper()) |
| | | //{ |
| | | // var bb = ""; |
| | | //} |
| | | //注æï¼æ¥è¯¢å®ä½å°±ä¸è½æç
§æ°æ®åºçå¯NULLéå¶äºï¼å 为æ¥è¯¢å
容鿶å¯ä»¥ä¸ºNULLå¦ |
| | | string str_NullFlag = " "; |
| | | str_NullFlag = "? "; |
| | | string emptyStr = " ";//ç©ºæ ¼ |
| | | |
| | | string attrStr = ""; |
| | | attrStr += " /// <summary>\n"; |
| | | attrStr += " /// " + columnModel.Description + "\n"; |
| | | attrStr += " /// </summary>\n"; |
| | | |
| | | DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); |
| | | switch (myDataType) |
| | | { |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | attrStr += " //è¡¨ç¤ºæ¯ é«çº§æ¥è¯¢èå´æ¥è¯¢ç¹æ§\n"; |
| | | attrStr += " [HighSearchRangeAttribute]\n"; |
| | | attrStr += " public List<string>" + emptyStr + attr + " { get; set; }\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | attrStr += " public long" + str_NullFlag + emptyStr + attr + " { get; set; }\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | attrStr += " public int" + str_NullFlag + emptyStr + attr + " { get; set; }\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | default: |
| | | attrStr += " public string" + emptyStr + attr + " { get; set; }\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | } |
| | | |
| | | return attrStr; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæå±æ§å符串ForQueryModel |
| | | /// </summary> |
| | | /// <param name="columnModel"></param> |
| | | /// <returns></returns> |
| | | public static string GenerateAttributeForQueryModelMode(ColumnModel columnModel) |
| | | { |
| | | try |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | string attrStr = ""; |
| | | attrStr += " /// <summary>\n"; |
| | | attrStr += " /// " + columnModel.Description + "-æ¥è¯¢å
³ç³»è¿ç®ç¬¦ \n"; |
| | | attrStr += " /// </summary>\n"; |
| | | |
| | | string highSearchModeSuffix = "_FilterMode"; |
| | | |
| | | DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); |
| | | switch (myDataType) |
| | | { |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | return "\n"; |
| | | case DataTypeEnum.dt_bigint: |
| | | case DataTypeEnum.dt_int: |
| | | attrStr += " public SearchFilterModeEnum " + attr + highSearchModeSuffix + " { get; set; }= SearchFilterModeEnum.ç²¾åæ¥è¯¢;\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | default: |
| | | attrStr += " public SearchFilterModeEnum " + attr + highSearchModeSuffix + " { get; set; }= SearchFilterModeEnum.æ¨¡ç³æ¥è¯¢;\n"; |
| | | attrStr += "\n";//æåæ¯å ä¸ä¸ªç©ºæ ¼ |
| | | break; |
| | | } |
| | | |
| | | return attrStr; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæ¥è¯¢åå符串 |
| | | /// </summary> |
| | | /// <param name="columnNameList">åéå</param> |
| | | /// <param name="tableAlias">表å«å</param> |
| | | /// <returns>åç¬¦ä¸²ï¼æ ¼å¼å¦ å1ï¼å2ï¼å3</returns> |
| | | public static string GetQueryColumnsStr(List<ColumnModel> columnNameList, string tableAlias = null) |
| | | { |
| | | StringBuilder selectSql = new StringBuilder(); |
| | | tableAlias = tableAlias == null ? "" : (tableAlias + "."); |
| | | ColumnModel columnModel = null; |
| | | string attrColumnName = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | attrColumnName = columnModel.ColumnName; |
| | | if (i == (columnNameList.Count - 1)) |
| | | selectSql.Append(" " + tableAlias + attrColumnName + "\n"); |
| | | else |
| | | selectSql.Append(" " + tableAlias + attrColumnName + ",\n"); |
| | | } |
| | | return selectSql.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·ååå符串(ä¸å
æ¬ID) ãæå
¥ç¨ã |
| | | /// </summary> |
| | | /// <param name="columnNameList">åéå</param> |
| | | /// <param name="prefix">@åç¼</param> |
| | | /// <returns>åç¬¦ä¸²ï¼æ ¼å¼å¦ å1ï¼å2ï¼å3</returns> |
| | | public static string GetColumnsStrNoIDForAdd(List<ColumnModel> columnNameList, string prefix) |
| | | { |
| | | StringBuilder selectSql = new StringBuilder(); |
| | | ColumnModel columnModel = null; |
| | | string description = ""; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | description = " -- " + columnModel.ColumnName + " " + columnModel.Description; |
| | | string attrColumnName = columnModel.ColumnName; |
| | | if (attrColumnName.ToUpper() == "ID") |
| | | continue; |
| | | if (i == (columnNameList.Count - 1)) |
| | | selectSql.Append(" " + prefix + attrColumnName + description + "\n"); |
| | | else |
| | | selectSql.Append(" " + prefix + attrColumnName + "," + description + "\n"); |
| | | } |
| | | return selectSql.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·ååå符串(ä¸å
æ¬ID) ãçæInsertSQLææ¬ä½¿ç¨ã |
| | | /// </summary> |
| | | /// <param name="columnNameList">åéå</param> |
| | | /// <returns>åç¬¦ä¸²ï¼æ ¼å¼å¦ å1ï¼å2ï¼å3</returns> |
| | | public static string GetColumnsStrNoIDForInsertSQL(List<ColumnModel> columnNameList) |
| | | { |
| | | StringBuilder selectSql = new StringBuilder(); |
| | | ColumnModel columnModel = null; |
| | | string description = ""; |
| | | string defaultValue = ""; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | description = " -- " + columnModel.ColumnName + " " + columnModel.Description; |
| | | string attrColumnName = columnModel.ColumnName; |
| | | if (attrColumnName.ToUpper() == "ID") |
| | | continue; |
| | | DataTypeEnum myDataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType); |
| | | switch (myDataType) |
| | | { |
| | | case DataTypeEnum.dt_bigint: |
| | | case DataTypeEnum.dt_int: |
| | | defaultValue = "0"; |
| | | break; |
| | | case DataTypeEnum.dt_decimal: |
| | | case DataTypeEnum.dt_float: |
| | | defaultValue = "0.00"; |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | defaultValue = "getdate()"; |
| | | break; |
| | | case DataTypeEnum.dt_bit: |
| | | defaultValue = "0"; |
| | | break; |
| | | default: |
| | | defaultValue = "''"; |
| | | break; |
| | | } |
| | | if (i == (columnNameList.Count - 1)) |
| | | selectSql.Append(" " + defaultValue + description + "\n"); |
| | | else |
| | | selectSql.Append(" " + defaultValue + "," + description + "\n"); |
| | | } |
| | | return selectSql.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åå¢å 使ç¨çåå¨è¿ç¨åæ°åå符串ï¼è¦æé¤idï¼ |
| | | /// </summary> |
| | | /// <param name="columnNameList">åéå</param> |
| | | /// <returns>å符串ï¼@processCardNumber nvarchar(50),@partNumber nvarchar(50), |
| | | ///</returns> |
| | | public static string GetInputParamColumnsStrForAdd(List<ColumnModel> columnNameList) |
| | | { |
| | | StringBuilder sql = new StringBuilder(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | string attrColumnName = columnModel.ColumnName; |
| | | if (attrColumnName.ToUpper() == "ID") |
| | | continue; |
| | | |
| | | var fuhao = ","; |
| | | if (i == columnNameList.Count - 1) |
| | | { |
| | | fuhao = ""; |
| | | } |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | var dataLength = columnModel.DataLength; |
| | | if (dataLength == "-1") |
| | | { |
| | | dataLength = "max"; |
| | | } |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType + "(" + dataLength + ") " + fuhao + "\n"); |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | case DataTypeEnum.dt_bit: |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType + " " + fuhao + "\n"); |
| | | break; |
| | | case DataTypeEnum.dt_decimal: |
| | | case DataTypeEnum.dt_float: |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType |
| | | + "(" + columnModel.Precision.ToString() + "," + columnModel.Scale.ToString() + ") " + fuhao + "\n"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | return sql.ToString(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åæ´æ°ä½¿ç¨çåå¨è¿ç¨åæ°åå符串ï¼è¦æé¤idï¼ |
| | | /// </summary> |
| | | /// <param name="columnNameList">åéå</param> |
| | | /// <returns>å符串ï¼@processCardNumber nvarchar(50),@partNumber nvarchar(50), |
| | | ///</returns> |
| | | public static string GetInputParamColumnsStrForUpdate(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | columnNameList = ListHelper.RemoveCreator(columnNameList); |
| | | |
| | | StringBuilder sql = new StringBuilder(); |
| | | ColumnModel columnModel = null; |
| | | string attrColumnName = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | attrColumnName = columnModel.ColumnName; |
| | | |
| | | var fuhao = ","; |
| | | if (i == columnNameList.Count - 1) |
| | | { |
| | | fuhao = ""; |
| | | } |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | var dataLength = columnModel.DataLength; |
| | | if (dataLength == "-1") |
| | | { |
| | | dataLength = "max"; |
| | | } |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType + "(" + dataLength + ") " + fuhao + "\n"); |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | case DataTypeEnum.dt_bit: |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType + " " + fuhao + "\n"); |
| | | break; |
| | | case DataTypeEnum.dt_decimal: |
| | | case DataTypeEnum.dt_float: |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType |
| | | + "(" + columnModel.Precision.ToString() + "," + columnModel.Scale.ToString() + ") " + fuhao + "\n"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | return sql.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åæ¥è¯¢å页使ç¨çåå¨è¿ç¨åæ°åå符串 |
| | | /// </summary> |
| | | /// <param name="columnNameList">åéå</param> |
| | | /// <returns>å符串ï¼@processCardNumber nvarchar(50),@partNumber nvarchar(50), |
| | | ///</returns> |
| | | public static string GetInputParamColumnsStrForQueryPage(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | columnNameList = ListHelper.RemoveAll(columnNameList); |
| | | |
| | | StringBuilder sql = new StringBuilder(); |
| | | ColumnModel columnModel = null; |
| | | string attrColumnName = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | attrColumnName = columnModel.ColumnName; |
| | | |
| | | var fuhao = "," + "\n"; |
| | | if (i == columnNameList.Count - 1) |
| | | { |
| | | fuhao = ","; |
| | | } |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | var dataLength = columnModel.DataLength; |
| | | if (dataLength == "-1") |
| | | { |
| | | dataLength = "max"; |
| | | } |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType + "(" + dataLength + ") " + fuhao); |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | case DataTypeEnum.dt_bit: |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType + " " + fuhao); |
| | | break; |
| | | case DataTypeEnum.dt_decimal: |
| | | case DataTypeEnum.dt_float: |
| | | sql.Append("@" + attrColumnName + " " + columnModel.DataType |
| | | + "(" + columnModel.Precision.ToString() + "," + columnModel.Scale.ToString() + ") " + fuhao); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | return sql.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæèµå¼sqlå符串ï¼ç¨äºä¿®æ¹ |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <param name="primaryKey"></param> |
| | | /// <returns></returns> |
| | | public static string GetCols_AssignmentStrForUpdate(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | columnNameList = ListHelper.RemoveCreator(columnNameList); |
| | | |
| | | StringBuilder sql = new StringBuilder(); |
| | | ColumnModel columnModel = null; |
| | | string attrColumnName = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | attrColumnName = columnModel.ColumnName; |
| | | if (columnModel.IsPrimaryKey) |
| | | continue; |
| | | |
| | | if (i == columnNameList.Count - 1) |
| | | { |
| | | sql.Append(attrColumnName + "=@" + attrColumnName + " \n"); |
| | | } |
| | | else |
| | | { |
| | | sql.Append(attrColumnName + "=@" + attrColumnName + ",\n"); |
| | | } |
| | | |
| | | } |
| | | return sql.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæèµå¼sqlå符串ï¼ç¨äºæ¥è¯¢å页 |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <param name="primaryKey"></param> |
| | | /// <returns></returns> |
| | | public static string GetCols_AssignmentStrForWherePage(string TableAlias, List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | columnNameList = ListHelper.RemoveAll(columnNameList); |
| | | |
| | | StringBuilder sql = new StringBuilder(); |
| | | ColumnModel columnModel = null; |
| | | string attrColumnName = null; |
| | | sql.Append(" 1=1 \n"); |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | attrColumnName = columnModel.ColumnName; |
| | | sql.Append(" AND ( @" + attrColumnName + " IS NULL OR @" + attrColumnName + "='' OR " + TableAlias + "." + attrColumnName + "=@" + attrColumnName + " ) \n"); |
| | | |
| | | |
| | | } |
| | | return sql.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæèµå¼sqlå符串ï¼ç¨äºä¿®æ¹ |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <param name="primaryKey"></param> |
| | | /// <returns></returns> |
| | | public static string GetCols_AssignmentStrForUpdate2(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | columnNameList = ListHelper.RemoveCreator(columnNameList); |
| | | |
| | | StringBuilder sql = new StringBuilder(); |
| | | ColumnModel columnModel = null; |
| | | string attrColumnName = null; |
| | | var updateSql = ""; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | attrColumnName = columnModel.ColumnName; |
| | | if (columnModel.IsPrimaryKey) |
| | | continue; |
| | | |
| | | if (attrColumnName.ToUpper() == "lastModifier".ToUpper() || attrColumnName.ToUpper() == "lastModifyTime".ToUpper()) |
| | | { |
| | | updateSql = " " + attrColumnName + "=@" + attrColumnName + " "; |
| | | } |
| | | else |
| | | { |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | updateSql = " " + attrColumnName + "= case ISNULL(@" + attrColumnName + ",'') when '' then " |
| | | + attrColumnName + " else @" + attrColumnName + " end "; |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_decimal: |
| | | case DataTypeEnum.dt_float: |
| | | updateSql = " " + attrColumnName + "= case ISNULL(@" + attrColumnName + ",0) when 0 then " |
| | | + attrColumnName + " else @" + attrColumnName + " end "; |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | case DataTypeEnum.dt_bit: |
| | | updateSql = " " + attrColumnName + "= case @" + attrColumnName + " when NULL then " + attrColumnName + " else @" + attrColumnName + " end "; |
| | | break; |
| | | default: |
| | | updateSql = " " + attrColumnName + "=@" + attrColumnName + " "; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | sql.Append(updateSql + ",\n"); |
| | | } |
| | | //æªåææåä¸ä¸ª ,\n |
| | | var strSql = sql.ToString().Substring(0, sql.ToString().Length - 2); |
| | | return strSql; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æé æ°å¢SQLçåæ°ForDALæä»¶ |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static string GetParameterForAddDAL(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | List<ColumnModel> newList = new List<ColumnModel>(); |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | if (columnModel.IsPrimaryKey) |
| | | {//æ°å¢çæ¶åï¼ä¸ç¨ä¸»é® |
| | | continue; |
| | | } |
| | | newList.Add(columnModel); |
| | | } |
| | | |
| | | StringBuilder paramSql = new StringBuilder(); |
| | | paramSql.Append("SqlParameter[] parameters = { " + "\n"); |
| | | for (int i = 0; i < newList.Count; i++) |
| | | { |
| | | paramSql.Append(GetSqlParameterStr(newList[i])); |
| | | } |
| | | paramSql.Append(" param_id \n"); |
| | | paramSql.Append(" };\n"); |
| | | |
| | | for (int i = 0; i < newList.Count; i++) |
| | | { |
| | | paramSql.Append(" parameters[" + i.ToString() + "].Value = model." + newList[i].ColumnName + ";\n"); |
| | | } |
| | | |
| | | return paramSql.ToString(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æé æ´æ°SQLçåæ°ForDALæä»¶ |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static string GetParameterForUpdateDAL(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | columnNameList = ListHelper.RemoveCreator(columnNameList); |
| | | |
| | | |
| | | StringBuilder paramSql = new StringBuilder(); |
| | | paramSql.Append("SqlParameter[] parameters = { " + "\n"); |
| | | string firstParam = "", secondParam = ""; |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | firstParam += GetSqlParameterStr(columnModel); |
| | | secondParam += " parameters[" + i.ToString() + "].Value = model." + columnModel.ColumnName + ";\n"; |
| | | } |
| | | paramSql.Append(firstParam); |
| | | paramSql.Append(" };\n"); |
| | | paramSql.Append(secondParam); |
| | | |
| | | return paramSql.ToString(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// æé æ¥è¯¢å页SQLçåæ°ForDALæä»¶ |
| | | /// </summary> |
| | | /// <param name="columnNameList"></param> |
| | | /// <returns></returns> |
| | | public static string GetParameterForQueryPageDAL(List<ColumnModel> columnNameList) |
| | | { |
| | | //æé æ°çList |
| | | columnNameList = ListHelper.RemoveAll(columnNameList); |
| | | |
| | | |
| | | StringBuilder paramSql = new StringBuilder(); |
| | | paramSql.Append("SqlParameter[] parameters = { " + "\n"); |
| | | string firstParam = "", secondParam = ""; |
| | | ColumnModel columnModel = null; |
| | | for (int i = 0; i < columnNameList.Count; i++) |
| | | { |
| | | columnModel = columnNameList[i]; |
| | | firstParam += GetSqlParameterStr(columnModel); |
| | | secondParam += " parameters[" + i.ToString() + "].Value = pageParam." + columnModel.ColumnName + ";\n"; |
| | | if (i == (columnNameList.Count - 1)) |
| | | { //å¢å å页忰 |
| | | firstParam += " new SqlParameter(\"@pageIndex\", SqlDbType.Int) , \n"; |
| | | firstParam += " new SqlParameter(\"@pageSize\", SqlDbType.Int) \n"; |
| | | secondParam += " parameters[" + (i + 1).ToString() + "].Value = pageParam.pageIndex;\n"; |
| | | secondParam += " parameters[" + (i + 2).ToString() + "].Value = pageParam.pageSize;\n"; |
| | | } |
| | | } |
| | | paramSql.Append(firstParam); |
| | | paramSql.Append(" };\n"); |
| | | paramSql.Append(secondParam); |
| | | |
| | | |
| | | |
| | | return paramSql.ToString(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private static string GetSqlParameterStr(ColumnModel columnModel) |
| | | { |
| | | string str = " new SqlParameter(\"@" + columnModel.ColumnName + "\","; |
| | | try |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | //è·åæ°æ®ç±»å |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | str += "SqlDbType.NChar," + columnModel.DataLength.ToString(); |
| | | break; |
| | | case DataTypeEnum.dt_varchar: |
| | | str += "SqlDbType.VarChar," + columnModel.DataLength.ToString(); |
| | | break; |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | str += "SqlDbType.NVarChar," + columnModel.DataLength.ToString(); |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | str += "SqlDbType.DateTime"; |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | str += "SqlDbType.Int," + columnModel.DataLength.ToString(); |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | str += "SqlDbType.BigInt," + columnModel.DataLength.ToString(); |
| | | break; |
| | | case DataTypeEnum.dt_decimal: |
| | | str += "SqlDbType.Decimal," + columnModel.DataLength.ToString(); |
| | | break; |
| | | case DataTypeEnum.dt_float: |
| | | str += "SqlDbType.Float," + columnModel.DataLength.ToString(); |
| | | break; |
| | | case DataTypeEnum.dt_bit: |
| | | str += "SqlDbType.Bit," + columnModel.DataLength.ToString(); |
| | | break; |
| | | } |
| | | str += "),\n";//æåæ¯å ä¸ä¸ªå车 |
| | | return str; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// çæèµå¼å®ä½ç±»çå符串 |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetToModelStr(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | foreach (var columnModel in columnModelList) |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | //è·åæ°æ®ç±»å |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | sb.Append("model." + columnModel.ColumnName.ToString() + "=dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString();\n"); |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); |
| | | sb.Append("{ \n"); |
| | | sb.Append(" model." + columnModel.ColumnName.ToString() + " = DateTime.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); |
| | | sb.Append("} \n"); |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); |
| | | sb.Append("{ \n"); |
| | | sb.Append(" model." + columnModel.ColumnName.ToString() + " = int.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); |
| | | sb.Append("} \n"); |
| | | break; |
| | | case DataTypeEnum.dt_bigint: |
| | | sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); |
| | | sb.Append("{ \n"); |
| | | sb.Append(" model." + columnModel.ColumnName.ToString() + " = long.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); |
| | | sb.Append("} \n"); |
| | | break; |
| | | case DataTypeEnum.dt_decimal: |
| | | sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); |
| | | sb.Append("{ \n"); |
| | | sb.Append(" model." + columnModel.ColumnName.ToString() + " = decimal.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); |
| | | sb.Append("} \n"); |
| | | break; |
| | | case DataTypeEnum.dt_float: |
| | | sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); |
| | | sb.Append("{ \n"); |
| | | sb.Append(" model." + columnModel.ColumnName.ToString() + " = float.Parse(dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString()); \n"); |
| | | sb.Append("} \n"); |
| | | break; |
| | | case DataTypeEnum.dt_bit: |
| | | sb.Append("if (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() != \"\") \n"); |
| | | sb.Append("{ \n"); |
| | | |
| | | sb.Append(" if ((dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString() == \"1\") || (dataRow[\"" + columnModel.ColumnName.ToString() + "\"].ToString().ToLower() == \"true\")) \n"); |
| | | sb.Append("{ \n"); |
| | | sb.Append(" model." + columnModel.ColumnName.ToString() + " = true; \n"); |
| | | sb.Append("} \n"); |
| | | sb.Append("else \n"); |
| | | sb.Append("{ \n"); |
| | | sb.Append(" model." + columnModel.ColumnName.ToString() + " = false; \n"); |
| | | sb.Append("} \n"); |
| | | |
| | | sb.Append("} \n"); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | return sb.ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | |
| | | #region WCFå± |
| | | |
| | | /// <summary> |
| | | /// çæéè¦éªè¯ä¸ä¸ºç©ºçå符串 |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <param name="isInsert">æ¯å¦æ¯æ°å¢</param> |
| | | /// <returns></returns> |
| | | public static string GetValidateEmptyStr(List<ColumnModel> columnModelList, bool isInsert = true) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = null; |
| | | if (isInsert) |
| | | {//æ°å¢ |
| | | newList = ListHelper.RemoveAll(columnModelList); |
| | | } |
| | | else |
| | | {//æ´æ° |
| | | newList = ListHelper.RemoveDelFlagCreatorModifier(columnModelList); |
| | | } |
| | | |
| | | sb.Append(" List<ColumnsModel> columnsList = new List<ColumnsModel>() { \n"); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | //è·åæ°æ®ç±»å |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | if (!columnModel.IsNullable) |
| | | { |
| | | sb.Append(" new ColumnsModel(){ ChinaName=\"" + columnModel.Description + "\",PropertyName=\"" + columnModel.ColumnName + "\" },\n"); |
| | | } |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | if (!columnModel.IsNullable) |
| | | {//æ¥æå¿
è¾ |
| | | sb.Append(" new ColumnsModel(){ ChinaName=\"" + columnModel.Description + "\",PropertyName=\"" + columnModel.ColumnName + "\",DataType=typeof(DateTime) },\n"); |
| | | } |
| | | else |
| | | {//æ¥æä¸å¿
è¾ |
| | | sb.Append(" new ColumnsModel(){ ChinaName=\"" + columnModel.Description + "\",PropertyName=\"" + columnModel.ColumnName + "\",DataType=typeof(DateTime),IsNullable=true },\n"); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | } |
| | | sb.Append(" };\n"); |
| | | return sb.ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®ä¸»é®ç±»åè·åéªè¯ä¸»é®çå符串 |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <param name="primaryKey"></param> |
| | | /// <returns></returns> |
| | | public static string GetValidateEmptyStrForPrimaryKey(List<ColumnModel> columnModelList, string primaryKey) |
| | | { |
| | | if (primaryKey.ToUpper() == "ID".ToUpper()) |
| | | { |
| | | return " model.id == 0 "; |
| | | } |
| | | foreach (var item in columnModelList) |
| | | { |
| | | if (item.ColumnName.ToUpper() == primaryKey.ToUpper()) |
| | | { |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + item.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | return " string.IsNullOrEmpty(model.$PrimaryKey$) "; |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_bigint: |
| | | return " model.$PrimaryKey$ == 0 "; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region Controllerå± |
| | | |
| | | #region Controllerå± |
| | | |
| | | /// <summary> |
| | | /// çæéè¦éªè¯ä¸ä¸ºç©ºçå符串 |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <param name="isInsert">æ¯å¦æ¯æ°å¢</param> |
| | | /// <returns></returns> |
| | | public static string GetValidateEmptyStrForController(List<ColumnModel> columnModelList, bool isInsert = true) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = null; |
| | | if (isInsert) |
| | | {//æ°å¢ |
| | | newList = ListHelper.RemoveAll(columnModelList); |
| | | } |
| | | else |
| | | {//æ´æ° |
| | | newList = ListHelper.RemoveDelFlagCreatorModifier(columnModelList); |
| | | } |
| | | var commonStr = string.Empty; |
| | | foreach (var columnModel in newList) |
| | | { |
| | | commonStr = " new ValidateModel(){ ChinaName=\"" + columnModel.Description + "\",PropertyName=\"" + columnModel.ColumnName + "\",DataValue=request." + columnModel.ColumnName; |
| | | string attr = columnModel.ColumnName; |
| | | //è·åæ°æ®ç±»å |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | if (!columnModel.IsNullable) |
| | | { |
| | | sb.Append(commonStr + " },\n"); |
| | | } |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | if (!columnModel.IsNullable) |
| | | {//æ°åå¿
è¾ |
| | | sb.Append(commonStr + ",DataType=typeof(int) },\n"); |
| | | } |
| | | else |
| | | {//æ°åä¸å¿
è¾ |
| | | sb.Append(commonStr + ",DataType=typeof(int),IsNullable=true },\n"); |
| | | } |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | if (!columnModel.IsNullable) |
| | | {//æ¥æå¿
è¾ |
| | | sb.Append(commonStr + ",DataType=typeof(DateTime) },\n"); |
| | | } |
| | | else |
| | | {//æ¥æä¸å¿
è¾ |
| | | sb.Append(commonStr + ",DataType=typeof(DateTime),IsNullable=true },\n"); |
| | | } |
| | | break; |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | if (!columnModel.IsNullable) |
| | | {//æ¥æå¿
è¾ |
| | | sb.Append(commonStr + ",DataType=typeof(DateTimeOffset) },\n"); |
| | | } |
| | | else |
| | | {//æ¥æä¸å¿
è¾ |
| | | sb.Append(commonStr + ",DataType=typeof(DateTimeOffset),IsNullable=true },\n"); |
| | | } |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | } |
| | | return sb.ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region VUEæä»¶ |
| | | |
| | | /// <summary> |
| | | /// è·åVUE el-table-column |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetElTableColumnStr(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = ListHelper.RemoveIdOperationRemarkCreateIdModifyId(columnModelList); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | sb.Append(" <el-table-column prop=\"" + columnModel.ColumnName + "\" label=\"" + columnModel.Description + "\" width=\"150\" align=\"center\" :formatter=\"formatterDateTime\" > \n"); |
| | | sb.Append(" </el-table-column> \n"); |
| | | break; |
| | | case DataTypeEnum.dt_bit: |
| | | sb.Append(" <el-table-column prop=\"" + columnModel.ColumnName + "\" label=\"" + columnModel.Description + "\" align=\"center\" > \n"); |
| | | sb.Append("<template slot-scope=\"scope\">"); |
| | | sb.Append("<el-tag :type=\"scope.row." + columnModel.ColumnName + " ? 'danger' : 'success'\""); |
| | | sb.Append("disable-transitions>{{scope.row." + columnModel.ColumnName + " ? \"æ¯\":\"å¦\"}}</el-tag>"); |
| | | sb.Append(" </template>"); |
| | | sb.Append(" </el-table-column> \n"); |
| | | break; |
| | | default: |
| | | sb.Append(" <el-table-column prop=\"" + columnModel.ColumnName + "\" label=\"" + columnModel.Description + "\" align=\"center\" > \n"); |
| | | sb.Append(" </el-table-column> \n"); |
| | | break; |
| | | } |
| | | } |
| | | return sb.ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åVUE el-form-item (æ°å¢/ç¼è¾çé¢) |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetElFormItemStrForAddEditForm(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = ListHelper.RemoveIdCreatorModifier(columnModelList); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | if (columnModel.IsNullable) |
| | | {//å¯ä»¥ä¸ºç©º |
| | | sb.Append(" <el-form-item label=\"" + columnModel.Description + "\" prop=\"" + columnModel.ColumnName + "\" > \n"); |
| | | } |
| | | else |
| | | { |
| | | sb.Append(" <el-form-item label=\"" + columnModel.Description + "\" prop=\"" + columnModel.ColumnName + "\" :rules=\"[{ required: true, message: '" + columnModel.Description + "ä¸è½ä¸ºç©º'}]\"> \n"); |
| | | } |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_bit: |
| | | sb.Append(" <el-switch v-model=\"addForm." + columnModel.ColumnName + "\"></el-switch> \n"); |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | sb.Append(" <el-date-picker placeholder=\"éæ©æ¥ææ¶é´\" type=\"datetime\" v-model=\"addForm." + columnModel.ColumnName + "\"></el-date-picker> \n"); |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_bigint: |
| | | case DataTypeEnum.dt_decimal: |
| | | case DataTypeEnum.dt_float: |
| | | sb.Append(" <el-input-number v-model=\"addForm." + columnModel.ColumnName + "\"></el-input-number> \n"); |
| | | break; |
| | | default: |
| | | sb.Append(" <el-input v-model=\"addForm." + columnModel.ColumnName + "\"></el-input> \n"); |
| | | break; |
| | | } |
| | | |
| | | sb.Append(" </el-form-item> \n"); |
| | | } |
| | | return sb.ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åVUE el-form-item (æ¥ççé¢) |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetElFormItemStrForViewForm(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = ListHelper.RemoveIdCreateIdModifyId(columnModelList); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | sb.Append(" <el-form-item label=\"" + columnModel.Description + "\" prop=\"" + columnModel.ColumnName + "\" > \n"); |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_bit: |
| | | sb.Append(" <el-switch v-model=\"viewDetailForm." + columnModel.ColumnName + "\"></el-switch> \n"); |
| | | break; |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | sb.Append(" <el-date-picker placeholder=\"éæ©æ¥ææ¶é´\" type=\"datetime\" v-model=\"viewDetailForm." + columnModel.ColumnName + "\"></el-date-picker> \n"); |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_bigint: |
| | | case DataTypeEnum.dt_decimal: |
| | | case DataTypeEnum.dt_float: |
| | | sb.Append(" <el-input-number v-model=\"viewDetailForm." + columnModel.ColumnName + "\"></el-input-number> \n"); |
| | | break; |
| | | default: |
| | | sb.Append(" <el-input v-model=\"viewDetailForm." + columnModel.ColumnName + "\"></el-input> \n"); |
| | | break; |
| | | } |
| | | |
| | | sb.Append(" </el-form-item> \n"); |
| | | } |
| | | return sb.ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åVUE formOptionså符串(é«çº§æ¥è¯¢ä¸ç) |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetVueFormOptionsStr(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | /* |
| | | { |
| | | label: '代ç ç¼ç ', |
| | | prop: 'code', |
| | | element: 'el-input' |
| | | }, |
| | | */ |
| | | List<ColumnModel> newList = ListHelper.RemoveIdOperationRemarkCreateIdModifyId(columnModelList); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | var elment = "el-input"; |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_datetime: |
| | | elment = "el-date-picker"; |
| | | break; |
| | | case DataTypeEnum.dt_bit: |
| | | elment = "el-select"; |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | sb.Append(" { \n"); |
| | | sb.Append(" label: '" + columnModel.Description + "', \n"); |
| | | sb.Append(" prop: '" + columnModel.ColumnName + "', \n"); |
| | | |
| | | //æ·»å ç±»å |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_datetime: |
| | | sb.Append(" type: 'datetimerange', \n"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | sb.Append(" element: '" + elment + "', \n"); |
| | | //æ·»å ç±»å |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_bit: |
| | | sb.Append(" options: [{label: 'æ¯',value: 'true'}, {label: 'å¦',value: 'false'}] \n"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | sb.Append(" }, \n"); |
| | | } |
| | | //廿æåä¸ä¸ª, |
| | | var res = sb.ToString(); |
| | | res = res.Substring(0, res.Length - 1); |
| | | return res; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åVUE å¯¼åºæ°ç»å符串-æ±å+屿§ |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetVueExportTHeaderArrayStr(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = ListHelper.RemoveIdOperationRemarkCreateIdModifyId(columnModelList); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | if (columnModel.IsPrimaryKey == false) |
| | | { |
| | | sb.Append("'" + columnModel.ColumnName + "':'" + columnModel.Description + "',"); |
| | | } |
| | | } |
| | | //廿æåä¸ä¸ª, |
| | | var res = sb.ToString(); |
| | | res = res.Substring(0, res.Length - 1); |
| | | return res; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è·åVUE æç´¢æ¡è¾å
¥çæç¤ºææ¬ |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetVueSearchFormInputPlaceholderStr(List<ColumnModel> columnModelList, ref string names) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = ListHelper.OnlyStringProValue(columnModelList); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | if (columnModel.IsPrimaryKey == false) |
| | | { |
| | | sb.Append("" + columnModel.Description + "/"); |
| | | names += "'" + columnModel.ColumnName + "',"; |
| | | } |
| | | } |
| | | //廿æåä¸ä¸ª, |
| | | var res = sb.ToString(); |
| | | res = res.Substring(0, res.Length - 1); |
| | | |
| | | names = names.Substring(0, names.Length - 1); |
| | | |
| | | return res; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// è·åVUE el-form-item æ¥è¯¢ç¨ |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetElFormItemForSearchStr(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = ListHelper.RemoveIdCreatorModifier(columnModelList); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | sb.Append(" <el-form-item label=\"" + columnModel.Description + "\"> \n"); |
| | | |
| | | //è·åæ°æ®ç±»å |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | sb.Append("<el-input v-model=\"serachObj." + columnModel.ColumnName + "\" placeholder=\"请è¾å
¥" + columnModel.Description + "\"></el-input> \n"); |
| | | break; |
| | | case DataTypeEnum.dt_bit: |
| | | sb.Append("<el-checkbox-group v-model=\"ck_delflag\" @change=\"ckDelFlag\">\n"); |
| | | sb.Append(" <el-checkbox-button label=\"å¯ç¨\" name=\"ck_delflag\"></el-checkbox-button>\n"); |
| | | sb.Append(" <el-checkbox-button label=\"ç¦ç¨\" name=\"ck_delflag\"></el-checkbox-button>\n"); |
| | | sb.Append("</el-checkbox-group> \n"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | |
| | | |
| | | sb.Append(" </el-form-item> \n"); |
| | | } |
| | | return sb.ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region Controller |
| | | |
| | | /// <summary> |
| | | /// è·åå页çéå符串 |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetPageFilterStrForController(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | string mohuFilter = "&& (";//æ¨¡ç³æ¥è¯¢ |
| | | string filter = "";//鿍¡ç³æ¥è¯¢ |
| | | List<ColumnModel> newList = ListHelper.RemoveIdCreatorModifier(columnModelList); |
| | | |
| | | foreach (var columnModel in newList) |
| | | { |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_bit: |
| | | case DataTypeEnum.dt_datetime: |
| | | case DataTypeEnum.dt_datetime2: |
| | | case DataTypeEnum.dt_datetimeoffset: |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_decimal: |
| | | case DataTypeEnum.dt_float: |
| | | break; |
| | | default: |
| | | if (columnModel.IsPrimaryKey == false) |
| | | { |
| | | mohuFilter += "(a." + columnModel.ColumnName + " != null && a." + columnModel.ColumnName + ".Contains(param.searchVal))"; |
| | | mohuFilter += " ||"; |
| | | |
| | | filter += "&& (string.IsNullOrEmpty(param." + columnModel.ColumnName + ") || param." + columnModel.ColumnName + " == a." + columnModel.ColumnName + ") \n"; |
| | | } |
| | | else |
| | | { |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | mohuFilter += "1==1)"; |
| | | filter += ";"; |
| | | return mohuFilter + filter; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// çæWhereæ¥è¯¢æ¡ä»¶çå符串 |
| | | /// </summary> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static string GetStrForWhereQuery(List<ColumnModel> columnModelList) |
| | | { |
| | | StringBuilder sb = new StringBuilder(); |
| | | try |
| | | { |
| | | List<ColumnModel> newList = ListHelper.RemoveIdCreatorModifier(columnModelList); |
| | | foreach (var columnModel in newList) |
| | | { |
| | | string attr = columnModel.ColumnName; |
| | | //è·åæ°æ®ç±»å |
| | | DataTypeEnum enumDT = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), "dt_" + columnModel.DataType.ToString()); |
| | | switch (enumDT) |
| | | { |
| | | case DataTypeEnum.dt_char: |
| | | case DataTypeEnum.dt_varchar: |
| | | case DataTypeEnum.dt_Varchar_Desc: |
| | | case DataTypeEnum.dt_uniqueidentifier: |
| | | case DataTypeEnum.dt_Varchar_Ext_Link: |
| | | case DataTypeEnum.dt_nvarchar: |
| | | sb.Append(" if (!string.IsNullOrEmpty(queryModel." + columnModel.ColumnName + ")) \n"); |
| | | sb.Append(" { \n"); |
| | | sb.Append(" strWhere += \" AND $TableAlias$." + columnModel.ColumnName + " LIKE '%\" + queryModel." + columnModel.ColumnName + " + \"%'\"; \n"); |
| | | sb.Append(" } \n"); |
| | | break; |
| | | case DataTypeEnum.dt_bit: |
| | | sb.Append(" if (!string.IsNullOrEmpty(queryModel." + columnModel.ColumnName + ")) \n"); |
| | | sb.Append(" { \n"); |
| | | sb.Append(" strWhere += \" AND $TableAlias$." + columnModel.ColumnName + " = '\" + queryModel." + columnModel.ColumnName + " + \"'\"; \n"); |
| | | sb.Append(" } \n"); |
| | | break; |
| | | case DataTypeEnum.dt_int: |
| | | case DataTypeEnum.dt_bigint: |
| | | sb.Append(" if (queryModel." + columnModel.ColumnName + " !=0) \n"); |
| | | sb.Append(" { \n"); |
| | | sb.Append(" strWhere += \" AND $TableAlias$." + columnModel.ColumnName + " = \" + queryModel." + columnModel.ColumnName + " + \"\"; \n"); |
| | | sb.Append(" } \n"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | return sb.ToString(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éè¿å忥æ¾å对象 |
| | | /// </summary> |
| | | /// <param name="columnName"></param> |
| | | /// <param name="columnModelList"></param> |
| | | /// <returns></returns> |
| | | public static ColumnModel GetColumnModelByName(string columnName, List<ColumnModel> columnModelList) |
| | | { |
| | | foreach (var item in columnModelList) |
| | | { |
| | | if (item.ColumnName.ToUpper() == columnName.ToUpper()) |
| | | { |
| | | return item; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | |  |
| | | using GenerateCode_GEBrilliantFactory; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | namespace GenerateCode_GEBrilliantFactory |
| | | { |
| | | public class TextHelper |
| | | { |
| | | |
| | | /// <summary> |
| | | /// 读åtextææ¬å
容 |
| | | /// </summary> |
| | | /// <param name="path"></param> |
| | | /// <returns></returns> |
| | | public static string ReadText(string path) |
| | | { |
| | | try |
| | | { |
| | | StreamReader sr = new StreamReader(path, Encoding.Default); |
| | | String line; |
| | | StringBuilder sb = new StringBuilder(); |
| | | while ((line = sr.ReadLine()) != null) |
| | | { |
| | | sb.Append(line.ToString() + " \n"); |
| | | } |
| | | sr.Close(); |
| | | sr.Dispose(); |
| | | return sb.ToString(); |
| | | } |
| | | catch |
| | | { |
| | | throw; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// åå
¥textææ¬å
容 |
| | | /// </summary> |
| | | /// <param name="path"></param> |
| | | /// <param name="data"></param> |
| | | public static void WriteText(string path, string data) |
| | | { |
| | | //å¤æè·¯å¾æ¯å¦åå¨ |
| | | if (!System.IO.File.Exists(path)) |
| | | { |
| | | throw new Exception("æä»¶ä¸åå¨"); |
| | | } |
| | | |
| | | //æä»¶è¦çæ¹å¼æ·»å å
容 |
| | | System.IO.StreamWriter file = new System.IO.StreamWriter(path, false); |
| | | //ä¿åæ°æ®å°æä»¶ |
| | | file.Write(data); |
| | | //å
³éæä»¶ |
| | | file.Close(); |
| | | //éæ¾å¯¹è±¡ |
| | | file.Dispose(); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// çææä»¶ |
| | | /// </summary> |
| | | /// <param name="_strPath">è·¯å¾</param> |
| | | /// <param name="_tableName">表å</param> |
| | | /// <param name="_code">çæç代ç å符串</param> |
| | | /// <param name="fileType">çæçæä»¶ç±»å</param> |
| | | /// <param name="filePrefixName">åç¼</param> |
| | | /// <param name="entityName">å®ä½ç±»å</param> |
| | | /// <param name="modulelogo">模ååå</param> |
| | | /// <returns></returns> |
| | | public static bool Export2File(string _strPath, string _tableName, string _code, FileType fileType, |
| | | string filePrefixName, string entityName, string modulelogo) |
| | | { |
| | | string fileFolderPath = _strPath + "\\" + _tableName; |
| | | |
| | | string fileTypeName = ""; |
| | | switch (fileType) |
| | | { |
| | | case FileType.Model: |
| | | fileTypeName = ".cs"; |
| | | break; |
| | | case FileType.AddModelParam: |
| | | entityName = "Add" + modulelogo + "Param"; |
| | | fileTypeName = ".cs"; |
| | | break; |
| | | case FileType.IBLL: |
| | | entityName = "I" + filePrefixName + "BLL"; |
| | | fileTypeName = ".cs"; |
| | | break; |
| | | case FileType.Controller: |
| | | entityName = entityName + "Controller"; |
| | | fileTypeName = ".cs"; |
| | | break; |
| | | case FileType.JS: |
| | | entityName = filePrefixName; |
| | | fileTypeName = ".js"; |
| | | break; |
| | | case FileType.CSHTML_List: |
| | | entityName = filePrefixName; |
| | | fileTypeName = ".cshtml"; |
| | | break; |
| | | case FileType.CSHTML_Detail: |
| | | entityName = filePrefixName; |
| | | fileTypeName = "Detail.cshtml"; |
| | | break; |
| | | case FileType.XML: |
| | | entityName = filePrefixName; |
| | | fileTypeName = ".xml"; |
| | | break; |
| | | case FileType.Proc: |
| | | entityName = filePrefixName; |
| | | fileTypeName = "Proc.sql"; |
| | | break; |
| | | case FileType.DAL: |
| | | entityName = filePrefixName; |
| | | fileTypeName = "DAL.cs"; |
| | | break; |
| | | case FileType.BLL: |
| | | entityName = filePrefixName; |
| | | fileTypeName = "BLL.cs"; |
| | | break; |
| | | case FileType.InputModel: |
| | | entityName = entityName + "Input"; |
| | | fileTypeName = ".cs"; |
| | | fileFolderPath += "\\Dto"; |
| | | break; |
| | | case FileType.OutputModel: |
| | | entityName = entityName + "Output"; |
| | | fileTypeName = ".cs"; |
| | | fileFolderPath += "\\Dto"; |
| | | break; |
| | | case FileType.WCF_InterFace: |
| | | entityName = "I" + entityName + "Service"; |
| | | fileTypeName = ".cs"; |
| | | break; |
| | | case FileType.WCF_InterFaceRealize: |
| | | entityName = entityName + "Service"; |
| | | fileTypeName = ".cs"; |
| | | break; |
| | | case FileType.SQL_Insert: |
| | | entityName = _tableName + "InsertSQL"; |
| | | fileTypeName = ".txt"; |
| | | break; |
| | | case FileType.VUE_FunConfig: |
| | | entityName = _tableName + "VUEæ¹æ³é
ç½®"; |
| | | fileTypeName = ".txt"; |
| | | break; |
| | | case FileType.VUEFile: |
| | | entityName = modulelogo; |
| | | fileTypeName = ".vue"; |
| | | break; |
| | | } |
| | | if (!Directory.Exists(fileFolderPath)) |
| | | { |
| | | Directory.CreateDirectory(fileFolderPath); |
| | | } |
| | | string filePath = fileFolderPath + "\\" + entityName + fileTypeName; |
| | | using (StreamWriter outfile = new StreamWriter(filePath, false, Encoding.GetEncoding("UTF-8"))) |
| | | { |
| | | outfile.Write(_code); |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <packages> |
| | | <package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" /> |
| | | <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.2" targetFramework="net48" /> |
| | | <package id="Microsoft.Extensions.Logging.Abstractions" version="8.0.2" targetFramework="net48" /> |
| | | <package id="MySqlConnector" version="2.4.0" targetFramework="net48" /> |
| | | <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net451" /> |
| | | <package id="System.Buffers" version="4.5.1" targetFramework="net48" /> |
| | | <package id="System.Diagnostics.DiagnosticSource" version="8.0.1" targetFramework="net48" /> |
| | | <package id="System.Memory" version="4.5.5" targetFramework="net48" /> |
| | | <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" /> |
| | | <package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net48" /> |
| | | <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" /> |
| | | </packages> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | Weben-CMSä¸ç¨ä»£ç çæå¨ |
| | | V1.0 |
| | | 1ãå建 2025-04-29 |
| | | |
| | | |