示例#1
0
 internal void AddTypesARestrictionsSurObjets(Dictionary <Type, bool> dicTypesARestrictionsSurObjets, int?nIdVersion)
 {
     if (Profil != null)
     {
         Profil.AddTypesARestrictionsSurObjets(dicTypesARestrictionsSurObjets, nIdVersion, false);
     }
     if (Profil_Inclusion != null && Profil_Inclusion.ProfilFils != null)
     {
         Profil_Inclusion.AddTypesARestrictionsSurObjets(dicTypesARestrictionsSurObjets, nIdVersion, false);
     }
 }
示例#2
0
        ////////////////////////////////////////////////
        public void CompleteRestriction(IElementAEO element, CRestrictionUtilisateurSurType restriction)
        {
            DataRowVersion originalVersion = ((CObjetDonnee)element).VersionToReturn;

            try
            {
                if (element.Row.RowState == DataRowState.Deleted)
                {
                    ((CObjetDonnee)element).VersionToReturn = DataRowVersion.Original;
                }

                string strCodesEO = element.CodesEntitesOrganisationnelles;
                int?   nIdVersion = element.ContexteDonnee.IdVersionDeTravail;
                if (nIdVersion < 0)
                {
                    //On ne travaille ni dans le référentiel, ni dans une version,
                    //Il faut donc prendre les droits pour l'objet dans sa propre version
                    if (element.Row.Table.Columns[CSc2iDataConst.c_champIdVersion] != null)
                    {
                        nIdVersion = (int?)element.Row[CSc2iDataConst.c_champIdVersion, true];
                    }
                    else
                    {
                        nIdVersion = null;
                    }
                }
                CProfilUtilisateur profil = Profil;
                if (profil == null)
                {
                    if (Profil_Inclusion != null)
                    {
                        if (!Profil_Inclusion.ShouldApply(nIdVersion))
                        {
                            return;
                        }
                        profil = Profil_Inclusion.ProfilFils;
                    }
                }

                bool bApplique = false;
                //Si pas de relations EO sur l'utilisateur, on applique si
                //-Le profil n'est pas lié à une EO, ou si l'élément appartient à cette EO
                if (RelationsEntiteOrganisationnelles.Count == 0 || !profil.Affinable)
                {
                    if (profil.EntiteOrganisationnelle != null)
                    {
                        bApplique = strCodesEO.IndexOf("~" + profil.EntiteOrganisationnelle.CodeSystemeComplet) >= 0;
                    }
                    else
                    {
                        bApplique = true;//Pas d'EO, donc, on applique
                    }
                }

                if (profil.Affinable)
                {
                    foreach (CRelationUtilisateur_Profil_EO rel in RelationsEntiteOrganisationnelles)
                    {
                        if (rel.EntiteOrganisationnelle != null && strCodesEO.IndexOf("~" + rel.EntiteOrganisationnelle.CodeSystemeComplet) >= 0)
                        {
                            bApplique = true;
                            break;
                        }
                    }
                }
                if (bApplique)
                {
                    if (profil != null)
                    {
                        foreach (CProfilUtilisateur_Restriction relRes in profil.RelationsRestrictions)
                        {
                            CListeRestrictionsUtilisateurSurType lstRes = relRes.Restrictions.ListeRestrictions;
                            CRestrictionUtilisateurSurType       newRes = lstRes.GetRestriction(element.GetType());
                            restriction.Combine(newRes);
                        }
                    }
                    foreach (CRelationUtilisateur_Profil sousRel in RelationFilles)
                    {
                        sousRel.CompleteRestriction(element, restriction);
                    }
                }
            }
            finally
            {
                ((CObjetDonnee)element).VersionToReturn = originalVersion;
            }
        }
示例#3
0
        ////////////////////////////////////////////////
        public string GetFiltreEO(int?nIdVersion, Type typeElements)
        {
            string             strFiltre = "";
            CProfilUtilisateur profilLie = Profil;

            if (profilLie == null && Profil_Inclusion != null)
            {
                if (!Profil_Inclusion.ShouldApply(nIdVersion))
                {
                    return("");
                }
                profilLie = Profil_Inclusion.ProfilFils;
            }
            if (profilLie == null)
            {
                return("");
            }
            string strTmp = "";

            if (profilLie.ShouldFiltrerSur(typeElements))
            {
                CEntiteOrganisationnelle entite = profilLie.EntiteOrganisationnelle;
                CEntiteOrganisationnelle racine = entite;
                if (racine == null)
                {
                    return("");
                }
                while (racine.EntiteParente != null)
                {
                    racine = racine.EntiteParente;
                }
                if (!profilLie.MasquerLesHorsBranche)
                {
                    strFiltre = CUtilElementAEO.c_champEO + " not like '%~" + racine.CodeSystemeComplet + "%'";
                }
                if (!profilLie.Affinable || RelationsEntiteOrganisationnelles.Count == 0)//Pas de lien spécifique
                {
                    if (strFiltre != "")
                    {
                        strFiltre += " or ";
                    }
                    strFiltre += CUtilElementAEO.c_champEO + " like '%~" + entite.CodeSystemeComplet + "%'";
                }
                if (profilLie.Affinable)
                {
                    foreach (CEntiteOrganisationnelle entiteLiee in EntitesLiesExplicites)
                    {
                        if (strTmp != "")
                        {
                            strTmp += " or ";
                        }
                        strTmp += CUtilElementAEO.c_champEO + " like '%~" + entiteLiee.CodeSystemeComplet + "%'";
                    }
                    if (strTmp != "")
                    {
                        if (strFiltre != "")
                        {
                            strFiltre += " or ";
                        }
                        strFiltre += strTmp;
                    }
                    if (strFiltre != "")
                    {
                        strFiltre = "(" + strFiltre + ")";
                    }
                }
            }

            string strSousFiltres = "";

            foreach (CRelationUtilisateur_Profil relSousProfil in RelationFilles)
            {
                strTmp = relSousProfil.GetFiltreEO(nIdVersion, typeElements);
                if (strTmp != "")
                {
                    if (strSousFiltres != "")
                    {
                        strSousFiltres += " or ";
                    }
                    strSousFiltres += "(" + strTmp + ")";
                }
            }
            if (strSousFiltres != "")
            {
                if (strFiltre != "")
                {
                    strFiltre += " and ";
                }
                strFiltre += "(" + strSousFiltres + ")";
            }
            return(strFiltre);
        }