public bool Import(Guid solutionId, IList <Domain.Entity> entities) { if (entities.NotEmpty()) { foreach (var item in entities) { var existEntity = _entityFinder.FindById(item.EntityId); if (existEntity != null) { existEntity.DuplicateEnabled = item.DuplicateEnabled; existEntity.AuthorizationEnabled = item.AuthorizationEnabled; existEntity.LogEnabled = item.LogEnabled; existEntity.LocalizedName = item.LocalizedName; existEntity.BusinessFlowEnabled = item.BusinessFlowEnabled; existEntity.WorkFlowEnabled = item.WorkFlowEnabled; _entityUpdater.Update(existEntity); } else { item.SolutionId = solutionId; item.ComponentState = 0; item.CreatedBy = _appContext.GetFeature <ICurrentUser>().SystemUserId; item.CreatedOn = DateTime.Now; item.IsCustomizable = true; item.OrganizationId = _appContext.OrganizationId; _entityCreater.Create(item, false); } //字段 _attributeImporter.Import(solutionId, item, item.Attributes); } } return(true); }
public IActionResult CreateEntity(CreateEntityModel model) { if (ModelState.IsValid) { model.Name = model.Name.Trim(); var entity = new Schema.Domain.Entity(); model.CopyTo(entity); entity.EntityId = Guid.NewGuid(); entity.IsCustomizable = true; entity.CreatedBy = CurrentUser.SystemUserId; entity.OrganizationId = CurrentUser.OrganizationId; if (model.EntityGroupId.NotEmpty()) { entity.EntityGroups = model.EntityGroupId.SerializeToJson(); } if (_entityCreater.Create(entity, model.DefaultAttributes)) { //创建默认按钮 if (model.DefaultButtons.NotEmpty()) { _eventPublisher.Publish(new CreateDefaultButtonsEvent(entity, model.DefaultButtons)); } //创建默认表单 if (model.CreateDefaultForm) { _eventPublisher.Publish(new CreateDefaultFormEvent(entity)); } //创建默认视图 if (model.CreateDefaultView) { _eventPublisher.Publish(new CreateDefaultViewEvent(entity)); } return(CreateSuccess(new { id = entity.EntityId })); } return(CreateFailure()); } return(CreateFailure(GetModelErrors())); }
public IActionResult Post(CreateEntityModel model) { if (ModelState.IsValid) { if (_entityFinder.FindByName(model.Name) != null) { return(JError(T["name_already_exists"])); } model.Name = model.Name.Trim(); var entity = new Schema.Domain.Entity(); model.CopyTo(entity); entity.SolutionId = _solutionId.Value; entity.IsCustomizable = true; entity.EntityId = Guid.NewGuid(); entity.CreatedBy = CurrentUser.SystemUserId; entity.CreatedOn = DateTime.Now; entity.OrganizationId = CurrentUser.OrganizationId; _entityCreater.Create(entity); return(CreateSuccess(new { id = entity.EntityId })); } return(CreateFailure(GetModelErrors())); }