Esempio n. 1
0
        ///// <summary>
        ///// 添加实体映射(新)
        ///// </summary>
        //public void AddEntityMapping(EntityMapping entityMapping)
        //{
        //    DEObjectExecutor executor = null;

        //    if (this._NeedCheckPermissions)
        //        CheckPermissions(DEOperationType.AddEntityMapping, null, "AddEntityMapping", string.Empty);

        //    OuterEntity outerEntity = new OuterEntity();
        //    OuterEntityFieldCollection outerEntityFields = new OuterEntityFieldCollection();

        //    using (TransactionScope scope = TransactionScopeFactory.Create())
        //    {
        //        #region [实体与外部实体映射][外部实体]入库
        //        if (entityMapping.InnerEntity.OuterEntities.Any(p => p.ID.Equals(entityMapping.OuterEntityID)))
        //        {
        //            var outentity = entityMapping.InnerEntity.OuterEntities.FirstOrDefault(p => p.ID.Equals(entityMapping.OuterEntityID));
        //            outentity.Name = entityMapping.OuterEntityName;
        //            outentity.CustomType = entityMapping.OuterEntityInType;
        //            outerEntity = outentity;
        //        }
        //        else
        //        {
        //            outerEntity = new OuterEntity() { ID = entityMapping.OuterEntityID, Name = entityMapping.OuterEntityName, CustomType = entityMapping.OuterEntityInType };
        //            entityMapping.InnerEntity.OuterEntities.Add(outerEntity);
        //        }

        //        executor = new DEMemberCollectionRelativeExecutor
        //        (
        //            DEOperationType.AddEntityMapping,
        //            entityMapping.InnerEntity,
        //            entityMapping.InnerEntity.OuterEntities.ToSchemaObjects(),
        //            DEStandardObjectSchemaType.DynamicEntityMapping
        //        ) { SaveContainerData = false, NeedValidation = this.NeedValidationAndStatusCheck };

        //        ExecuteWithActions(DEOperationType.AddEntityMapping, () => SCActionContext.Current.DoActions(() => executor.Execute()));
        //        #endregion

        //        #region 实体字段与外部实体字段映射入库
        //        entityMapping.EntityFieldMappingCollection.Where(field => field.OuterFieldName.IsNotEmpty()).ForEach(field =>
        //        {
        //            DynamicEntityField container = DESchemaObjectAdapter.Instance.Load(field.FieldID) as DynamicEntityField;

        //            var outerFiled = container.OuterEntityFields.FirstOrDefault(of => of.OuterEntity.ID.Equals(entityMapping.OuterEntityID));//&& of.ID.Equals(field.OuterFieldID)
        //            if (outerFiled != null)
        //            {
        //                outerFiled.Name = field.OuterFieldName;
        //                outerEntityFields.Add(outerFiled);
        //            }
        //            else
        //            {
        //                OuterEntityField new_outerField = new OuterEntityField() { ID = string.IsNullOrEmpty(field.OuterFieldID) ? Guid.NewGuid().ToString() : field.OuterFieldID, Name = field.OuterFieldName };
        //                container.OuterEntityFields.Add(new_outerField);

        //                outerEntityFields.Add(new_outerField);
        //            }

        //            executor = new DEMemberCollectionRelativeExecutor(DEOperationType.AddEntityFieldMapping, container, container.OuterEntityFields.ToSchemaObjects(), DEStandardObjectSchemaType.DynamicEntityFieldMapping) { SaveContainerData = false, NeedValidation = this.NeedValidationAndStatusCheck };

        //            ExecuteWithActions(DEOperationType.AddEntityFieldMapping, () => SCActionContext.Current.DoActions(() => executor.Execute()));
        //        });
        //        #endregion

        //        #region 外部实体与外部实体属性关系入库
        //        executor = new DEMemberCollectionRelativeExecutor(DEOperationType.AddOuterEntityFieldMapping, outerEntity, outerEntityFields.ToSchemaObjects(), DEStandardObjectSchemaType.OuterEntityFieldMapping) { SaveContainerData = false, SaveMemberData = false, NeedValidation = this.NeedValidationAndStatusCheck };

        //        ExecuteWithActions(DEOperationType.AddOuterEntityFieldMapping, () => SCActionContext.Current.DoActions(() => executor.Execute()));
        //        #endregion
        //        scope.Complete();

        //    }
        //}

        #endregion

        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="entity"></param>
        public void DeleteEntity(DynamicEntity entity)
        {
            entity.Status = SchemaObjectStatus.Deleted;
            entity.Fields.ForEach(p => p.Status = SchemaObjectStatus.DeletedByContainer);

            // 查询出引用实体地址的字段 然后删除该字段和mapping 关系
            //WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            //builder.AppendItem("SchemaType", "DynamicEntityField");
            //builder.AppendItem("CodeName",entity.CodeName);
            //DESchemaObjectAdapter.Instance.Load(builder);
            // DeleteEntityField(DynamicEntityField entityField)

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                //删除映射关系 注释掉。2015-8-13 王雷平
                //DeleteEntityMapping(entity, entity.OuterEntities);

                DEObjectExecutor executor = null;

                if (this._NeedCheckPermissions)
                {
                    CheckPermissions(DEOperationType.DeleteEntity, null, "DeleteEntity", string.Empty);
                }

                executor = new DEMemberCollectionRelativeExecutor(DEOperationType.DeleteEntity, entity, entity.Fields.ToSchemaObjects())
                {
                    SaveContainerData = true, NeedValidation = this.NeedValidationAndStatusCheck
                };

                ExecuteWithActions(DEOperationType.DeleteEntity, () => SCActionContext.Current.DoActions(() => executor.Execute()));

                scope.Complete();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新实体属性
        /// </summary>
        /// <param name="entityField"></param>
        public void UpdateEntityField(DynamicEntityField entityField)
        {
            DEObjectExecutor executor = null;

            if (this._NeedCheckPermissions)
            {
                CheckPermissions(DEOperationType.UpdateEntityField, null, "UpdateEntityField", string.Empty);
            }

            executor = new DEObjectExecutor(DEOperationType.UpdateEntityField, entityField);
            ExecuteWithActions(DEOperationType.UpdateEntityField, () => SCActionContext.Current.DoActions(() => executor.Execute()));
        }
Esempio n. 3
0
        /// <summary>
        /// 删除实体属性
        /// </summary>
        /// <param name="entityField"></param>
        public void DeleteEntityField(DynamicEntityField entityField)
        {
            entityField.Status = SchemaObjectStatus.Deleted;
            DEObjectExecutor executor = null;

            if (this._NeedCheckPermissions)
            {
                CheckPermissions(DEOperationType.DeleteEntityField, null, "DeleteEntityField", string.Empty);
            }

            executor = new DEObjectExecutor(DEOperationType.DeleteEntityField, entityField);
            ExecuteWithActions(DEOperationType.DeleteEntityField, () => SCActionContext.Current.DoActions(() => executor.Execute()));
        }
Esempio n. 4
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity"></param>
        public void UpdateEntity(DynamicEntity entity)
        {
            DEObjectExecutor executor = null;

            if (this._NeedCheckPermissions)
            {
                CheckPermissions(DEOperationType.UpdateEntity, null, "UpdateEntity", string.Empty);
            }

            executor = new DEMemberCollectionRelativeExecutor(DEOperationType.UpdateEntity, entity, entity.Fields.ToSchemaObjects())
            {
                SaveContainerData = true, NeedValidation = this.NeedValidationAndStatusCheck
            };

            ExecuteWithActions(DEOperationType.UpdateEntity, () => SCActionContext.Current.DoActions(() => executor.Execute()));

            //DeleteEntityMapping(entity, entity.OuterEntities);
        }
Esempio n. 5
0
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity"></param>
        public void AddEntity(DynamicEntity entity)
        {
            DEObjectExecutor executor = null;

            entity.NullCheck <ArgumentNullException>("待添加的实体不能为Null");

            if (this._NeedCheckPermissions)
            {
                CheckPermissions(DEOperationType.AddEntity, null, "AddEntity", string.Empty);
            }

            //生成CodeName
            entity.BuidCodeName();

            //验证实体数据
            entity.Validate();

            executor = new DEMemberCollectionRelativeExecutor(DEOperationType.AddEntity, entity, entity.Fields.ToSchemaObjects())
            {
                SaveContainerData = true, NeedValidation = this.NeedValidationAndStatusCheck
            };

            ExecuteWithActions(DEOperationType.AddEntity, () => SCActionContext.Current.DoActions(() => executor.Execute()));
        }