예제 #1
0
        public static string MakeAuditFields(TableInfo tableInfo, Info item, string textTemplateAudit, DefineTemplateFolder defineTemplateFolder)
        {
            var pathTemplateAudit = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, defineTemplateFolder.Define(tableInfo), "models.audit");

            if (string.IsNullOrEmpty(textTemplateAudit))
            {
                textTemplateAudit = Read.AllText(tableInfo, pathTemplateAudit, defineTemplateFolder);
            }

            textTemplateAudit = textTemplateAudit.Replace("<#className#>", tableInfo.ClassName);

            if (item.PropertyName == "UserCreateId" || item.PropertyName == "UserAlterId")
            {
                var cast = String.Format("({0})userId", TypeConvertCSharp.Convert(item.TypeOriginal, item.IsNullable));

                if (item.PropertyName == "UserCreateId")
                {
                    textTemplateAudit = textTemplateAudit.Replace("<#propertCastInsert#>", cast);
                }

                if (item.PropertyName == "UserAlterId")
                {
                    textTemplateAudit = textTemplateAudit.Replace("<#propertCastUpdate#>", cast);
                }
            }
            return(textTemplateAudit);
        }