コード例 #1
0
        private static string GetImplementStr(string baseNameSpace, string ignoreFirstPrefix, TableInfo tableInfo, string dataBaseName)
        {
            var           bizName           = tableInfo.GetBizName(ignoreFirstPrefix);
            var           bizNameSpace      = string.IsNullOrWhiteSpace(bizName) ? string.Empty : "." + bizName;
            StringBuilder stringBuilder     = new StringBuilder();
            var           domainWithoutInfo = tableInfo.GetDomainNameWithoutInfo(ignoreFirstPrefix);

            stringBuilder.AppendLine("using Warship.Results;")
            .AppendLine("using Warship.Application;")
            .AppendLine("using Microsoft.Extensions.Logging;")
            .AppendLine($"using {baseNameSpace}.UnitOfWork;")
            .AppendFormat("using {0}.Repository{1};", baseNameSpace, bizNameSpace).AppendLine().AppendLine()
            .AppendFormat("namespace {0}.Application{1}.Implement", baseNameSpace, bizNameSpace).AppendLine()
            .AppendLine("{")
            .AppendLine("\t/// <summary>")
            .AppendFormat("\t/// desc:{0}", tableInfo.TableDescription).AppendLine()
            .AppendFormat("\t/// table:{0}", tableInfo.TableName).AppendLine()
            .AppendFormat("\t/// author:template {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).AppendLine()
            .AppendLine("\t/// </summary>")
            .AppendFormat("\tpublic class {0}Application : BaseApplication,I{0}Application", domainWithoutInfo).AppendLine()
            .AppendLine("\t{")
            .AppendFormat("\t\tprivate readonly I{0}Repository _{1}Repository;", domainWithoutInfo, domainWithoutInfo.ToLowwerFirst()).AppendLine()
            .AppendLine()
            .AppendFormat("\t\tpublic {0}Application(I{0}Repository {1}Repository, ILogger<{0}Application> warshipLogger, I{2}UnitOfWork unitOfWork) : base(warshipLogger, unitOfWork)", domainWithoutInfo, domainWithoutInfo.ToLowwerFirst(), dataBaseName.ToUpperFirst()).AppendLine()
            .AppendLine("\t\t{")
            .AppendFormat("\t\t\t_{0}Repository = {0}Repository;", domainWithoutInfo.ToLowwerFirst()).AppendLine()
            .AppendLine("\t\t}")
            .AppendLine("\t}")
            .AppendLine("}")
            ;
            return(stringBuilder.ToString());
        }
コード例 #2
0
        private static string GetDomainStr(string baseNameSpace, string ignoreFirstPrefix, TableInfo tableInfo)
        {
            var           bizName       = tableInfo.GetBizName(ignoreFirstPrefix);
            var           bizNameSpace  = string.IsNullOrWhiteSpace(bizName) ? string.Empty : "." + bizName;
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("using System;").AppendLine()
            .AppendFormat("namespace {0}.Domain{1}", baseNameSpace, bizNameSpace).AppendLine()
            .AppendLine("{")
            .AppendLine("\t/// <summary>")
            .AppendFormat("\t/// desc:{0}", tableInfo.TableDescription).AppendLine()
            .AppendFormat("\t/// table:{0}", tableInfo.TableName).AppendLine()
            .AppendFormat("\t/// author:template {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).AppendLine()
            .AppendLine("\t/// </summary>")
            .AppendFormat("\tpublic class {0}", tableInfo.GetDomainNameWithInfo(ignoreFirstPrefix)).AppendLine()
            .AppendLine("\t{");
            foreach (var columnInfo in tableInfo.ColumnList.OrderBy(m => m.ColumnPosition))
            {
                stringBuilder.AppendLine("\t\t/// <summary>");
                stringBuilder.AppendLine("\t\t/// " + columnInfo.ColumnDescription + "");
                stringBuilder.AppendLine("\t\t/// </summary>");
                stringBuilder.AppendLine(string.Format("\t\tpublic {0} {1} {{ get; set; }}", SqlUtil.ChangeDBTypeToCSharpType(columnInfo.DataType, columnInfo.MaxLength, columnInfo.IsNullable == 1), columnInfo.ColumnName));
                stringBuilder.AppendLine();
            }
            stringBuilder.AppendLine("\t}");
            stringBuilder.Append("}").AppendLine();
            return(stringBuilder.ToString());
        }
コード例 #3
0
        public static string GetImplementStr(string baseNameSpace, string ignoreFirstPrefix, string databaseName, TableInfo tableInfo)
        {
            StringBuilder stringBuilder     = new StringBuilder();
            var           keyColumnInfo     = tableInfo.GetKeyColumn();
            var           domainWithoutInfo = tableInfo.GetDomainNameWithoutInfo(ignoreFirstPrefix);
            var           keyStr            = SqlUtil.ChangeDBTypeToCSharpType(keyColumnInfo.DataType, keyColumnInfo.MaxLength, keyColumnInfo.IsNullable == 1);
            var           bizName           = tableInfo.GetBizName(ignoreFirstPrefix);
            var           bizNameSpace      = string.IsNullOrWhiteSpace(bizName) ? string.Empty : "." + bizName;

            stringBuilder.AppendLine("using System;")
            .AppendLine("using Warship.DataAccess;")
            .AppendFormat("using {0}.Domain{1};", baseNameSpace, bizNameSpace).AppendLine()
            .AppendFormat("using {0}.Constants;", baseNameSpace).AppendLine()
            .AppendFormat("using {0}.Constants.Tables{1};", baseNameSpace, bizNameSpace).AppendLine()
            .AppendLine()
            .AppendFormat("namespace {0}.Repository{1}.Implement", baseNameSpace, bizNameSpace).AppendLine()
            .AppendLine("{")
            .AppendLine("\t/// <summary>")
            .AppendFormat("\t/// desc:{0}", tableInfo.TableDescription).AppendLine()
            .AppendFormat("\t/// table:{0}", tableInfo.TableName).AppendLine()
            .AppendFormat("\t/// author:template {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).AppendLine()
            .AppendLine("\t/// </summary>")
            .AppendFormat("\tpublic class {0}Repository : BaseDataRepository<{0}Info, {1}>, I{0}Repository", domainWithoutInfo, keyStr).AppendLine()
            .AppendLine("\t{")
            .AppendFormat("\t\tpublic {0}Repository(IDataAccessFactory dataAccessFactory) : base(dataAccessFactory, ConfigNameConstants.Config_{1}, TableConstants.{2})", domainWithoutInfo, databaseName.Replace(".", "_").ToUpperFirst(), tableInfo.GetTableConstantName()).AppendLine()
            .AppendLine("\t\t{")
            .AppendLine("\t\t}")
            .AppendLine()
            .AppendFormat("\t\tprotected override Action<{0}Info, {1}> SetKey => (info,key) => info.{2} = key ;", domainWithoutInfo, keyStr, keyColumnInfo.ColumnName).AppendLine()
            .AppendLine("\t}")
            .AppendLine("}")
            ;
            return(stringBuilder.ToString());
        }
コード例 #4
0
        private static string GetInterfaceStr(string baseNameSpace, string ignoreFirstPrefix, TableInfo tableInfo)
        {
            StringBuilder stringBuilder = new StringBuilder();
            var           bizName       = tableInfo.GetBizName(ignoreFirstPrefix);
            var           bizNameSpace  = string.IsNullOrWhiteSpace(bizName) ? string.Empty : "." + bizName;

            stringBuilder.AppendFormat("namespace {0}.DomainService{1}", baseNameSpace, bizNameSpace).AppendLine()
            .AppendLine("{")
            .AppendLine("\t/// <summary>")
            .AppendFormat("\t/// desc:{0}", tableInfo.TableDescription).AppendLine()
            .AppendFormat("\t/// table:{0}", tableInfo.TableName).AppendLine()
            .AppendFormat("\t/// author:template {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).AppendLine()
            .AppendLine("\t/// </summary>")
            .AppendFormat("\tpublic interface I{0}DomainService", tableInfo.GetDomainNameWithoutInfo(ignoreFirstPrefix)).AppendLine()
            .AppendLine("\t{")
            .AppendLine("\t}")
            .AppendLine("}");
            return(stringBuilder.ToString());
        }
コード例 #5
0
        private static string GetTableConstantsStr(string baseNameSpace, string ignoreFirstPrefix, TableInfo tableInfo)
        {
            var           keyColumnInfo = tableInfo.GetKeyColumn();
            StringBuilder stringBuilder = new StringBuilder();
            var           bizName       = tableInfo.GetBizName(ignoreFirstPrefix);
            var           bizNameSpace  = string.IsNullOrWhiteSpace(bizName) ? string.Empty : "." + bizName;

            stringBuilder.AppendLine("using Warship.DataAccess;")
            .AppendLine()
            .AppendFormat("namespace {0}.Constants.Tables{1}", baseNameSpace, bizNameSpace).AppendLine()
            .AppendLine("{")
            .AppendLine("\tpublic partial class TableConstants")
            .AppendLine("\t{")
            .AppendLine("\t\t/// <summary>")
            .AppendFormat("\t\t/// {0}", tableInfo.TableDescription).AppendLine()
            .AppendLine("\t\t/// </summary>")
            .AppendFormat("\t\tpublic static readonly TableKeyInfo {0} = new TableKeyInfo(\"{1}\", \"{2}\", {3});", tableInfo.GetTableConstantName(), tableInfo.TableName, keyColumnInfo?.ColumnName, (keyColumnInfo != null && keyColumnInfo.IsIdentity == 1).ToString().ToLower()).AppendLine()
            .AppendLine("\t}")
            .AppendLine("}");
            return(stringBuilder.ToString());
        }
コード例 #6
0
        private static string GetInterfaceStr(string baseNameSpace, string ignoreFirstPrefix, TableInfo tableInfo)
        {
            StringBuilder stringBuilder = new StringBuilder();
            var           keyColumnInfo = tableInfo.GetKeyColumn();
            var           bizName       = tableInfo.GetBizName(ignoreFirstPrefix);
            var           bizNameSpace  = string.IsNullOrWhiteSpace(bizName) ? string.Empty : "." + bizName;

            stringBuilder.AppendLine("using System;")
            .AppendLine("using Warship.DataAccess;")
            .AppendFormat("using {0}.Domain{1};", baseNameSpace, bizNameSpace).AppendLine()
            .AppendLine()
            .AppendFormat("namespace {0}.Repository{1}", baseNameSpace, bizNameSpace).AppendLine()
            .AppendLine("{")
            .AppendLine("\t/// <summary>")
            .AppendFormat("\t/// desc:{0}", tableInfo.TableDescription).AppendLine()
            .AppendFormat("\t/// table:{0}", tableInfo.TableName).AppendLine()
            .AppendFormat("\t/// author:template {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")).AppendLine()
            .AppendLine("\t/// </summary>")
            .AppendFormat("\tpublic interface I{0}Repository : IDataRepository<{0}Info, {1}>", tableInfo.GetDomainNameWithoutInfo(ignoreFirstPrefix), SqlUtil.ChangeDBTypeToCSharpType(keyColumnInfo.DataType, keyColumnInfo.MaxLength, keyColumnInfo.IsNullable == 1)).AppendLine()
            .AppendLine("\t{")
            .AppendLine("\t}")
            .AppendLine("}");
            return(stringBuilder.ToString());
        }