Beispiel #1
0
        public bool Create(Privilege entity)
        {
            //判断重复
            if (IsExists(entity))
            {
                return(false);
            }

            if (!entity.ParentPrivilegeId.Equals(Guid.Empty))
            {
                var parent = FindById(entity.ParentPrivilegeId);
                if (parent != null)
                {
                    entity.Level = parent.Level + 1;
                }
            }
            if (entity.Level <= 0)
            {
                entity.Level = 1;
            }
            var flag = _privilegeRepository.Create(entity);

            if (flag)
            {
                //add to cache
                _cacheService.SetEntity(entity);
                //本地化标签
                //_localizedLabelService.Create(SolutionService.DefaultSolutionId, entity.DisplayName.IfEmpty(""), LabelTypeCodeEnum.Privilege, "DisplayName", entity.PrivilegeId, this._appContext.Org.LanguageId);
            }
            return(flag);
        }
Beispiel #2
0
        public bool Update(Domain.QueryView entity)
        {
            var original = _queryViewRepository.FindById(entity.QueryViewId);

            entity.ModifiedBy = _currentUser.SystemUserId;
            entity.ModifiedOn = DateTime.Now;
            var result = true;

            using (UnitOfWork.Build(_queryViewRepository.DbContext))
            {
                result = _queryViewRepository.Update(entity);
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.QueryViewId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.QueryViewId, _appContext.BaseLanguage);
                //assigning roles
                if (original.AuthorizationEnabled || !entity.AuthorizationEnabled)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.QueryViewId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = QueryViewDefaults.ModuleName
                    });
                }
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #3
0
        public bool Update(Domain.Attribute entity)
        {
            var result = true;

            using (UnitOfWork.Build(_attributeRepository.DbContext))
            {
                result = _attributeRepository.Update(entity);
                if (entity.OptionSetId.HasValue && entity.OptionSet != null && !entity.OptionSet.IsPublic)
                {
                    var details = _optionSetDetailFinder.Query(n => n.Select(f => f.OptionSetDetailId).Where(f => f.OptionSetId == entity.OptionSetId.Value));
                    foreach (var item in entity.OptionSet.Items)
                    {
                        if (item.OptionSetDetailId.Equals(Guid.Empty))
                        {
                            item.OptionSetDetailId = Guid.NewGuid();
                            result = _optionSetDetailCreater.Create(item);
                        }
                        else
                        {
                            result = _optionSetDetailUpdater.Update(item);
                        }
                    }
                    //delete lost
                    var ids    = entity.OptionSet.Items.Select(n => n.OptionSetDetailId);
                    var lostid = details.Select(n => n.OptionSetDetailId).Except(ids).ToList();
                    if (lostid.NotEmpty())
                    {
                        result = _optionSetDetailDeleter.DeleteById(lostid.ToArray());
                    }
                }
                if (entity.PickLists.NotEmpty())//bit
                {
                    foreach (var item in entity.PickLists)
                    {
                        if (item.StringMapId.Equals(Guid.Empty))
                        {
                            result = _stringMapCreater.Create(item);
                        }
                        else
                        {
                            result = _stringMapUpdater.Update(item);
                        }
                    }
                }
                //localization
                _localizedLabelService.Update(entity.LocalizedName.IfEmpty(""), "LocalizedName", entity.AttributeId, this._appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.AttributeId, this._appContext.BaseLanguage);
                //set to cache
                var optionSetEntity = _optionSetFinder.FindById(entity.OptionSet.OptionSetId);
                _cacheService.SetEntity(entity);
                _cacheServiceOption.RemoveEntity(optionSetEntity);
            }
            return(result);
        }
Beispiel #4
0
        public bool Update(EntityPlugin entity)
        {
            var result = false;

            using (UnitOfWork.Build(_entityPluginRepository.DbContext))
            {
                result = _entityPluginRepository.Update(entity);
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #5
0
        private bool CreateCore(Domain.SystemForm entity, Action <Domain.SystemForm> createDependents)
        {
            if (entity.FormConfig.IsEmpty())
            {
                return(false);
            }
            entity.OrganizationId = _appContext.OrganizationId;
            _formService.Init(entity);
            var result = true;

            using (UnitOfWork.Build(_systemFormRepository.DbContext))
            {
                result = _systemFormRepository.Create(entity);
                //依赖项
                createDependents?.Invoke(entity);
                //本地化标签
                _localizedLabelService.Append(entity.SolutionId, entity.Name.IfEmpty(""), entity.FormType == (int)FormType.Dashboard ? DashBoardDefaults.ModuleName : FormDefaults.ModuleName, "LocalizedName", entity.SystemFormId)
                .Append(entity.SolutionId, entity.Description.IfEmpty(""), entity.FormType == (int)FormType.Dashboard ? DashBoardDefaults.ModuleName : FormDefaults.ModuleName, "Description", entity.SystemFormId)
                .Save();
                _formService.UpdateLocalizedLabel(null);
                if (entity.FormType == (int)FormType.Dashboard)
                {
                    //solution component
                    result = _solutionComponentService.Create(entity.SolutionId, entity.SystemFormId, DashBoardDefaults.ModuleName);
                }
                //add to cache
                _cacheService.SetEntity(_systemFormRepository.FindById(entity.SystemFormId));
            }
            return(result);
        }
Beispiel #6
0
        private bool DeleteCore(params DuplicateRule[] deleteds)
        {
            Guard.NotEmpty(deleteds, nameof(deleteds));
            var result = false;
            var ids    = deleteds.Select(x => x.DuplicateRuleId).ToArray();

            using (UnitOfWork.Build(_duplicateRuleRepository.DbContext))
            {
                //cascade delete
                _cascadeDeletes?.ToList().ForEach((x) => { x.CascadeDelete(deleteds.ToArray()); });
                result = _duplicateRuleRepository.DeleteMany(ids);
                //删除依赖项
                _dependencyService.Delete(ids);
                //localization
                _localizedLabelService.DeleteByObject(ids);
                var entityIds = deleteds.Select(x => x.EntityId).Distinct().ToArray();
                //plugin
                foreach (var eid in entityIds)
                {
                    _entityPluginDeleter.DeleteByEntityId(eid);
                }
                foreach (var item in deleteds)
                {
                    //remove from cache
                    _cacheService.SetEntity(item);
                }
            }
            return(result);
        }
Beispiel #7
0
        public bool Create(FilterRule entity)
        {
            bool result = false;

            using (UnitOfWork.Build(_filterRuleRepository.DbContext))
            {
                result = _filterRuleRepository.Create(entity);
                //依赖
                _dependencyService.Create(entity);
                //plugin
                _entityPluginCreater.Create(new EntityPlugin()
                {
                    AssemblyName = FilterRuleDefaults.AssemblyName
                    ,
                    ClassName = FilterRuleDefaults.PluginClassName
                    ,
                    EntityId = entity.EntityId
                    ,
                    EventName = entity.EventName
                    ,
                    IsVisibled = false
                    ,
                    TypeCode = 0
                    ,
                    StateCode = RecordState.Enabled
                });
                //set to cache
                _cacheService.SetEntity(_filterRuleRepository.FindById(entity.FilterRuleId));
            }
            return(result);
        }
Beispiel #8
0
        public bool Update(DuplicateRule entity)
        {
            var result = false;

            using (UnitOfWork.Build(_duplicateRuleRepository.DbContext))
            {
                result = _duplicateRuleRepository.Update(entity);
                //依赖于字段
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.DuplicateRuleId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.DuplicateRuleId, _appContext.BaseLanguage);
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #9
0
        public bool Create(Domain.Entity entity, params string[] defaultAttributeNames)
        {
            if (_entityRepository.Exists(x => x.Name == entity.Name))
            {
                throw new XmsException(_loc["name_already_exists"]);
            }
            var solutionid = entity.SolutionId;                     //当前解决方案

            entity.SolutionId = SolutionDefaults.DefaultSolutionId; //组件属于默认解决方案
            var result = true;

            if (defaultAttributeNames.IsEmpty())
            {
                //默认添加主键字段
                defaultAttributeNames = new string[] { entity.Name + "Id" };
            }
            else if (!defaultAttributeNames.Contains(entity.Name + "Id", StringComparer.InvariantCultureIgnoreCase))
            {
                var namesList = defaultAttributeNames.ToList();
                namesList.Add(entity.Name + "Id");
                defaultAttributeNames = namesList.ToArray();
            }
            var parentEntity      = entity.ParentEntityId.HasValue ? _entityRepository.FindById(entity.ParentEntityId.Value) : null;
            var defaultAttributes = _defaultAttributeProvider.GetSysAttributes(entity).Where(x => defaultAttributeNames.Contains(x.Name, StringComparer.InvariantCultureIgnoreCase)).Distinct().ToList();

            using (UnitOfWork.Build(_entityRepository.DbContext))
            {
                result = _entityRepository.Create(entity, defaultAttributes, _defaultAttributeProvider.GetSysAttributeRelationShips(entity, defaultAttributes));

                //创建默认字段
                _attributeCreater.CreateDefaultAttributes(entity, defaultAttributeNames);
                //如果是子实体,则创建引用字段
                if (parentEntity != null)
                {
                    _attributeCreater.Create(new Domain.Attribute {
                        Name = parentEntity.Name + "Id"
                        , AttributeTypeName  = AttributeTypeIds.LOOKUP
                        , EntityId           = entity.EntityId
                        , EntityName         = entity.Name
                        , IsRequired         = true
                        , LocalizedName      = parentEntity.LocalizedName
                        , ReferencedEntityId = parentEntity.EntityId
                    });
                }
                //事件发布
                _eventPublisher.Publish(new ObjectCreatedEvent <Domain.Entity>(entity));
                //solution component
                _solutionComponentService.Create(solutionid, entity.EntityId, EntityDefaults.ModuleName);
                //本地化标签
                _localizedLabelService.Append(entity.SolutionId, entity.LocalizedName.IfEmpty(""), EntityDefaults.ModuleName, "LocalizedName", entity.EntityId)
                .Append(entity.SolutionId, entity.Description.IfEmpty(""), EntityDefaults.ModuleName, "Description", entity.EntityId)
                .Save();

                //add to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #10
0
        public bool Update(Domain.SerialNumberRule entity)
        {
            //检查是否已存在相同字段的编码规则
            if (_serialNumberRuleRepository.Exists(x => x.SerialNumberRuleId != entity.SerialNumberRuleId && x.EntityId == entity.EntityId && x.AttributeId == entity.AttributeId))
            {
                throw new XmsException(_loc["serial_number_duplicated"]);
            }
            bool result = _serialNumberRuleRepository.Update(entity);

            if (result)
            {
                //依赖于字段
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.SerialNumberRuleId, this._appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.SerialNumberRuleId, this._appContext.BaseLanguage);
                //set to cache
                _cacheService.SetEntity(_serialNumberRuleRepository.FindById(entity.SerialNumberRuleId));
            }
            return(result);
        }
Beispiel #11
0
        public bool Update(Domain.RelationShip entity)
        {
            bool flag = _relationShipRepository.Update(entity);

            if (flag)
            {
                //this.WrapLocalizedLabel(entity);
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(flag);
        }
Beispiel #12
0
        public bool Update(Domain.WebResource entity)
        {
            var flag = _webResourceRepository.Update(entity);

            if (flag)
            {
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.WebResourceId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.WebResourceId, _appContext.BaseLanguage);
                _cacheService.SetEntity(entity);
            }
            return(flag);
        }
Beispiel #13
0
        public bool Update(FilterRule entity)
        {
            var result = false;

            using (UnitOfWork.Build(_filterRuleRepository.DbContext))
            {
                result = _filterRuleRepository.Update(entity);
                //依赖
                _dependencyService.Update(entity);
                //set to cache
                _cacheService.SetEntity(_filterRuleRepository.FindById(entity.FilterRuleId));
            }
            return(result);
        }
Beispiel #14
0
        public bool Update(Domain.SystemForm entity, bool updatedConfig)
        {
            var original = _systemFormRepository.FindById(entity.SystemFormId);
            var result   = true;

            _formService.Init(entity);
            using (UnitOfWork.Build(_systemFormRepository.DbContext))
            {
                result = _systemFormRepository.Update(entity);
                _dependencyService.Update(entity);
                //localization
                _localizedLabelService.Update(entity.Name.IfEmpty(""), "LocalizedName", entity.SystemFormId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.SystemFormId, _appContext.BaseLanguage);
                if (updatedConfig)
                {
                    _formService.UpdateLocalizedLabel(original);
                }
                //assigning roles
                if (original.AuthorizationEnabled || !entity.AuthorizationEnabled)
                {
                    _eventPublisher.Publish(new AuthorizationStateChangedEvent
                    {
                        ObjectId = new List <Guid> {
                            entity.SystemFormId
                        }
                        ,
                        State = false
                        ,
                        ResourceName = FormDefaults.ModuleName
                    });
                }
                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #15
0
        public bool Update(Domain.Entity entity)
        {
            var oldEntity = _entityRepository.FindById(entity.EntityId);

            if (oldEntity == null)
            {
                return(false);
            }
            var result = true;

            if (!oldEntity.IsCustomizable)
            {
                entity.AuthorizationEnabled = oldEntity.AuthorizationEnabled;
                entity.WorkFlowEnabled      = oldEntity.WorkFlowEnabled;
                entity.BusinessFlowEnabled  = oldEntity.BusinessFlowEnabled;
                entity.EntityMask           = oldEntity.EntityMask;
            }
            using (UnitOfWork.Build(_entityRepository.DbContext))
            {
                result = _entityRepository.Update(entity);
                //从组织范围改成用户范围
                if (oldEntity.EntityMask != entity.EntityMask && entity.EntityMask == EntityMaskEnum.User)
                {
                    //创建所有者字段
                    _attributeCreater.CreateOwnerAttributes(entity);
                }
                //启用审批流,创建相关字段
                if (!oldEntity.WorkFlowEnabled && entity.WorkFlowEnabled)
                {
                    _attributeCreater.CreateWorkFlowAttributes(entity);
                }
                //启用业务流,创建相关字段
                if (!oldEntity.BusinessFlowEnabled && entity.BusinessFlowEnabled)
                {
                    _attributeCreater.CreateBusinessFlowAttributes(entity);
                }
                //localization
                _localizedLabelService.Update(entity.LocalizedName.IfEmpty(""), "LocalizedName", entity.EntityId, _appContext.BaseLanguage);
                _localizedLabelService.Update(entity.Description.IfEmpty(""), "Description", entity.EntityId, _appContext.BaseLanguage);

                //set to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #16
0
        public bool Create(DuplicateRule entity)
        {
            entity.SolutionId = SolutionDefaults.DefaultSolutionId;//组件属于默认解决方案
            var result = false;

            using (UnitOfWork.Build(_duplicateRuleRepository.DbContext))
            {
                result = _duplicateRuleRepository.Create(entity);
                //检测条件
                if (entity.Conditions.NotEmpty())
                {
                    foreach (var item in entity.Conditions)
                    {
                        item.EntityId = entity.EntityId;
                    }
                    result = _duplicateRuleConditionService.CreateMany(entity.Conditions);
                }
                //依赖于字段
                _dependencyService.Create(entity);
                //本地化标签
                _localizedLabelService.Create(entity.SolutionId, entity.Name.IfEmpty(""), DuplicateRuleDefaults.ModuleName, "LocalizedName", entity.DuplicateRuleId, this._appContext.BaseLanguage);
                _localizedLabelService.Create(entity.SolutionId, entity.Description.IfEmpty(""), DuplicateRuleDefaults.ModuleName, "Description", entity.DuplicateRuleId, this._appContext.BaseLanguage);
                //plugin
                _entityPluginCreater.Create(new EntityPlugin()
                {
                    AssemblyName = DuplicateRuleDefaults.AssemblyName
                    ,
                    ClassName = DuplicateRuleDefaults.PluginClassName
                    ,
                    EntityId = entity.EntityId
                    ,
                    EventName = Enum.GetName(typeof(OperationTypeEnum), OperationTypeEnum.Create)
                    ,
                    IsVisibled = false
                    ,
                    TypeCode = 0
                    ,
                    StateCode = RecordState.Enabled
                });
                //add to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #17
0
        public bool Create(EntityPlugin entity)
        {
            entity.SolutionId     = SolutionDefaults.DefaultSolutionId;//组件属于默认解决方案
            entity.CreatedBy      = _appContext.GetFeature <ICurrentUser>().SystemUserId;
            entity.OrganizationId = _appContext.OrganizationId;
            var result = true;

            using (UnitOfWork.Build(_entityPluginRepository.DbContext))
            {
                result = _entityPluginRepository.Create(entity);
                //solution component
                _solutionComponentService.Create(entity.SolutionId, entity.EntityPluginId, PluginDefaults.ModuleName);
                //依赖于实体
                _dependencyService.Create(PluginDefaults.ModuleName, entity.EntityPluginId, EntityDefaults.ModuleName, entity.EntityId);
                //add to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #18
0
        public bool Create(Domain.SerialNumberRule entity)
        {
            //检查是否已存在相同字段的编码规则
            if (_serialNumberRuleRepository.Exists(x => x.EntityId == entity.EntityId && x.AttributeId == entity.AttributeId))
            {
                throw new XmsException(_loc["serial_number_duplicated"]);
            }
            entity.OrganizationId = this._appContext.OrganizationId;
            var result = true;

            using (UnitOfWork.Build(_serialNumberRuleRepository.DbContext))
            {
                result = _serialNumberRuleRepository.Create(entity);
                //依赖于字段
                _dependencyService.Create(entity);
                //solution component
                result = _solutionComponentService.Create(entity.SolutionId, entity.SerialNumberRuleId, SerialNumberRuleDefaults.ModuleName);
                //本地化标签
                _localizedLabelService.Create(entity.SolutionId, entity.Name.IfEmpty(""), SerialNumberRuleDefaults.ModuleName, "LocalizedName", entity.SerialNumberRuleId, this._appContext.BaseLanguage);
                _localizedLabelService.Create(entity.SolutionId, entity.Description.IfEmpty(""), SerialNumberRuleDefaults.ModuleName, "Description", entity.SerialNumberRuleId, this._appContext.BaseLanguage);
                //plugin
                _entityPluginCreater.Create(new EntityPlugin()
                {
                    AssemblyName = SerialNumberRuleDefaults.AssemblyName
                    ,
                    ClassName = SerialNumberRuleDefaults.PluginClassName
                    ,
                    EntityId = entity.EntityId
                    ,
                    EventName = Enum.GetName(typeof(OperationTypeEnum), OperationTypeEnum.Create)
                    ,
                    IsVisibled = false
                    ,
                    TypeCode = 0
                    ,
                    StateCode = RecordState.Enabled
                });
                //add to cache
                _cacheService.SetEntity(_serialNumberRuleRepository.FindById(entity.SerialNumberRuleId));
            }
            return(result);
        }
Beispiel #19
0
        private bool CreateCore(Domain.QueryView entity, Action <Domain.QueryView> createDependents)
        {
            entity.SolutionId = SolutionDefaults.DefaultSolutionId;//组件属于默认解决方案
            var result = true;

            using (UnitOfWork.Build(_queryViewRepository.DbContext))
            {
                result = _queryViewRepository.Create(entity);
                //依赖项
                createDependents(entity);

                //本地化标签
                _localizedLabelService.Append(entity.SolutionId, entity.Name.IfEmpty(""), QueryViewDefaults.ModuleName, "LocalizedName", entity.QueryViewId)
                .Append(entity.SolutionId, entity.Description.IfEmpty(""), QueryViewDefaults.ModuleName, "Description", entity.QueryViewId)
                .Save();
                //add to cache
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #20
0
        public bool Create(Domain.WebResource entity)
        {
            var solutionid = entity.SolutionId;                     //当前解决方案

            entity.SolutionId = SolutionDefaults.DefaultSolutionId; //组件属于默认解决方案
            var result = true;

            using (UnitOfWork.Build(_webResourceRepository.DbContext))
            {
                result = _webResourceRepository.Create(entity);
                //solution component
                _solutionComponentService.Create(solutionid, entity.WebResourceId, WebResourceDefaults.ModuleName);
                //本地化标签
                _localizedLabelService.Append(entity.SolutionId, entity.Name.IfEmpty(""), WebResourceDefaults.ModuleName, "LocalizedName", entity.WebResourceId)
                .Append(entity.SolutionId, entity.Description.IfEmpty(""), WebResourceDefaults.ModuleName, "Description", entity.WebResourceId)
                .Save();
                _cacheService.SetEntity(entity);
            }
            return(result);
        }
Beispiel #21
0
        public bool Create(Domain.Attribute entity)
        {
            //检查名称是否已存在
            if (_attributeRepository.Exists(x => x.EntityId == entity.EntityId && x.Name == entity.Name))
            {
                throw new XmsException(_loc["ATTRIBUTE_NAME_EXISTS"]);
            }
            var result = true;

            if (entity.DefaultValue.IsEmpty() && (entity.TypeIsBit() || entity.TypeIsDecimal() || entity.TypeIsFloat() ||
                                                  entity.TypeIsInt() || entity.TypeIsMoney() || entity.TypeIsSmallInt() || entity.TypeIsSmallMoney() || entity.TypeIsState() || entity.TypeIsStatus()))
            {
                entity.DefaultValue = "0";
            }
            var parentEntity = _entityFinder.FindById(entity.EntityId);

            using (UnitOfWork.Build(_attributeRepository.DbContext))
            {
                result = _attributeRepository.Create(entity);
                if (result)
                {
                    //引用类型
                    if (entity.TypeIsLookUp() || entity.TypeIsOwner() || entity.TypeIsCustomer())
                    {
                        var referencing  = _entityFinder.FindById(entity.EntityId);
                        var referenced   = _attributeRepository.Find(x => x.EntityId == entity.ReferencedEntityId.Value && x.AttributeTypeName == AttributeTypeIds.PRIMARYKEY);
                        var relationShip = new Domain.RelationShip
                        {
                            Name                   = "lk_" + referencing.Name + "_" + entity.Name,
                            RelationshipType       = RelationShipType.ManyToOne,
                            ReferencingAttributeId = entity.AttributeId,
                            ReferencingEntityId    = entity.EntityId,
                            ReferencedAttributeId  = referenced.AttributeId,
                            ReferencedEntityId     = referenced.EntityId,
                            CascadeLinkMask        = parentEntity.ParentEntityId.HasValue ? 1 : 2,
                            CascadeAssign          = parentEntity.ParentEntityId.HasValue ? 1 : 4,
                            CascadeDelete          = parentEntity.ParentEntityId.HasValue ? 1 : 4,
                            CascadeShare           = parentEntity.ParentEntityId.HasValue ? 1 : 4,
                            CascadeUnShare         = parentEntity.ParentEntityId.HasValue ? 1 : 4,
                            IsCustomizable         = !parentEntity.ParentEntityId.HasValue
                        };
                        _relationShipCreater.Create(relationShip);
                    }
                    //选项类型
                    else if (entity.TypeIsPickList())
                    {
                        if (entity.OptionSet != null && !entity.OptionSet.IsPublic)
                        {
                            _optionSetCreater.Create(entity.OptionSet);
                        }
                    }
                    //bit类型
                    else if (entity.TypeIsBit())
                    {
                        _stringMapCreater.CreateMany(entity.PickLists);
                    }
                    //update db view
                    _metadataService.AlterView(_entityFinder.FindById(entity.EntityId));
                    //依赖项
                    _dependencyService.Create(entity);
                    //本地化标签
                    _localizedLabelService.Append(SolutionDefaults.DefaultSolutionId, entity.LocalizedName.IfEmpty(""), AttributeDefaults.ModuleName, "LocalizedName", entity.AttributeId)
                    .Append(SolutionDefaults.DefaultSolutionId, entity.Description.IfEmpty(""), AttributeDefaults.ModuleName, "Description", entity.AttributeId)
                    .Save();

                    //add to cache
                    _cacheService.SetEntity(entity);
                }
            }
            return(result);
        }