public override void Update() { if (Session.FindObject <PersistentAssemblyInfo>(info => info.Name == DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly) == null) { IPersistentAssemblyInfo persistentAssemblyInfo = new DynamicAssemblyBuilder(Session).Build(DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer, DMDOrder, DMDOrderLine, DynamicAssemblyCalculatedField.AttributeRegistrator.MasterDetailDynamicAssembly); IPersistentClassInfo persistentClassInfo = persistentAssemblyInfo.PersistentClassInfos.Single(info => info.Name == DynamicAssemblyCalculatedField.AttributeRegistrator.DMDCustomer); var persistentCoreTypeMemberInfo = new PersistentCoreTypeMemberInfo(persistentClassInfo.Session); persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInDetailViewAttribute(persistentCoreTypeMemberInfo.Session)); persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInListViewAttribute(persistentCoreTypeMemberInfo.Session)); persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentVisibleInLookupListViewAttribute(persistentCoreTypeMemberInfo.Session)); persistentCoreTypeMemberInfo.TypeAttributes.Add(new PersistentPersistentAliasAttribute(persistentCoreTypeMemberInfo.Session) { AliasExpression = "DMDOrders.Min(OrderDate)" }); persistentCoreTypeMemberInfo.Name = "FirstOrderDate"; persistentCoreTypeMemberInfo.DataType = DBColumnType.DateTime; var codeTemplateInfo = new CodeTemplateInfo(persistentCoreTypeMemberInfo.Session); var codeTemplate = new CodeTemplate(codeTemplateInfo.Session) { TemplateType = TemplateType.XPCalculatedPropertyMember }; codeTemplate.SetDefaults(); codeTemplate.Name = "CalculatedProperty"; codeTemplateInfo.TemplateInfo = codeTemplate; persistentCoreTypeMemberInfo.CodeTemplateInfo = codeTemplateInfo; persistentClassInfo.OwnMembers.Add(persistentCoreTypeMemberInfo); XPObjectSpace.FindObjectSpaceByObject(persistentClassInfo).CommitChanges(); } }
private static CodeTemplateInfo CreateCalculatedCodeTemplateInfo(IPersistentCoreTypeMemberInfo persistentCoreTypeMemberInfo) { var codeTemplateInfo = new CodeTemplateInfo(persistentCoreTypeMemberInfo.Session); var codeTemplate = new CodeTemplate(codeTemplateInfo.Session) { TemplateType = TemplateType.XPCalculatedPropertyMember }; codeTemplate.SetDefaults(); codeTemplate.Name = "CalculatedProperty"; codeTemplateInfo.TemplateInfo = codeTemplate; return(codeTemplateInfo); }
private static List <CodeTemplateInfo> Get52abpDefaultCodeTemplates(CodeGenDto dto) { List <CodeTemplateInfo> list = new List <CodeTemplateInfo>(); BasicOptionCfg option = dto.option; string entityDir = dto.EntityDir; string templateBasePath = dto.TemplateBasePath; EntityModel entity = dto.Entity; string uiParentDirName = dto.UiParentDirName; SolutionInfoModel solutionInfoModel = dto.solutionInfoModel; if (option.IsAllGeneratorCode || option.UseApplicationServiceCode) { string basePath = Global.SolutionInfo.Application.BasePath; string buildPath = Path.Combine(basePath, entityDir, "Mapper", entity.Name + "DtoAutoMapper.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\Mapper\\EntityDtoAutoMapper.txt"), buildPath)); if (option.UseExportExcel) { buildPath = Path.Combine(basePath, entityDir, "Exporting", "I" + entity.Name + "ListExcelExporter.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\Exporting\\IEntityListExcelExporter.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Exporting", entity.Name + "ListExcelExporter.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\Exporting\\EntityListExcelExporter.txt"), buildPath)); } buildPath = Path.Combine(basePath, entityDir, "I" + entity.Name + "AppService.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\IEntityApplicationService.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, entity.Name + "AppService.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\EntityApplicationService.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Dtos", "CreateOrUpdate" + entity.Name + "Input.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\Dtos\\CreateOrUpdateEntityInput.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Dtos", "Get" + entity.Name + "ForEditOutput.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\Dtos\\GetEntityForEditOutput.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Dtos", "Get" + entity.Name + "sInput.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\Dtos\\GetEntitysInput.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Dtos", entity.Name + "EditDto.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\Dtos\\EntityEditDto.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Dtos", entity.Name + "ListDto.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Application\\Dtos\\EntityListDto.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Readme.md"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Readme.txt"), buildPath)); if (option.UseNgZorro) { buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, "Readme.md" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Client\\NGZorro\\Readme.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, "create-or-edit-" + entity.SplitName, "create-or-edit-" + entity.SplitName + ".component.less" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Client\\NGZorro\\EntityEditViewCss.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, "create-or-edit-" + entity.SplitName, "create-or-edit-" + entity.SplitName + ".component.html" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Client\\NGZorro\\EntityEditViewHtml.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, "create-or-edit-" + entity.SplitName, "create-or-edit-" + entity.SplitName + ".component.ts" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Client\\NGZorro\\EntityEditViewTs.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, entity.SplitName + ".component.less" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Client\\NGZorro\\EntityListViewCss.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, entity.SplitName + ".component.html" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Client\\NGZorro\\EntityListViewHtml.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, entity.SplitName + ".component.ts" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Client\\NGZorro\\EntityListViewTs.txt"), buildPath)); } } if (option.IsAllGeneratorCode || option.UseDomainAuthorizeCode || option.UseDomainManagerCode) { string basePath2 = Global.SolutionInfo.Core.BasePath; string buildPath2 = string.Empty; if (option.UseDomainAuthorizeCode) { buildPath2 = Path.Combine(basePath2, entityDir, "Authorization", entity.Name + "AuthorizationProvider.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Domain\\Authorization\\EntityAuthorizationProvider.txt"), buildPath2)); buildPath2 = Path.Combine(basePath2, entityDir, "Authorization", entity.Name + "Permissions.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Domain\\Authorization\\EntityPermissions.txt"), buildPath2)); } if (option.UseDomainManagerCode) { buildPath2 = Path.Combine(basePath2, entityDir, "DomainService", "I" + entity.Name + "Manager.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Domain\\DomainService\\IEntityManager.txt"), buildPath2)); buildPath2 = Path.Combine(basePath2, entityDir, "DomainService", entity.Name + "Manager.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Domain\\DomainService\\EntityManager.txt"), buildPath2)); buildPath2 = Path.Combine(basePath2, entityDir, "Duoyuyan.md"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Domain\\Duoyuyan.txt"), buildPath2)); } buildPath2 = Path.Combine(basePath2, entityDir, "Readme.md"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Readme.txt"), buildPath2)); } string buildPath3 = Path.Combine(Global.SolutionInfo.EF.BasePath, "EntityMapper", entity.Name + "s", entity.Name + "Cfg.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\EntityFrameworkCore\\EntityMapper\\EntityCfg.txt"), buildPath3)); if (option.UseXUnitTests) { string buildPath4 = Path.Combine(Global.SolutionInfo.Tests.BasePath, entity.Name + "s", entity.Name + "AppService_Tests.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\Tests\\EntityAppService_Tests.txt"), buildPath4)); } if (option.InitGeneratorCode) { string basePath3 = Global.SolutionInfo.Application.BasePath; string buildPath5 = Path.Combine(basePath3, "Dtos", "PagedAndFilteredInputDto.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\InitGeneratorCode\\Dtos\\PagedAndFilteredInputDto.txt"), buildPath5)); buildPath5 = Path.Combine(basePath3, "Dtos", "PagedAndSortedInputDto.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\InitGeneratorCode\\Dtos\\PagedAndSortedInputDto.txt"), buildPath5)); buildPath5 = Path.Combine(basePath3, "Dtos", "PagedInputDto.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\InitGeneratorCode\\Dtos\\PagedInputDto.txt"), buildPath5)); buildPath5 = Path.Combine(basePath3, "Dtos", "PagedSortedAndFilteredInputDto.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\InitGeneratorCode\\Dtos\\PagedSortedAndFilteredInputDto.txt"), buildPath5)); basePath3 = Global.SolutionInfo.Core.BasePath; buildPath5 = Path.Combine(basePath3, "Authorization", "AppLtmPermissions.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\InitGeneratorCode\\AppLtmPermissions.txt"), buildPath5)); buildPath5 = Path.Combine(basePath3, solutionInfoModel.SolutionNamespace + "DomainServiceBase.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\InitGeneratorCode\\SolutionNameDomainServiceBase.txt"), buildPath5)); buildPath5 = Path.Combine(basePath3, "AppLtmConsts.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\InitGeneratorCode\\AppLtmConsts.txt"), buildPath5)); buildPath5 = Path.Combine(basePath3, "YoYoAbpefCoreConsts.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Server\\InitGeneratorCode\\YoYoAbpefCoreConsts.txt"), buildPath5)); } return(list); }
private static List <CodeTemplateInfo> GetMoonsXStCodeTemplates(CodeGenDto dto) { List <CodeTemplateInfo> list = new List <CodeTemplateInfo>(); BasicOptionCfg option = dto.option; string entityDir = dto.EntityDir; string templateBasePath = dto.TemplateBasePath; EntityModel entity = dto.Entity; string uiParentDirName = dto.UiParentDirName; SolutionInfoModel solutionInfoModel = dto.solutionInfoModel; if (option.IsAllGeneratorCode || option.UseApplicationServiceCode) { string basePath = Global.SolutionInfo.Application_Shared.BasePath; string buildPath = Path.Combine(basePath, entityDir, "I" + entity.Name + "AppService.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Application\\IEntityApplicationService.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Dtos", "Get" + entity.Name + "ForEditOutput.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Application\\Dtos\\GetEntityForEditOutput.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Dtos", entity.Name + "EditDto.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Application\\Dtos\\EntityEditDto.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Dtos", "Get" + entity.Name + "ForViewDto.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Application\\Dtos\\GetEntityForViewDto.txt"), buildPath)); basePath = Global.SolutionInfo.Application.BasePath; buildPath = Path.Combine(basePath, entityDir, "Mapper", entity.Name + "DtoAutoMapper.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Application\\Mapper\\EntityDtoAutoMapper.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, entity.Name + "AppService.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Application\\EntityApplicationService.txt"), buildPath)); buildPath = Path.Combine(basePath, entityDir, "Readme.md"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Readme.txt"), buildPath)); basePath = Global.SolutionInfo.Host.BasePath; buildPath = Path.Combine(new string[] { basePath, "wwwroot", "ConfigFiles", "ListViews", entity.ParentDirName + "." + entity.Name + ".xml" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\WebHost\\wwwroot\\EntityListViews.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, "wwwroot", "ConfigFiles", "PageFilters", entity.ParentDirName + "." + entity.Name + ".json" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\WebHost\\wwwroot\\PageFilters.txt"), buildPath)); if (!option.IsAbpZero && option.UseNgZorro) { buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, "Readme.md" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Moons\\Client\\NGZorro\\Readme.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, "create-or-edit-" + entity.SplitName, "create-or-edit-" + entity.SplitName + ".component.less" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Moons\\Client\\NGZorro\\EntityEditViewCss.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, "create-or-edit-" + entity.SplitName, "create-or-edit-" + entity.SplitName + ".component.html" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Moons\\Client\\NGZorro\\EntityEditViewHtml.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, "create-or-edit-" + entity.SplitName, "create-or-edit-" + entity.SplitName + ".component.ts" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Moons\\Client\\NGZorro\\EntityEditViewTs.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, entity.SplitName + ".component.less" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Client, Path.Combine(templateBasePath, "Templates\\Moons\\Client\\NGZorro\\EntityListViewCss.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, entity.SplitName + ".component.html" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Client\\NGZorro\\EntityListViewHtml.txt"), buildPath)); buildPath = Path.Combine(new string[] { basePath, entityDir, "Client", "NGZorro", uiParentDirName, entity.SplitName + ".component.ts" }); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Client\\NGZorro\\EntityListViewTs.txt"), buildPath)); } } if (option.IsAllGeneratorCode || option.UseDomainAuthorizeCode || option.UseDomainManagerCode) { string basePath2 = Global.SolutionInfo.Core.BasePath; string buildPath2 = string.Empty; if (option.UseDomainAuthorizeCode) { buildPath2 = Path.Combine(basePath2, entityDir, "Authorization", entity.Name + "Permissions.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Domain\\Authorization\\EntityPermissions.txt"), buildPath2)); } if (option.UseDomainManagerCode) { buildPath2 = Path.Combine(basePath2, entityDir, "DomainService", "I" + entity.Name + "Manager.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Domain\\DomainService\\IEntityManager.txt"), buildPath2)); buildPath2 = Path.Combine(basePath2, entityDir, "DomainService", entity.Name + "Manager.cs"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Domain\\DomainService\\EntityManager.txt"), buildPath2)); } buildPath2 = Path.Combine(basePath2, entityDir, "Readme.md"); list.Add(CodeTemplateInfo.Create(CodeTemplateType.Server, Path.Combine(templateBasePath, "Templates\\Moons\\Server\\Readme.txt"), buildPath2)); } return(list); }