Ejemplo n.º 1
0
        //private string GetRelationshipPath(EntityRelationshipTail item)
        //{
        //    if (item.EntityRelationshipTail11.Any())
        //    {
        //        return item.Relationship.ID + "," + GetRelationshipPath(item.EntityRelationshipTail11.First());
        //    }
        //    else
        //        return item.Relationship.ID.ToString();
        //}
        public EntityRelationshipTail GetOrCreateEntityRelationshipTail(MyProjectEntities projectContext, int entityID, string path)
        {
            var dbItem = projectContext.EntityRelationshipTail.FirstOrDefault(x => x.TableDrivedEntityID == entityID && x.RelationshipPath == path);

            if (dbItem == null)
            {
                dbItem = new EntityRelationshipTail();
                dbItem.TableDrivedEntityID = entityID;

                int relationshipID = 0;
                if (path.Contains(","))
                {
                    var splt = path.Split(',');
                    relationshipID = Convert.ToInt32(splt[splt.Count() - 1]);
                }
                else
                {
                    relationshipID = Convert.ToInt32(path);
                }
                dbItem.TargetEntityID   = projectContext.Relationship.First(x => x.ID == relationshipID).TableDrivedEntityID2;
                dbItem.RelationshipPath = path;
                projectContext.EntityRelationshipTail.Add(dbItem);
            }
            return(dbItem);
        }
Ejemplo n.º 2
0
        //public bool CheckRelationshipTailPermission(DR_Requester requester, EntityRelationshipTailDTO relationshipTail)
        //{

        //    if (!bizTableDrivedEntity.IsEntityEnabled(relationshipTail.Relationship.EntityID2))
        //        return false;

        //    var entityPermission = securityHelper.GetAssignedPermissions(requester, relationshipTail.Relationship.EntityID2, false);
        //    if (entityPermission.GrantedActions.Any(y => y == SecurityAction.NoAccess))
        //        return false;

        //    BizRelationship bizRelationship = new BizRelationship();
        //    if (!bizRelationship.IsRelationshipEnabled(relationshipTail.Relationship.ID))
        //        return false;

        //    var relationshipPermission = securityHelper.GetAssignedPermissions(requester, relationshipTail.Relationship.ID, false);
        //    if (relationshipPermission.GrantedActions.Any(y => y == SecurityAction.NoAccess))
        //        return false;

        //    if (relationshipTail.ChildTail != null)
        //        return CheckRelationshipTailPermission(requester, relationshipTail.ChildTail);
        //    else
        //        return true;
        //}
        //public bool CheckRelationshipTailPermission(EntityRelationshipTailDTO relationshipTail)
        //{
        //    //if (first)
        //    //{
        //    //    var entityPermission = securityHelper.GetAssignedPermissions(requester, relationshipTail.Relationship.EntityID2, false);

        //    //    if (entityPermission.GrantedActions.Any(y => y == SecurityAction.NoAccess))
        //    //        return false;
        //    //}

        //    var relationshipPermission = securityHelper.GetAssignedPermissions(requester, relationshipTail.Relationship.ID, false);

        //    if (relationshipPermission.GrantedActions.Any(y => y == SecurityAction.NoAccess))
        //        return false;



        //    if (relationshipTail.ChildTail != null)
        //        return CheckRelationshipTailPermission(relationshipTail.ChildTail, false);
        //    else
        //        return true;
        //}

        //public EntityRelationshipTailDTO GetReverseRelationShipTail(int iD)
        //{
        //    List<EntityRelationshipTailDTO> result = new List<EntityRelationshipTailDTO>();
        //    using (var projectContext = new DataAccess.MyProjectEntities())
        //    {
        //        var EntityRelationshipTails = projectContext.EntityRelationshipTail.First(x => x.ReverseRelationshipTailID == iD);
        //        return ToEntityRelationshipTailDTO(EntityRelationshipTails);
        //    }
        //}

        public EntityRelationshipTailDTO ToEntityRelationshipTailDTO(EntityRelationshipTail tail)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var ittem = ToEntityRelationshipTailDTO(projectContext, tail.RelationshipPath, tail.TableDrivedEntityID, tail.TableDrivedEntity1.Alias, tail.TargetEntityID, tail.TableDrivedEntity.Alias, null, false);
                ittem.Item1.ID = tail.ID;
                return(ittem.Item1);
            }
        }
Ejemplo n.º 3
0
        public bool DataIsAccessable(DR_Requester requester, EntityRelationshipTail relationshipTail)
        {
            if (requester.SkipSecurity)
            {
                return(true);
            }
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var ittem    = ToEntityRelationshipTailDTO(projectContext, relationshipTail.RelationshipPath, relationshipTail.TableDrivedEntityID, relationshipTail.TableDrivedEntity.Alias, relationshipTail.TargetEntityID, relationshipTail.TableDrivedEntity1.Alias, null, true);
                var entities = ittem.Item2;
                if (entities.Any(x => !bizTableDrivedEntity.DataIsAccessable(requester, x)))
                {
                    return(false);
                }
                var relationships = ittem.Item3;
                if (relationships.Any(x => !bizRelationship.DataIsAccessable(requester, x, false, false)))
                {
                    return(false);
                }
                return(true);
            }

            //return CheckRelationshipTailPermission(requester, dto);
        }