示例#1
0
        //-------------------------------------------------------------------------
        private void ValideRestrictionEnCours()
        {
            if (m_restrictionAffichee == null)
            {
                return;
            }
            foreach (ListViewItem item in m_wndListeChamps.Items)
            {
                string       strProp = (string)item.Tag;
                ERestriction rest    = ERestriction.Aucune;
                if (item.ImageIndex == 1)
                {
                    rest = ERestriction.ReadOnly;
                }
                if (item.ImageIndex == 2)
                {
                    rest = ERestriction.Hide;
                }
                m_restrictionAffichee.SetRestrictionLocale(strProp, rest);
            }
            //m_restrictionAffichee.Priorite = m_txtSeuil.IntValue != null?m_txtSeuil.IntValue.Value:0;
            ListViewItem itemToModify = GetItemForType(m_restrictionAffichee.TypeAssocie);

            if (itemToModify != null)
            {
                InitItem(itemToModify, m_restrictionAffichee);
            }
        }
示例#2
0
        public static CResultAErreur InitFromXml(string strFichier)
        {
            /*
             * <configuration>
             *	<sc2iRestrictions>
             *		<Mode cle="  ">
             *			<Restriction type="Cafel.data.partenaire" restriction="NoCreate">
             *				<Propriete name="Libelle" restriction="ReadOnly"/>
             *			</Restriction>
             *		</Mode>
             *	</sc2iRestrictions>
             * <configuration>
             * */
            CResultAErreur result = CResultAErreur.True;
            XmlDocument    xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.Load(new StreamReader(strFichier));

                //Noeud login
                XmlNode node = xmlDoc.SelectSingleNode("/configuration/sc2iRestrictions");
                if (node == null)
                {
                    return(result);
                }
                XmlNode child = node.FirstChild;
                while (child != null)
                {
                    if (child.Name.ToUpper() == "MODE")
                    {
                        string  strMode   = child.Attributes["cle"].Value;
                        XmlNode nodeClass = child.FirstChild;
                        while (nodeClass != null)
                        {
                            if (nodeClass.Name.ToUpper() == "RESTRICTION")
                            {
                                CListeRestrictionsUtilisateurSurType liste = (CListeRestrictionsUtilisateurSurType)m_tableRestrictions[strMode];
                                if (liste == null)
                                {
                                    liste = new CListeRestrictionsUtilisateurSurType();
                                    m_tableRestrictions[strMode] = liste;
                                }
                                Type tp = CActivatorSurChaine.GetType(nodeClass.Attributes["type"].Value);
                                if (tp != null)
                                {
                                    CRestrictionUtilisateurSurType restriction = liste.GetRestriction(tp);
                                    string strRestriction = nodeClass.Attributes["restriction"].Value;
                                    restriction.RestrictionUtilisateur = (ERestriction)Enum.Parse(typeof(ERestriction), strRestriction);
                                    XmlNode nodePropriete = nodeClass.FirstChild;
                                    while (nodePropriete != null)
                                    {
                                        if (nodePropriete.Name.ToUpper() == "PROPRIETE")
                                        {
                                            restriction.SetRestrictionLocale(nodePropriete.Attributes["name"].Value,
                                                                             (ERestriction)Enum.Parse(typeof(ERestriction), nodePropriete.Attributes["restriction"].Value.ToString()));
                                        }
                                        nodePropriete = nodePropriete.NextSibling;
                                    }
                                    liste.AddRestriction(restriction);
                                }
                            }
                            nodeClass = nodeClass.NextSibling;
                        }
                    }
                    child = child.NextSibling;
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                result.EmpileErreur(I.T("Error in the restrictions configuration|102"));
            }

            return(result);
        }