Exemplo n.º 1
0
        public static string AllText(TableInfo tableInfo, string path, DefineTemplateFolder defineTemplateFolder)
        {
            var pathNew = path;

            if (!File.Exists(path))
            {
                var folderSpecial = defineTemplateFolder.Define(tableInfo);
                var folderDefault = defineTemplateFolder.GetDefaultTemplateFolder();
                if (folderSpecial != folderDefault)
                {
                    pathNew = path.Replace(folderSpecial, folderDefault);
                }
            }

            if (!File.Exists(pathNew))
            {
                return(string.Empty);
            }

            return(File.ReadAllText(pathNew));
        }
Exemplo n.º 2
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);
        }