Exemplo n.º 1
0
        public SuperToSubRelationshipDTO ToSuperToSubRelationshipDTO(SuperToSubRelationshipType item, RelationshipDTO baseRelationship = null)
        {
            BizRelationship biz = new BizRelationship();

            if (baseRelationship == null)
            {
                baseRelationship = biz.ToRelationshipDTO(item.RelationshipType.Relationship);
            }
            Mapper.Initialize(cfg => cfg.CreateMap <RelationshipDTO, SuperToSubRelationshipDTO>());
            var result = AutoMapper.Mapper.Map <RelationshipDTO, SuperToSubRelationshipDTO>(baseRelationship);

            result.ISARelationship = ToISARelationshipDTO(item.ISARelationship);


            foreach (var val in item.SuperToSubDeterminerValue)
            {
                result.DeterminerColumnValues.Add(new SuperToSubDeterminerValueDTO()
                {
                    ID = val.ID, Value = val.DeterminerValue
                });
            }
            if (item.SuperEntityDeterminerColumnID != null)
            {
                BizColumn bizColumn = new BizColumn();
                result.SuperEntityDeterminerColumnID = item.SuperEntityDeterminerColumnID.Value;
                result.SuperEntityDeterminerColumn   = bizColumn.GetColumn(result.SuperEntityDeterminerColumnID, true);
            }

            return(result);
        }
        public SuperToSubRelationshipDTO ToSuperToSubRelationshipDTO(SuperToSubRelationshipType item, RelationshipDTO baseRelationship = null)
        {
            BizRelationship biz = new BizRelationship();

            if (baseRelationship == null)
            {
                baseRelationship = biz.ToRelationshipDTO(item.RelationshipType.Relationship);
            }
            Mapper.Initialize(cfg => cfg.CreateMap <RelationshipDTO, SuperToSubRelationshipDTO>());
            var result = AutoMapper.Mapper.Map <RelationshipDTO, SuperToSubRelationshipDTO>(baseRelationship);

            result.ISARelationship = ToISARelationshipDTO(item.ISARelationship);
            return(result);
        }
        private TableDrivedEntityDTO ToTableDrivedEntityDTO(TableDrivedEntity item, EntityColumnInfoType columnInfoType, EntityRelationshipInfoType relationshipInfoType)
        {
            //var cachedItem = CacheManager.GetCacheManager().GetCachedItem(CacheItemType.Entity, item.ID.ToString(), columnInfoType.ToString(), relationshipInfoType.ToString());
            //if (cachedItem != null)
            //    return (cachedItem as TableDrivedEntityDTO);
            TableDrivedEntityDTO result = new TableDrivedEntityDTO();

            result.Name      = item.Name;
            result.ID        = item.ID;
            result.TableID   = item.TableID;
            result.TableName = item.Table.Name;
            //    result.Schema = item.Table.DBSchema.Name;
            result.EntityListViewID = item.EntityListViewID ?? 0;
            result.DatabaseID       = item.Table.DBSchema.DatabaseInformationID;
            result.DatabaseName     = item.Table.DBSchema.DatabaseInformation.Name;
            result.RelatedSchemaID  = item.Table.DBSchemaID;
            result.RelatedSchema    = item.Table.DBSchema.Name;
            result.ServerID         = item.Table.DBSchema.DatabaseInformation.DBServerID;
            result.Alias            = item.Alias;
            result.Criteria         = item.Criteria;
            //result.SecurityObjectID = item.SecurityObjectID.Value;

            //if (result.UnionTypeEntities == "")
            //    if (item.Relationship.Any(x => (x.RelationshipType == null && x.Relationship2 != null && x.TableDrivedEntity != x.TableDrivedEntity1 && !x.RelationshipColumns.All(y => y.Column.PrimaryKey == true))
            //        || (x.Relationship2 == null && x.TableDrivedEntity != x.TableDrivedEntity1 && !x.RelationshipColumns.All(y => y.Column1.PrimaryKey == true))))
            //        result.UnionTypeEntities = "Choose UnionType";

            result.BatchDataEntry       = item.BatchDataEntry;
            result.IsAssociative        = item.IsAssociative;
            result.IsDataReference      = item.IsDataReference;
            result.IsStructurReferencee = item.IsStructurReferencee;
            BizColumn bizColumn = new BizColumn();

            if (columnInfoType == EntityColumnInfoType.WithSimpleColumns)
            {
                result.Columns = bizColumn.GetColumns(item, true);
            }
            else if (columnInfoType == EntityColumnInfoType.WithFullColumns)
            {
                result.Columns = bizColumn.GetColumns(item, false);
            }
            if (relationshipInfoType == EntityRelationshipInfoType.WithRelationships)
            {
                BizISARelationship   bizISARelationship   = new BizISARelationship();
                BizUnionRelationship bizUnionRelationship = new Paper_MetadataManagement.BizUnionRelationship();
                BizRelationship      bizRelationship      = new BizRelationship();
                foreach (var relationship in item.Relationship)
                {
                    var relationshipDTO = bizRelationship.ToRelationshipDTO(relationship);
                    result.Relationships.Add(relationshipDTO);
                    if (relationship.RelationshipType != null)
                    {
                        if (relationship.RelationshipType.OneToManyRelationshipType != null)
                        {
                            result.OneToManyRelationships.Add(bizRelationship.ToOneToManyRelationship(relationship.RelationshipType.OneToManyRelationshipType, relationshipDTO));
                        }
                        else if (relationship.RelationshipType.ManyToOneRelationshipType != null)
                        {
                            result.ManyToOneRelationships.Add(bizRelationship.ToManyToOneRelationshipDTO(relationship.RelationshipType.ManyToOneRelationshipType, relationshipDTO));
                        }
                        else if (relationship.RelationshipType.ImplicitOneToOneRelationshipType != null)
                        {
                            result.ImplicitOneToOneRelationships.Add(bizRelationship.ToImplicitOneToOneRelationshipDTO(relationship.RelationshipType.ImplicitOneToOneRelationshipType, relationshipDTO));
                        }
                        else if (relationship.RelationshipType.ExplicitOneToOneRelationshipType != null)
                        {
                            result.ExplicitOneToOneRelationships.Add(bizRelationship.ToExplicitOneToOneRelationshipDTO(relationship.RelationshipType.ExplicitOneToOneRelationshipType, relationshipDTO));
                        }
                        else if (relationship.RelationshipType.SuperToSubRelationshipType != null)
                        {
                            result.SuperToSubRelationships.Add(bizISARelationship.ToSuperToSubRelationshipDTO(relationship.RelationshipType.SuperToSubRelationshipType, relationshipDTO));
                        }
                        else if (relationship.RelationshipType.SubToSuperRelationshipType != null)
                        {
                            result.SubToSuperRelationships.Add(bizISARelationship.ToSubToSuperRelationshipDTO(relationship.RelationshipType.SubToSuperRelationshipType, relationshipDTO));
                        }
                        else if (relationship.RelationshipType.UnionToSubUnionRelationshipType != null)
                        {
                            result.SuperUnionToSubUnionRelationships.Add(bizUnionRelationship.ToSuperUnionToSubUnionRelationshipDTO(relationship.RelationshipType.UnionToSubUnionRelationshipType, relationshipDTO));
                        }
                        else if (relationship.RelationshipType.SubUnionToUnionRelationshipType != null)
                        {
                            result.SubUnionToSuperUnionRelationships.Add(bizUnionRelationship.ToSubUnionToSuperUnionRelationshipDTO(relationship.RelationshipType.SubUnionToUnionRelationshipType, relationshipDTO));
                        }
                    }
                }
            }

            //CacheManager.GetCacheManager().AddCacheItem(result, CacheItemType.Entity, item.ID.ToString(), columnInfoType.ToString(), relationshipInfoType.ToString());
            return(result);
        }
Exemplo n.º 4
0
        private DataMenuSettingDTO ToDataMenuSettingDTO(DR_Requester requester, DataMenuSetting entity, bool withDetails)
        {
            var result = new DataMenuSettingDTO();

            if (withDetails)
            {
                foreach (var item in entity.DataMenuSearchableReportRelationship)
                {
                    //دسترسی به خود گزارش هم کنترل شود
                    if (bizEntityRelationshipTail.DataIsAccessable(requester, item.EntityRelationshipTail))
                    {
                        if (bizEntityReport.DataIsAccessable(requester, item.EntitySearchableReport.EntityReport))
                        {
                            var tail            = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
                            var entityReportDTO = new EntitySearchableReportDTO();
                            bizEntitySearchableReport.ToEntitySearchableReportDTO(item.EntitySearchableReport, entityReportDTO, withDetails);
                            result.SearchableReportRelationships.Add(ToDataMenuSearchableReportRelationshipDTO(item, tail, entityReportDTO));
                        }
                    }
                }
                foreach (var item in entity.DataMenuDataViewRelationship)
                {
                    if (bizEntityRelationshipTail.DataIsAccessable(requester, item.EntityRelationshipTail))
                    {
                        var tail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
                        result.DataViewRelationships.Add(ToDataMenuDataViewRelationshipDTO(item, tail));
                    }
                }
                foreach (var item in entity.DataMenuGridViewRelationship)
                {
                    if (bizEntityRelationshipTail.DataIsAccessable(requester, item.EntityRelationshipTail))
                    {
                        var tail = bizEntityRelationshipTail.ToEntityRelationshipTailDTO(item.EntityRelationshipTail);
                        result.GridViewRelationships.Add(ToDataMenuGridViewRelationshipDTO(item, tail));
                    }
                }
                foreach (var item in entity.DataMenuDataItemReportRelationship)
                {
                    if (bizEntityReport.DataIsAccessable(requester, item.EntityDataItemReportID))
                    {
                        var entityReportDTO = new EntityDataItemReportDTO();
                        bizEntityDataItemReport.ToEntityDataItemReportDTO(item.EntityDataItemReport, entityReportDTO, false);
                        result.DataItemReports.Add(ToDataMenuDataItemReportRelationshipDTO(item, entityReportDTO));
                    }
                }
            }
            result.EntityID         = entity.TableDrivedEntityID;
            result.EntityListViewID = entity.EntityListViewID;
            result.Name             = entity.Name;
            if (entity.DataMenuForViewEntity.Any())
            {
                result.RelationshipID = entity.DataMenuForViewEntity.First().RelationshipID;
                if (withDetails)
                {
                    if (bizRelationship.DataIsAccessable(requester, entity.DataMenuForViewEntity.First().Relationship, false, true))
                    {
                        result.Relationship = bizRelationship.ToRelationshipDTO(entity.DataMenuForViewEntity.First().Relationship);
                    }
                }
                result.TargetDataMenuSettingID = entity.DataMenuForViewEntity.First().TargetDataMenuSettingID;
                if (withDetails)
                {
                    result.DataMenuSetting = ToDataMenuSettingDTO(requester, entity.DataMenuForViewEntity.First().DataMenuSetting1, false);
                }
            }
            result.ID = entity.ID;
            if (withDetails)
            {
                result.IconContent = entity.IconContent;
            }
            return(result);
        }